You don't want to use $finish
to exit the simulator - that is considered a normal exit.
You should use $error or $fatal:
##1 assert(cb_module.dat_o == 4'h0) else $fatal("dat_o not 0");
Then you can script that into your -do file. After the run
command returns, the script should call runStatus
or runStatus -full
to determine if the run terminated for normal or abnormal reasons. Once the script determines that the script terminated because a user error, it can then call quit -code <n>
and return any non-zero number to indicate the failure condition.
Many tests do not want to exit the simulator on an assertion failure, so they use $error.
You can then use the command
coverage attribute -name TESTSTATUS
and it will return a severity code for the most severe message generated during your test run. So you may ultimately want to do
quit -code [coverage attribute -name TESTSTATUS -concise]