Hi,
I need to write a compact assertion equivalent with the version below , which contains sync_accept_on . My problem is that the property uses a local variable, consequently I cannot use sync_accept_on.
(in != 0, in_save = in) |-> sync_accept_on(erase == in_save)
##1 enable_out[->3] ##0 out == in_save;
“in_save” is the local variable.
How should be handled this situation in order to write a succinct assertion?
/* You'll need to call a function from the sequence match item to set a module variable.
The following code compiles and elaborates OK on Questa.
I added an action block to reset the save to a non-used value.
Note that there must be exclusivity when this assertion fires until it passes or fails, otherwise other successful attempts will reset the value of save.
You can do that with a go. */
module saccept;
bit clk, enable_out, go=1;
int in1, erase, out1, save=-1, in_save; // save==-1 assuming in_save is never -1
function void set_save(int v, bit b);
save=v;
go=b;
endfunction
property p1;
int in_save;
sync_accept_on(erase == save)
(go && in1 != 0, in_save = in1, set_save(in_save, 1'b0)) |->
##1 enable_out[->3] ##0 out1 == in_save;
endproperty
ap1: assert property(@(posedge clk) p1) set_save(-1, 1'b1); else set_save(-1, 1'b1);
endmodule
Note that the accept_on/reject_onfamily of operators terminates the property as an accept(true vacuously, with no contribution to the pass statistics) or reject (false vacuously, with contributions to the failed statistics). The previous solution (reiterated below) terminates the property as an accept true nonvacuously with contribution to the pass statistics; a difference.
property p1b;
int in_save;
//sync_accept_on(erase == save)
(go && in1 != 0, in_save = in1) |->
(##1 enable_out[->3] ##0 out1 == in_save) or (erase == save [->1]);
endproperty