Home > Community > Blogs > Digital Implementation > encounter puzzler 3 renaming a net logically
Login with a Cadence account.
Not a member yet?
Create a permanent login account to make interactions with Cadence more conveniennt.

Register | Membership benefits
Get email delivery of the Digital Implementation blog (individual posts).


* Required Fields

Recipients email * (separate multiple addresses with commas)

Your name *

Your email *

Message *

Contact Us

* Required Fields
First Name *

Last Name *

Email *

Company / Institution *

Comments: *

Encounter Puzzler #3: Renaming a Net Logically

Comments(3)Filed under: dbGet, Encounter Digital Implementation, TCL, puzzler

The other day a designer E-mailed me: How can we rename a net in Encounter?

I followed up to clarify whether the designer wanted to change the net associated with routed wire segments, or wanted to rename a signal net. He clarified that he wanted to change a logical signal net's name.

Changing the net name associated with a routed wire segments is described in this solution:

editSelect -nets VDD1
editSelectVia -nets VDD1
editChangeNet -to VDD2

However, it's not so easy to change a logical net name in Encounter. The "name" field for a net isn't editable in the Attribute Editor, there is no "dbSetNetName" command, and dbGet says the "name" attribute of the "net" object type isn't settable:

encounter 1> dbGet top.nets.?h
name: string, Canonical (flat) name of the net

If an attribute is settable dbGet will say "settable" after the attribute name. For example:

skipRouting(settable): bool, Specifies that Nanoroute should not route or re-route the net.

So how can we change the net name programatically? How would we take this netlist:

module testcase ();
 wire net;
 BUFX1 i0(.Y(net));
 BUFX1 i1(.A(net));

...and turn it into this:

module testcase ();
   wire new_net;
   BUFX1 i0 (.Y(new_net));
   BUFX1 i1 (.A(new_net));

Today's puzzler is to write a TCL script called "userChangeNetName" that changes the logical net name of nets programmatically:

proc userChangeNetName {oldNetName newNetName} {
  <your solution here>

Leave your solution as a comment below. I'll post further discussion and a round-up on Friday.

We're looking to change the net name logically so don't worry about things like wire segments or physical I/O pins.

For extra credit, check whether your scripted solution can handle the case where the net is connected to an I/O port and/or connected through Verilog hierarchy like top-level net "in" and "net2" in this example:

module testcase (in);
 input in;
 wire net1, net2;
 BUFX1 i0(.Y(net1));
 BUFX1 i1(.A(net1));
 BUFX1 i2(.A(in));
 BUFX1 i3(.Y(net2));
 a i_a(.in(net2));

module a(in);
 input in;
 BUFX1 i0(.A(in));

Related Reading:

I'll look forward to seeing your solutions!

Update: Click here to see solutions and discussion about this puzzler

Bob Dwyer


By J2mh on March 1, 2011
proc changeNetName { oldNetName newNetName} {
selectNet $oldNetName
addNet $newNetName
foreach selTerminals [dbGet selected.allTerms] {
attachTerm [dbGet $selTerminals.inst.name] [dbGet $selTerminals.cellTerm.name] $newNetName

By BobD on March 1, 2011
@J2mh Wow - that was fast! Excellent solution.
Want to take a crack at modifying the script to handle the situation where the net is connected to an IO port? Like the top level net "in" in the Verilog netlist above?
When I first wrote the script I just errored out when the net was connected to an IO port but it wasn't too hard to modify it to handle IO ports.

By Sims on March 1, 2011
proc userChangeNetName {oldNetName newNetName} {
set netPtr [dbGetNetByName $oldNetName]
# get hierarchical-net-ptr (hNet)
set hNetPtr [dbGet -p $netPtr.hNets.name $oldNetName]
# change net name only if the hNet is connected to leaf-instances (instTerm) or hier-instances (hInstTerm)
# but not module ports (hTerm)
if {[lsearch [dbGet $hNetPtr.allTerms.objType] "hTerm"] < 0} {
addNet $newNetName
# loop through each term of the hNet and change to new net name
foreach hNetTermPtr [dbGet $hNetPtr.allTerms] {
if {[dbGet $hNetTermPtr.objType] eq "instTerm"} {
set instName [dbGet $hNetTermPtr.inst.name]
set termName [lindex [dbGet $hNetTermPtr.cellTerm.name] 0]
attachTerm $instName $termName $newNetName
} elseif {[dbGet $hNetTermPtr.objType] eq "hInstTerm"} {
set hInstName [dbGet $hNetTermPtr.hInst.name]
set termName [lindex [dbGet $hNetTermPtr.term.name] 0]
attachModulePort $hInstName $termName $newNetName
deleteNet $oldNetName
puts "Changed netname from $oldNetName to $newNetName"
} else {
puts "Error: Did not change netname from $oldNetName to $newNetName"

Leave a Comment

E-mail (will not be published)
 I have read and agree to the Terms of use and Community Guidelines.
Community Guidelines
The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.