Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 35 additions & 2 deletions src/odb/src/defin/definNet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ void definNet::wire(dbWireType type)

_wire_type = type;
_taper_rule = nullptr;
_prev_junction_id = -1;
}

void definNet::path(const char* layer_name)
Expand Down Expand Up @@ -278,6 +279,7 @@ void definNet::pathBegin(const char* layer_name)
} else {
_wire_encoder.newPath(_cur_layer, _wire_type);
}
_prev_junction_id = -1;
}

void definNet::pathTaper(const char* layer)
Expand Down Expand Up @@ -312,7 +314,7 @@ void definNet::pathPoint(int x, int y)
_prev_x = dbdist(x);
_prev_y = dbdist(y);

_wire_encoder.addPoint(_prev_x, _prev_y);
_prev_junction_id = _wire_encoder.addPoint(_prev_x, _prev_y);
}

void definNet::pathPoint(int x, int y, int ext)
Expand All @@ -324,7 +326,38 @@ void definNet::pathPoint(int x, int y, int ext)
_prev_x = dbdist(x);
_prev_y = dbdist(y);

_wire_encoder.addPoint(_prev_x, _prev_y, dbdist(ext));
_prev_junction_id = _wire_encoder.addPoint(_prev_x, _prev_y, dbdist(ext));
}

void definNet::pathVirtualPoint(int x, int y)
{
if (_wire == nullptr) {
return;
}

if (_cur_layer == nullptr || _prev_junction_id < 0) {
_logger->warn(utl::ODB,
469,
"error: VIRTUAL routing point in net {} does not follow a "
"routing point",
_cur_net->getName());
++_errors;
dbWire::destroy(_wire);
_wire = nullptr;
return;
}

if (_taper_rule) {
_wire_encoder.newPathVirtualWire(
_prev_junction_id, _cur_layer, _wire_type, _taper_rule);
} else {
_wire_encoder.newPathVirtualWire(
_prev_junction_id, _cur_layer, _wire_type);
}

_prev_x = dbdist(x);
_prev_y = dbdist(y);
_prev_junction_id = _wire_encoder.addPoint(_prev_x, _prev_y);
}

void definNet::getUniqueViaName(std::string& viaName)
Expand Down
2 changes: 2 additions & 0 deletions src/odb/src/defin/definNet.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class definNet : public definBase
dbTechLayerRule* _taper_rule{nullptr};
dbTechNonDefaultRule* _non_default_rule{nullptr};
dbTechNonDefaultRule* _rule_for_path{nullptr};
int _prev_junction_id{-1};
std::map<std::string, dbVia*> _rotated_vias;

void getUniqueViaName(std::string& viaName);
Expand All @@ -59,6 +60,7 @@ class definNet : public definBase
void pathTaperRule(const char* layer, const char* rule);
void pathPoint(int x, int y);
void pathPoint(int x, int y, int ext);
void pathVirtualPoint(int x, int y);
void pathVia(const char* via);
void pathVia(const char* via, dbOrientType orient);
void pathRect(int deltaX1, int deltaY1, int deltaX2, int deltaY2);
Expand Down
8 changes: 6 additions & 2 deletions src/odb/src/defin/definReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -857,9 +857,13 @@ int definReader::netCallback(DefParser::defrCallbackType_e /* unused: type */,
break;
}

case DefParser::DEFIPATH_VIRTUALPOINT:
UNSUPPORTED("VIRTUAL in net's routing is unsupported");
case DefParser::DEFIPATH_VIRTUALPOINT: {
int x;
int y;
path->getVirtualPoint(&x, &y);
netR->pathVirtualPoint(x, y);
break;
}

case DefParser::DEFIPATH_MASK:
netR->pathColor(path->getMask());
Expand Down
30 changes: 30 additions & 0 deletions src/odb/src/defout/defout_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1473,6 +1473,8 @@ void DefOut::Impl::writeWire(dbWire* wire)
int path_cnt = 0;
int prev_x = std::numeric_limits<int>::max();
int prev_y = std::numeric_limits<int>::max();
int prev_junction_id = -1;
bool virtual_point = false;

