Skip to content
hw.dev
hw.dev/signal/hdlsim-vhdl-finish-exit-code-2026
Signalhdlsim

A VHDL Testbench Can Finally Fail the Shell With Its Own Status

hdlsim fixes a small exit-code bug that determines whether automated hardware tests can stop a build.

Thesis connection

A hardware test only helps an automated build when its failure reaches the shell correctly.

#eda#testing#verification#software
Read Original

hdlsim used to turn a deliberate testbench failure into a successful shell command. A Very High Speed Integrated Circuit Hardware Description Language (VHDL) test calling std.env.finish(3) exited with status zero, so a continuous integration (CI) job could keep going after the test had told it to stop.

The simulator had mapped VHDL's finish call and Verilog's $finish onto the same internal operation. That was wrong because the VHDL argument is a process exit status, while the Verilog argument controls diagnostic output. hdlsim now keeps the two operations separate, stores the VHDL status in simulation checkpoints, and returns a value from zero through 255 to the shell. Regression tests cover both languages so the fix for one can't change the other.

This is a small patch with an outsized consequence: passing test output is useless when the build system receives the wrong result. Teams adding a newer simulator to CI should plant one test that exits with a known nonzero status before trusting any larger regression run.