Open zyedidia opened 3 years ago
Thanks @zyedidia for reporting this issue. This is indeed something that should work, and off the top of my head I don't think there is anything technical that prevents having non-constants in this case statement.
The relevant code is here: https://github.com/fabianschuiki/moore/blob/eb4d44cf0da15617b312ada81bd8f5da844f720b/src/svlog/codegen.rs#L2278-L2301
It looks like the only thing that requires a bit of care are casex
/casez
, where the code generation currently wants a constant value to check for X
and Z
bits. This is due to the current lack of support for four-/nine-valued logic in LLHD (it's planned, but not implemented yet) -- so the codegen tries to do this ahead of time for the common case of casex
/casez
.
The above code could instead first check if the value is a constant (there's a compiler query for that), and if yes perform the whole masking/matching magic, and otherwise just use the non-constant value for the comparison.
It seems like moore requires that case items evaluate to integer constants even though this is more restrictive than the SystemVerilog standard. For example, this code should be valid SystemVerilog:
But moore reports an error: