1
\$\begingroup\$

Given a SystemVerilog design modeling an ASIC, how can I enforce the rule that all logic/reg elements that are used in flip-flops should not be initialized to a certain value? Is there a directive that I can use in my code that would prevent this?

Here's an example:

module asic (...);
    logic a;    // this is fine
    // logic a = 1;    // but this is not fine

    reg b = 1;  // this is fine since it is not a flip-flop

    always @(posedge clk, posedge rst)
    if (rst)
        a <= 0;
    else if (b)
        a <= ~a;
endmodule

I think a check like this would be really helpful in ensuring that all registers in the ASIC design have a reset. The tools I use are Verilator (for linting and simulation) and Yosys (for synthesis), but I haven't been able to find a related option in their documentation.

\$\endgroup\$
4
  • \$\begingroup\$ I don't know System Verilog, but can you use logic a = X; ? \$\endgroup\$ Commented Jul 22, 2020 at 23:41
  • \$\begingroup\$ If by 'X' you mean the 'X'/unknown value, what I'm trying to achieve is the prevention of any use of logic initialization of the form 'logic NAME = VALUE'. \$\endgroup\$ Commented Jul 24, 2020 at 21:36
  • \$\begingroup\$ OK, then just verify that all flip flop outputs are X before you assert reset. Or grep the source for "logic .* = [01]" \$\endgroup\$ Commented Jul 25, 2020 at 0:26
  • \$\begingroup\$ I'm actually doing this for now until support is added for the feature. I'll make sure to update this post once I find a solution. \$\endgroup\$ Commented Jul 28, 2020 at 1:42

1 Answer 1

2
\$\begingroup\$

Inline initialization is not good, even for the b signal. A commercial tool I use for ASIC synthesis ignores those initializations and throws warnings.

If b is a constant, the below would be better (still not ideal).

logic b;
assign b = 1;

I experienced failures in formal equivalence checking (RTL vs. synthesis netlist) as well, so I avoid inline initializations in design.

\$\endgroup\$
4
  • \$\begingroup\$ I'm thinking you can't tell me, but could you tell me which tool you were using so I could do some research into how it checks for those initializations? I can't use it myself since I have to use open-source tools since the software I wrote that uses it is used in academia. \$\endgroup\$ Commented Jul 24, 2020 at 21:34
  • \$\begingroup\$ @norandomtechie It was Synopsys Design Compiler. \$\endgroup\$
    – user154136
    Commented Jul 24, 2020 at 22:29
  • \$\begingroup\$ Is Synopsys Design Compiler accepting assignment of logic inside initial block to synthesis ??? \$\endgroup\$
    – Mitu Raj
    Commented Nov 14, 2020 at 8:31
  • 1
    \$\begingroup\$ @MituRaj No. \$\endgroup\$
    – user154136
    Commented Nov 14, 2020 at 14:44

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.