Open polybeandip opened 3 weeks ago
Thanks @polybeandip, and congrats(? 😅) on finding an interesting issue! A few suggestions to make other readers' lives easier:
compile-invoke
pass. Consider pointing folks to permalinks for those, since those are the first two things people will want to see.invoke
is involved on a seq
memory. Please document that, as I think that will really help the team!Changes looking great, thanks for bearing with my somewhat pedantic request!
Hey, @polybeandip—REALLY nice work on the bug writeup here; this is a model of how to make a description like this clear and self-contained. 👏
This looks like a real doozy. It's especially delicious that Icarus and Verilator disagree, with is example number 54089454 of how Verilog is under-specified to such a degree that even very popular implementations routinely disagree. I feel like there is a strong chance that this problem exists in our Verilog backend rather than in the compiler lowering per se.
I don't know if it will reveal anything, but one potentially-useful next step here would be to do some test case reduction on the generated Calyx program, or perhaps the one produced after compile-invoke
. Maybe we can produce the smallest possible (lowered) Calyx program that elicits this disagreement…
This issue is about divergent behavior between
icarus-verilog
,verilator
, and the Calyx interpreter.Here's a toy eDSL program and it's associated data file:
This program should read
5
from memoryA
and write this value into memoryB
. However, depending on whether it's run withicarus-verilog
,verilator
, or the calyx interpreter, we find different results:Verilator:
Icarus-verilog:
Calyx interpreter:
(run on Havarti by @anshumanmohan)
verilator
and the Calyx interpreter produce the correct result, whileicarus-verilog
does not.It appears this behavior is specific to reading from sequential memories passed as references to a component called via
invoke
. For example, running either of these programs withbug.data
causes no issues.A
changed from seq to comb memory:Memories no longer passed via reference through
invoke
:You can find the files referenced here on this branch:
bug.py
bug.data
bug.futil
; from runningpython bug.py > bug.futil
bug-after-compile-invoke.futil
; from running the compile-invoke pass onbug.futil
:calyx -p compile-invoke bug.futil -m file > bug-after-compile-invoke.futil