Closed dsdve closed 1 year ago
The same issue arises with functions:
interface foo #(int WIDTH = 8);
function get_width();
return WIDTH;
endfunction
endinterface
module bar(foo f);
if (f.get_width() > 1)
$error("oh no!");
endmodule
module test();
foo f();
bar b(.f(f));
endmodule
Assigning the parameter to a signal in the interface seems to be a decent workaround, though at least Verilator will complain when accessing the signal:
interface foo #(int WIDTH = 8);
int width;
assign width = WIDTH;
endinterface
[sorry for the earlier mis-click] Thanks for filing this! Indeed the errors raised here are incorrect. I have an idea of how to fix this properly, but I'll need some time to work on it. If you are blocked in the meantime, you could short circuit the check in checkExprResolution
locally (e.g., add False &&
).
Thanks! The workaround seems to work quite well for now.
I pushed 59b416f9b4a79e83b295793fd4807d7ca96c51c2, which should fix the original issue. Can you let me know if it works for you?
It does work for me. Thank you!
The following example fails to convert:
With the error
Though clearly,
f.WIDTH
is resolvable before inlining.However, if the
foo
-instance intest
is renamed to anything but the port name onbar
, it converts just fine. This behavior seems to be limited to interface parameters (includinglocalparam
), since doing a similar thing with interface signals works just fine.Given some pointers I'd be happy to try and fix this myself, though my Haskell skills might be lacking.