Originally seemed to have meant 'Tool Command Language'.
Popular with EDA tools
tclsh: a simple tcl interpreter
General
- loop:
foreach elem in [seqvar]
Variables
- Starts with a
$
sign - Declare with
set
??
set outputDir ./my_dir
file mkdir $outputDir
Comments
- Starts with
#
. - Hacky way to have multi-line comment also possible.
https://wiki.tcl-lang.org/page/comment
File operations
- Delete a file (non-existant file won't cause error):
file delete file1 file2
- Delete a directory:
file delete -force <dirname>
Command line arguments
https://stackoverflow.com/questions/24376421/passing-arguments-from-command-line-into-a-tcl-script
argc
: number of command line argumentsargv
: command line arguments- first argument:
lindex $argv 0
- first argument:
argv0
: name of script (as in$argv0
)indexing a list:
lindex
Printing (puts
)
# A newline is added by default
puts "hello world"
%
hello world
# Use -nonewline to skip the new line
puts -nonewline "hello world"
% hello world%
See: https://wiki.tcl-lang.org/page/Tcl+cheat+sheet
Procedures (proc
)
This is how new commands are made in tcl.
proc say_hello {} {
puts "Hello!"
}
% say_hello Hello!
Or with an argument:
proc say_hello name {
puts "Hello $name!"
}
"Jack"
% say_hello Hello Jack!
Or with multiple arguments:
proc say_hello {fname lname} {
puts "Hello $fname $lname!"
}
"Jack" "Sparrow"
% say_hello Hello Jack Sparrow!
See:
Xilinix Vivado
Launch (no gui, but with tcl prompt):
vivado -mode tcl
- Can use
source name.tcl
to load a tcl file interactively
- Can use
launch in batch mode (no gui, no tcl prompt):
vivado -mode batch -source filename.tcl
tcl console:
start_gui
stop_gui
Globbing in paths:
[ glob ./src/hdl/*.vhdl ]
Read source file:
read_verilog top.v
- Use with
-sv
for systemverilog
- Use with
read_vhdl
read_edif
: netlist. Usable for proprietary IPs ??read_ip
: useful for core generators (xco, xci)
synthdesign: synthesis
optdesign: optimizations ??
poweroptdesign: (optional)
- Can introduce clock gating to save power
placedesign: placing
physoptdesign: (optional)
- Try additional logic optimizations
- Improve timing and area
routedesign: routing
writecheckpoint
opencheckpoint: open a previously save dcp file
launchrun: launch a run that was previously created
- Properties of a run can be set with
set_property
before running - Runs are used only in project mode ??
- Properties of a run can be set with
createrun: create a run
reportdesignanalysis
Checkpoint: netlist at a particular stage of the EDA process
Reports
- reportutilization
- reporttiming
- reportdrc: design rule check
writeverilog: write the netlist at its current stage as verilog
- Useful for examining/simulating
writexdc: write the constraints which were used during routing
- can be used only after routing can be done, I suppose ?
writebitstream: generate bitstream
remove_files PYNQ-Z2_3pin.xdc
: remove a file that was added to project- This won't delete the file, just removes it from current vivado project
—
- https://www.adiuvoengineering.com/post/microzed-chronicles-scripting-vivado
- https://byu-cpe.github.io/ComputingBootCamp/tutorials/vivado_tcl/
- https://support.xilinx.com/s/question/0D52E00006jDbmJSAS/synthesis-and-implementation-from-command-line?language=en_US
- https://support.xilinx.com/s/question/0D52E00006hpiWYSAY/runing-synthesis-using-tcl?language=en_US
- vivado design suite tcl command reference guide
- https://github.com/byu-cpe/BYU-Computing-Tutorials/wiki/TclVivado
- An official tcl vivado reference guide: https://docs.amd.com/v/u/2019.2-English/ug835-vivado-tcl-commands
—
# https://github.com/ATaylorCEngFIET/mz_428/blob/master/project/project-flow.tcl
# https://www.adiuvoengineering.com/post/microzed-chronicles-scripting-vivado
# start_gui
-part xc7k160tffv676-1
create_project hello /media/julinusername/zwei/data/vivado_projs/hello -norecurse /home/julinusername/verilog/Demo.topEntity/topEntity.v
add_files[current_fileset]
set_property top topEntity -fileset sources_1
update_compile_order1 -jobs 8
launch_runs synth_1
wait_on_run synth_1 -jobs 8 -to_step write_bitstream
launch_runs impl_1 wait_on_run impl_
Trivia
- stooop: a single file sourcable library