Hello,
I am trying to write a assertion for the below scenario.
A box has 4 inputs (a,b,c,d) and a single output (ack). We need to write an assertion to make sure when output (ack) is asserted, a and b and c and d should have asserted (in any order) in the last 4 cycles.
Below is my try: I want to specify the range in the $past, can someone review the code and let me know?
module tb;
bit clk,ack;
bit req[4];
default clocking @(posedge clk);
endclocking
initial forever #10 clk=!clk;
bit was_a_req, was_b_req,was_c_req,was_d_req;
always @(posedge clk) begin
if(was_a_req) req[0] <= 1'b1;
if(was_b_req) req[1] <= 1'b1;
if (was_c_req) req[2] <= 1'b1;
if (was_d_req) req[3] <=1;
end
ap_valid_req: assert property(@ (posedge clk)
$rose(ack) |-> $past((req[3] & req[2] & req[1] & req [0]),4)) $display ("Assertion passed",$time);
initial begin
$dumpfile ("hello.vcd");
$dumpvars (0,tb);
end
initial begin
repeat(200) begin
repeat(1) @(posedge clk)#1;
if (!randomize(was_a_req,was_b_req,was_c_req,was_d_req,ack) with
{ was_a_req dist { 1'b1:=1,1'b0:=1};
was_b_req dist { 1'b1:=1,1'b0:=1};
was_c_req dist { 1'b1:=1,1'b0:=1};
was_d_req dist { 1'b1:=1,1'b0:=1};
ack dist { 1'b1:=1,1'b0:=1};
}) `uvm_error("MYERR", "This is a randomize error");
end
$stop;
end
endmodule