User Tools


Using TCL Files in Simulations

You can make a TCL file for each circuit you want to simulate. This is extremely useful as it allows you to easily run the same string of commands for a simulation without having to type the commands in the TCL Console over and over again! You will need to submit tcl simulation files with many of your laboratory reports.

Essentially a TCL file is simply a sequence of commands (like those you entered into the console to run simulations in Lab 3) that gets executed when you run it.

To start a new TCL file in Vivado, click on File then New File. (A TCL file is not a source so you can't add it by using the add sources command.) Name the TCL file after the module that you intend to use it for and include .tcl at the end of the file name. It's a good idea to save this inside a folder named TCL_files or something similar inside of your project folder. You can include spaces in your file/folder names for these, but it will make using them less pleasant.

In the TCL file, type out all your add_force commands like you did in Lab 3 to put values on your module's inputs. Be sure to have a run command at the end.

Here is an example TCL file for a 4:1 multiplexor that has inputs A, B, C, and D with a select line named sel. This TCL file will exhaustively test the module (test all possible input combinations).

restart     ;# Returns the current simulation to its initial state.
 
add_force A {0 0} {1 40} -repeat_every 80
add_force B {0 0} {1 20} -repeat_every 40
add_force C {0 0} {1 10} -repeat_every 20
add_force D {0 0} {1 5} -repeat_every 10
 
add_force sel {00 0} {01 40} {10 80} {11 120} -repeat_every 160
 
run 160

Note that everything after and on the same line as ;# is a comment. The restart command is not necessary, but it is nice to include to make sure your previous waveforms are cleared out to make room for the new ones.

Below is the waveform that this simulation produces. Note that the pattern on the inputs resembles a truth table turned sideways with A being the MSB. This is done by toggling the value of the MSB, A, the slowest in the TCL file above and progressively speeding up the toggling by a factor of 2 (because this is binary) for each input till you reach the LSB, D, which will toggle the fastest. You should always do this in your own simulations.

This mux also includes another input which holds two bits, sel. You can include this in the MSB to LSB chain if you want. Select inputs merely need to be cycled through all the inputs in a manner so that it becomes obvious that the correct operation is being selected.

Some new commands that are need to properly run TCL files are explained below.

Console Commands

source

To load and run a TCL file, you'll need the source command. This will run a TCL file. The following example explains the syntax of the source command.

  source J:\\ECEn\ 220/labs/myLab/myTCL.tcl 
  • source begins the command.
  • J:\\… is the path of the TCL file that you want to run. You must escape any spaces by putting a backslash \ character before them, as is done in the above example. If you have trouble entering the complete path name, simply copy what is above and enter in the appropriate folder names for your TCL file's path.

Notice that an escaped backslash \\ is needed after the drive letter but each folder is separated with a forward slash / instead.

cd

cd is a common command in many command line interfaces that means change directory. This can be very helpful when using source to load TCL files from the same folder over and over. Instead of needing to include the entire file path every time, you can use cd to navigate to the current folder of the TCL, then simple source the TCL file by name. The following example shows how the TCL file from the source section above can be used in this manner. The first line is typed out and executed and then the second line is typed out and executed.

  cd J:\\ECEn\ 220/labs/myLab
  source myTCL.tcl

You can then source any other TCL file in the myLab folder quickly without needing to type out the entire file path every time.

Changing Waveform Radix

Now that you'll be dealing with inputs and outputs that are larger than a single bit, change the radix of your waveforms will prove useful in reading your simulations.

The waveforms in Vivado's simulation tools default to binary. To change individual waveforms, right click on the name of the waveform, select radix, then choose a value. To change your simulation's default radix for all waveforms, click on Waveform Options from the simulation tools pane and change the Default Radix setting.