-
Notifications
You must be signed in to change notification settings - Fork 532
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1166 from larsclausen/fix-ix-load-sign
tgt-vvp: Use signedness of expression instead of signal for index load
- Loading branch information
Showing
4 changed files
with
58 additions
and
2 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
module test; | ||
|
||
// Check that the right hand side for a shift instruction is always treated as | ||
// unsigned. Even if its a signed register, or a transformation thereof. | ||
|
||
reg failed = 1'b0; | ||
|
||
`define check(val, exp) \ | ||
if ((val) !== (exp)) begin \ | ||
$display("FAILED(%0d): `%s`, expected `%0d`, got `%0d`.", `__LINE__, \ | ||
`"val`", (exp), (val), 4); \ | ||
failed = 1'b1; \ | ||
end | ||
|
||
reg signed [1:0] shift = 2'b10; | ||
|
||
initial begin | ||
`check(1 << shift, 4) | ||
`check(1 << shift[1:0], 4) | ||
`check(2 << shift[1], 4) | ||
`check(1 << $unsigned(shift), 4) | ||
`check(1 << $signed(shift), 4) | ||
`check(1 << {shift}, 4) | ||
|
||
`check(1 <<< shift, 4) | ||
`check(1 <<< shift[1:0], 4) | ||
`check(2 <<< shift[1], 4) | ||
`check(1 <<< $unsigned(shift), 4) | ||
`check(1 <<< $signed(shift), 4) | ||
`check(1 <<< {shift}, 4) | ||
|
||
`check(16 >> shift, 4) | ||
`check(16 >> shift[1:0], 4) | ||
`check(8 >> shift[1], 4) | ||
`check(16 >> $unsigned(shift), 4) | ||
`check(16 >> $signed(shift), 4) | ||
`check(16 >> {shift}, 4) | ||
|
||
`check(16 >>> shift, 4) | ||
`check(16 >>> shift[1:0], 4) | ||
`check(8 >>> shift[1], 4) | ||
`check(16 >>> $unsigned(shift), 4) | ||
`check(16 >>> $signed(shift), 4) | ||
`check(16 >>> {shift}, 4) | ||
|
||
if (!failed) begin | ||
$display("PASSED"); | ||
end | ||
end | ||
|
||
endmodule |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
{ | ||
"type" : "normal", | ||
"source" : "shift6.v" | ||
} |
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