for (decode.begin(wire);;) {
dbWireDecoder::OpCode opcode = decode.next();
Expand All @@ -1484,6 +1486,12 @@ void DefOut::Impl::writeWire(dbWire* wire)
case dbWireDecoder::SHORT:
case dbWireDecoder::VWIRE:
case dbWireDecoder::JUNCTION: {
if (opcode == dbWireDecoder::VWIRE
&& decode.getJunctionValue() == prev_junction_id) {
virtual_point = true;
break;
}

layer = decode.getLayer();
const std::string lname = layer->getName();

Expand All @@ -1504,6 +1512,8 @@ void DefOut::Impl::writeWire(dbWire* wire)

prev_wire_type = wire_type;
point_cnt = 0;
prev_junction_id = -1;
virtual_point = false;
++path_cnt;
break;
}
Expand All @@ -1518,6 +1528,15 @@ void DefOut::Impl::writeWire(dbWire* wire)
*_out << "\n ";
}

if (virtual_point) {
*_out << " VIRTUAL ( " << x << " " << y << " )";
virtual_point = false;
prev_x = x;
prev_y = y;
prev_junction_id = decode.getJunctionId();
break;
}

std::string mask_statement;
if (point_cnt % 2 == 0 && color) {
mask_statement = fmt::format("MASK {}", color.value());
Expand All @@ -1533,6 +1552,7 @@ void DefOut::Impl::writeWire(dbWire* wire)

prev_x = x;
prev_y = y;
prev_junction_id = decode.getJunctionId();
break;
}

Expand All @@ -1547,6 +1567,15 @@ void DefOut::Impl::writeWire(dbWire* wire)
*_out << "\n ";
}

if (virtual_point) {
*_out << " VIRTUAL ( " << x << " " << y << " )";
virtual_point = false;
prev_x = x;
prev_y = y;
prev_junction_id = decode.getJunctionId();
break;
}

if (point_cnt == 1) {
*_out << " ( " << x << " " << y << " " << ext << " )";
} else if ((x == prev_x) && (y == prev_y)) {
Expand All @@ -1559,6 +1588,7 @@ void DefOut::Impl::writeWire(dbWire* wire)

prev_x = x;
prev_y = y;
prev_junction_id = decode.getJunctionId();
break;
}

