Professional Documents
Culture Documents
TCL Session Notes
TCL Session Notes
Special Variables :
argc : it gives the count of arguments.
argv : it prints the argument values.
argv0 : it prints the name of the script.
Example:
#!/usr/bin/tclsh
puts $argc
puts $argv
puts $argv0
#!/usr/bin/tclsh
if {$argc != 8 } {
puts "Incorrect no.of arguments"
exit
}
Output :
$ ./Area.txt -x2 20 -x1 10 -y1 3 -y2 20
170
Syntax :
if {condition 1} {
} elseif {condition 2} {
} elseif {condition 3} {
} else {
}
Loops :
a) For loop
Syntax :
statement(s);
b) while loop
syntax :
initialization
while {condition} {
statement(s);
incrementation;
Break :
Continue:
FILE MANAGEMENT
Open a file
Read content
Write file content (new content replaces the old content)
Append file content (new content is added after the old content at the
end)
Reading a file : We can read the contents of a file using gets command.
gets command will read a line one by one from a file. When it completes
reading first line, it automatically increments to the second line. When all the
lines are read, it will return -1.
RULES :
QUESTION :
To extract the entity name in entity declaration from a VHDL file and to save
result in file.
Note: Create one VHDL file with many enity declarations and with different
entity names
RULES OF VHDL:
Any of spaces is allowed at beginning or no spaces is also fine
key word entity will be there in the beginning.
Min one space is required after entity and any number of space is fine
Entity_name: First char should be always a alphabet #:other character can
be alphabets/numbers/_
Min one space is required after entity_name and after that any no of space
is fine
Keyword is is compulsory
PLEASE REFER TO THE SCRIPT FILE FOR SOLUTION
OPERATORS
Boolean Operators :
&& logical and
|| logical or
! not
Arithmetic Operators :
+ : Adds 2 operands
- : Subtracts 2 operands
* : Multiplies 2 operands
/ : Divides 2 operands. Returns the quotient
% : Modulus Operator. Returns the remainder.
Ternary Operator:
?:
Condition true ? true value : false value
Relational Operator:
< : less than
< = : less than or equal to
> : greater than
>= : greater than or equal to
= = : equal to
!= : not equal to
Bitwise Operators :
~ : bitwise negation
^ : bitwise exclusive or
& : bitwise and
| : bitwise or