Skip to content

Commit 061de9b

Browse files
committed
dbNetwork: Fixed a bug where get_ports fails for top-level bus port in hierarchical flow.
Signed-off-by: Jaehyun Kim <[email protected]>
1 parent 14d4add commit 061de9b

File tree

7 files changed

+270
-1
lines changed

7 files changed

+270
-1
lines changed

src/dbSta/src/dbNetwork.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2012,6 +2012,8 @@ void dbNetwork::makeCell(Library* library, dbMaster* master)
20122012
}
20132013
// Assume msb first busses because LEF has no clue about busses.
20142014
// This generates the top level ports
2015+
// TODO: MSB first assumption looks risky because there can be LSB first
2016+
// buses.
20152017
groupBusPorts(cell, [](const char*) { return true; });
20162018

20172019
// Fill in liberty to db/LEF master correspondence for libraries not used
@@ -3237,9 +3239,12 @@ Port* DbNetworkPortMemberIterator::next()
32373239

32383240
PortMemberIterator* dbNetwork::memberIterator(const Port* port) const
32393241
{
3240-
if (!hierarchy_) {
3242+
// top-level port is concrete port. DbNetworkPortMemberIterator cannot handle
3243+
// it.
3244+
if (!hierarchy_ || isConcretePort(port)) {
32413245
return ConcreteNetwork::memberIterator(port);
32423246
}
3247+
32433248
return new DbNetworkPortMemberIterator(port, this);
32443249
}
32453250

src/dbSta/test/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ or_integration_tests(
77
constant1
88
find_clks1
99
find_clks2
10+
get_ports1
11+
get_ports1_hier
1012
hier2
1113
hierclock
1214
hierwrite

src/dbSta/test/get_ports1.ok

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
[INFO ODB-0227] LEF file: Nangate45/Nangate45.lef, created 22 layers, 27 vias, 135 library cells
2+
clk {top_in_bus[0]} {top_in_bus[1]} {top_in_bus[2]} {top_in_bus[3]} {top_in_bus[4]} {top_in_bus[5]} {top_in_bus[6]} {top_in_bus[7]} top_in_single {top_out_bus[0]} {top_out_bus[1]} {top_out_bus[2]} {top_out_bus[3]} {top_out_bus[4]} top_out_single
3+
count: 16
4+
5+
{top_in_bus[0]} {top_in_bus[1]} {top_in_bus[2]} {top_in_bus[3]} {top_in_bus[4]} {top_in_bus[5]} {top_in_bus[6]} {top_in_bus[7]}
6+
count: 8
7+
8+
{top_in_bus[0]} {top_in_bus[1]} {top_in_bus[2]} {top_in_bus[3]} {top_in_bus[4]} {top_in_bus[5]} {top_in_bus[6]} {top_in_bus[7]}
9+
count: 8
10+
11+
top_in_single
12+
count: 1
13+
14+
top_out_single
15+
count: 1
16+
17+
{top_in_bus[0]} {top_in_bus[1]} {top_in_bus[2]} {top_in_bus[3]} {top_in_bus[4]} {top_in_bus[5]} {top_in_bus[6]} {top_in_bus[7]} top_in_single
18+
count: 9
19+
20+
{top_out_bus[0]} {top_out_bus[1]} {top_out_bus[2]} {top_out_bus[3]} {top_out_bus[4]} top_out_single
21+
count: 6
22+
23+
clk
24+
count: 1
25+
26+
[WARNING STA-0349] instance 'sub_inst' not found.
27+
28+
count: 0
29+
30+
[WARNING STA-0363] pin 'sub_inst/in_bus*' not found.
31+
32+
count: 0
33+
34+
[WARNING STA-0363] pin 'sub_inst/out_bus*' not found.
35+
36+
count: 0
37+
38+
[WARNING STA-0363] pin 'sub_inst/in_single*' not found.
39+
40+
count: 0
41+
42+
[WARNING STA-0363] pin 'sub_inst/out_single*' not found.
43+
44+
count: 0
45+
46+
[WARNING STA-0363] pin 'sub_inst/in*' not found.
47+
48+
count: 0
49+
50+
[WARNING STA-0363] pin 'sub_inst/out*' not found.
51+
52+
count: 0
53+
54+
[WARNING STA-0363] pin 'sub_inst/*[1]' not found.
55+
56+
count: 0
57+
58+
{top_in_bus[3]}
59+
count: 1
60+
61+
{top_in_bus[2]}
62+
count: 1
63+
64+
{top_in_bus[1]}
65+
count: 1
66+
67+
{top_in_bus[0]}
68+
count: 1
69+
70+
{top_in_bus[2]} {top_out_bus[2]}
71+
count: 2
72+

src/dbSta/test/get_ports1.tcl

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# get_ports on a bus
2+
source "helpers.tcl"
3+
read_lef Nangate45/Nangate45.lef
4+
read_liberty Nangate45/Nangate45_typ.lib
5+
read_verilog get_ports1.v
6+
link_design top
7+
8+
proc print_info {objs} {
9+
set obj_names {}
10+
foreach obj $objs {
11+
lappend obj_names [get_name $obj]
12+
}
13+
puts "[lsort $obj_names]"
14+
puts "count: [llength $objs]"
15+
puts ""
16+
}
17+
18+
print_info [get_ports *]
19+
20+
# top module ports
21+
print_info [get_ports "top_in_bus*"]
22+
print_info [get_ports "top_in_bus*"]
23+
print_info [get_ports "top_in_single*"]
24+
print_info [get_ports "top_out_single*"]
25+
print_info [get_ports top_in*]
26+
print_info [get_ports top_out*]
27+
print_info [get_ports clk]
28+
29+
# sub_module port - WARNINGS
30+
print_info [get_cells "sub_inst"]
31+
print_info [get_pins "sub_inst/in_bus*"]
32+
print_info [get_pins "sub_inst/out_bus*"]
33+
print_info [get_pins "sub_inst/in_single*"]
34+
print_info [get_pins "sub_inst/out_single*"]
35+
print_info [get_pins sub_inst/in*]
36+
print_info [get_pins sub_inst/out*]
37+
print_info [get_pins sub_inst/*[1]]
38+
39+
# Test getting a bit of a bus
40+
print_info [get_ports top_in_bus[3]]
41+
print_info [get_ports top_in_bus[2]]
42+
print_info [get_ports top_in_bus[1]]
43+
print_info [get_ports top_in_bus[0]]
44+
print_info [get_ports *[2]]

src/dbSta/test/get_ports1.v

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// get_ports1.v
2+
3+
module sub_module (
4+
input [3:0] in_bus,
5+
input in_single,
6+
output [1:0] out_bus,
7+
output out_single
8+
);
9+
// Dummy logic
10+
wire in_single_buf;
11+
INV_X1 buf_inst (.A(in_single), .ZN(in_single_buf));
12+
assign out_bus = in_bus[3:2];
13+
assign out_single = in_single_buf;
14+
endmodule
15+
16+
module top (
17+
input [7:0] top_in_bus,
18+
input top_in_single,
19+
output [4:0] top_out_bus,
20+
output top_out_single,
21+
input clk
22+
);
23+
24+
wire [1:0] sub_out_bus;
25+
wire sub_out_single;
26+
27+
sub_module sub_inst (
28+
.in_bus(top_in_bus[3:0]),
29+
.in_single(top_in_single),
30+
.out_bus(sub_out_bus),
31+
.out_single(sub_out_single)
32+
);
33+
34+
assign top_out_bus = {top_in_bus[7:5], sub_out_bus[1], sub_out_single};
35+
assign top_out_single = sub_out_bus[0];
36+
37+
endmodule

src/dbSta/test/get_ports1_hier.ok

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
[INFO ODB-0227] LEF file: Nangate45/Nangate45.lef, created 22 layers, 27 vias, 135 library cells
2+
[WARNING ORD-0011] Hierarchical flow (-hier) is currently in development and may cause multiple issues. Do not use in production environments.
3+
clk {top_in_bus[0]} {top_in_bus[1]} {top_in_bus[2]} {top_in_bus[3]} {top_in_bus[4]} {top_in_bus[5]} {top_in_bus[6]} {top_in_bus[7]} top_in_single {top_out_bus[0]} {top_out_bus[1]} {top_out_bus[2]} {top_out_bus[3]} {top_out_bus[4]} top_out_single
4+
count: 16
5+
6+
{top_in_bus[0]} {top_in_bus[1]} {top_in_bus[2]} {top_in_bus[3]} {top_in_bus[4]} {top_in_bus[5]} {top_in_bus[6]} {top_in_bus[7]}
7+
count: 8
8+
9+
{top_in_bus[0]} {top_in_bus[1]} {top_in_bus[2]} {top_in_bus[3]} {top_in_bus[4]} {top_in_bus[5]} {top_in_bus[6]} {top_in_bus[7]}
10+
count: 8
11+
12+
top_in_single
13+
count: 1
14+
15+
top_out_single
16+
count: 1
17+
18+
{top_in_bus[0]} {top_in_bus[1]} {top_in_bus[2]} {top_in_bus[3]} {top_in_bus[4]} {top_in_bus[5]} {top_in_bus[6]} {top_in_bus[7]} top_in_single
19+
count: 9
20+
21+
{top_out_bus[0]} {top_out_bus[1]} {top_out_bus[2]} {top_out_bus[3]} {top_out_bus[4]} top_out_single
22+
count: 6
23+
24+
clk
25+
count: 1
26+
27+
sub_inst
28+
count: 1
29+
30+
{in_bus[0]} {in_bus[1]} {in_bus[2]} {in_bus[3]}
31+
count: 4
32+
33+
{out_bus[0]} {out_bus[1]}
34+
count: 2
35+
36+
in_single
37+
count: 1
38+
39+
out_single
40+
count: 1
41+
42+
{in_bus[0]} {in_bus[1]} {in_bus[2]} {in_bus[3]} in_single
43+
count: 5
44+
45+
{out_bus[0]} {out_bus[1]} out_single
46+
count: 3
47+
48+
{in_bus[1]} {out_bus[1]}
49+
count: 2
50+
51+
{top_in_bus[3]}
52+
count: 1
53+
54+
{top_in_bus[2]}
55+
count: 1
56+
57+
{top_in_bus[1]}
58+
count: 1
59+
60+
{top_in_bus[0]}
61+
count: 1
62+
63+
{top_in_bus[2]} {top_out_bus[2]}
64+
count: 2
65+

src/dbSta/test/get_ports1_hier.tcl

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# get_ports on a bus
2+
source "helpers.tcl"
3+
read_lef Nangate45/Nangate45.lef
4+
read_liberty Nangate45/Nangate45_typ.lib
5+
read_verilog get_ports1.v
6+
link_design top -hier
7+
8+
proc print_info {objs} {
9+
set obj_names {}
10+
foreach obj $objs {
11+
lappend obj_names [get_name $obj]
12+
}
13+
puts "[lsort $obj_names]"
14+
puts "count: [llength $objs]"
15+
puts ""
16+
}
17+
18+
print_info [get_ports *]
19+
20+
# top module ports
21+
print_info [get_ports "top_in_bus*"]
22+
print_info [get_ports "top_in_bus*"]
23+
print_info [get_ports "top_in_single*"]
24+
print_info [get_ports "top_out_single*"]
25+
print_info [get_ports top_in*]
26+
print_info [get_ports top_out*]
27+
print_info [get_ports clk]
28+
29+
# sub_module pins
30+
print_info [get_cells "sub_inst"]
31+
print_info [get_pins "sub_inst/in_bus*"]
32+
print_info [get_pins "sub_inst/out_bus*"]
33+
print_info [get_pins "sub_inst/in_single*"]
34+
print_info [get_pins "sub_inst/out_single*"]
35+
print_info [get_pins sub_inst/in*]
36+
print_info [get_pins sub_inst/out*]
37+
print_info [get_pins sub_inst/*[1]]
38+
39+
# Test getting a bit of a bus
40+
print_info [get_ports top_in_bus[3]]
41+
print_info [get_ports top_in_bus[2]]
42+
print_info [get_ports top_in_bus[1]]
43+
print_info [get_ports top_in_bus[0]]
44+
print_info [get_ports *[2]]

0 commit comments

Comments
 (0)