-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lab3 #12
Closed
Lab3 #12
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
0ea18d5
updated five cycle
1061dcf
updated pipelined
4c721e1
updated register file
b4e756f
added tests for five cycle CPU
e6e30ef
added tests for Pipelined CPU
e532aec
miscellaneous additions/changes
79ae54c
Add documentation to forwarding
powerjg ba89173
minor changes
a988f33
minor additions
9bf91c8
Remove five cycle tests that will always fail
powerjg c1267c1
Update whitespace?
powerjg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,5 +35,4 @@ class HazardUnit extends Module { | |
io.ifid_write := false.B | ||
io.idex_bubble := true.B | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,10 +28,10 @@ class FiveCycleCPU(implicit val conf: CPUConfig) extends Module { | |
} | ||
|
||
class EXControl extends Bundle { | ||
val add = UInt(2.W) | ||
val add = Bool() | ||
val immediate = Bool() | ||
val alusrc1 = UInt(2.W) | ||
val branch = Bool() | ||
val alusrc1 = UInt(2.W) | ||
val branch = Bool() | ||
} | ||
|
||
class MControl extends Bundle { | ||
|
@@ -46,7 +46,6 @@ class FiveCycleCPU(implicit val conf: CPUConfig) extends Module { | |
class WBControl extends Bundle { | ||
val toreg = UInt(2.W) | ||
val regwrite = Bool() | ||
val pctoreg = Bool() | ||
} | ||
|
||
class IDEXBundle extends Bundle { | ||
|
@@ -108,8 +107,8 @@ class FiveCycleCPU(implicit val conf: CPUConfig) extends Module { | |
val branch_taken = Wire(Bool()) | ||
|
||
// For flushing stages. | ||
val flush_idex = Wire(Bool()) | ||
val flush_exmem = Wire(Bool()) | ||
val bubble_idex = Wire(Bool()) | ||
val bubble_exmem = Wire(Bool()) | ||
|
||
///////////////////////////////////////////////////////////////////////////// | ||
// FETCH STAGE | ||
|
@@ -153,7 +152,7 @@ class FiveCycleCPU(implicit val conf: CPUConfig) extends Module { | |
id_ex.pc := if_id.pc | ||
id_ex.pcplusfour := if_id.pcplusfour | ||
|
||
when (flush_idex) { | ||
when (bubble_idex) { | ||
id_ex.excontrol := 0.U.asTypeOf(new EXControl) | ||
id_ex.mcontrol := 0.U.asTypeOf(new MControl) | ||
id_ex.wbcontrol := 0.U.asTypeOf(new WBControl) | ||
|
@@ -162,10 +161,13 @@ class FiveCycleCPU(implicit val conf: CPUConfig) extends Module { | |
id_ex.excontrol.immediate := control.io.immediate | ||
id_ex.excontrol.alusrc1 := control.io.alusrc1 | ||
id_ex.excontrol.branch := control.io.branch | ||
|
||
id_ex.mcontrol.jump := control.io.jump | ||
id_ex.mcontrol.memread := control.io.memread | ||
id_ex.mcontrol.memwrite := control.io.memwrite | ||
id_ex.mcontrol.maskmode := if_id.instruction(13,12) | ||
id_ex.mcontrol.sext := ~if_id.instruction(14) | ||
|
||
|
||
id_ex.wbcontrol.toreg := control.io.toreg | ||
id_ex.wbcontrol.regwrite := control.io.regwrite | ||
|
@@ -205,11 +207,12 @@ class FiveCycleCPU(implicit val conf: CPUConfig) extends Module { | |
ex_mem.readdata2 := id_ex.readdata2 | ||
ex_mem.aluresult := alu.io.result | ||
ex_mem.taken := branchCtrl.io.taken | ||
ex_mem.mcontrol.jump := id_ex.mcontrol.jump | ||
|
||
when (branchCtrl.io.taken || control.io.jump === 2.U) { | ||
when (branchCtrl.io.taken || id_ex.mcontrol.jump === 2.U) { | ||
ex_mem.nextpc := branchAdd.io.result | ||
ex_mem.taken := true.B | ||
} .elsewhen (control.io.jump === 3.U) { | ||
} .elsewhen (id_ex.mcontrol.jump === 3.U) { | ||
ex_mem.nextpc := alu.io.result & Cat(Fill(31, 1.U), 0.U) | ||
ex_mem.taken := true.B | ||
} .otherwise { | ||
|
@@ -220,7 +223,7 @@ class FiveCycleCPU(implicit val conf: CPUConfig) extends Module { | |
ex_mem.writereg := id_ex.writereg | ||
ex_mem.pcplusfour := id_ex.pcplusfour | ||
|
||
when (flush_exmem) { | ||
when (bubble_exmem) { | ||
ex_mem.mcontrol := 0.U.asTypeOf(new MControl) | ||
ex_mem.wbcontrol := 0.U.asTypeOf(new WBControl) | ||
} .otherwise { | ||
|
@@ -233,7 +236,7 @@ class FiveCycleCPU(implicit val conf: CPUConfig) extends Module { | |
///////////////////////////////////////////////////////////////////////////// | ||
// MEM STAGE | ||
///////////////////////////////////////////////////////////////////////////// | ||
|
||
printf("jump =%x\n", control.io.jump) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this needed? |
||
io.dmem.address := ex_mem.aluresult | ||
io.dmem.writedata := ex_mem.readdata2 | ||
io.dmem.memread := ex_mem.mcontrol.memread | ||
|
@@ -254,13 +257,13 @@ class FiveCycleCPU(implicit val conf: CPUConfig) extends Module { | |
// Now we know the direction of the branch. If it's taken, clear the control | ||
// for the previous stages. | ||
when (branch_taken) { | ||
flush_exmem := true.B | ||
flush_idex := true.B | ||
bubble_exmem := true.B | ||
bubble_idex := true.B | ||
} .otherwise { | ||
flush_exmem := false.B | ||
flush_idex := false.B | ||
bubble_exmem := false.B | ||
bubble_idex := false.B | ||
} | ||
|
||
printf(p"MEM/WB: $mem_wb\n") | ||
|
||
///////////////////////////////////////////////////////////////////////////// | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert this line. Why did you get rid of this space?