Skip to content

Commit 691fc07

Browse files
authored
Merge pull request #275 from The-OpenROAD-Project/dbSta_find_clks
dbSta::findClkNets
2 parents b110862 + 4228473 commit 691fc07

File tree

15 files changed

+12491
-6
lines changed

15 files changed

+12491
-6
lines changed

src/dbSta/include/db_sta/dbSta.hh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ public:
5454
virtual void postReadDef(odb::dbBlock* block) override;
5555
virtual void postReadDb(odb::dbDatabase* db) override;
5656

57+
// Find clock nets connected by combinational gates from the clock roots.
58+
void findClkNets(std::set<dbNet*> &clk_nets);
59+
5760
protected:
5861
virtual void makeNetwork() override;
5962
virtual void makeSdcNetwork() override;

src/dbSta/src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ add_custom_command(OUTPUT ${DBSTA_TCL_INIT}
5353
)
5454

5555
add_custom_command(OUTPUT ${DBSTA_WRAP}
56-
COMMAND ${SWIG_EXECUTABLE} -tcl8 -c++ -namespace -prefix sta -I${OPENSTA_HOME} -o ${DBSTA_WRAP} ${DBSTA_HOME}/src/dbSta.i
56+
COMMAND ${SWIG_EXECUTABLE} -tcl8 -c++ -namespace -prefix sta -I${OPENSTA_HOME} -I${OPENDB_HOME}/src/swig/tcl -o ${DBSTA_WRAP} ${DBSTA_HOME}/src/dbSta.i
5757
COMMAND ${OPENSTA_HOME}/etc/SwigCleanup.tcl ${DBSTA_WRAP}
5858
WORKING_DIRECTORY ${OPENROAD_HOME}/src/dbSta
5959
DEPENDS ${DBSTA_SWIG_FILES}

src/dbSta/src/dbSta.cc

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
#include <tcl.h>
2020

2121
#include "sta/StaMain.hh"
22+
#include "sta/Graph.hh"
23+
#include "sta/Search.hh"
24+
#include "sta/Bfs.hh"
2225
#include "db_sta/dbNetwork.hh"
2326
#include "db_sta/MakeDbSta.hh"
2427
#include "opendb/db.h"
@@ -152,5 +155,32 @@ dbSta::netSlack(const dbNet *db_net,
152155
return netSlack(net, min_max);
153156
}
154157

158+
void
159+
dbSta::findClkNets(std::set<dbNet*> &clk_nets)
160+
{
161+
ensureGraph();
162+
ensureLevelized();
163+
ClkArrivalSearchPred srch_pred(this);
164+
BfsFwdIterator bfs(BfsIndex::other, &srch_pred, this);
165+
PinSet clk_pins;
166+
search_->findClkVertexPins(clk_pins);
167+
for (Pin *pin : clk_pins) {
168+
Vertex *vertex, *bidirect_drvr_vertex;
169+
graph_->pinVertices(pin, vertex, bidirect_drvr_vertex);
170+
bfs.enqueue(vertex);
171+
if (bidirect_drvr_vertex)
172+
bfs.enqueue(bidirect_drvr_vertex);
173+
}
174+
while (bfs.hasNext()) {
175+
Vertex *vertex = bfs.next();
176+
const Pin *pin = vertex->pin();
177+
if (!network_->isTopLevelPort(pin)) {
178+
Net *net = network_->net(pin);
179+
clk_nets.insert(db_network_->staToDb(net));
180+
}
181+
bfs.enqueueAdjacentVertices(vertex);
182+
}
183+
}
184+
155185
} // namespace sta
156186

src/dbSta/src/dbSta.i

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,18 @@ make_block_sta(odb::dbBlock *block)
3232
return sta::makeBlockSta(block);
3333
}
3434

