Skip to content

Commit

Permalink
Fix offgrid segment translation problem in LefImport.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpc-lip6 committed Jan 21, 2024
1 parent ef6471d commit 11b0002
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 25 deletions.
90 changes: 65 additions & 25 deletions crlcore/src/ccore/lefdef/LefImport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ namespace {
Net* _net;
string _busBits;
double _unitsMicrons;
DbU::Unit _oneGrid;
map< string, vector<Component*> > _pinComponents;
static map<string,Layer*> _layerLut;
vector<string> _unmatchedLayers;
Expand Down Expand Up @@ -257,10 +256,10 @@ namespace {
inline DbU::Unit LefParser::fromUnitsMicrons ( double d ) const
{
DbU::Unit u = DbU::fromPhysical(d,DbU::Micro);
if (u % _oneGrid) {
if (u % DbU::oneGrid) {
cerr << Error( "LefParser::fromUnitsMicrons(): Offgrid value %s (DbU=%d), grid %s (DbU=%d)."
, DbU::getValueString(u).c_str(), u
, DbU::getValueString(_oneGrid).c_str(), _oneGrid )
, DbU::getValueString(DbU::oneGrid).c_str(), DbU::oneGrid )
<< endl;
}
return u;
Expand Down Expand Up @@ -339,7 +338,6 @@ namespace {
, _net (nullptr)
, _busBits ("()")
, _unitsMicrons (0.01)
, _oneGrid (DbU::fromGrid(1.0))
, _unmatchedLayers ()
, _errors ()
, _nthMetal (0)
Expand Down Expand Up @@ -638,10 +636,10 @@ namespace {
{
LefParser* parser = (LefParser*)ud;

const Layer* layer = NULL;
const Layer* blockageLayer = NULL;
Cell* cell = parser->getCell();
Net* blockageNet = cell->getNet( "blockage" );
const Layer* layer = NULL;
const Layer* blockageLayer = NULL;
Cell* cell = parser->getCell();
Net* blockageNet = cell->getNet( "blockage" );

if (not blockageNet) {
blockageNet = Net::create( cell, "blockage" );
Expand Down Expand Up @@ -671,19 +669,53 @@ namespace {
double h = r->yh - r->yl;
Segment* segment = NULL;
if (w >= h) {
segment = Horizontal::create( blockageNet, blockageLayer
, parser->fromUnitsMicrons( (r->yl + r->yh)/2 )
, parser->fromUnitsMicrons( h )
, parser->fromUnitsMicrons( r->xl )
, parser->fromUnitsMicrons( r->xh )
);
DbU::Unit yl = parser->fromUnitsMicrons( r->yl );
DbU::Unit yh = parser->fromUnitsMicrons( r->yh );
if ((yl % DbU::twoGrid) xor (yh % DbU::twoGrid)) {
segment = Horizontal::create( blockageNet, blockageLayer
, yh - DbU::oneGrid
, DbU::twoGrid
, parser->fromUnitsMicrons( r->xl )
, parser->fromUnitsMicrons( r->xh )
);
segment = Horizontal::create( blockageNet, blockageLayer
, (yh - DbU::oneGrid + yl) / 2
, yh - DbU::oneGrid - yl
, parser->fromUnitsMicrons( r->xl )
, parser->fromUnitsMicrons( r->xh )
);
} else {
segment = Horizontal::create( blockageNet, blockageLayer
, (yh + yl) / 2
, yh - yl
, parser->fromUnitsMicrons( r->xl )
, parser->fromUnitsMicrons( r->xh )
);
}
} else {
segment = Vertical::create( blockageNet, blockageLayer
, parser->fromUnitsMicrons( (r->xl + r->xh)/2 )
, parser->fromUnitsMicrons( w )
, parser->fromUnitsMicrons( r->yl )
, parser->fromUnitsMicrons( r->yh )
);
DbU::Unit xl = parser->fromUnitsMicrons( r->xl );
DbU::Unit xh = parser->fromUnitsMicrons( r->xh );
if ((xl % DbU::twoGrid) xor (xh % DbU::twoGrid)) {
segment = Vertical::create( blockageNet, blockageLayer
, xh - DbU::oneGrid
, DbU::twoGrid
, parser->fromUnitsMicrons( r->yl )
, parser->fromUnitsMicrons( r->yh )
);
segment = Vertical::create( blockageNet, blockageLayer
, (xh - DbU::oneGrid + xl) / 2
, xh - DbU::oneGrid - xl
, parser->fromUnitsMicrons( r->yl )
, parser->fromUnitsMicrons( r->yh )
);
} else {
segment = Vertical::create( blockageNet, blockageLayer
, (xh + xl) / 2
, xh - xl
, parser->fromUnitsMicrons( r->yl )
, parser->fromUnitsMicrons( r->yh )
);
}
}
cdebug_log(100,0) << "| " << segment << endl;
}
Expand Down Expand Up @@ -785,7 +817,7 @@ namespace {

//cerr << " @ _pinCbk: " << pin->name() << endl;

bool created = false;
bool created = false;
parser->earlyGetCell( created );

Net* net = nullptr;
Expand Down Expand Up @@ -850,16 +882,24 @@ namespace {
float formFactor = (float)w / (float)h;

if ( (formFactor > 0.5) and not parser->isVH() ) {
DbU::Unit yl = parser->fromUnitsMicrons( r->yl );
DbU::Unit yh = parser->fromUnitsMicrons( r->yh );
if ((yl % DbU::twoGrid) xor (yh % DbU::twoGrid))
yh -= DbU::oneGrid;
segment = Horizontal::create( net, layer
, parser->fromUnitsMicrons( (r->yl + r->yh)/2 )
, h
, (yh + yl) / 2
, yh - yl
, parser->fromUnitsMicrons( r->xl )
, parser->fromUnitsMicrons( r->xh )
);
} else {
DbU::Unit xl = parser->fromUnitsMicrons( r->xl );
DbU::Unit xh = parser->fromUnitsMicrons( r->xh );
if ((xl % DbU::twoGrid) xor (xh % DbU::twoGrid))
xh -= DbU::oneGrid;
segment = Vertical::create( net, layer
, parser->fromUnitsMicrons( (r->xl + r->xh)/2 )
, w
, (xh + xl) / 2
, xh - xl
, parser->fromUnitsMicrons( r->yl )
, parser->fromUnitsMicrons( r->yh )
);
Expand Down
4 changes: 4 additions & 0 deletions hurricane/src/hurricane/DbU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ namespace Hurricane {
DbU::Unit DbU::_polygonStep = DbU::fromGrid ( 1.0);
const DbU::Unit DbU::Min = std::numeric_limits<DbU::Unit>::min();
const DbU::Unit DbU::Max = std::numeric_limits<DbU::Unit>::max();
DbU::Unit DbU::oneGrid = DbU::fromGrid( 1.0 );
DbU::Unit DbU::twoGrid = DbU::fromGrid( 2.0 );


// -------------------------------------------------------------------
Expand Down Expand Up @@ -101,6 +103,8 @@ namespace Hurricane {
_gridMax = toGrid ( Max );
_lambdaMax = toLambda ( Max );
_physicalMax = toPhysical( Max, Unity );
oneGrid = fromGrid ( 1.0 );
twoGrid = fromGrid ( 2.0 );
}


Expand Down
2 changes: 2 additions & 0 deletions hurricane/src/hurricane/hurricane/DbU.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ namespace Hurricane {
// Static Attributes: constants.
static const Unit Min;
static const Unit Max;
static Unit oneGrid;
static Unit twoGrid;
private:
// Internal: Static Attributes.
static const unsigned int _maximalPrecision;
Expand Down

0 comments on commit 11b0002

Please sign in to comment.