Closed Icenowy closed 5 years ago
The problem involved stems from the fact that $clog2 only works with compile time constants. These can be generated with literals, such as 25 or 32'hdead_beef, or from parameters. Further, if the compile time constant comes from a parameter, that parameter needs to have a default definition in order to avoid this error.
We would like to implement this feature in the future since other tools seem to be able to handle this construct. The 2002 Verilog synthesis standard, however, specifically states that system function calls are not supported for synthesis.
From the Verilog Synthesis standard (IEEE Std 1364.1):
Yosys, however, does support $clog2
(and a few other system functions), but only on simple compile time constants.
@olofk -- please see above
As for this case, I'm pretty convinced no one has ever used it with something other than 32-bit buses. Not even sure the other stuff in wb_common works with anything else, but I'll do a new release where I rewrite the clog2 stuff to if (dw == 64) shift = 3; else if (dw == 32) shift = 2; else if (dw == 16) shift = 1; else shift = 0;
that should be enough to avoid this problem, right?
Released version v1.0.3 with this fixed
@udif : Thank you so much for that comment! I've been dealing with a couple pieces of (somebody else's) code that haven't had defaults for their parameters. Now I can report back to them that these reflect actual bugs in their designs.
@cliffordwolf : I think we can close this issue now.
Steps to reproduce the issue
Let Yosys run read_verilog on the wb_common verilog file from wb_common. https://github.com/fusesoc/wb_common/blob/master/wb_common.v
Expected behavior
The file should be successfully processed.
Actual behavior
If define BROKEN_CLOG2, then there will be another error: