-
Notifications
You must be signed in to change notification settings - Fork 541
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 #852 from larsclausen/vvp-string-vpi
vvp: Handle null-bytes in a conistent way when reading through VPI
- Loading branch information
Showing
10 changed files
with
138 additions
and
12 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,4 @@ | ||
Const Positive yes | ||
Const Negative NO | ||
Var Positive yes | ||
Var Negative NO |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
first..last first,last last..first | ||
(a)..(c) (a,b,c) (c)..(a) | ||
(a )..(c ) (a,b,c) (c )..(a ) | ||
sumsqr(3,4) = 25 | ||
sumsqr(5,12) = 169 |
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,9 @@ | ||
module test; | ||
reg expected = 1; | ||
initial begin | ||
$display("Const Positive %s", 1 ? "yes" : "NO"); | ||
$display("Const Negative %s", !1 ? "yes" : "NO"); | ||
$display("Var Positive %s", expected ? "yes" : "NO"); | ||
$display("Var Negative %s", !expected ? "yes" : "NO"); | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Check that null-bytes are handled consistently between string literals, | ||
// number literals and signals of all kinds, especially when formatting as a | ||
// string. | ||
|
||
module test; | ||
|
||
reg failed = 1'b0; | ||
|
||
`define check(val, exp) \ | ||
if (val != exp) begin \ | ||
$display("FAILED(%0d): Expected '%0s', got '%0s'.", `__LINE__, exp, val); \ | ||
failed = 1'b1; \ | ||
end | ||
|
||
reg [255:0] s; | ||
reg [31:0] x; | ||
reg [31:0] y[1:0]; | ||
wire [31:0] z; | ||
wire [31:0] w; | ||
|
||
assign z = "\000a\000b"; | ||
assign w = 32'h00610062; | ||
|
||
initial begin | ||
$sformat(s, ":%x:%0x:%s:%0s:", "\000a\000b", "\000a\000b", "\000a\000b", "\000a\000b"); | ||
`check(s, ":00610062:610062: a b:a b:") | ||
$sformat(s, ":%x:%0x:%s:%0s:", 32'h00610062, 32'h00610062, 32'h00610062, 32'h00610062); | ||
`check(s, ":00610062:610062: a b:a b:") | ||
|
||
x = "\000a\000b"; | ||
$sformat(s, ":%x:%0x:%s:%0s:", x, x, x, x); | ||
`check(s, ":00610062:610062: a b:a b:") | ||
|
||
x = 32'h00610062; | ||
$sformat(s, ":%x:%0x:%s:%0s:", x, x, x, x); | ||
`check(s, ":00610062:610062: a b:a b:") | ||
|
||
y[0] = "\000a\000b"; | ||
$sformat(s, ":%x:%0x:%s:%0s:", y[0], y[0], y[0], y[0]); | ||
`check(s, ":00610062:610062: a b:a b:") | ||
|
||
y[1] = 32'h00610062; | ||
$sformat(s, ":%x:%0x:%s:%0s:", y[1], y[1], y[1], y[1]); | ||
`check(s, ":00610062:610062: a b:a b:") | ||
|
||
$sformat(s, ":%x:%0x:%s:%0s:", z, z, z, z); | ||
`check(s, ":00610062:610062: a b:a b:") | ||
|
||
$sformat(s, ":%x:%0x:%s:%0s:", w, w, w, w); | ||
`check(s, ":00610062:610062: a b:a b:") | ||
|
||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Check that the empty string "" is equivalent to 8'h00 | ||
|
||
module test; | ||
|
||
reg failed = 1'b0; | ||
|
||
`define check(val, exp) \ | ||
if (val != exp) begin \ | ||
$display("FAILED(%0d): Expected '%0s', got '%0s'.", `__LINE__, exp, val); \ | ||
failed = 1'b1; \ | ||
end | ||
|
||
reg [47:0] s; | ||
reg [7:0] x; | ||
wire [7:0] y; | ||
|
||
assign y = ""; | ||
|
||
initial begin | ||
`check("", 8'h00); | ||
`check($bits(""), 8); | ||
|
||
$sformat(s, ":%s:%0s:", "", ""); | ||
`check(s, ": ::"); | ||
|
||
x = 8'h00; | ||
$sformat(s, ":%s:%0s:", x, x); | ||
`check(s, ": ::"); | ||
|
||
$sformat(s, ":%s:%0s:", y, y); | ||
`check(s, ": ::"); | ||
|
||
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
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
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