fabianschuiki / llhd

Low Level Hardware Description — A foundation for building hardware design tools.
http://www.llhd.io
Apache License 2.0
392 stars 30 forks source link

Entity creating suspend action during simulation #143

Closed wbouillo closed 4 years ago

wbouillo commented 4 years ago

When attempting to use the llhd-sim binary to simulate an entity with a proc manipulating inputs to the entity, I am getting a thread '<unnamed> panicked at 'cannot suspend entity', src/bin/llhd-sim/engine.rs:377:40 error. It appears to me that a halt is being interpreted at the end of entities. However, simulating a proc by itself works fine.

Inverter_TB.txt

fabianschuiki commented 4 years ago

Excellent catch! Are you running v0.14 of llhd-sim? Your suspicion of the halt being executed sounds very plausible.

wbouillo commented 4 years ago

I am currently using v0.15-dev.

fabianschuiki commented 4 years ago

Cool, thanks for checking. The culprit seems to be this line: https://github.com/fabianschuiki/llhd/blob/f64affed256df08c9a4e6ab12138562b55cd36a2/src/bin/llhd-sim/engine.rs#L661

Since the most recent IR refactoring in LLHD, entities now have a dummy halt terminator instruction at the end, to make them more uniform with functions and processes. If you're up for it, my suggestion would be to insert a line just before the above one:

Opcode::Halt if unit.is_entity() => Action::None,
fabianschuiki commented 4 years ago

Fixed as part of #144.