Home > Community > Blogs > Digital Implementation > a dbget code example
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: *

A dbGet Code Example

Comments(6)Filed under: Digital Implementation, dbGet, SoC-Encounter, dbSet, database access

I've been having a lot of fun with power switch cells lately. That's a whole other story (and perhaps a future blog entry), but in my experiments I was able to use dbGet in some neat ways. I posted previously about getting started with dbGet here.

After you've experimented with dbGet for a while, the natural next step is to start using it in scripts or pieces of code.

The scenario: All of my switch cells were the largest size. (This particular design utilizes switch cells placed in columns on every row.) This caused my block to be too congested and therefore unroutable. I needed to reduce area without sacrificing too much IR drop, so I only wanted to change every other row to a smaller switch cell. My first thought was to key off of the orientation. As you go up the column, the switch cell orientations are R0, MX, R0, MX, etc. So I could swap out all the R0 or all the MX to get what I want.

The plan: Select all the switch cells. (I used the design browser to get all cells of type SWITCH32X, but you could script this part too.) Grab only the ones that are R0 orientation. Deselect everything. Now select all the R0 cells. Set their status from FIXED to PLACED (otherwise ecoChangeCell won't work). Cycle through the list of cells and change them from SWITCH32X to SWITCH16X. Finally, set their status back to FIXED so they don't get moved later in the flow.

The code:

#all switch cells are selected to begin with
set or R0
set insts [dbGet -p selected.orient $or]
foreach inst $insts {selectInst [dbGet $inst.name]}
dbSet [dbGet -p selected].pStatus placed
set changes [dbGet -p selected]
foreach change $changes {ecoChangeCell -inst [dbGet $change.name] -cell SWITCH16X}
dbSet [dbGet -p selected].pStatus fixed

While this is a good example of using dbGet selected and selectInst, as well as a good visual way to make sure I'm grabbing the cells I want, I realized it wasn't the most efficient code. So I revised it to look like this:

set or R0
set s32 [dbGet -p2 top.insts.cell.name SWITCH32X]
set s32R0 [dbGet -p $s32.orient $or]
dbSet [dbGet -p $s32R0].pStatus placed
foreach inst $s32R0 {ecoChangeCell -inst [dbGet $inst.name] -cell SWITCH16X}
dbSet [dbGet -p $s32R0].pStatus fixed

Let's break that down line-by-line:

set or R0 --> create a variable for the orientation
set s32 [dbGet -p2 top.insts.cell.name SWITCH32X] --> grab the database pointers to all SWITCH32X cells in the design
set s32R0 [dbGet -p $s32.orient $or] --> grab the database pointers for all SWITCH32X cells that have orientation matching R0 (or whatever the variable $or is set to)
dbSet [dbGet -p $s32R0].pStatus placed --> change the placement status from FIXED to PLACED so the next line will work
foreach inst $s32R0 {ecoChangeCell -inst [dbGet $inst.name] -cell SWITCH16X} --> change all R0 SWITCH32X cells to SWITCH16X cells
dbSet [dbGet -p $s32R0].pStatus fixed --> change the new cells from PLACED back to FIXED

You'll notice the use of -p and -p2 in the dbGet commands. Using -p will return the database pointers of what you're examining with dbGet. This is important because certain commands need the database pointers to the instance or cell and not the instance name or cell name. In the dbGet -p2 line, we used -p2 because we want to step back two places in the sequence to grab our pointers. (In the sequence top.insts.cell.name, stepping back one place from name would give us a pointer to the cell; stepping back two places gives us the pointers to the insts.) In the next line, we used -p (which is the same as -p1) because we want to step back one item in the sequence to grab the pointers. (In the sequence $s32.orient, we step back one item from orient to get the pointers for $s32.) The use of -p can be confusing at first, but you'll get the hang of it after you try it a few times.

I hope this has inspired some of you to start using dbGet in your scripts. Happy coding, everyone!


By Scrivner on February 3, 2009
Thanks Kari. This helped me build a little script to help do some failure analysis on one of our chips. We needed to get the coordinates of a list of failing instances and I was able to write a script using dbGet to find the locations of the instances and highlight them in the Encounter window.

By Kari on February 3, 2009
Scrivner, that's awesome! Thanks for the feedback. I love to hear how others are using dbGet, and your script is a great example.

By NAADHAN on April 17, 2009
Hi Kari,
             the way the code is expalined i love it... the main thing is...i was a bit unclear about the -p & -p2 in dbGet but it was explained clearly with an example... thanks a lot Kari... will play around with this & let you know :-)

By PrashantMathur on April 21, 2009
dbGet is really a wonderful utility.
Those who are familiar with analysis using db command will really find thise new very useful to access db.
I really had fun with using this utility , some of my db scripts went half of size when I wrote them with dbGet.
To me using dbGet seems self learning :-).
Something that you will learn when you use..use more and learn more :-).

By Kari on April 23, 2009
Naadhan, Yes, the -p notation was confusing to me at first too.
PrashantMathur, you are absolutely right - the best way to learn dbGet is just to start using it!

By Kumar K on November 23, 2009
Recently I started using dbGet command & now I could extract all the required info using this command. I had a doubt related to -p & -p2 parameters & here its explained clearly.
Thanks alot.

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.