# Passing VHDL generics and constants via a tcl script

Status
Not open for further replies.

#### matrixofdynamism

Often tcl scripts are used to setup simulation environment. Is it possible to pass values for variables and constants in VHDL from within a tcl script?

#### rahdirs

Hi,

In an instantiated cell,if your entity has a generic "test_parameter" and your instantiated entity is "test_inst", then you can use Tcl calls to the Vivado to get the value of the generic.

Code:
set generic_val [get_property my_generic [get_cells test_inst]

The above code gets you value,i am not sure how to set constant value from tcl.Why not do it from a text file ?

matrixofdynamism

### matrixofdynamism

Points: 2

#### matrixofdynamism

OK, then lets do it this way. Is it possible that I put name of all constants with their values in a text file. Then in tcl script I tell which file to use. How will a value be assigned to each constant by reading from a file? The constants are not an array. They are different constants and have different names.

How to assign value to constant from a text file since constant is declared as 'constant myconstant : std_logic_vector := ???'?

#### TrickyDicky

you should be passing generics down from the top level setup. You're implying you want to override values set up in the code? why?

vsim has a -G switch that allows you to set top level generics.

##### Super Moderator
Staff member
you should be passing generics down from the top level setup. You're implying you want to override values set up in the code? why?

vsim has a -G switch that allows you to set top level generics.

Besides what Tricky said, you shouldn't be changing constants in your code, they are CONSTANTS for a reason, i.e. they don't change for any reason. Generics are used if a compile time constant can be different between compilations. This avoids the need to modify code to "change" a constant buried in the code.

Status
Not open for further replies.