2
\$\begingroup\$

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 the final 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.

\$\endgroup\$
5
  • 1
    \$\begingroup\$ What tool are you trying to use? Assertions are for simulation or formal checking tools, not synthesis. \$\endgroup\$
    – dave_59
    Commented Jul 9, 2023 at 1:32
  • \$\begingroup\$ @dave_59 I use modelsim for simulation and intel Quartus Prime lite edition for synthesis. I was under the impression that assertions where synthesisable \$\endgroup\$ Commented Jul 9, 2023 at 1:32
  • \$\begingroup\$ Is the error coming from modelsim or quartus? \$\endgroup\$ Commented Jul 9, 2023 at 8:08
  • \$\begingroup\$ syntax error at properties.sv(6) near text: "final"; is odd: Does line counting start at zero? \$\endgroup\$
    – greybeard
    Commented Jul 9, 2023 at 9:44
  • 1
    \$\begingroup\$ The error is coming from quartus and the syntax error is on the line assert final (pa == pb)... \$\endgroup\$ Commented Jul 9, 2023 at 10:33

1 Answer 1

1
\$\begingroup\$

Bind syntax: bind dut : dut_inst properties dut_bind (.pa(da), .pb(db));

Place it inside the testbench module after instantiating the DUT.

Since Quartus tool is for synthesis, use a compiler directive to let the synthesis tool skip the assertion.

Example:

module tb();

    logic [7:0] ta;
    logic [7:0] tb;

    dut dut_inst(.da(ta), .db(tb));

// if SYNTHESIS is not defined, include below code  
`ifndef SYNTHESIS
    bind dut : dut_inst properties dut_bind (.pa(da), .pb(db));
`endif
// end if
    initial begin

       // do something here...

    end

endmodule

Pass SYNTHESIS as a compilation option during synthesis to let the tool skip the assertion.

\$\endgroup\$
6
  • \$\begingroup\$ What is and how do I use the directive you mentioned? \$\endgroup\$ Commented Jul 9, 2023 at 10:35
  • \$\begingroup\$ @KyriafinisVasilis updated my answer \$\endgroup\$ Commented Jul 9, 2023 at 10:40
  • \$\begingroup\$ @KyriafinisVasilis since Quartus is for synthesis, don't include testbench in it. Please accept my answer if that helped! \$\endgroup\$ Commented Jul 9, 2023 at 10:55
  • 1
    \$\begingroup\$ I surrounded the bind with the // synthesis translate_off // synthesis translate_on directives and Quartus synthesized the code but now I have problems on modelsim saying Error: (vsim-3033) Instantiation of 'properties' failed. The design unit was not found.. I suspect it is because the design was not synthesized \$\endgroup\$ Commented Jul 9, 2023 at 11:02
  • \$\begingroup\$ Also, I don't use the testbench as the top module and I have it set up in Quartus as a testbench for the dut \$\endgroup\$ Commented Jul 9, 2023 at 11:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.