Translate page

Thursday, November 29, 2018

TCL Practice Task 4 (Scripting Language)

During the automation using TCL, sometime we have to ask inputs from the user even before running the program. One of the option is "Template" and other option is command line input. In the command line input, we uses switches which can help user to give input.
Example -file_name "name_of_file" . Here -flie_name is the switch and "name_of_file" is the input from the user. This type of program is very common in VLSI Industry. Understanding of this is important, if you are doing automation with large number of different inputs but at a time with only few combinations.

This is the forth and last part of this series. If you have missed first, second and third part, please visit it. TCL Practice Task 1, TCL Practice Task 2 and TCL Practice Task 3

To understand this Task, you should have Task 1, 2 and 3 program handy. :)

Task 4:- Command Line Development

Step 1: Create 1 Input file ("file_input1.txt")
Content of "file_input1.txt" is same as in the first 2 Tasks. So, you can copy this file from previous programs. Snapshot of the file is present below.

Input File: “file_input1.txt”

    Name        Delay    Trans    Load
    AND1_2X      1.50ns    0.1    1.25ff
    AND1_3X      1.75ns    0.2    1.98ff
    AND2_3X      2.37ns    0.3    2.27ff
    AND2_4X      1.82ns    0.5    2.54ff
    NAND1_2X    2.14ns    0.2    1.69ff
    NAND2_3X    2.48ns    0.3    2.11ff

Step 2: Write a TCL program, where you are going to ask different inputs as per below switches from the user.

User Input Switches


  • -trans , -load, -delay and -total_delay all are optional but minimum 1 is required.
  • There is no input of switches -trans , -load, -delay and -total_delay.
  • -cell_name is required switch.
  • In -cell_name switch user has to define cell names as per input "file_input1.txt". If Cell names are more then 1 , they should be separated by "," (comma).
  • If -cell_name is not present, user should get an error message with use model of this file and program should exit.

Step 3: As per the user defined name of the cell in "-cell_name" switch, extract respective information (as per switch or switches "-trans", "-load", "-delay" and "-total_delay") from input file ("file_input1.txt") and display it in the below format (This is same output format as per Task 2 or 3 output).

Example 1:- If user Enter Cell name AND1_2X with all properties then display data should be...

user command -cell_name AND1_2X -trans -load -delay -total_delay

    Name        Trans    Load    Delay    Total_Delay
    AND1_2X      0.1    1.25ff    1.50ns      1.50ns

Example 2:- If user Enter Cell name AND1_2X, AND2_3X, AND2_4X & NAND2_3X with all properties then display data should be...

user command -cell_name AND1_2X,AND2_3X,AND2_4X,NAND2_3X -trans -load -delay -total_delay

    Name        Trans    Load    Delay    Total_Delay
    AND1_2X      0.1    1.25ff    1.50ns      1.50ns
    AND2_3X      0.3    2.27ff    2.37ns      3.87ns
    AND2_4X      0.5    2.54ff    1.82ns      5.69ns
    NAND2_3X    0.3    2.11ff    2.48ns      8.17ns

Example 3:- If user Enter Cell name AND1_2X, AND2_3X with -trans switch only then display data should be...

user command -cell_name AND1_2X,AND2_3X -trans

    Name        Trans
    AND1_2X      0.1
    AND2_3X      0.3

Step 4: Print the above formated data as per user input in output file "file_output2.txt"

  • You have to reuse TCL program of Task 1, 2 and 3.
    • Reading of File "file_input1.txt" should be with the help of previous program only.
    • Get the user input and create a new file (temporary file) as per second input file (file_input2.txt) format of Task 2.
    • Once you create a temp file, you can reuse the program of Task 2 as it is (just by converting that into procedure)

Learning after this Program:
  • How to Open, Close, Read, write different files
  • How to take inputs from the users using command prompt.
  • How to display info, warning and Error messages to user.
  • Looping in a program and resetting a particular variable.
  • Exit option.
  • How to save user inputs in a variable or list of variables, even you don't know the number of inputs.
  • How to save data in List and do different operations on that
  • How to do Matching or say comparison of Data
  • How to select only a specific data
  • How to do mathematical calculations
  • Different commands use-model
    • argv option
    • split, join, shift, incr, expr
    • list, lindex, lappend
    • Foreach loop, While loop, If-else loop
    • gets and puts
  • How to manage single space, multiple space
  • Regular expression concepts
  • Procedure concepts (proc in tcl)
    • How to write a Procedure
    • How to pass a value to Procedure
    • How to call a Procedure
    • How to get return from a Procedure (return command)

I am sure these articles will help you to prepare for TCL scripting. I have few more such programs which I will try to capture later sometime.

-By Rajat Bansal
(Btech-EC:- 2019 Passout)
(ABES Engineering College)

-Supervised By Puneet Mittal
(Founder & Director)
(VLSI Expert Private Limited)


  1. Please post solutions to these task's (1,2,3,4), it would be helpful.

  2. Awesome post, you have shared an informative article about testing and tagging brisbane for us. Your method of writing is great. Keep it up.


Must Read Article

Related Posts Plugin for WordPress, Blogger...