December 18, 2024

Vivado and Tcl - constraint files

I have mentioned several times that constraint files are just tcl scripts.
Let's take a look at a few of them.
set_property IOSTANDARD LVCMOS33 [get_ports {leds_tri_o[*]}]
set_property SLEW SLOW [get_ports {leds_tri_o[*]}]
set_property DRIVE 8 [get_ports {leds_tri_o[*]}]

set_property PACKAGE_PIN F16 [get_ports {leds_tri_o[0]}]
set_property PACKAGE_PIN L19 [get_ports {leds_tri_o[1]}]
set_property PACKAGE_PIN M19 [get_ports {leds_tri_o[2]}]
set_property PACKAGE_PIN M17 [get_ports {leds_tri_o[3]}]
As you can see, this is just invoking the command "set_property" a bunch of times. The general form of "set_property" is:
set_property property value object
The last lines set the "PACKAGE_PIN" property to values like F16 for the object given as the last argument.

The last argument is obtained by invoking the "get_ports" command. This does a lookup given the string we like to use for a port name and returns an object, which is whatever thing the set_property command is happy with.

In Tcl, curly braces are pretty much the same as quotes. Curly braces do not allow interpolation inside of them, but double quotes do. Just for the record, single quotes have no meaning in Tcl -- they are just another character.


Feedback? Questions? Drop me a line!

Tom's Computer Info / tom@mmto.org