fabianschuiki / moore

A hardware compiler based on LLHD and CIRCT
http://www.llhd.io
Apache License 2.0
246 stars 31 forks source link

Wait with unit-less duration generates incorrect code #220

Open fabianschuiki opened 3 years ago

fabianschuiki commented 3 years ago

Wait statements with an integer argument instead of a exact duration with units generate LLHD wait instructions with an i32 duration. For example:

module foo;
    initial #1;
endmodule

Generates the following LLHD:

proc %foo.initial.3.0 () -> () {
0:
    %1 = const i32 1  ; wrong, should be a time constant
    wait %2 for %1
2:
    halt
}

entity @foo () -> () {
    inst %foo.initial.3.0 () -> ()
}

This should generate a time constant, at least picking some arbitrary unit as a starting point, and later actually honoring the timescale and timeunit statements and preprocessor macros in the SV source code.