Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to wait for Modelsim Simulations to complete before proceeding in TCL script

Tags:

tcl

vhdl

modelsim

I am trying to execute a regression test in Modelsim. I call a TCL script which compiles my source files and launches vsim. I launch a .do file and it runs a series of testbenches which all output result files. What I am adding is an automated checker that verifies the result files match known good runs. The problem is that after launching modelsim the TCL script doesn't wait for the completion of simulation before executing the checker "results_pass.py".

set nice_pid [open "|$modelsim_dir/vsim.exe -do do_files/vsim.do -novopt -gui"]
cd ../../Scripts
set script_name "results_pass.py"
set tb_name "rcp"
call_python $script_name $tb_name
vwait forever

For those wondering why I am calling a Python script. Mostly because I know very little TCL but don't have the time to go and change the legacy TCL script into Python.

Anyway, I am confident there is something I can stick between lines 1 and 2 that will wait for some indication from modelsim that it has completed executing my .do file. Any advice is appreciated.

like image 660
jarickc Avatar asked Jan 08 '23 05:01

jarickc


2 Answers

Have you tried VUnit?https://github.com/LarsAsplund/vunit

It is an open source VHDL test framework that already does what you want.

It can run tests in parallel as well as with different generics values.

A test bench can have multiple tests which can be run in independent simulations as well as in the same simulation.

It can emit a test report that is understood by Jenkins containing test output, runtime and status.

It comes with a VHDL library of convenience functions such as check_equal.

It has complete VHDL dependency scanning so that files can just be added and VUnit will know what to incrementally compile to speedup the edit/compile/run cycle.

Can run user defined post simulation checks to verify for instance an output file against golden data.

In addition to running in batch it can launch the test in a GUI with a single flag.

It supports Modelsim and GHDL with Aldec and NVC coming soon.

I have personally used it to manage 200+ test cases.

Disclaimer I am one of the main authors. It was created to avoid each VHDL team in the world to re-inventong the wheel with inhouse scripts of varying quality.

like image 159
kraigher Avatar answered Mar 15 '23 23:03

kraigher


Answering my own question I wound up getting this to work before receiving responses. The other suggested solutions may be better.

First I modified my .do file adding line three below.

project open my_project.mpf
do do_files/regression.do
file delete -force "lock.txt"

Then I modified my TCL script as follows.

set nice_pid [open "|$modelsim_dir/vsim.exe -do do_files/vsim.do -novopt -gui"]

,# Create a "lock file" that is cleared at the completion of the .do file.
set lock_file "lock.txt"
set lock_PID [open $lock_file w]
close $lock_PID  

while {[file exists $lock_file]} 
    {after 1000}

cd ../../Scripts
set script_name "results_pass.py"
set tb_name "my_tb"
call_python $script_name $tb_name
vwait forever

This way the calling process waits for Modelsim to complete before proceeding.

For anyone looking to use this here is call_python proc which I found here

;#----------------------------------------------------------------------------;
;# Procedure to call python scripts. Include ".py" extention.
;#----------------------------------------------------------------------------;

proc call_python {script_name tb_name} {
    set output [exec python $script_name $tb_name]
    print $output
}

$tb_name is just an argument for my python script.

like image 36
jarickc Avatar answered Mar 15 '23 23:03

jarickc