Skip to content

Commit

Permalink
Small changes to pipelined CPUs for combin mem to work
Browse files Browse the repository at this point in the history
  • Loading branch information
Jared Barocsi committed Jul 27, 2019
1 parent 8482c75 commit b44429b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/main/scala/pipelined/cpu-bp.scala
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ class PipelinedCPUBP(implicit val conf: CPUConfig) extends BaseCPU {
if_id.instruction := io.imem.instruction
if_id.pc := pc
if_id.pcplusfour := pcPlusFour.io.result
io.imem.valid := true.B
} .otherwise {
io.imem.valid := false.B
}

// Flush IF/ID when required
Expand Down Expand Up @@ -368,6 +371,9 @@ class PipelinedCPUBP(implicit val conf: CPUConfig) extends BaseCPU {
io.dmem.maskmode := ex_mem.mcontrol.maskmode
io.dmem.sext := ex_mem.mcontrol.sext

// Set dmem request as valid when a write or read is being requested
io.dmem.valid := (io.dmem.memread || io.dmem.memwrite)

// Send next_pc back to the fetch stage
mem_next_pc := ex_mem.nextpc

Expand All @@ -385,6 +391,9 @@ class PipelinedCPUBP(implicit val conf: CPUConfig) extends BaseCPU {
mem_wb.readdata := io.dmem.readdata
mem_wb.wbcontrol := ex_mem.wbcontrol

// Stall pipeline if neither instruction nor data memory are ready
val memStall = ~(io.imem.good && io.dmem.good)

if (conf.debug) { printf(p"MEM/WB: $mem_wb\n") }

/////////////////////////////////////////////////////////////////////////////
Expand Down
11 changes: 11 additions & 0 deletions src/main/scala/pipelined/cpu.scala
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ class PipelinedCPU(implicit val conf: CPUConfig) extends BaseCPU {
if_id.instruction := io.imem.instruction
if_id.pc := pc
if_id.pcplusfour := pcPlusFour.io.result

io.imem.valid := true.B
} .otherwise {
io.imem.valid := false.B
}

// Flush IF/ID when required
Expand Down Expand Up @@ -312,6 +316,10 @@ class PipelinedCPU(implicit val conf: CPUConfig) extends BaseCPU {
io.dmem.maskmode := ex_mem.mcontrol.maskmode
io.dmem.sext := ex_mem.mcontrol.sext

// Set dmem request as valid when a write or read is being requested
io.dmem.valid := (io.dmem.memread || io.dmem.memwrite)


// Send next_pc back to the fetch stage
next_pc := ex_mem.nextpc

Expand All @@ -329,6 +337,9 @@ class PipelinedCPU(implicit val conf: CPUConfig) extends BaseCPU {
mem_wb.readdata := io.dmem.readdata
mem_wb.wbcontrol := ex_mem.wbcontrol

// Stall pipeline if neither instruction nor data memory are ready
val memStall = ~(io.imem.good && io.dmem.good)

if (conf.debug) { printf(p"MEM/WB: $mem_wb\n") }

/////////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit b44429b

Please sign in to comment.