-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
External function incorrectly pruned if rule is otherwise uneffectful #12
Comments
This is correct behavior, although it can be unexpected: functions are specified to be pure (they need to have a pure model), so if their return value is unused they can be eliminated. The trick to force them to be kept is to use the return value, e.g. by writing it to a dummy register, as you noticed. I don't understand your second example too well — what is it about the nonconstant value? (This will be fixed when we have proper support for modules, since function calls will become observable and hence not tivially optimizable) |
I might be approaching this wrong, but my problem is that my Koika design will be part of a larger design, and the larger design is not combinational. To get signals in/out of my design I have been using external functions with
I just noticed that the external call was dropped with |
You're doing it right, but it requires extra care because Kôika doesn't have a good story about its module system at the moment. I summarized this in #2 (comment) , and there are more details about this in #10 ; the first link in particular has a pretty detailed description of how to do this safely (the main example we have of this is the bus in the RISCV core. If you want me to look at a concrete case I'll be happy to give design-specific advice. |
In the following example, an external function is written to but the input value is unused/dropped. The generated verilog drops the call to total_o completely (even though it is effectful as we write a value to it). I would guess the logic optimisation pass does not correctly account for external functions.
Full source example. Relevant sections:
Note no mention of the external call in generated verilog (occurs also for
efr_internal := false
):Adding a dummy register and writing to it with a nonconstant value generates correct verilog:
The text was updated successfully, but these errors were encountered: