Skip to content

Commit d4336ae

Browse files
authored
Merge pull request #8433 from titan73/master
odb: Replace CDL <> (normal and escaped) to [] to match master term name when exporting CDL file.
2 parents cccc6d0 + 9677807 commit d4336ae

File tree

11 files changed

+241
-0
lines changed

11 files changed

+241
-0
lines changed

src/odb/src/cdl/cdl.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ readMasters(utl::Logger* logger, dbBlock* block, const char* fileName)
129129
}
130130
mterms = &mtermMap[master];
131131
} else {
132+
// Replace CDL <> (normal and escaped) to []
133+
token = std::regex_replace(token, std::regex(R"(\\?<)"), "[");
134+
token = std::regex_replace(token, std::regex(R"(\\?>)"), "]");
132135
dbMTerm* mterm = master->findMTerm(token.c_str());
133136
if (!mterm) {
134137
logger->warn(utl::ODB,

src/odb/test/BUILD

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ COMPULSORY_TESTS = [
195195
"smash_vias",
196196
"transform",
197197
"wire_encoder",
198+
"write_cdl",
198199
"write_def58",
199200
"write_def58_gzip",
200201
"write_lef_and_def",
@@ -344,6 +345,9 @@ filegroup(
344345
"replace_hier_mod4": [
345346
"gcd_abstract_lef.lefok",
346347
],
348+
"write_cdl": [
349+
"write_cdl_escaped.cdl",
350+
],
347351
}.get(
348352
test_name,
349353
[],

src/odb/test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ or_integration_tests(
5353
smash_vias
5454
transform
5555
wire_encoder
56+
write_cdl
5657
write_def58
5758
write_def58_gzip
5859
write_lef_and_def

src/odb/test/write_cdl.cdl

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
*.BIPOLAR
2+
*.RESI = 2000
3+
*.RESVAL
4+
*.CAPVAL
5+
*.DIOPERI
6+
*.DIOAREA
7+
*.EQUATION
8+
*.SCALE METER
9+
*.MEGA
10+
.PARAM
11+
*.EXPAND_ON_M_FACTOR
12+
13+
.SUBCKT BUFFER A Z inh_gnd inh_vdd
14+
*.PININFO A:I Z:O inh_gnd:B inh_vdd:B
15+
MM0 netx A inh_vdd inh_vdd P250 W=1e-6 L=1e-6 M=1 ngcon=1 nfing=1 srcefirst=1
16+
MM1 Z netx inh_vdd inh_vdd P250 W=1e-6 L=1e-6 M=1 ngcon=1 nfing=1 srcefirst=1
17+
MMN1 netx A inh_gnd inh_gnd N250 W=1u L=1u M=1 ngcon=1 nfing=1 srcefirst=1
18+
MMN10 Z netx inh_gnd inh_gnd N250 W=1u L=1u M=1 ngcon=1 nfing=1 srcefirst=1
19+
.ENDS
20+
21+
.SUBCKT MACRO_CELL IN_REG<0> IN_REG<1> OUT_REG<0> OUT_REG<1> VDD GND
22+
*.PININFO IN_REG<0>:I IN_REG<1>:I
23+
*.PININFO OUT_REG<0>:O OUT_REG<1>:O
24+
*.PININFO VDD:B GND:B
25+
BUFFER IN_REG<0> OUT_REG<0> VDD GND / buffer0
26+
BUFFER IN_REG<1> OUT_REG<1> VDD GND / buffer1
27+
.ENDS

src/odb/test/write_cdl.cdlok

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
* CDL Netlist generated by OpenROAD
2+
3+
*.BUSDELIMITER [
4+
5+
.SUBCKT top in_reg[0] in_reg[1] out_reg[0] out_reg[1]
6+
Xi_macro in_reg[0] in_reg[1] out_reg[0] out_reg[1] _unconnected_0
7+
+ _unconnected_1 MACRO_CELL
8+
.ENDS top

src/odb/test/write_cdl.lef

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
VERSION 5.8 ;
2+
BUSBITCHARS "[]" ;
3+
DIVIDERCHAR "/" ;
4+
UNITS
5+
DATABASE MICRONS 1000 ;
6+
END UNITS
7+
8+
MANUFACTURINGGRID 0.005 ;
9+
10+
USEMINSPACING OBS OFF ;
11+
12+
PROPERTYDEFINITIONS
13+
LAYER LEF58_TYPE STRING ;
14+
LAYER LEF58_SPACING STRING ;
15+
LAYER LEF58_WIDTH STRING ;
16+
LAYER LEF58_AREA STRING ;
17+
LAYER LEF58_MINENCLOSEDAREA STRING ;
18+
END PROPERTYDEFINITIONS
19+
20+
LAYER metal1
21+
TYPE ROUTING ;
22+
DIRECTION HORIZONTAL ;
23+
PITCH 1 ;
24+
WIDTH 1 ;
25+
END metal1
26+
27+
MACRO MACRO_CELL
28+
CLASS BLOCK ;
29+
ORIGIN 0 0 ;
30+
SIZE 10 BY 10 ;
31+
SYMMETRY X Y R90 ;
32+
PIN VDD
33+
DIRECTION INPUT ;
34+
USE SIGNAL ;
35+
PORT
36+
LAYER metal1 ;
37+
RECT 0 5 0 5 ;
38+
END
39+
END VDD
40+
PIN GND
41+
DIRECTION INPUT ;
42+
USE SIGNAL ;
43+
PORT
44+
LAYER metal1 ;
45+
RECT 0 5 0 5 ;
46+
END
47+
END GND
48+
PIN IN_REG[0]
49+
DIRECTION INPUT ;
50+
USE SIGNAL ;
51+
PORT
52+
LAYER metal1 ;
53+
RECT 0 5 0 5 ;
54+
END
55+
END IN_REG[0]
56+
PIN IN_REG[1]
57+
DIRECTION INPUT ;
58+
USE SIGNAL ;
59+
PORT
60+
LAYER metal1 ;
61+
RECT 0 5 0 5 ;
62+
END
63+
END IN_REG[1]
64+
PIN OUT_REG[0]
65+
DIRECTION INPUT ;
66+
USE SIGNAL ;
67+
PORT
68+
LAYER metal1 ;
69+
RECT 0 5 0 5 ;
70+
END
71+
END OUT_REG[0]
72+
PIN OUT_REG[1]
73+
DIRECTION INPUT ;
74+
USE SIGNAL ;
75+
PORT
76+
LAYER metal1 ;
77+
RECT 0 5 0 5 ;
78+
END
79+
END OUT_REG[1]
80+
END MACRO_CELL
81+
82+
END LIBRARY

src/odb/test/write_cdl.lib

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
library(MACRO_CELL){
2+
3+
input_threshold_pct_fall : 60;
4+
input_threshold_pct_rise : 40;
5+
output_threshold_pct_fall : 60;
6+
output_threshold_pct_rise : 40;
7+
slew_lower_threshold_pct_fall : 10;
8+
slew_lower_threshold_pct_rise : 10;
9+
slew_upper_threshold_pct_fall : 90;
10+
slew_upper_threshold_pct_rise : 90;
11+
12+
type(bus_1_0){
13+
base_type : array;
14+
bit_from : 1;
15+
bit_to : 0;
16+
bit_width : 2;
17+
data_type : bit;
18+
downto : true;
19+
}
20+
21+
cell(MACRO_CELL){
22+
is_macro_cell : true;
23+
pg_pin(GND){
24+
pg_type : primary_ground;
25+
}
26+
pg_pin(VDD){
27+
pg_type : primary_power;
28+
}
29+
bus(IN_REG){
30+
bus_type : bus_1_0;
31+
direction : input;
32+
pin(IN_REG[0]){
33+
direction : input;
34+
related_ground_pin : GNDD;
35+
related_power_pin : VDDD;
36+
}
37+
pin(IN_REG[1]){
38+
direction : input;
39+
related_ground_pin : GNDD;
40+
related_power_pin : VDDD;
41+
}
42+
}
43+
bus(OUT_REG){
44+
bus_type : bus_1_0;
45+
direction : output;
46+
pin(OUT_REG[0]){
47+
direction : output;
48+
related_ground_pin : GNDD;
49+
related_power_pin : VDDD;
50+
}
51+
pin(OUT_REG[1]){
52+
direction : output;
53+
related_ground_pin : GNDD;
54+
related_power_pin : VDDD;
55+
}
56+
}
57+
}
58+
}

src/odb/test/write_cdl.ok

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[INFO ODB-0227] LEF file: write_cdl.lef, created 1 layers, 1 library cells
2+
[WARNING ODB-0284] Master BUFFER not found.
3+
[WARNING ODB-0284] Master BUFFER not found.
4+
No differences found.
5+
No differences found.

src/odb/test/write_cdl.tcl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
source "helpers.tcl"
2+
3+
read_lef write_cdl.lef
4+
read_liberty write_cdl.lib
5+
6+
read_verilog write_cdl.v
7+
8+
link_design top
9+
10+
set cdl_file [make_result_file write_cdl_out.cdl]
11+
write_cdl -masters {write_cdl.cdl} $cdl_file
12+
13+
set cdl_escaped_file [make_result_file write_cdl_escaped_out.cdl]
14+
write_cdl -masters {write_cdl_escaped.cdl} $cdl_escaped_file
15+
16+
diff_files write_cdl.cdlok $cdl_file
17+
18+
diff_files write_cdl.cdlok $cdl_escaped_file

src/odb/test/write_cdl.v

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module top ( in_reg, out_reg );
2+
output [1:0] in_reg;
3+
output [1:0] out_reg;
4+
MACRO_CELL i_macro (
5+
.IN_REG(in_reg),
6+
.OUT_REG(out_reg)
7+
);
8+
endmodule

0 commit comments

Comments
 (0)