Extend non-blocking event control with <= 0 repeat test

Extend the non-blocking event control assignment tests to check that a 0 or
negative repeat value is handled correctly. In this case the assignment
should be executed like a regular non-blocking assignment and the event
control should be ignored.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
Lars-Peter Clausen 2022-06-06 17:18:35 +02:00
parent 7e7d0ae94b
commit e35c857a24
7 changed files with 118 additions and 0 deletions

View File

@ -78,6 +78,23 @@ module top;
pass = 1'b0; pass = 1'b0;
end end
// These should execute as if there was no event control
result[0] <= repeat(0) @(posedge clk) 4'h4;
#1
if ($simtime != 171 || result[0] !== 4'h4) begin
$display("Failed @ at %0t, expected 4'h4, got %h",
$simtime, result[0]);
pass = 1'b0;
end
result[0] <= repeat(-1) @(posedge clk) 4'h5;
#1
if ($simtime != 172 || result[0] !== 4'h5) begin
$display("Failed @ at %0t, expected 4'h5, got %h",
$simtime, result[0]);
pass = 1'b0;
end
if (pass) $display("PASSED"); if (pass) $display("PASSED");
$finish; $finish;
end end

View File

@ -81,6 +81,16 @@ module top;
pass = 1'b0; pass = 1'b0;
end end
// These should execute as if there was no event control
result[0][3:0] <= repeat(0) @(posedge clk) 4'h3;
result[0][7:4] <= repeat(-1) @(posedge clk) 4'h4;
#1
if ($simtime != 171 || result[0] !== 8'h43) begin
$display("Failed @ at %0t, expected 8'h43, got %h",
$simtime, result[0]);
pass = 1'b0;
end
if (pass) $display("PASSED"); if (pass) $display("PASSED");
$finish; $finish;
end end

View File

@ -84,6 +84,16 @@ module top;
pass = 1'b0; pass = 1'b0;
end end
// These should execute as if there was no event control
result[j][i+:4] <= repeat(0) @(posedge clk) 4'h3;
result[j][i+4+:4] <= repeat(-1) @(posedge clk) 4'h4;
#1
if ($simtime != 171 || result[j] !== 8'h43) begin
$display("Failed @ at %0t, expected 8'h43, got %h",
$simtime, result[j]);
pass = 1'b0;
end
if (pass) $display("PASSED"); if (pass) $display("PASSED");
$finish; $finish;
end end

View File

@ -78,6 +78,16 @@ module top;
pass = 1'b0; pass = 1'b0;
end end
// These should execute as if there was no event control
result[3:0] <= repeat(0) @(posedge clk) 4'h3;
result[7:4] <= repeat(-1) @(posedge clk) 4'h4;
#1
if ($simtime != 171 || result !== 8'h43) begin
$display("Failed @ at %0t, expected 8'h43, got %h",
$simtime, result);
pass = 1'b0;
end
if (pass) $display("PASSED"); if (pass) $display("PASSED");
$finish; $finish;
end end

View File

@ -5,6 +5,7 @@ module top;
reg clk = 0; reg clk = 0;
reg [7:0] result; reg [7:0] result;
reg [3:0] bit; reg [3:0] bit;
integer count;
always #10 clk = ~clk; always #10 clk = ~clk;
@ -12,6 +13,7 @@ module top;
// Since the bit is not defined this assignment will not happen. // Since the bit is not defined this assignment will not happen.
// We will check to verify this fact 1 time step after it should // We will check to verify this fact 1 time step after it should
// happen (50). // happen (50).
#0;
result[bit] <= repeat(3) @(posedge clk) 1'b0; result[bit] <= repeat(3) @(posedge clk) 1'b0;
if ($simtime != 0 || result !== 8'bx) begin if ($simtime != 0 || result !== 8'bx) begin
$display("Failed repeat(3) blocked at %0t, expected 8'hxx, got %h", $display("Failed repeat(3) blocked at %0t, expected 8'hxx, got %h",
@ -34,6 +36,41 @@ module top;
pass = 1'b0; pass = 1'b0;
end end
// These should execute as if there was no event control
count = 0;
result[bit] <= repeat(count) @(posedge clk) 1'b1;
#1
if ($simtime != 71 || result !== 8'bxxxxxxx1) begin
$display("Failed @ at %0t, expected 8'bxxxxxxx1, got %h",
$simtime, result);
pass = 1'b0;
end
count = -1;
result[bit+1] <= repeat(count) @(posedge clk) 1'b0;
#1
if ($simtime != 72 || result !== 8'bxxxxxx01) begin
$display("Failed @ at %0t, expected 8'bxxxxxx01, got %h",
$simtime, result);
pass = 1'b0;
end
result[bit+2] <= repeat(0) @(posedge clk) 1'b1;
#1
if ($simtime != 73 || result !== 8'bxxxxx101) begin
$display("Failed @ at %0t, expected 8'bxxxxx101, got %h",
$simtime, result);
pass = 1'b0;
end
result[bit+3] <= repeat(-1) @(posedge clk) 1'b0;
#1
if ($simtime != 74 || result !== 8'bxxxx0101) begin
$display("Failed @ at %0t, expected 8'bxxxx0101, got %h",
$simtime, result);
pass = 1'b0;
end
if (pass) $display("PASSED"); if (pass) $display("PASSED");
$finish; $finish;
end end

View File

@ -78,6 +78,23 @@ module top;
pass = 1'b0; pass = 1'b0;
end end
// These should execute as if there was no event control
result <= repeat(0) @(posedge clk) 4.0;
#1
if ($simtime != 171 || result != 4.0) begin
$display("Failed @ at %0t, expected 4.0, got %f",
$simtime, result);
pass = 1'b0;
end
result <= repeat(-1) @(posedge clk) 5.0;
#1
if ($simtime != 172 || result != 5.0) begin
$display("Failed @ at %0t, expected 5.0, got %f",
$simtime, result);
pass = 1'b0;
end
if (pass) $display("PASSED"); if (pass) $display("PASSED");
$finish; $finish;
end end

View File

@ -78,6 +78,23 @@ module top;
pass = 1'b0; pass = 1'b0;
end end
// These should execute as if there was no event control
result <= repeat(0) @(posedge clk) 4'h4;
#1
if ($simtime != 171 || result !== 4'h4) begin
$display("Failed @ at %0t, expected 4'h4, got %h",
$simtime, result);
pass = 1'b0;
end
result <= repeat(-1) @(posedge clk) 4'h5;
#1
if ($simtime != 172 || result !== 4'h5) begin
$display("Failed @ at %0t, expected 4'h5, got %h",
$simtime, result);
pass = 1'b0;
end
if (pass) $display("PASSED"); if (pass) $display("PASSED");
$finish; $finish;
end end