Play with Strings
3
and Lists
Play with Strings and Lists Lab 3-1
Lab 3
Lab 3-2 Play with Strings and Lists
The Power of Tcl 1: Becoming a Proficient Tcl User
Lab Overview
During this lab, you will build a broad and useful command repertoire for manipulating strings and lists.
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.
Lab Tasks
Create a useful command while applying
金膜the commands learned in lecture
LAB 2
Learn skills that will be essential every
time you write Tcl scripts
LAB 3
Master the commands to count patterns in strings, and gain comfort with the basic
components of a Tcl script
LAB 1
Lab 3 File Locations
Directory Structure
design_data ORCA netlist
scripts Constraint and run scripts
libs Technology libraries
tcl_procs Tcl procedures and solutions
.synopsys_pt.setup PrimeTime setup file
.
超导空调synopsys_dc.setup Design Compiler setup file
Relevant Files
scripts/
l Incomplete TNV command
tcl_procs/
l Full TNV solution for homework
l Solution for Q25 in Task 5
l Solution for Q26 in Task 5
Play with Strings and Lists Lab 3-3 The Power of Tcl 1: Becoming a Proficient Tcl User
Lab 3
Lab Instructions
Task 1.Playing With Tcl Strings
Before applying strings to real world examples, you will go through some basic
examples to gain an understanding of what strings are all about.
The skills learned will be useful in the future whenever you explore new Tcl
commands or forget how to use commands you learned in the past.
1.Invoke either Design Compiler or PrimeTime.
There is no need to read a design for the following exercises.
pgd678
All subsequent instructions are generic for either tool - Design
Compiler or PrimeTime.
1.Create two strings by executing the following commands.
2.Use the command regexp –all to count patterns in a string.
Question 1. How many letter l’s are in the string captured by variable a
(you should get 3)?
....................................................................................................
Question 2. How many newlines in the string captured by variable b (you
should get 2)?
.
................................................................................................... Lab 3-4 Play with Strings and Lists
The Power of Tcl 1: Becoming a Proficient Tcl User
电玉粉Lab 3
3.Count the total number of characters in a string using the command string
length. Execute the following example.
Question 3. Did the above exercise confirm that spaces and newlines
count as individual characters in strings?
....................................................................................................
4.Determine if a string matches a pattern using globbing and the command
string match.
导电膜For string matching to succeed (i.e. the return value is 1), the pattern and the
string must be identical except that the pattern may include wildcard
characters such as *.
Question 4. Did the above commands work as expected?
雨水弃流井.................................................................................................... 5.Extract characters from a string using the command string index.
Question 5. Does the index range start at 1 or 0 (i.e. to get the first
character in a string, do you use an index of 1 or 0)?
....................................................................................................
Question 6. Do you need to know the total number of characters in a
string to extract the LAST character of the string?
.................................................................................................... Play with Strings and Lists Lab 3-5 The Power of Tcl 1: Becoming a Proficient Tcl User