35+
// For debugging because I can't get a dbNet vector thru swig.
36+
void
37+
report_clk_nets()
38+
{
39+
ord::OpenRoad *openroad = ord::getOpenRoad();
40+
sta::dbSta *sta = openroad->getSta();
41+
std::set<dbNet*> clk_nets;
42+
sta->findClkNets(clk_nets);
43+
for (dbNet *net : clk_nets)
44+
printf("%s\n", net->getConstName());
45+
}
46+
3547
odb::dbInst *
3648
sta_to_db_inst(Instance *inst)
3749
{

src/dbSta/test/Nangate45

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../test/Nangate45

src/dbSta/test/bus1.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION 5.5 ;
1+
VERSION 5.8 ;
22
NAMESCASESENSITIVE ON ;
33
DIVIDERCHAR "/" ;
44
BUSBITCHARS "[]" ;

src/dbSta/test/find_clks1.def

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
VERSION 5.8 ;
2+
NAMESCASESENSITIVE ON ;
3+
DIVIDERCHAR "/" ;
4+
BUSBITCHARS "[]" ;
5+
6+
DESIGN top ;
7+
8+
UNITS DISTANCE MICRONS 1000 ;
9+
10+
DIEAREA ( 0 0 ) ( 1000 1000 ) ;
11+
12+
COMPONENTS 5 ;
13+
- r1 DFF_X1 ;
14+
- r2 DFF_X1 ;
15+
- u1 BUF_X1 ;
16+
- p1 PAD ;
17+
END COMPONENTS
18+
19+
PINS 6 ;
20+
- in1 + NET in1 + DIRECTION INPUT ;
21+
- clk1 + NET clk1 + DIRECTION INPUT ;
22+
- out1 + NET out + DIRECTION OUTPUT ;
23+
END PINS
24+
25+
SPECIALNETS 2 ;
26+
- VSS ( * VSS )
27+
+ USE GROUND ;
28+
- VDD ( * VDD )
29+
+ USE POWER ;
30+
END SPECIALNETS
31+
32+
NETS 10 ;
33+
- in1 ( PIN in1 ) ( r1 D ) ;
34+
- clk1 ( PIN clk1 ) ( p1 PAD ) ;
35+
- clk2 ( p1 Y ) ( r1 CK ) ( r2 CK ) ;
36+
- r1q ( r1 Q ) ( u1 A ) ;
37+
- u1z ( u1 Z ) ( r2 D ) ;
38+
- out1 ( r2 Q ) ( PIN out1 ) ;
39+
END NETS
40+
41+
END DESIGN

src/dbSta/test/find_clks1.ok

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Notice 0: Reading LEF file: Nangate45/Nangate45.lef
2+
Notice 0: Created 22 technology layers
3+
Notice 0: Created 27 technology vias
4+
Notice 0: Created 134 library cells
5+
Notice 0: Finished LEF file: Nangate45/Nangate45.lef
6+
Notice 0: Reading LEF file: pad.lef
7+
Notice 0: error: undefined layer (C4) referenced
8+
Notice 0: Created 1 library cells
9+
Notice 0: Finished LEF file: pad.lef
10+
Notice 0:
11+
Reading DEF file: find_clks1.def
12+
Notice 0: Design: top
13+
Notice 0: Created 3 pins.
14+
Notice 0: Created 4 components and 23 component-terminals.
15+
Notice 0: Created 2 special nets and 6 connections.
16+
Notice 0: Created 6 nets and 10 connections.
17+
Notice 0: Finished DEF file: find_clks1.def
18+
clk1
19+
clk2

src/dbSta/test/find_clks1.tcl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# find_clks from input port thru pad
2+
read_lef Nangate45/Nangate45.lef
3+
read_lef pad.lef
4+
read_liberty Nangate45/Nangate45_typ.lib
5+
read_liberty pad.lib
6+
read_def find_clks1.def
7+
8+
create_clock -name clk -period 10 clk1
9+
sta::report_clk_nets

src/dbSta/test/pad.lef

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
VERSION 5.8 ;
2+
BUSBITCHARS "[]" ;
3+
DIVIDERCHAR "/" ;
4+
5+
SITE IO_SITE
6+
CLASS PAD ;
7+
SIZE 1 BY 150 ;
8+
END IO_SITE
9+
10+
MACRO PAD
11+
CLASS PAD ;
12+
ORIGIN 0 0 ;
13+
SIZE 25 BY 100 ;
14+
SYMMETRY X Y ;
15+
SITE IO_SITE ;
16+
PIN PAD
17+
DIRECTION INOUT ;
18+
USE SIGNAL ;
19+
PORT
20+
LAYER C4 ;
21+
RECT 1.15 0 28.85 0.5 ;
22+
END
23+
END PAD
24+
PIN NDOUT
25+
DIRECTION OUTPUT ;
26+
USE SIGNAL ;
27+
END NDOUT
28+
PIN Y
29+
DIRECTION OUTPUT ;
30+
USE SIGNAL ;
31+
END Y
32+
PIN TRIEN
33+
DIRECTION INPUT ;
34+
USE SIGNAL ;
35+
END TRIEN
36+
PIN RXEN
37+
DIRECTION INPUT ;
38+
USE SIGNAL ;
39+
END RXEN
40+
PIN DATA
41+
DIRECTION INPUT ;
42+
USE SIGNAL ;
43+
END DATA
44+
PIN NDIN
45+
DIRECTION INPUT ;
46+
USE SIGNAL ;
47+
END NDIN
48+
END PAD
49+

0 commit comments

Comments
 (0)