I am trying to add a “conditional assertion” inside modular scope that check my shiftData from DUT is not high until done signal is high.
Ex:
module MyModule (
input wire shiftData,
input wire done
);
property shiftData_until_done;
@(posedge clk) disable iff (!reset) // Disable during reset
(shiftData === 0) until (done === 1);
endproperty
if ($test$plusargs("ENABLE_ASSERTION")) begin
assert property (shiftData_until_done)
else $display("Assertion failed: shiftData is high before done signal is high");
end
endmodule
But this syntactically incorrect. Wrote the code to convey my aim.
Is there a way to add conditional processing for assertion?
NB: I don’t want to use `ifdef since the arg should be passed during simulation.
Have you tried using vunit?
vunit is alternative of bind except you don’t need to probe/connect the design signals.
Moreover, you can keep the Assertions and Covergroup out of the design code for readability.
vunit supports the SVA and covergroup to be within and it’s kind of extending the design where you have access to all the design signals.
here is the example I made it for the code you provided.
I added the missing clk and reset signals.
Command to run:
xrun -sv -clean assert_in_mod.sv -propfile_vlog vunit_assert.vunit +ENABLE_ASSERTION
module MyModule (
input wire shiftData,
input wire done,
input clk,
input reset
);
endmodule : MyModule
vunit mod_assert(MyModule) {
property shiftData_until_done;
@(posedge clk) disable iff (!reset & **!$test$plusargs("ENABLE_ASSERTION")**) // Disable during reset
(shiftData === 0) until (done === 1);
endproperty
//if ($test$plusargs("ENABLE_ASSERTION")) begin
assert property (shiftData_until_done)
else $display("Assertion failed: shiftData is high before done signal is high");
//end
}
In reply to bachan21:
I guess the missing code was always@ or initial.
module MyModule (
input wire shiftData,
input wire done,
input clk,
input reset
);
property shiftData_until_done;
@(posedge clk) disable iff (!reset) // &!$test$plusargs("ENABLE_ASSERTION")) // Disable during reset
(shiftData === 0) until (done === 1);
endproperty
always@(posedge clk) begin
if ($test$plusargs("ENABLE_ASSERTION")) begin
assert property (shiftData_until_done)
else $display("Assertion failed: shiftData is high before done signal is high");
end
end
endmodule : MyModul