You are on page 1of 8

Count Timing

3 Reports

Learning Objectives

After completing this lab, you should be able to:


 Apply the skills and concepts taught thus far in building
the procedure clean_log.

Lab Duration:
35 minutes

Count Timing Reports Lab 3-1


Lab 3

Lab Overview

This lab continues the building of a complex Tcl procedure to clean duplicate timing
reports from a log file.

Answers & Solutions


This lab guide contains answers and solutions to all questions. If you need help
with answering a question or would like to confirm your results, check the back
portion of this document.

There are two levels of help available in the Answer/Solutions section at the end of
this lab for each task – starting from a flow diagram to the complete procedure.

Lab Tasks
Start the procedure clean_log by
Apply file I/O commands and
reading and writing a log file
define procedure attributes
LAB 1

Gain comfort with a useful component


of Tcl scripts and add non-positional Playing with Tcl arrays and
arguments and validateion to clean_log parse procedure arguments
LAB 2

Gain experience with the commands


Count timing reports in
and concepts taught thus far
timing.log
LAB 3

Gain experience with the commands


Remove duplicate timing
and concepts taught thus far
reports in timing.log
LAB 4

Lab 3-2 Count Timing Reports


The Power of Tcl 2: Creating High-Impact Procedures
Lab 3

File Locations

Directory Structure
design_data ORCA netlist
scripts Run scripts
libs Technology libraries
tcl_procs Solution directory
log Log file directory
.synopsys_dc.setup Setup file for Design Compiler
.synopsys_pt.setup Setup file for PrimeTime

Relevant Files
scripts/
clean_log.tcl Continuation for clean_log proc
runtiming.tcl To regenerate timing.log file
tcl_procs/
clean_log4.tcl Solution for lab 2
clean_log5.tcl Solution for lab 3
clean_log.tcl Final solution
log/
timing.log Log file to be cleaned

Count Timing Reports Lab 3-3


The Power of Tcl 2: Creating High-Impact Procedures
Lab 3

Lab Instructions

Your goal is to continue building clean_log that strips out the duplicate timing
reports and returns a clean log file for more efficient analysis.

Task 1. Identify and Understand Relevant Commands

Utilize all of the job aids for help!

1. Answer the following questions.


Use the answers as hints when you modify the procedure clean_log in the
next task.

Question 1. What does the gets command do with the end of line
character (the newline)?

....................................................................................................

Question 2. By default, will puts add a newline to the end of the string
written to a file?

....................................................................................................

Question 3. Which Tcl command is useful for appending strings together?

....................................................................................................

Lab 3-4 Count Timing Reports


The Power of Tcl 2: Creating High-Impact Procedures
Lab 3

Task 2. Count Timing Reports in timing.log

Modify clean_log to count the total number of timing reports in timing.log.

1. Count the total number of timing reports in timing.log.


(The in and out files should still remain exactly the same).

If you were unable to complete lab 2, please use


./tcl_procs/clean_log4.tcl for this task.

Modify your procedure to include the following three bullets:


 Within the while loop, capture each complete timing report from the in
file as a single string. Each line in the timing report must be separated by
a newline.
Identify the first line of a timing report using the characters *Startpoint*
and use *slack* to identify the last line of a timing report (the *
represents a wildcard, matching any sequence of characters).

It is important to capture each complete timing report as a single


string as this will be utilized in the next task when completing the
procedure clean_log.

 After each complete timing report is captured, write the complete report to
the out file.
 The command clean_log should return the total number of timing reports
in the in file.

2. Source the modified procedure into either Design Compiler or PrimeTime and
verify the following:

# Execute the following lines in either Design Compiler or PrimeTime


pt_shell> clean_log –in ./log/timing.log –out ./log/clean.log
 200
# The two log files should once again be equivalent
pt_shell> exec diff timing.log clean.log

3. Quit the Synopsys tool and return to lecture.

Count Timing Reports Lab 3-5


The Power of Tcl 2: Creating High-Impact Procedures
Lab 3 Answers / Solutions

Answers / Solutions

Task 1. Identify and Understand Relevant Commands

Question 1. What does the gets command do with the end of line
character (the newline)?

It will strip the end of line character (the newline) from each
full line in the file being read.

Question 2. By default, will puts add a newline to the end of the string
being written to a file?

Yes.

Question 3. Which Tcl command is useful for appending strings


together?

Use the Tcl command append. Use “hello world” type


examples if necessary to recall how this command works.

Lab 3-6 Count Timing Reports


The Power of Tcl 2: Creating High-Impact Procedures
Answers / Solutions Lab 3

Task 2. Count Timing Reports in timing.log


Below is a flow diagram for this task in creating clean_log.tcl, followed by the
complete code for the relevant portion of the procedure.

From within the while loop,


if each_line contains if
*Startpoint*, then start string match
building the report string and set
set a trigger

else if each_line contains elseif


*slack*, then reset the string match
trigger, increment the count puts
and write out the complete append
report to the out file incr

else if inside a timing report,


continue building the report append
string

else write each_line to the else


outfile puts

Outside the while loop,


return
return the report count

Count Timing Reports Lab 3-7


The Power of Tcl 2: Creating High-Impact Procedures
Lab 3 Answers / Solutions

# Full solution in ./tcl_procs/clean_log5.tcl


# True if inside a timing report, false if not
set inside_rpt 0
# Number of timing reports in infile
set infile_count 0

while {[gets $in_file_handle each_line] != -1 } {


if {[string match *Startpoint* $each_line]} {
set inside_rpt 1
set capture_rpt $each_line\n
} elseif {[string match *slack* $each_line]} {
set inside_rpt 0
incr infile_count
append capture_rpt $each_line
puts $out_file_handle $capture_rpt
} elseif {$inside_rpt} {
append capture_rpt $each_line\n
} else {
puts $out_file_handle $each_line
}
}; # End while

close $in_file_handle
close $out_file_handle
return $infile_count

Lab 3-8 Count Timing Reports


The Power of Tcl 2: Creating High-Impact Procedures

You might also like