0

I'm trying to pass multiple VHDL generics to the testbench in Modelsim 10.7b using -g switch in the vsim command. How do I pass multiple generic where all the generics are defined in another string/file.

in short : When I use

set generics "-gHEIGHT=1 -gWIDTH=2" vsim $generic work.test only the first generic, i.e., HEIGHT is getting changed. WIDTH is not getting the value 2. It remains at the value initialised at the entity.

test.vhd file:

library IEEE;
use IEEE.std_logic_1164.all;

entity test is

  generic (
    HEIGHT : integer := 0;
    WIDTH  : integer := 0);

  port (
    clk : in std_logic);

end entity test;

architecture arch of test is

begin  -- architecture arch



end architecture arch;

used commands to run the sim :

vlib work
vmap work work
vcom test.vhd
set generics  "-gHEIGHT=1 -gWIDTH=2"

vsim command where both generics are passed to the vhdl file successfully using -g switch :

vsim -gHEIGHT=1 -gWIDTH=2 work.test

vsim command where only first generic in the string generic is passed to the vhdl..i.e only HEIGHT is passed:

vsim $generics  work.test

I'm trying to pass multiple (~10) generics from python via vsim command. So I cannot list the generics name in the vsim command which executes the simulation.

3 Answers 3

4

To pass multiple arguments contained in a single variable to a command, expand the variable using {*}:

vsim {*}$generics work.test
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks. That worked! Just an additional question, do you happen to know how do I pass other arguments of the vsim. For example : vsim -wlf test.wlf -c -do run.do doesn't actually creates a wlf named test.wlf. I had to add it as vsim -wlf test.wlf work.test
Sorry, I don't have a clue about modelsim. Your first question was really just plain Tcl, which is why I was able to answer that.
@Rakend in your first vsim command in your comment (vsim -wlf test.wlf -c -do run.do), you don't specify a design unit, like you do in the second command (vsim -wlf test.wlf work.test), where work.test is the library and design unit. Maybe that's why it didn't create a WLF, because it didn't know what design unit to simulate.
1

As an alternative, you can use the -f argument to the vsim command and specify a file containing various vsim arguments, including generic arguments. E.g.:

vsim -f arg_file.txt

Then your file (arg_file.txt in this case) can contain your generic arguments or whatever else you might need:

-gHEIGHT=1 -gWIDTH=2

Comments

0

It worked with eval "vsim $generics work.test"

Even though Modelsim evaluates this statement and displays it as vsim -gHEIGHT=1 -gWIDTH=2 work.test on command execution, looks like vsim parser is not taking this as an argument.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.