Encounter Fanout Nets Script

Embed Size (px)

Citation preview

  • 7/26/2019 Encounter Fanout Nets Script

    1/5

    5/30/2016 Encounter How To: Wri ting To/Reading From a File With TCL - Digital Implementation - Cadence Blogs - Cadence Community

    http://community.cadence.com/cadence_blogs_8/b/di/archive/2010/02/24/encounter-how-to-writing-to-reading-from-a-file-with-tcl

    Home> Community> Blogs> Digital Implementation> Encounter How To: Writing To/Reading From a File With T

    Encounter How To: Writing To/Reading From a File With TCLComments(9)

    A couple weeks ago, there wa s a good thread in the Digital Implementation Forumsabout managing buffering on netsbetween IOs and registers. The post touched on a number of interesting topics, but one of the fundamental buildi ng

    blocks I'd like to expand upon in this blog entry is the fundamental task of writing to and reading from a file: File I/O.

    It may seem like second nature for folks who use TCL-based tools like Encounter regularly, and it's pretty muchstraight TCL that we use to write and read, but I hope having concise examples of how to do this within Encounter is a

    useful reference.

    Reading From a File

    Say for example you received a list of nets in a file that needed to be routed on upper metal layers. Here's an

    example of how you would read from that file and use the "setAttribute" command to apply that routing constraint. Sayyour file looked like this:

    critical.nets: n_5822

    n_5828

    n_5834

    Here's how we'd do it:

    set infile [open critical.nets "r"]

    while {[gets $infile line] >= 0} { setAttribute -net $line -bottom_preferred_routing_layer 5

    } close $infile

    Writing To A File

    Say we wanted to capture a list of all of the nets in the design that are connected to IO pins? Here's how we could doit:

    set outfile [open io.nets "w"] foreach net [dbGet [dbGet -u top.terms.net].name] {

    puts $outfile $net

    } close $outfile

    Redirecting Command Output To A File

    Another scen ario that's often useful is when we want to take command output that's echoed to the console andredirect it to a file. We can use the "redirect" command for this purpose. (Note: The command is not documented. This

    will be rectified in the next release.) Say for example you wanted to parse the output of the verifyGeometry commandto see whether there were any violations. Here's one way you could do it:

    http://community.cadence.com/forums/T/14730.aspxhttp://community.cadence.com/cadence_blogs_8/b/dihttp://community.cadence.com/cadence_blogs_8/http://community.cadence.com/http://www.cadence.com/
  • 7/26/2019 Encounter Fanout Nets Script

    2/5

    5/30/2016 Encounter How To: Wri ting To/Reading From a File With TCL - Digital Implementation - Cadence Blogs - Cadence Community

    http://community.cadence.com/cadence_blogs_8/b/di/archive/2010/02/24/encounter-how-to-writing-to-reading-from-a-file-with-tcl

    EDI system encounter digital implementation system Digital Implementation Closure

    Foundation Flow Design scripting tcl

    redirect verifyGeometry > verifyGeometry.outset infile [open verifyGeometry.out "r"]

    while {[gets $infile line] >= 0} { if {[string match *Verification* $line]} {

    set nrViols [lindex $line 3]}

    } close $infile

    puts "verifyGeometry reported $nrViols violation(s)"

    Tip: It's much easier to use "dbGet top.markers" to see whether there are violations in the design after runningverifyGeometry:

    encounter 1> dbGet top.markers

    0x2aab94d740 0x2aab94d5f0

    Separately, some commands like report_timing support ">" and ">>" redirection. For example:

    report_timing > timing.report

    We're looking to expand this easy ">" mechanism to include other commands in a future release.

    I hope these examples are useful. Any related tips you'd like to share?

    -Bob Dwyer

    Robert DwyerHi John,

    I see same here. Let me check with R&D and get back to you. Thanks for the comment!

    -Bob

    Anonymous Hi Bob,

    Thanks for the comment! Great to hear that the redirect works with variables. I've given it a

    try, and it works on the command line, but not within a procedure (proc). Is there a

    workaround to use redirect within a proc?

    Thanks,

    John

    Robert DwyerGood news - in EDI 10.1.USR1 redirect supports redirection to variable. It's

    not documented yet but here's the syntax:

    redirect {command} > &variable_name

    For example:

    http://community.cadence.com/members/bobdhttp://community.cadence.com/members/bobdhttp://community.cadence.com/members/bobdhttp://community.cadence.com/members/bobdhttp://community.cadence.com/tags/tclhttp://community.cadence.com/tags/scriptinghttp://community.cadence.com/tags/Foundation%2bFlow%2bDesignhttp://community.cadence.com/tags/Closurehttp://community.cadence.com/tags/Digital%2bImplementationhttp://community.cadence.com/tags/encounter%2bdigital%2bimplementation%2bsystemhttp://community.cadence.com/tags/EDI%2bsystem
  • 7/26/2019 Encounter Fanout Nets Script

    3/5

    5/30/2016 Encounter How To: Wri ting To/Reading From a File With TCL - Digital Implementation - Cadence Blogs - Cadence Community

    http://community.cadence.com/cadence_blogs_8/b/di/archive/2010/02/24/encounter-how-to-writing-to-reading-from-a-file-with-tcl

    redirect {verifyGeometry} > &verify_geometry_output

    puts "$verify_geometry_output"

    Hope this helps,

    Bob

    Robert Dwyer Currently, Encounter's redirect command doesn't support redirection tovariable. I'll try to get it enhanced so it can do so.

    Thanks for asking!

    Anonymous Hi Bob

    Can the command output be redirected to a variable?

    Thanks

    Khandaker

    Robert DwyerSorry suhas - I missed your comment for some time. Try this:

    redirect {query_objects [get_pins -of_objects CELL_NAME]} (greater than) filename.txt

    Anonymous How do we redirect the given command into a file ??

    get_pins -of_objects CELL_NAME

    Robert Dwyer Awesome tips, Jason. Very useful.

    Your use model of redirect will be useful in sharing with R&D how the more advanced

    options are used in practice. I'll pass this along to them as it will help improve the

    documentation when redirect becomes officially supported.

    jgentryBob,

    I've found redirect to be very useful when you don't want your logfile to be dominated by,

    what's in my opinion, useless output. For instance:

    deleteInst *INSTPATTERN*

    ...will give you a "Deleting instance [INSTNAME]" messages for each and every instance

    that is being deleted. In some cases, we have thousands of these messages in our

    logfiles. To get rid of this:

    redirect -quiet -nolog {

    http://community.cadence.com/members/jgentryhttp://community.cadence.com/members/jgentryhttp://community.cadence.com/members/bobdhttp://community.cadence.com/members/bobdhttp://community.cadence.com/members/bobdhttp://community.cadence.com/members/bobdhttp://community.cadence.com/members/bobdhttp://community.cadence.com/members/bobd
  • 7/26/2019 Encounter Fanout Nets Script

    4/5

    5/30/2016 Encounter How To: Wri ting To/Reading From a File With TCL - Digital Implementation - Cadence Blogs - Cadence Community

    http://community.cadence.com/cadence_blogs_8/b/di/archive/2010/02/24/encounter-how-to-writing-to-reading-from-a-file-with-tcl

    Post

    deleteInst *INSTPATTERN*

    } >& /dev/null

    The several thousand messages gets reduced to none. Be careful though, if anything

    when wrong during the commands being executed in the redirect body, you won't know

    about it.

    Regarding reading/writing files, it is pretty simple to add compression to the mix. Forinstance:

    ### To read a file that might be gzipped:

    if {[file extension $fileName] == ".gz"} {

    set inFile [list | gzip -dc $fileName]

    } else {

    set inFile $fileName

    }

    if {[catch {open $inFile r} IN]} {

    ... do any cleanup necessary, then error gracefully.

    error $IN

    }

    ### To gzip an output file (make sure $fileName has .gz at the end):

    set outFile [list | gzip > $fileName]

    if {[catch {open $outFile w} OUT]} {

    ... do any cleanup necessary, then error gracefully.

    error $OUT

    }

    Don't forget to close your file handles using the 'close' command.

    Enjoy,

    JG

    http://community.cadence.com/login?returnurl=/cadence_blogs_8/b/di/archive/2010/02/24/encounter-how-to-writing-to-reading-from-a-file-with-tcl
  • 7/26/2019 Encounter Fanout Nets Script

    5/5

    5/30/2016 Encounter How To: Wri ting To/Reading From a File With TCL - Digital Implementation - Cadence Blogs - Cadence Community

    http://community.cadence.com/cadence_blogs_8/b/di/archive/2010/02/24/encounter-how-to-writing-to-reading-from-a-file-with-tcl