Skip to content

Commit 06c01f9

Browse files
committed
odb: Validate 3dbv region coordinate count (#10460)
Signed-off-by: Mohnish <kmohnishm@gmail.com>
1 parent 946b12e commit 06c01f9

7 files changed

Lines changed: 101 additions & 2 deletions

File tree

src/odb/src/3dblox/dbvParser.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,20 @@ void DbvParser::parseRegion(ChipletRegion& region,
235235
extractValue(region_node, "gds_layer", region.gds_layer);
236236
}
237237

238-
if (region_node["coords"]) {
238+
if (!region_node["coords"]) {
239+
logError("3DBV region " + region.name + " must specify coords.");
240+
} else {
239241
parseCoordinates(region.coords, region_node["coords"]);
242+
if (region.coords.size() != 4) {
243+
if (region.coords.size() > 4) {
244+
logError("3DBV region " + region.name
245+
+ " must have exactly 4 coordinates. Polygonal regions are "
246+
"not yet supported.");
247+
} else {
248+
logError("3DBV region " + region.name
249+
+ " must have exactly 4 coordinates.");
250+
}
251+
}
240252
}
241253
}
242254

src/odb/test/BUILD

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ COMPULSORY_TESTS = [
219219

220220
PASSFAIL_TESTS = [
221221
# pass-fail
222+
"read_3dbv_fail",
222223
"read_def_virtual_invalid",
223224
"test_block",
224225
"test_bterm",
@@ -283,6 +284,8 @@ filegroup(
283284
"data/example2.bmap",
284285
"data/example3.bmap",
285286
"data/example4.bmap",
287+
"data/example_no_coords.3dbv",
288+
"data/example_polygon.3dbv",
286289
"data/floorplan_initialize.def",
287290
"data/floorplan_initialize.v",
288291
"data/floorplan_initialize2.def",

src/odb/test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ or_integration_tests(
7373
write_macro_placement
7474
PASSFAIL_TESTS
7575
cpp_tests
76+
read_3dbv_fail
7677
read_def_virtual_invalid
7778
test_block
7879
test_bterm
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Header:
2+
version: 2.5
3+
unit: micron
4+
precision: 2000
5+
6+
ChipletDef:
7+
SoC:
8+
type: die
9+
design_area: [955, 1082]
10+
shrink: 1
11+
tsv: false
12+
thickness: 300
13+
offset: [0, 0]
14+
cad_layer:
15+
108;101:
16+
type: design_area
17+
regions:
18+
front_reg:
19+
side: front
20+
back_reg:
21+
side: back
22+
coords:
23+
- [0, 0]
24+
- [955, 0]
25+
- [955, 1082]
26+
- [0, 1082]
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Header:
2+
version: 2.5
3+
unit: micron
4+
precision: 2000
5+
6+
ChipletDef:
7+
SoC:
8+
type: die
9+
design_area: [955, 1082]
10+
shrink: 1
11+
tsv: false
12+
thickness: 300
13+
offset: [0, 0]
14+
cad_layer:
15+
108;101:
16+
type: design_area
17+
regions:
18+
front_reg:
19+
side: front
20+
coords:
21+
- [0, 0]
22+
- [955, 0]
23+
- [955, 1082]
24+
- [0, 1082]
25+
back_reg:
26+
side: back
27+
coords:
28+
- [0, 0]
29+
- [955, 0]
30+
- [955, 1082]
31+
- [0, 1082]
32+
- [100, 100]

src/odb/test/read_3dbv_fail.tcl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
source "helpers.tcl"
2+
3+
# Test 1: Region with no coordinates
4+
set status [catch { read_3dbv "data/example_no_coords.3dbv" } msg]
5+
if { $status != 1 } {
6+
puts "fail: read_3dbv accepted region without coordinates"
7+
exit 1
8+
}
9+
if { ![regexp "ODB-0521" $msg] } {
10+
puts "fail: unexpected error for no coords: $msg"
11+
exit 1
12+
}
13+
14+
# Test 2: Region with polygon (5 coordinates)
15+
set status [catch { read_3dbv "data/example_polygon.3dbv" } msg]
16+
if { $status != 1 } {
17+
puts "fail: read_3dbv accepted region with 5 coordinates (polygon)"
18+
exit 1
19+
}
20+
if { ![regexp "ODB-0521" $msg] } {
21+
puts "fail: unexpected error for polygon: $msg"
22+
exit 1
23+
}
24+
25+
puts "pass"

src/odb/test/write_3dbv.3dbvok

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ ChipletDef:
3333
- [0, 0]
3434
- [955, 0]
3535
- [955, 1082]
36-
- [0, 1082]
36+
- [0, 1082]

0 commit comments

Comments
 (0)