Tuesday, December 15, 2015

TCL example scripts

In this post, I will upload sample scripts to refer : (Under cons)

EXAMPLE : 1
For the engineers who are familiar with static timing analysis, as a programmer I want to calculate arrival time, required time, slack at each node using the given circuit. The example script will be able to demonstrate some of the tcl functions. The following circuit 10 nodes excluding (Out node), delay of each node is represented in the brackets. The objective of this program is to write a TCL script to analyse the slack at each and every node using graph based slack analysis.

Brief introduction about the graph based STA :
We need to break the entire program into three sections :
1. Arrival time calculation (AT)
2. Required time calculation (RT)
3. Slack calculation. 

First we need to calculate AT at each node, Let's do hand calculation of arrival time at few nodes. Arrival time at node 'A' is 10 as delay of node  'A' is 10 and then it passes through node 'D' whose delay is '8',  so the arrival time at node 'D' is 18 adding the delay of traversed path. But we can reach D by traversing IN->B->D accounting the delay of 13 (5+8), so we need to choose bigger one of the two arrival times (18,13) and assign that  arrival time to node 'D' in this case it is '18'. We need to repeat the same for all the nodes.


In the second section we need to calculate the required time starting from out node 'O'. In general we might be given required time by the clock specification. But in this case we take RT as the max of all the arrival times.









The above circuit can be represented using the adjacency matrix. Please refer to following link to know more about adjacency matrix. https://en.wikipedia.org/wiki/Adjacency_matrix




Sunday, December 13, 2015

physical design

Please visit this blog to learn/discuss all about physical design tips, techniques, fundamentals.

Monday, December 7, 2015

regex

Regex,regsub  :


A regular expression is simply a description of a pattern that describes a set of possible characters in an input string.

Example :



strings

Strings

  • A string is a sequence of letters, it always need not be enclosed in the quotes until you use some white spaces in between the words. Tcl is a string based language it provides rich set of operations on strings.
Examples :
set str1 one
set str2 "two three"

set str3 I\ need\ not\ enclose\ this\ in\ quotes

  • Following operations can be executed on strings:
    • string compare
    • string equal
    • string length
    • string match #global expression
    • string toupper
    • string tolower
    • string totitle #it will convert the starting letter of string to uppercase
    • string index
    • string range
    • string reverse
Example :




lists


  • Lists
    • Lists are equivalent to arrays in the conventional programming language like C.
    • Lists can be expanded and collapsed on the fly.

  • Example 1:
    • set list1 "a  b c d"

File handling

File Handling :

File names could be specified in Unix format.
In order to work with a file, first one has to open a channel to the file...this is also called handle
Once the channel is opened, TCL retruns a channelId which is used to work with the files
Typical steps to be followed while working with files:
Step 1: Check whether the file specified exists or not
Step 2: Open a channel pointing to the file...TCL returns an ID
Step 3: Use the ID to work with the file
Step 4: Close the channel after use

File Open :

"open" could be used to open a channel to a file. This command returns the file-handle (channelID) which could be used to work with the files.
Syntax:
open fileName ?access mode?
where
fileName - is the name of the file to be opened for use
access mode - either r, r+, w, w+, a or a+. These are the access modes (similar to C language)
"open" opens a channel to the file specified by the fileName with the access permissions specified by the access mode. Default is "r".
A channel once opened, remains open until specifically closed.

File Close :

"close" is used to close a channel previously opened using the "open" command.
Syntax:
close fileID
where
fileID - is the channel ID of the file opened


Example :




some of the useful file operations are: (no need to open a channel for these operations)
file exists      --> checks if the specifie file exists or not
file dirname     --> returns the parent directory of the specified file
file extension   --> returns the extension (suffix) of the specified file (incl. dot)
file isfile      --> returns 1 if “name” is a normal file
file isdirectory --> returns 1 if “name” is a directory
file executable  --> returns 1 if “name” has executable permissions
file readable    --> returns 1 if “name” has read permissions
file writable    --> returns 1 if “name” has write permissions
file tail        --> returns the last pathname component of “name”

file rootname    --> returns all but the extension of the “name”

procs

procedures are supported by TCL :

Procedures return to the calling program through "return" statement
Every procedure must have a corresponding return statement. This however is not strictly required.
Once they are created, procedures could be used just as any other TCL command
Procedures are declared with the help of keyword "proc"

Each procedure may have a set of formal parameters and some variables - local and global
Syntax:
proc proc_name { formal parameters } {
  statement1
  statement2
  :
  return
}
Example:
proc plus { a b } {
  expr $a + $b
  return
}

Syntax:
proc name argList body
where,
name - is the procedure name
argList - List of arguments. If a procedure takes more than one argument, they should be specified within braces.
body - body of the procedure
Example:

% proc proc_a { a b c } { body of procedure }
% proc proc_b b { body of procedure }
Once created, a procedure could be invoked/ called just by its name
Example: proc_a { $a $b $c }, proc_b { $b } w.r.t. The above example
Every procedure has its own set of local variables.
Any two procedures may have variables with the same names. The values of the variables do not get affected since they are not visible outside the procedure block.

"global" could be used to declare the scope of some variables as global
"global" should be used inside a procedure
Syntax:
global varName ?varName ...?
where
varName - is the name of variable whose scope has to be
extended beyond a procedure. More than one variable could be 
specified.
"global" binds variable names "varName"... to global variables. References to these names will refer to global variables instead of local variables for the duration of the current procedure.




Example 1:

Example 2: Simple tree traversal iterative procedure.

Example 3 :