当前位置:网站首页>TCL scripting language foundation (2)
TCL scripting language foundation (2)
2022-07-23 19:08:00 【qq_ forty-four million nine hundred and eighty-five thousand si】
One 、 brief introduction
Tcl It's a kind of quilt EDA Scripting languages widely supported by the tool , Usually as EDA The tool shell practical .Tcl Extremely XDC Extension enables users to take advantage of Tcl Language in VIvado Complete some series of development operations on , To complete the path 、 The clock 、 Multiple constraints on ports , So as to realize FPGA Design engineering test and correction . Here is a brief introduction to these statements , Concrete XDC Special sentences are explained in other articles .
Two 、Tcl Variable
stay Tcl in , All variables are controlled by ASCII String representation . Variable usage set Command to assign , Its use format is as follows :
set a 1234; # notes : take 1234 Assign a value to a variable a
Using symbols $ Variables can be processed , Replace the assigned value with , And when it is {} Inside , It has no special meaning . As shown below :
set a 1; # hold 1 Assigned to a variable a
set b {
$a}; # hold $a Assign to b
puts a; # Print out characters a
puts $a; # Print out a Given value 1
puts b; # The result is $a
If you add an index after a variable name , Then the variable is automatically converted to an array , The index can be a number , It could be a string :
set a(1) 1; # Array a The index of 1 The value of is assigned as 1
puts $a(1); # The printed result is 1
puts $a; # If no index is given , Is invalid ;
set a(b) 2; # Array a The index of b The value of is assigned to 2
You must pay special attention when buying here $ Usage of , He converts variables into their actual values .
3、 ... and 、Tcl list
A list is a collection of objects , You can add 、 Search and other operations .
1. List creation
set gates [list AND OR NOT NAND NOR];
set gates [{
AND} {
OR} {
NOT} {
NAND} {
NOR}];
set gates [split "AND.OR.NOT.NAND.NOR" "."];
All three methods above can create a Tcl list , As can be seen from the above example :
1、list Keywords created for the list ;
2、AND OR After escaping the parentheses {} After escaping, it is assigned to the list as a normal string ;
3、split Represents the string cutting function , Its return value is list .
2. List operation keywords :lappend、lsearch
lappend Add a new element to the list :
set List name [lappend List name Specific elements ];
lsearch Realize whether there is a specific element in the search list , If there is , Returns the index , If it doesn't exist , return -1
lsearch $ List name Element name ;
Four 、Tcl Expressions and operators
1. Expression evaluation
Expression evaluation uses keywords expr
expr function Numbers ;
Example :set x 10;
expr $x+10; Get the results 20
2. Self adding keywords : incr
incr Variable Numbers ;
Add variables to numbers , The result is assigned to the variable .
3. Operator list
Tcl Operators supported in
| Operator | describe |
|---|---|
| -、 +、 ~ 、! | One dollar minus 、 One yuan plus 、 According to the not 、 Logic is not |
| + 、-、 *、 / | Add 、 reduce 、 ride 、 except |
| ** | Index |
| <、> 、<=、 >= 、==、 != | Less than 、 Greater than 、 Less than or equal to 、 Greater than or equal to 、 be equal to 、 It's not equal to |
| eq、ne | Compare two strings equal 、 It's not equal to |
| in、ni | The checklist contains 、 Operators without strings |
| &、 | 、^ |
| && | Logic and |
| <<、>> | Move left 、 Move right |
5、 ... and 、 Control flow statement
1. List traversal
List traversal uses foreach structure
foreach Variable name $ List name [];
In parentheses, guard the circular body , All elements in the list will be traversed , The element value is assigned to the variable defined in the statement .
2.if sentence
if{
Discriminant }
{
sentence }
elseif{
Discriminant }
{
sentence }
else
{
sentence }
Tcl Provides break and contiune Two keywords are related to If Sentence combination , For loop control .
3.for sentence
for initial value Discriminant Step change
{
Execute statement }
4.while sentence
while Conditions
{
Execute statement }
5. The process ( function ) Definition
proc The process of {
Parameters 1 Parameters 2 ...}
{
The process of body
return parameter }
边栏推荐
- 图的存储结构与方法(二)
- [2013] [paper notes] terahertz band nano particle surface enhanced Raman——
- MQ【MessageQueue 图文详解及四大MQ比较】
- Multithreading & high concurrency (the latest in the whole network: interview questions + map + Notes) the interviewer is calm
- Deepstream learning notes (II): description of GStreamer and deepstream-test1
- Multithreading [comprehensive study of graphics and text]
- 【2020】【论文笔记】基于Rydberg原子的——
- Conception de l'interface UART basée sur la FPGA
- jumpserver管理员账号被锁定
- 【2018】【论文笔记】石墨烯场效应管及【2】——石墨烯的制备、转移
猜你喜欢

Conception de l'interface UART basée sur la FPGA

LeetCode 剑指 Offer II 115.重建序列:图解 - 拓扑排序

Great God "magic change" airpods, equipped with usb-c interface, 3D printing shell makes maintenance easier

AE 教程,如何在 After Effects 中对 Illustrator 分图层文档进行动画绘制?

Analysis on the implementation of Flink exactly once delivery
![[2020] [paper notes] new terahertz detection - Introduction to terahertz characteristics, various terahertz detectors](/img/94/ff67867ef3237d8779628c8872b694.png)
[2020] [paper notes] new terahertz detection - Introduction to terahertz characteristics, various terahertz detectors

How to become a modeler? Which is more popular, industrial modeling or game modeling?

Completion report of communication software development and Application

图的存储结构与方法(二)

How to replace the double quotation marks of Times New Roman in word with the double quotation marks in Tahoma
随机推荐
398. 随机数索引-哈希表法
Three things programmers want to do most | comics
Error "failed to fetch" XXX "temporary failure resolvingw: some index files failed to download" solution
[paper reading] gettext: trajectory flow map enhanced transformer for next POI recommendation
【2020】【论文笔记】基于二维光子晶体的光控分光比可调Y——
SQL 语句练习
FPGA实现IIC协议(二)之IIC总线的FPGA实现(单次读写驱动)
80 + guests took the stage, users from more than 10 countries attended the meeting, and 70000 + viewers watched the end of "Gwei 2022 Singapore"
Redis [2022 latest interview question]
FPGA基于spi的flash读写
日志框架【详解学习】
1259. 不相交的握手 動態規劃
C#Split的用法,Split分割字符串
Log framework [detailed learning]
398. Random number index hash table method
1259. 不相交的握手 动态规划
Implementation of SPI communication protocol based on FPGA
LM393低功耗双电压比较器参数、引脚、应用详解
How to use quota
ResponseBodyAdvice接口使用导致的报错及解决