TCL Basics

TCL (Tool Command Language): is a generic scripting language, which means it is used to execute other scripting languages.

Features of TCL:
1. It can be used only in its own shell called tcl shell or tclsh.
2. Every statement in TCL is like a command:
Every statement in TCL maps to a procedure in C language. Therefore, TCL is at a higher level than C, and therefore is more abstract.
3. All statements/commands in TCL return a string:
even if a number is returned, it is implicitly converted to a string and then returned.
4. New line in the script becomes a distinguisher between commands.
Though if command has to spread on multiple lines, the new line in every line except the last has to be escaped.
Commands can be separated by semicolon as well.
5. Most of the EDA tools are implemented in TCL commands.
So, almost every tool supports your customized TCL scripts.
6. It is case sensitive.

Tokens:
1. Keywords: all keywords in C like if, while, etc are treated like commands in TCL.

2. Identifiers: absolutely no restriction on identifiers. It can also include a space character if it is escaped.
Example:
%set a\ b 20
        %set 20 a


3. Literals:
3 types:

a. Integers: could be in base 10, 8 or 16

b. Real numbers: 123.4, 123E+02
c. Lists: Eg: set L1 {10 20 30 {a b c} 40}


Variables:

Can be of 2 types:

1. Scalar and lists:
set x 10

set L1 {10 20 30}

Lists cannot be accessed using elements like L1[0]. This is not allowed.



2. Hash:
Stored in key-value pairs.

Substitutions:
1. Variable substitution: It can be triggered by a $ sign, with or without double quotes.
It can be prevented by braces{}, or backslash\
    Example:
    % puts {$x}
$x
% puts “$x”
10
% puts “\$x”
$x

2. Backslash substitution:It happens with or without double quotes. It can be prevented by {}.
Ex: \n, \b, \t, \000

3. Command substitution:
It happens inside square brackets[]
Ex:
% set x [date]
% puts $x
26\06\2019

Comments

Popular posts from this blog

What should you expect in an VLSI interview as a fresher

The struggle to enter VLSI industry is for real