table of contents
When using development tools, there may be times when you wish certain features were available, and you wished you could automate and streamline operations.
However, with the wide variety of customers and usage, implementing all the requested features into the development tools would be
There are concerns that having too many functions will make it complicated and difficult to use, and that bugs will increase.
We will introduce Libero SoC's tcl commands as a way for you to implement behavior that suits your usage.
- tcl command example
- How to run a tcl file
- About the documentation and samples
- Check basic operation: Let's run tcl!
- Example 1: Let's make it into a batch file!
- Example 2: Let's play a notification sound when writing to the FPGA is complete!
- Example 3: Count up the Design version!
- Inquiry
*The information provided is based on the operation of Libero SoC v2024.1.
*This article will omit explanations of general information such as the scripting language tcl (Tool Command Language), command prompt, batch files, and PowerShell.
*Please note that we cannot take any responsibility for any consequences resulting from using the examples presented here.
tcl command example
As an example, the following tcl command is provided:
Executing logic synthesis
run_tool -name {SYNTHESIZE}
Run Place and Route
run_tool -name {PLACEROUTE}
Writing to FPGA
configure_tool -name {PROGRAMDEVICE} -params {prog_action:PROGRAM}
run_tool -name {PROGRAMDEVICE}
Writing to Flash memory
configure_tool -name {PROGRAM_SPI_FLASH_IMAGE} -params {spi_flash_prog_action:PROGRAM_SPI_IMAGE}
run_tool -name {PROGRAM_SPI_FLASH_IMAGE}
How to run a tcl file
The tcl file can be executed in two ways:
・Execute from Libero SoC Project > Execute Script...
・Execute from a Windows command script
(example)
> C:\Microchip\Libero_SoC_v2024.1\Designer\bin\libero.exe SCRIPT:C:\test\test.tcl LOGFILE:C:\test\tclresult.log
*Libero SoC installation path
- The path and file name of the tcl file to be executed
- The path and file name of the log file to be generated
Please change as necessary.
About the documentation and samples
[document]
For details on Libero SoC Tcl commands, please refer to the Libero SoC Tcl Command Reference Guide.
The User Guides tab at the following URL has documents for each version of Libero SoC.
https://www.microchip.com/en-us/products/fpgas-and-plds/fpga-and-soc-design-tools/fpga/libero-software-later-versions#Documentation
For example, how to run Tcl commands from the command line is described in the "Running Tcl Scripts from the Command Line" section.
[sample]
When you download Microchip FPGA design files, they often do not include an actual Libero SoC project.
Basically, you create a Libero SoC project from scratch by running the included tcl script.
Therefore, the tcl scripts in the xxxxxxx_df.zip file can be used as reference.
https://www.microchip.com/en-us/application-notes
[others]
Operated by Libero SoC
Libero SoC > Project > Export Script File...
When you run this command, you can check the reference tcl code to see what kind of tcl your operation will be.
Check basic operation: Let's run tcl!
Let's try running logic synthesis using the tcl command.
Running tcl from Libero SoC
(1) Prepare a Libero SoC project that is already synthesizable.
Just to be sure, check that Synthesize is possible on the Libero SoC GUI.
(2) Prepare a text file and save it as test.tcl.
The text file contains the following:
Please change C:/lab/top/top.prjx according to your Libero SoC project.
open_project -file {C:/lab/top/top.prjx}
run_tool -name {SYNTHESIZE}
save_project
(3) Execute the test.tcl you created from Libero SoC Project > Execute Script...
The Libero SoC project will open and you will see that Synthesize is running.
If it doesn't work, check test.tcl for typos, etc.
(4) Close the Libero SoC.
Running tcl from the Windows command prompt
(1) Prepare a Libero SoC project that is already synthesizable.
Just to be sure, check that Synthesize is possible on the Libero SoC GUI.
(2) On the Libero SoC GUI, right-click Synthesize and click Clean.
Verify that the green check mark indicating Synthesized has disappeared, then close Libero SoC.
(3) The tcl file is the one used in "Executing tcl from Libero SoC".
test.tcl (unchanged)
open_project -file {C:/lab/top/top.prjx}
run_tool -name {SYNTHESIZE}
save_project
(4) Start the Windows command prompt, enter the following and press Enter.
Please change the Libero SoC version, installation path, tcl file and log file paths and file names as appropriate.
C:\Microchip\Libero_SoC_v2024.1\Designer\bin\libero.exe SCRIPT:C:\test\test.tcl LOGFILE:C:\test\tclresult.log
(5) Check the generated log file tclresult.log to confirm that synthesis has been completed.
(6) Open the Libero SoC project and make sure there is a green check mark to the left of Synthesize.
* When you run tcl from the Windows command prompt with a project open in Libero SoC
The GUI may or may not work in conjunction with this, so here we will describe the steps to close Libero SoC once.
Note :
In the above example, we used the already working Libero SoC project to check the operation of tcl.
When actually using it, we will use the tcl catch command to add error handling.
For example, in the case of Synthesize
Libero SoC Tcl Command Reference Guide > 2.1.4 Running Synthesis
https://coredocs.s3.amazonaws.com/Libero/2024_1/Tool/libero_soc_tcl_cmd_ref_ug.pdf#page=28
An example is provided in.
Example 1: Let's make it into a batch file!
As an example, we will create a batch file that can be executed by double-clicking "Check basic operation: Let's run tcl!".
For test.tcl, we will use the same one (which has been confirmed to work) used in "Check basic operation: Let's try running tcl!"
test.tcl (unchanged)
open_project -file {C:/lab/top/top.prjx}
run_tool -name {SYNTHESIZE}
save_project
(1) Open a text editor, write the code below, and save it as hogehoge.bat.
(Change the Libero SoC version, installation path, tcl file and log file paths and file names accordingly.)
@echo off rem tclスクリプトの実行 "C:\Microchip\Libero_SoC_v2024.1\Designer\bin\libero.exe" SCRIPT:C:\test\test.tcl LOGFILE:C:\test\tclresult.log rem キーが押されるまで待つ pause
(2) Double-click hogehoge.bat to run it.
(3) Check the generated log file tclresult.log to confirm that synthesis has been completed.
※ After executing the bat file
Press any key to continue...
To close the command prompt without a message, use the batch file:
rem pause
and comment it out.
Example 2: Let's play a notification sound when writing to the FPGA is complete!
(1) Prepare a Libero SoC project that can be written to the FPGA.
Just to be sure, check that you can Run PROGRAM Action on the Libero SoC GUI.
(2) Prepare a tcl file that performs the Run PROGRAM Action and confirm that you can write to the FPGA using the tcl command.
Change the C:/lab/top/top.prjx part according to your Libero SoC project.
writefpga.tcl
open_project -file {C:/lab/top/top.prjx}
configure_tool -name {PROGRAMDEVICE} -params {prog_action:PROGRAM}
run_tool -name {PROGRAMDEVICE}
save_project
(3) As an example, we will prepare a batch file in PowerShell that plays a system sound.
Please change the path and file name as appropriate for your environment.
finishsound.bat
@echo off rem tclスクリプトの実行 "C:\Microchip\Libero_SoC_v2024.1\Designer\bin\libero.exe" SCRIPT:C:\test\writefpga.tcl LOGFILE:C:\test\tclresult.log rem PowerShellでシステム音を鳴らす powershell -nop -c "[System.Media.SystemSounds]::Exclamation.Play()" rem キーが押されるまで待つ rem pause
(4) Double-click the batch file you created, finishsound.bat, to run it.
(5) When writing to the FPGA is complete, confirm that the PC system sound is heard.
Verify that the writing was successful by checking the FPGA operation after writing and the log file.
Example 3: Count up the Design version!
When using Auto Update, set the Design version in Congure Programming Options in the Design Flow tab on the left side of Libero SoC.
Let's set this design version using tcl.
(1) Prepare a text file (C:\test\PrjVer.txt) to store the design version.
Enter the Design version in the file.
PrjVer.txt
5
(2) Create a batch file.
- Read the current number from the text file PrjVer.txt
- Add 1 to the number you loaded as the new version
- Run the tcl file, passing the incremented number as an argument
- Overwrite the numbers in the text file PrjVer.txt
Please change the tool installation path, the names and paths of tcl files and log files, etc. as appropriate for your environment.
PrjVerCounter.bat
@echo off rem C:\test\PrjVer.txt から値を読み取る set /p ReadValue=<C:\test\PrjVer.txt rem 読み取った値に 1 を加算 set /a UseValue=ReadValue + 1 echo ReadValue : %ReadValue% echo UseValue : %UseValue% rem UseValueを C:\test\PrjVer.txt に上書き echo %UseValue% > C:\test\PrjVer.txt rem tclスクリプトの実行 "C:\Microchip\Libero_SoC_v2024.1\Designer\bin\libero.exe" SCRIPT:C:\test\PrjVerSetting.tcl "SCRIPT_ARGS:%UseValue%" LOGFILE:C:\test\tclresult.log rem キーが押されるまで待つ pause
(3) Prepare a tcl file.
PrjVerSetting.tcl
set value [lindex $argv 0]
puts $value
open_project -file {C:/lab/top/top.prjx}
configure_tool -name CONFIGURE_PROG_OPTIONS -params "design_version:${value}" -params "silicon_signature:${value}"
save_project
(4) Run the batch file.
(5) Open Congure Programming Options in the Design Flow tab on the left side of Libero SoC and check the Design version.
For example, if PrjVer.txt contains 5, the new Design version will be set to 6, which is +1.
In this example, Silicon signature is also configured in the same way.
Inquiry
If you have any questions regarding this article, please contact us below.
To Microchip manufacturer information Top
If you want to return to Microchip manufacturer information top page, please click below.