Expand Down
4 changes: 4 additions & 0 deletions src/odb/test/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ COMPULSORY_TESTS = [
"read_3dbx",
"read_db",
"read_def",
"read_def_virtual",
"read_def58",
"read_lef",
"read_zipped",
Expand Down Expand Up @@ -217,6 +218,7 @@ COMPULSORY_TESTS = [

PASSFAIL_TESTS = [
# pass-fail
"read_def_virtual_invalid",
"test_block",
"test_bterm",
"test_destroy",
Expand Down Expand Up @@ -303,6 +305,8 @@ filegroup(
"data/rounding.def",
"data/sky130_fd_sc_hd__inv_1.gds",
"data/sky130hd_multi_patterned.def",
"data/virtual_route.def",
"data/virtual_route_invalid.def",
"dump_netlists.tcl",
"dump_netlists_withfill.tcl",
"fake_macros.def",
Expand Down
2 changes: 2 additions & 0 deletions src/odb/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ or_integration_tests(
read_3dbx
read_db
read_def
read_def_virtual
read_def58
read_lef
read_zipped
Expand Down Expand Up @@ -71,6 +72,7 @@ or_integration_tests(
write_macro_placement
PASSFAIL_TESTS
cpp_tests
read_def_virtual_invalid
test_block
test_bterm
test_destroy
Expand Down
14 changes: 14 additions & 0 deletions src/odb/test/data/virtual_route.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
VERSION 5.8 ;
DIVIDERCHAR "/" ;
BUSBITCHARS "[]" ;
DESIGN virtual_route ;
UNITS DISTANCE MICRONS 2000 ;
DIEAREA ( 0 0 ) ( 20000 20000 ) ;

NETS 1 ;
- net1
+ ROUTED metal1 ( 0 0 ) ( 2000 0 ) VIRTUAL ( 2000 1000 )
RECT ( -500 -500 500 500 ) ( 2000 2000 ) ;
END NETS

END DESIGN
13 changes: 13 additions & 0 deletions src/odb/test/data/virtual_route_invalid.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
VERSION 5.8 ;
DIVIDERCHAR "/" ;
BUSBITCHARS "[]" ;
DESIGN virtual_route_invalid ;
UNITS DISTANCE MICRONS 2000 ;
DIEAREA ( 0 0 ) ( 20000 20000 ) ;

NETS 1 ;
- net1
+ ROUTED metal1 M2_M1_via VIRTUAL ( 2000 1000 ) ;
END NETS

END DESIGN
16 changes: 16 additions & 0 deletions src/odb/test/read_def_virtual.ok
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[INFO ODB-0388] unsupported contactResistance property for layer contact :"10.5"
[INFO ODB-0388] unsupported contactResistance property for layer via1 :"5.69"
[WARNING ODB-0423] LEF58_REGION layer via1R1 ignored
[INFO ODB-0388] unsupported contactResistance property for layer via2 :"11.39"
[INFO ODB-0388] unsupported contactResistance property for layer via3 :"16.73"
[INFO ODB-0388] unsupported contactResistance property for layer via4 :"21.44"
[INFO ODB-0388] unsupported contactResistance property for layer via5 :"24.08"
[INFO ODB-0388] unsupported contactResistance property for layer via6 :"11.39"
[INFO ODB-0388] unsupported contactResistance property for layer via7 :"5.69"
[INFO ODB-0388] unsupported contactResistance property for layer via8 :"16.73"
[INFO ODB-0388] unsupported contactResistance property for layer via9 :"21.44"
[INFO ODB-0227] LEF file: data/gscl45nm.lef, created 22 layers, 14 vias, 33 library cells
[INFO ODB-0128] Design: virtual_route
[INFO ODB-0133] Created 1 nets and 0 connections.
Summary 3 / 3 (100% pass)
pass
44 changes: 44 additions & 0 deletions src/odb/test/read_def_virtual.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
source "helpers.tcl"

read_lef "data/gscl45nm.lef"
read_def "data/virtual_route.def"

set block [ord::get_db_block]
set net [$block findNet "net1"]
set wire [$net getWire]

set decoder [odb::dbWireDecoder]
$decoder begin $wire

set ops {}
set points {}
while { 1 } {
set op [$decoder next]
if { $op == $odb::dbWireDecoder_END_DECODE } {
break
}
if { $op == $odb::dbWireDecoder_PATH } {
lappend ops "PATH"
} elseif { $op == $odb::dbWireDecoder_POINT } {
lappend ops "POINT"
lappend points [$decoder getPoint]
} elseif { $op == $odb::dbWireDecoder_VWIRE } {
lappend ops "VWIRE"
} elseif { $op == $odb::dbWireDecoder_RECT } {
lappend ops "RECT"
}
}

check "wire opcode sequence" {join $ops " "} "PATH POINT POINT VWIRE POINT RECT POINT"
check "wire points" {join $points " "} "0 0 2000 0 2000 1000 2000 2000"

set out_def [make_result_file "read_def_virtual.def"]
write_def $out_def
set stream [open $out_def r]
set def_text [read $stream]
close $stream
check "write_def preserves virtual point" {
expr {[string first "VIRTUAL ( 2000 1000 )" $def_text] >= 0}
} 1

exit_summary
16 changes: 16 additions & 0 deletions src/odb/test/read_def_virtual_invalid.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
source "helpers.tcl"

read_lef "data/gscl45nm.lef"

set status [catch { read_def "data/virtual_route_invalid.def" } msg]
if { $status != 1 } {
puts "fail: read_def accepted VIRTUAL without a prior routing point"
exit 1
}

if { $msg != "ODB-0421" } {
puts "fail: unexpected error: $msg"
exit 1
}

puts "pass"
Loading