Guest
Hi everyone,
In using Accellera assertions in Verilog, I have seen that for many
assertions, any error flagged is reported at the next clk edge (i.e.,
the active clk edge *after* the one where the error was detected). I
just want to know whether this behaviour is correct or not, because if
it's not, then I'm probably triggering the assertion incorrectly.
Could you please go through this very simple example of an
'assert_always' assertion ?
`define OVL_ASSERT_ON
`define OVL_INIT_MSG
`include "assert_always.vlib"
/*---- Module Definition ----*/
module ctr_4_bit (q, clk, clear);
output [3:0] q;
input clk, clear;
reg [3:0] q;
always @ (negedge clear or posedge clk)
begin
if (clear == 0) q <= 4'd0;
else q <= q + 1;
end
endmodule
/*--- Stimulus Block ----*/
module top;
reg clk, reset;
wire [3:0] q;
ctr_4_bit st (q, clk, reset);
initial
clk = 1'b0;
always
#1 clk = ~clk;
initial
begin
reset = 1'b0;
#1 reset = 1'b1;
#20 reset = 1'b0;
#1 $finish;
end
/*---- SHM Dump Block ----*/
initial
begin
$shm_open ("assert_always_example.shm");
$shm_probe ("as");
end
/*---- Assertion Block ---*/
assert_always #(
`OVL_ERROR,
`OVL_ASSERT,
"Error",
`OVL_COVER_ALL)
check (
clk == 1,
reset == 1,
q[2] == 1'b1);
endmodule
A very quick explanation: This program is a simple 4 bit counter and
it's allowed to run for a few clks and then made to end via the $finish
statement. The assertion has to flag the errors at all those clks where
q[2] = 1 doesn't hold true, right ?
The assertions are indeed triggering, but all of them are reported at
the consecutive clk of the error condition. For example, q[2] = 0 at
time = 1, 3 and 5 units in the output (I'm specifying only the posedges
of the clk) and the corresponding errors are reported at t = 3, 5 and 7
units. At t = 7, q[2] does become 1, and so, this should not set off
the assertion, but as I just mentioned, it does, which is what prompted
me to reach the conclusion that the bad behaviours may be reported 1
clk later.
Also, this particular property holds true for not only 'assert_always',
but many others, like 'assert_cycle_sequence', 'assert-handshake',
'assert_next', 'assert_no_overflow', 'assert_no_transition' etc.
If someone could tell me whether this is OK or not, I'd be really
grateful.
Thanks in advance,
Amit.
In using Accellera assertions in Verilog, I have seen that for many
assertions, any error flagged is reported at the next clk edge (i.e.,
the active clk edge *after* the one where the error was detected). I
just want to know whether this behaviour is correct or not, because if
it's not, then I'm probably triggering the assertion incorrectly.
Could you please go through this very simple example of an
'assert_always' assertion ?
`define OVL_ASSERT_ON
`define OVL_INIT_MSG
`include "assert_always.vlib"
/*---- Module Definition ----*/
module ctr_4_bit (q, clk, clear);
output [3:0] q;
input clk, clear;
reg [3:0] q;
always @ (negedge clear or posedge clk)
begin
if (clear == 0) q <= 4'd0;
else q <= q + 1;
end
endmodule
/*--- Stimulus Block ----*/
module top;
reg clk, reset;
wire [3:0] q;
ctr_4_bit st (q, clk, reset);
initial
clk = 1'b0;
always
#1 clk = ~clk;
initial
begin
reset = 1'b0;
#1 reset = 1'b1;
#20 reset = 1'b0;
#1 $finish;
end
/*---- SHM Dump Block ----*/
initial
begin
$shm_open ("assert_always_example.shm");
$shm_probe ("as");
end
/*---- Assertion Block ---*/
assert_always #(
`OVL_ERROR,
`OVL_ASSERT,
"Error",
`OVL_COVER_ALL)
check (
clk == 1,
reset == 1,
q[2] == 1'b1);
endmodule
A very quick explanation: This program is a simple 4 bit counter and
it's allowed to run for a few clks and then made to end via the $finish
statement. The assertion has to flag the errors at all those clks where
q[2] = 1 doesn't hold true, right ?
The assertions are indeed triggering, but all of them are reported at
the consecutive clk of the error condition. For example, q[2] = 0 at
time = 1, 3 and 5 units in the output (I'm specifying only the posedges
of the clk) and the corresponding errors are reported at t = 3, 5 and 7
units. At t = 7, q[2] does become 1, and so, this should not set off
the assertion, but as I just mentioned, it does, which is what prompted
me to reach the conclusion that the bad behaviours may be reported 1
clk later.
Also, this particular property holds true for not only 'assert_always',
but many others, like 'assert_cycle_sequence', 'assert-handshake',
'assert_next', 'assert_no_overflow', 'assert_no_transition' etc.
If someone could tell me whether this is OK or not, I'd be really
grateful.
Thanks in advance,
Amit.