-
Notifications
You must be signed in to change notification settings - Fork 13
Add Zbs single-bit operations implementation (RV32, SystemVerilog) #191
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
Open
jeff-7
wants to merge
18
commits into
main
Choose a base branch
from
zbs-implementation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 11 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
3c22477
Add Zbs single-bit operations implementation (RV32, SystemVerilog)
jeff-7 1804796
Ignore macOS .DS_Store
jeff-7 38ffa5d
Fix svlint style issues in Zbs
jeff-7 07a4556
Fix svlint issues
jeff-7 c627fe2
Fix final svlint whitespace issues
jeff-7 227077b
Force CI
jeff-7 41fd19e
Fix final svlint whitespace issues
jeff-7 9bcdeb1
Force CI
jeff-7 9c90038
Fix comma-leading and keyword spacing
jeff-7 533d464
Force CI
jeff-7 a897b44
Fix comma-leading and keyword spacing
jeff-7 4a918f2
Replace parameter with localparam in params.svh
jeff-7 adab42b
Merge branch 'main' into zbs-implementation
TheDeepestSpace f8678c9
Add Zbs instruction testbench with assertions and randomized tests
Dazhou-20383 50f5aee
Match bit width in bext comparison
Dazhou-20383 de0a360
Fix: Resolve svlint style violations
Dazhou-20383 0894e45
fix svlint infractions
TheDeepestSpace fae9204
Merge pull request #210 from UTOSS/zbs-testbench-fix
TheDeepestSpace 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,3 +28,4 @@ out/** | |
| !out/.gitkeep | ||
| build/** | ||
| !build/.gitkeep | ||
| .DS_Store | ||
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,50 @@ | ||
| // Zbs: Single-Bit Operations (RV32) | ||
| // | ||
| // Implements: | ||
| // - bclr / bclri | ||
| // - bset / bseti | ||
| // - binv / binvi | ||
| // - bext / bexti | ||
| // | ||
| // Design note: | ||
| // - Purely combinational ALU block | ||
| // - reg2[4:0] used as bit index | ||
| // - R/I distinction handled in decoder | ||
|
|
||
| module zbs ( | ||
| input logic [31:0] reg1 // rs1 operand | ||
| , input logic [31:0] reg2 // rs2 or immediate (bit index source) | ||
|
TheDeepestSpace marked this conversation as resolved.
Outdated
|
||
| , input logic [1:0] inst // operation selector | ||
| , output logic [31:0] out //result | ||
| ); | ||
|
|
||
| logic [4:0] index; | ||
| logic [31:0] mask; | ||
|
|
||
| always_comb | ||
| index = reg2[4:0]; | ||
|
|
||
| always_comb | ||
| mask = 32'h1 << index; | ||
|
|
||
| always_comb | ||
| case (inst) | ||
|
|
||
| // 00 : bclr / bclri → clear selected bit | ||
| 2'b00: out = reg1 & ~mask; | ||
|
|
||
| // 01 : bset / bseti → set selected bit | ||
| 2'b01: out = reg1 | mask; | ||
|
|
||
| // 10 : binv / binvi → invert selected bit | ||
| 2'b10: out = reg1 ^ mask; | ||
|
|
||
| // 11 : bext / bexti → extract selected bit (to bit[0]) | ||
| 2'b11: out = (reg1 >> index) & 32'h1; | ||
|
|
||
| // others → safe default | ||
| default: out = 32'd0; | ||
|
|
||
| endcase | ||
|
|
||
| endmodule | ||
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.
for the documentation here I would just specify the section of the specification that corresponds to Zbs extension