( ESNUG 343 Item 12 ) -------------------------------------------- [2/16/00]

From: Mark Andrews <Mark.Andrews@eng.efi.com>
Subject: ( ESNUG 334 #9 )  My Less Messy "Translating DC To TCL" Story

John,

As I just ported most of my dc scripts from dc_shell to dc_shell -tcl, I
thought I would share my experiences and ask my unanswered questions.

I found the following references essential...

    1) Recent posts from Gzim Derti and "Tickle Me Elmo" in ESNUG 334 #9
    2) DC-Tcl Questions from SNUG '99 (Synthesis-490.html from Solvit)
       which has an description of what Synopsys did with
       collections - or why they didn't use lists. You will need
       to understand collections if you plan to use Tcl in dc_shell.

I found the following references helpful...

    1) Chapter 3 from John Ousterhouts "Tcl and the TK Toolkit" which
       describes how and why the Tcl parser does what it does. It 
       explains why the parser drops off the end of the file if a }
       is missing.
    2) The Tcl/Tk Reference Guide (from Tcl web sites)
    3) "Introduction to Tcl" from the Synopsys Solvit web site

DC-TRANSCRIPT

Overall dc-transcript did an awful job of converting my dc-shell scripts to
tcl.  Very few of them worked first time, but it at least put me in the
right ballpark. I was pretty frustrated for the first few files, but once I
started to understand the dumb things it repeatedly did (thanks Gzim), it
became relatively simple to fix its output. 

HELPFUL HINT 1
--------------

Say you have this in dc_shell, i.e. you are using a variable to test
something in a filter command:

    test="true"
    filter( find( design, "*" ), "@is_mapped == test" )

dc-transcript will convert it to:

    set test {true}
    filter [find design {*}] {@is_mapped == test}

This always returns an empty collection, it should have been:

    set test {true}
    filter [find design {*}] "@is_mapped == $test"

Note:
 1) We need a $ in front of test in the filter command to indicate that
    test is a variable
 2) In order for $test to be correctly substituted we need "" instead of {}

HELPFUL HINT 2
--------------

If you have "foreach" in a dc_shell script, dc-transcript will either select
"foreach" or "foreach_in_collection".  In my experience the tcl script
always needed "foreach_in_collection".  Note also that unlike "foreach" in
dc_shell "foreach_in_collection {variable, collection} {}" leaves variable
empty after the last loop.

QUESTION 1
----------

Do we need the tcl equivalent of this in dc_shell -tcl?

    foreach(design_name,dc_shell_status){}

QUESTION 2
----------

Do we need these anymore?

    list_name = {}
    int_name = 0
    str_name = ""

Dc-transcript dutifully converts them to tcl, but tcl doesn't know the
difference between and integer and a string. And we don't really want a
list in tcl, we need a collection. I wasn't really sure what the correct
thing to do was, so I just deleted them all, (everything still seems to
work...).

QUESTION 3
----------

How do I create an empty collection?

QUESTION 4
----------

Is a collection a regular tcl variable with a hidden Synopsys type?  Or is
it a tcl list with one entry and a hidden Synopsys type?  By type I mean
design, net, port etc.

    - Mark Andrews
      Electronics For Imaging, Inc.             Foster City, CA



 Sign up for the DeepChip newsletter.
Email
 Read what EDA tool users really think.


Feedback About Wiretaps ESNUGs SIGN UP! Downloads Trip Reports Advertise

"Relax. This is a discussion. Anything said here is just one engineer's opinion. Email in your dissenting letter and it'll be published, too."
This Web Site Is Modified Every 2-3 Days
Copyright 1991-2024 John Cooley.  All Rights Reserved.
| Contact John Cooley | Webmaster | Legal | Feedback Form |

   !!!     "It's not a BUG,
  /o o\  /  it's a FEATURE!"
 (  >  )
  \ - / 
  _] [_     (jcooley 1991)