I have a SystemVerilog module that I want to test using assertions. For simplicity let's say the DUT is this:
module dut (
input logic [7:0] da
output logic [7:0] db
);
always_comb begin:
if (da == '0)
db <= '1;
else
db <= '0
end
endmodule
I have also created a file containing a module with the assertions for the DUT:
module properties(
input logic [7:0] pa,
input logic [7:0] pb
);
always_comb begin:
assert final (pa == pb) $error("assertion failed"); else $display("PASS");
end
endmodule
And finally I have a test bench:
module tb();
logic [7:0] ta;
logic [7:0] tb;
dut dut_inst(.da(ta), .db(tb));
bind dut_inst properties dut_bind(.pa(da), .pb(db));
initial begin:
// do something here...
end
endmodule
The problem: When compiling the code I get two errors from Quartus :
- The first one is about the properties module and says:
Error (10170): Verilog HDL syntax error at properties.sv(6) near text: "final"; expecting "(".
If I remove thefinal
keyword the error goes away but I must use final to filter out simulation glitches. - The second one says
Error (10170): Verilog HDL syntax error at tb.sv(8) near text: "bind"; expecting "endmodule".
What I have tried so far
Regarding the first issue I only tried to remove the final
keyword but it is not a solution as I said before.
For the second error, I tried binding this way:
bind dut properties dut_bind(.pa(da), .pb(db));
but I get the same error. I also tried moving the bind out of the tb
module like that:
module tb();
logic [7:0] ta;
logic [7:0] tb;
dut dut_inst(.da(ta), .db(tb));
initial begin:
// do something here...
end
endmodule
bind dut properties dut_bind(.pa(da), .pb(db));
but I got a similar error saying Error (10170): Verilog HDL syntax error at tb.sv(8) near text: "bind"; expecting a description.
What am I doing wrong?
PS: I am using intel Quartus Prime lite edition.
syntax error at properties.sv(6) near text: "final";
is odd: Does line counting start at zero? \$\endgroup\$assert final (pa == pb)...
\$\endgroup\$