Skip to content

Commit 4558e92

Browse files
authored
Merge pull request #8564 from The-OpenROAD-Project-staging/odb-ndr-wrong-way
odb: fix wrong way dir width when an NDR is present
2 parents b23fa6a + cabe283 commit 4558e92

2 files changed

Lines changed: 37 additions & 2 deletions

File tree

src/odb/src/db/dbWireShapeItr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ bool dbWireShapeItr::next(dbShape& shape)
143143
goto nextOpCode;
144144
}
145145
auto dw = _dw;
146-
if (_layer->getDirection() == dbTechLayerDir::VERTICAL) {
146+
if (!_has_width && _layer->getDirection() == dbTechLayerDir::VERTICAL) {
147147
dw = _layer->getWrongWayWidth() / 2;
148148
}
149149

@@ -182,7 +182,7 @@ bool dbWireShapeItr::next(dbShape& shape)
182182
}
183183
auto dw = _dw;
184184

185-
if (_layer->getDirection() == dbTechLayerDir::HORIZONTAL) {
185+
if (!_has_width && _layer->getDirection() == dbTechLayerDir::HORIZONTAL) {
186186
dw = _layer->getWrongWayWidth() / 2;
187187
}
188188
shape.setSegment(_prev_x,

src/odb/test/cpp/TestDbWire.cc

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <memory>
1010

1111
#include "odb/db.h"
12+
#include "odb/dbShape.h"
1213
#include "odb/dbWireCodec.h"
1314
#include "odb/lefin.h"
1415
#include "tst/fixture.h"
@@ -36,6 +37,40 @@ class OdbMultiPatternedTest : public tst::Fixture
3637
odb::dbBlock* block_;
3738
};
3839

40+
TEST_F(OdbMultiPatternedTest, NdrWidth)
41+
{
42+
dbTechLayer* met1 = lib_->getTech()->findLayer("met1");
43+
ASSERT_NE(met1, nullptr);
44+
45+
// Setup an NDR
46+
dbTechNonDefaultRule* ndr = dbTechNonDefaultRule::create(block_, "ndr");
47+
dbTechLayerRule* rule = dbTechLayerRule::create(ndr, met1);
48+
const int width = 42;
49+
rule->setWidth(width);
50+
51+
// Apply it to some routing
52+
dbNet* net = dbNet::create(block_, "net");
53+
dbWire* wire = dbWire::create(net);
54+
dbWireEncoder encoder;
55+
encoder.begin(wire);
56+
encoder.newPath(met1, dbWireType::ROUTED, rule);
57+
encoder.addPoint(0, 0);
58+
encoder.addPoint(0, 100000);
59+
encoder.addPoint(100000, 100000);
60+
encoder.end();
61+
62+
// Check the width in both directions is correct
63+
int shape_cnt = 0;
64+
odb::dbWireShapeItr it;
65+
it.begin(wire);
66+
odb::dbShape shape;
67+
while (it.next(shape)) {
68+
EXPECT_EQ(shape.getBox().minDXDY(), width);
69+
++shape_cnt;
70+
}
71+
EXPECT_EQ(shape_cnt, 2);
72+
}
73+
3974
TEST_F(OdbMultiPatternedTest, CanColorColoredLayer)
4075
{
4176
// Arrange

0 commit comments

Comments
 (0)