I am using python's subprocess to start modelsim executable. In the CLI, I enter quit -f -code<-5>. This should exit modelsim with exit code -5. I've tried multiple different subprocesses such as call/run/check_call/checkoutput but they all return 0 as if it successfully ran. If modelsim is exiting with a non-zero exit code shouldn't the subprocesses be returning non-zero return code and also raising CalledProcessError?
For example:
python example.py
in CLI
status = subprocess.call([r"C:\...\...\vsim.exe", "-c", "-do"])
in python script
quit -f -code<non-zero integer>
in CLI
Instead of quit try "exit -f -code 5".
Note Modelsim uses 1 to 231 for their own error messages so I would use a number above 256.
added: Both quit and exit seems to work OK for me, might be a version issue? I used Modelsim 2019.4 and Python 3.7.1. Here is the code I used:
Python code:
` import sys
import subprocess
def main(argv):
status = subprocess.call([r"vsim.exe", "-c", "-do", "run.do"])
print("vsim returned",status)
sys.exit(status)
if __name__ == '__main__':
main(sys.argv[1:])`
run.do file:
vsim top
run 1 us
quit -f -code 34
CMD batch file:
python callvsim.py
@echo Python returned %ERRORLEVEL%
And the output:
Errors: 0, Warnings: 0
vsim returned 34
Python returned 34
Good luck,
Hans
www.ht-lab.com