TCL 2 2015.00 LG 04

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

\

Remove Duplicate
4 Timing 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

Remove Duplicate Timing Reports Lab 4-1


Lab 4

Lab Overview

This lab completes the 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
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 4-2 Remove Duplicate Timing Reports


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

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_log5.tcl Solution for lab 3
clean_log.tcl Final solution
log/
timing.log Log file to be cleaned

Remove Duplicate Timing Reports Lab 4-3


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

Lab Instructions

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

Task 1. Identify Relevant Commands

1. Answer the following questions.


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

Question 1. Which Tcl command is useful for searching a list for an


element that matches a pattern?

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

Question 2. What type of pattern matching (globbing or exact) is useful to


determine if two timing reports match?

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

Lab 4-4 Remove Duplicate Timing Reports


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

Task 2. Remove the Duplicate Reports

This final task will complete the procedure clean_log. Do not forget to utilize all of
the job aids!

The final step is to only write the unique reports to the outfile. If there are duplicate
reports, the in and out files will no longer be equivalent.

If you were unable to complete lab 3, please use


./tcl_procs/clean_log5.tcl for this task

1. Modify your procedure to include the following:


 After each complete timing report is found from the in file, compare the
new timing report string with a list of unique timing report strings that
were previously found. If there is a match, then ignore the new timing
report string and continue. If there is no match, add this new timing report
string to the list and write it to the out file log.
 If the list of unique timing reports does not exist, create it and write the
new timing report to the out file log.
 If the –verbose switch is provided, the command should output the
suggested summary shown below.
 The command should return the number of duplicate reports.

1. 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 -v

There were 200 timing reports in the original log file


Of these, 120 were unique timing reports
80 timing reports were cleaned
80

2. Quit the Synopsys tool.

Congratulations. This completes the labs for this workshop.

Remove Duplicate Timing Reports Lab 4-5


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

Answers / Solutions

Task 1. Identify Relevant Commands

Question 1. Which Tcl command is useful for searching a list for an


element that matches a pattern?

Use lsearch. This command returns –1 if no element is


found in the list that matches a pattern. Use man pages and
“hello world” type examples if necessary to explore this
command and its usage.

Question 2. What type of pattern matching (globbing or exact) is useful


to determine if two timing reports match?

Use exact pattern matching because the string and the


pattern must exactly match (with no special characters). A
timing report may contain characters such as the * and [ ]
that should be interpreted as those exact characters (and not
as wildcards).

Lab 4-6 Remove Duplicate Timing Reports


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

Task 2. Remove the Duplicate Timing Reports


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.

After a complete timing


report is found in the in file

If the unique list exists, if


search it for a matching info exist
report. If none if found, add lsearch -exact
the new report to the unique lappend
list and write it to the outfile puts

If the unique list does not


exist, create it with the new lappend
report and write it to the puts
outfile

After the while loop, write puts


out a summary llength

Remove Duplicate Timing Reports Lab 4-7


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

# Full solution in ./tcl_procs/clean_log.tcl


if {[info exists prev_rpts]} {
if {[lsearch -exact $prev_rpts $capture_rpt] == -1} {
lappend prev_rpts $capture_rpt
puts $out_file_handle $capture_rpt
}
} else {
lappend prev_rpts $capture_rpt
puts $out_file_handle $capture_rpt
}
# Skip to end of procedure
if {[info exists results(-verbose)]} {
echo \
"\nThere were $infile_count timing reports in the original log file"
ehco \
"Of these, [llength $prev_rpts] were unique timing reports"
echo \
"[expr $infile_count - [llength $prev_rpts]] timing reports were cleaned"
}
return [expr $infile_count – [llength $prev_rpts]]

Lab 4-8 Remove Duplicate Timing Reports


The Power of Tcl 2: Creating High-Impact Procedures