Assignment 2
1. You are reading a text document which is given below.
a. In which Company name has been mentioned repeatedly. Make a script which gives you number of
times Company name has been mentioned in the text.
b. Extend this for each and every word in the text file. [ only Words frequency except (, . $ # ) ].
Text File:
Hi, We are at sankguj Ahemdabad.
We want to celebrate #Sankguj day, as a Sankalp Team AhemDABAD.
SankGuj Day is celebrated on 02/01/2020
SANKGUJ Semi offers you an Integrated Portfolio .
SankGuj is fast Growing Company.
SankGuj has Large Business at $Physical Design && also , Verification Side.
2. Write a TCL script that reads the given set of log files from different simulations and generates a
consolidated report in .xls format which should contain the information as below. If the test is
successful, the log file has the status as “TEST PASSED” and if the test is unsuccessful, then the log
file has the status as “TEST FAILED”. [Take 2 log files one contains TEST PASSED the other contains
TEST FAILED,make combined report like Test1 → TEST PASSED Test2 → TEST FAILED]
3. Search for your name in the text file. In few lines of that text file your name has been mentioned.
Using regexp and regsub, replace your name with your surname.
4. You have been provided with names of pins in a file.
block_inst0/abcdef/i
block_inst0/abcdef/q
block_inst0/abcd/phi
block_inst0/abcd/def/clk
block_inst0/abcdef/o
block_inst0/abcdef/t
block_inst0/abcdef/tp
block_inst0/ab/cdef/ti
block_inst0/abcdef/en
block_inst0/abc/d/ef/test
block_inst0/abc/def/TEST
block_inst0/i
a. Scan through and filter out “ti,en,test,TEST” pins & print.
b. Add some more pins which should not be filtered.
block_inst0/TEST
block_inst0/ti
block_inst0/en
block_inst0/test
5. Check for file name abc.txt whether it exists or not.
a. If exists you should open that in append mode and insert some text else open that in write mode and
insert some text.
b. If exists you should delete that and create new one and insert some text.
6. You have been provided with names of pins & max trans in a file.
Pin Name Max Trans
block_inst0/abcdef/i 0.01
block_inst0/abcdef/q 0.02
block_inst0/abcd/phi 0.03
block_inst0/abcd/def/clk 0.04
block_inst0/abcdef/o 0.05
block_inst0/abcdef/t 0.06
block_inst0/abcdef/tp 0.07
block_inst0/ab/cdef/ti 0.08
block_inst0/abcdef/en 0.09
block_inst0/abc/d/ef/test 0.10
block_inst0/abc/def/TEST 0.11
block_inst0/i 0.12
Print only pins having more than 0.10.
7. Typical tcl script will run until first error in its execution.
For example
set a [lindex $argv 0]
set b [lindex $argv 1]
puts [expr $a/$b]
puts [expr $a+$b]
puts “Hello”
If this script is run for b=0; it will just come out and at line 3 and wont execute instruction 4 and 5.
With the help of error handling prevent that from happening. [Hint : Error Handling]
8. Write a tcl program to read date (dd/mm/yyyy) as command-line argument and convert and print the
month name and whether it is leap year or not. You should do validity check on the input. [Note: It
should match all the format like d/mm/yyyy or dd/m/yyyy d/m/yyyy]
9. Using proc example explain scope of variable. [local global] Also discuss variable related built in
commands. Also store proc in one file call the same proc in other file.
10. Find no of lines, words, chars in a input file