Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
14 years ago

Modelsim - trouble passing $ parameter from vsim to vlog

Hello all, I'm stumped on how to do something in modelsim. I was hoping maybe someone here has maybe done this before and can point me in the right direction. I think this must be a very common thing to do...

What I'm trying to do:

I am trying to pass in the name of a test file at the modelsim vsim command line. The whole idea is that everything in the sim environment stays the same and I have a number of these test files I feed into the simulation.

so my command would look something like this:

do run.do m3m_test_case

I am trying to pass in a $ parameter (m3m_test_case) from the modelsim vsim command line and use it in a vlog I'm able to pass in the $ parameter and use it for various other things, but when I try to use it in a vlog command, the vlog interprets it literally instead of converting it to the string I want.

This is my code in the do script

set m3m_test_case m3m_test_$1.v

vlog -vlog01compat -work work +incdir+../tests {../tests/"$m3m_test_case"}

This is the error message I get # Model Technology ModelSim ALTERA vlog 6.6d Compiler 2010.11 Nov 2 2010 # ** Error: (vlog-7) Failed to open design unit file "../tests/"$m3m_test_case"" in read mode. # Invalid argument. (errno = EINVAL)# ** Error: C:/altera/11.0/modelsim_ae/win32aloem/vlog failed. # Error in macro ./run_mpts_default.do line 141 # C:/altera/11.0/modelsim_ae/win32aloem/vlog failed. # while executing# "vlog -vlog01compat -work work +incdir+../tests {../tests/"$m3m_test_case"}"

Instead of evaluating the $m3m_test_case it treats it literally. It's almost like I need to escape it somehow or something. But I'm not sure how.

The following command works just fine so i know it's passing in the right stuff

code:

echo "this is the argument passed in: $m3m_test_case"

vsim command line: # this is the argument passed in: m3m_test_mpts_default_110709.v

Any help on this would be greatly appreciated.

Thanks

2 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    {} stops Tcl from expanding the variable.

    Use " " in place of {}

    vlog -vlog01compat -work work +incdir+../tests "../tests/$m3m_test_case"

    or just leave them out

    vlog -vlog01compat -work work +incdir+../tests ../tests/$m3m_test_case

    You can also use environment variables

    vlog -vlog01compat -work work +incdir+$env(TESTS) $env(TESTS)/m3m_test_case

    where TESTS is an environment variable pointing to your tests folder.

    Cheers,

    Dave
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Thanks Dave!

    I tried the quotes just as you said and it worked perfectly!

    vlog -vlog01compat -work work +incdir+../tests "../tests/$m3m_test_case"

    Best Regards