Skip to content

Commit

Permalink
Merge pull request #1008 from larsclausen/2state-net-array
Browse files Browse the repository at this point in the history
vvp: Add parser rule for unsigned 2-state net arrays
  • Loading branch information
caryr authored Oct 15, 2023
2 parents c498d53 + b7ef0b5 commit a9ef006
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
30 changes: 30 additions & 0 deletions ivtest/ivltests/sv_array_cassign8.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Check that continuous assignments to 2-state arrays are supported.

module test;

bit failed = 1'b0;

`define check(expr, val) do \
if (expr !== val) begin \
$display("FAILED(%0d): `%s`, expected %0d, got %0d", `__LINE__, `"expr`", val, expr); \
failed = 1'b1; \
end \
while (0)

int a1[0:1];
bit [31:0] a2[0:1];

assign a1[0] = -10;
assign a2[0] = 20;

initial begin
#0
`check(a1[0], -10);
`check(a2[0], 20);

if (!failed) begin
$display("PASSED");
end
end

endmodule
1 change: 1 addition & 0 deletions ivtest/regress-vvp.list
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ sv_array_assign_fail1 vvp_tests/sv_array_assign_fail1.json
sv_array_assign_fail2 vvp_tests/sv_array_assign_fail2.json
sv_array_cassign6 vvp_tests/sv_array_cassign6.json
sv_array_cassign7 vvp_tests/sv_array_cassign7.json
sv_array_cassign8 vvp_tests/sv_array_cassign8.json
sv_automatic_2state vvp_tests/sv_automatic_2state.json
sv_chained_constructor1 vvp_tests/sv_chained_constructor1.json
sv_chained_constructor2 vvp_tests/sv_chained_constructor2.json
Expand Down
5 changes: 5 additions & 0 deletions ivtest/vvp_tests/sv_array_cassign8.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type" : "normal",
"source" : "sv_array_cassign8.v",
"iverilog-args" : [ "-g2009" ]
}
4 changes: 4 additions & 0 deletions vvp/parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,10 @@ statement
symbols_net ';'
{ compile_netw($1, $3, $4, $6, $7, vpiLogicVar, true, $9.cnt, $9.vect); }

| T_LABEL K_NET_2U T_SYMBOL T_NUMBER ',' signed_t_number signed_t_number ','
symbols_net ';'
{ compile_netw($1, $3, $4, $6, $7, vpiIntVar, false, $9.cnt, $9.vect); }

| T_LABEL K_NET_2S T_SYMBOL T_NUMBER ',' signed_t_number signed_t_number ','
symbols_net ';'
{ compile_netw($1, $3, $4, $6, $7, vpiIntVar, true, $9.cnt, $9.vect); }
Expand Down

0 comments on commit a9ef006

Please sign in to comment.