-
Notifications
You must be signed in to change notification settings - Fork 13
Jalr branch #65
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
Closed
Closed
Jalr branch #65
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Binary file not shown.
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| `timescale 1ns/1ps | ||
|
|
||
| `include "src/types.svh" // <-- bring in enum literals like PC_SRC__JUMP | ||
| `include "test/utils.svh" | ||
|
|
||
| module jal_only_tb; | ||
|
|
||
| reg clk; | ||
| reg reset; | ||
|
|
||
| // DUT | ||
| top uut | ||
| ( .clk ( clk ) | ||
| , .reset ( reset ) | ||
| ); | ||
|
|
||
| // 10ns clock | ||
| initial begin | ||
| clk = 0; | ||
| forever #5 clk = ~clk; | ||
| end | ||
|
|
||
| // helper: wait one cycle then assert expected FSM state | ||
| task wait_till_next_cfsm_state(input [3:0] expected_state); | ||
| @(posedge clk); #1; | ||
| `assert_equal(uut.control_fsm.current_state, expected_state) | ||
| endtask | ||
|
|
||
| initial begin | ||
| reset <= `TRUE; | ||
|
|
||
| // Program: | ||
| // 0x00000000: JAL x1, +16 (target = 16) | ||
| // J-type encoding: opcode=0x6F, rd=x1, imm=+16 -> 0x010000EF | ||
| uut.memory.M[0] = 32'h010000EF; | ||
|
|
||
| // Enter FETCH first (with reset asserted) | ||
| wait_till_next_cfsm_state(uut.control_fsm.FETCH); | ||
|
|
||
| // Release reset | ||
| reset <= `FALSE; | ||
|
|
||
| // -------- Single instruction: JAL x1, +16 -------- | ||
|
|
||
| // DECODE: verify opcode, rd and immediate | ||
| wait_till_next_cfsm_state(uut.control_fsm.DECODE); | ||
| `assert_equal(uut.opcode, 7'b1101111) // JType (JAL) | ||
| `assert_equal(uut.instruction_decode.rd, 5'd1) // rd = x1 | ||
| `assert_equal(uut.instruction_decode.imm_ext, 32'sd16) // imm = +16 | ||
|
|
||
| // UNCONDJUMP: link = pc_old + 4, PC updates by pc + imm | ||
| wait_till_next_cfsm_state(uut.control_fsm.UNCONDJUMP); | ||
| `assert_equal(uut.alu.a, 32'd0) // pc_old at address 0 | ||
| `assert_equal(uut.alu.b, 32'd4) | ||
| `assert_equal(uut.alu.out, 32'd4) // link value | ||
| `assert_equal(uut.cfsm__pc_update, 1'b1) | ||
| `assert_equal(uut.cfsm__pc_src, PC_SRC__JUMP) // <-- enum literal, no hierarchy | ||
|
|
||
| // ALUWB: write link back to rd (x1) | ||
| wait_till_next_cfsm_state(uut.control_fsm.ALUWB); | ||
|
|
||
| // Back to FETCH: PC should be 16; x1 should be 4 | ||
| wait_till_next_cfsm_state(uut.control_fsm.FETCH); | ||
| `assert_equal(uut.instruction_decode.instanceRegFile.RFMem[1], 32'd4) // rd = link = 4 | ||
| `assert_equal(uut.fetch.pc_cur, 32'd16) // PC jumped to 16 | ||
|
|
||
| $finish; | ||
| end | ||
|
|
||
| `SETUP_VCD_DUMP(jal_only_tb) | ||
|
|
||
| endmodule |
Oops, something went wrong.
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.
we'll need to merge #44 first before this step will work; ill do that tomorrow