Open yutakang opened 6 months ago
See #436. IIRC Alasdair said it simply hasn't been implemented yet. I may have imagined that though.
Thanks, @Timmmm. I will leave this issue here, as it explains why the current translation of foreach
from Sail to SystemVerilog does not work as intended, using a concrete example.
This might be useful for someone at the University of Cambridge who will address this issue.
Hi there,
I've identified an issue related to the Sail-to-SystemVerilog translator. The problem arises when translating Sail code that involves the
foreach
construct. Simply put, I suspect that the translation of theforeach
construct in Sail toif… then… else…
in SystemVerilog is not working as expected. To illustrate this, let's consider theHighestSetBit
as an example.Note that I changed the function name from
HighestSetBit
toexecute
to trigger the translator.Even though one can sometimes emulate for-loops using
if-then-else
constructs and by exploiting SystemVerilog’s intrinsic parallelism, it seems that this translation is not working as expected.The problem becomes evident in the above example where the
if-then-else
constructs used to emulate for-loops are located inside a function in SystemVerilog. However, SystemVerilog’s atomic execution model forfunction
s does not allow us to effectively exploit intrinsic parallelism to emulate for-loops.Furthermore, it seems that we also need to use
always
constructs to introduce procedural blocks effectively. As a new user of Sail and SystemVerilog, it appears to me that translatingforeach
in Sail tofor
in SystemVerilog is a more straightforward approach.Are there reasons for using
if-then-else
constructs to emulate for-loops?