Compare commits

...

2 Commits

Author SHA1 Message Date
Jean-Paul Chaput d43fa49778 Add basic support for logo insertion in cumulus/plugins.chip. 2021-06-16 16:26:33 +02:00
Jean-Paul Chaput 15e7abf667 Use the DATATYPE for LAYER record in GdsStream.
* Change: In GdsStream::_gdsLayerTable, use a map<> instead of a vector<>,
    use a combined value of the layer index and the datatype as index.
        (index = (layer<<16) + datatype.
    This allow for layers that are represented by a pair of (layer,datatype)
    with same layer and different datatypes.
* Change: In GdsStream::gdsToLayer(), now have two parameters, the layer
    and the datatype.
2021-06-16 16:24:01 +02:00
4 changed files with 170 additions and 103 deletions

View File

@ -203,6 +203,7 @@ namespace {
void readString ();
void readUnits ();
void readLayer ();
void readDatatype ();
void readWidth ();
void readBgnextn ();
void readEndextn ();
@ -352,7 +353,7 @@ namespace {
case AREF: readDummy( false ); break;
case TEXT: readDummy( false ); break;
case LAYER: readLayer(); break;
case DATATYPE: readDummy( false ); break;
case DATATYPE: readDatatype(); break;
case WIDTH: readWidth(); break;
case XY: readXy(); break;
case ENDEL: readDummy( false ); break;
@ -542,6 +543,10 @@ namespace {
{ _int16s.push_back( _readInt<uint16_t>() ); }
void GdsRecord::readDatatype ()
{ _int16s.push_back( _readInt<uint16_t>() ); }
void GdsRecord::readWidth ()
{ _int32s.push_back( _readInt<uint32_t>() ); }
@ -640,36 +645,37 @@ namespace {
class GdsStream {
public:
static const Layer* gdsToLayer ( uint16_t );
public:
static void _staticInit ();
GdsStream ( string gdsPath );
inline bool isValidSyntax () const;
bool misplacedRecord ();
inline void resetStrans ();
bool read ( Library* );
bool readFormatType ();
bool readStructure ();
bool readBoundary ();
bool readPath ();
bool readSref ();
bool readAref ();
bool readNode ();
bool readBox ();
bool readText ();
bool readTextbody ( const Layer* );
bool readStrans ();
bool readProperty ();
void xyToComponent ( const Layer* );
void xyToPath ( uint16_t pathtype
, const Layer*
, DbU::Unit width
, DbU::Unit bgnextn
, DbU::Unit endextn );
void makeInstances ();
void makeExternals ();
Net* fusedNet ();
void addNetReference ( Net*, const Layer*, DbU::Unit x, DbU::Unit y );
static const Layer* gdsToLayer ( uint16_t gdsLayer, uint16_t datatype );
public:
static void _staticInit ();
GdsStream ( string gdsPath );
inline bool isValidSyntax () const;
bool misplacedRecord ();
inline void resetStrans ();
bool read ( Library* );
bool readFormatType ();
bool readStructure ();
const Layer* readLayerAndDatatype ();
bool readBoundary ();
bool readPath ();
bool readSref ();
bool readAref ();
bool readNode ();
bool readBox ();
bool readText ();
bool readTextbody ( const Layer* );
bool readStrans ();
bool readProperty ();
void xyToComponent ( const Layer* );
void xyToPath ( uint16_t pathtype
, const Layer*
, DbU::Unit width
, DbU::Unit bgnextn
, DbU::Unit endextn );
void makeInstances ();
void makeExternals ();
Net* fusedNet ();
void addNetReference ( Net*, const Layer*, DbU::Unit x, DbU::Unit y );
private:
struct DelayedInstance {
inline DelayedInstance ( Cell* owner, string masterName, const Transformation& );
@ -685,21 +691,21 @@ namespace {
Point _position;
};
private:
static vector<const Layer*> _gdsLayerTable;
vector<DelayedInstance> _delayedInstances;
string _gdsPath;
ifstream _stream;
GdsRecord _record;
double _angle;
bool _xReflection;
Library* _library;
Cell* _cell;
Component* _component;
string _text;
DbU::Unit _scale;
int64_t _SREFCount;
bool _validSyntax;
bool _skipENDEL;
static map<uint32_t,const Layer*> _gdsLayerTable;
vector<DelayedInstance> _delayedInstances;
string _gdsPath;
ifstream _stream;
GdsRecord _record;
double _angle;
bool _xReflection;
Library* _library;
Cell* _cell;
Component* _component;
string _text;
DbU::Unit _scale;
int64_t _SREFCount;
bool _validSyntax;
bool _skipENDEL;
map< Net*
, vector<PinPoint>
, DBo::CompareById > _netReferences;
@ -718,15 +724,14 @@ namespace {
{ }
vector<const Layer*> GdsStream::_gdsLayerTable;
map<uint32_t,const Layer*> GdsStream::_gdsLayerTable;
void GdsStream::_staticInit ()
{
_gdsLayerTable = vector<const Layer*>( 1024, NULL );
for ( const BasicLayer* layer : DataBase::getDB()->getTechnology()->getBasicLayers() ) {
uint16_t gdsNumber = layer->getGds2Layer();
if (gdsNumber < 1024) _gdsLayerTable[gdsNumber] = layer;
uint32_t gdsNumber = (layer->getGds2Layer() << 16) + layer->getGds2Datatype();
_gdsLayerTable[gdsNumber] = layer;
}
}
@ -734,8 +739,14 @@ namespace {
inline void GdsStream::resetStrans () { _angle = 0.0; _xReflection = false; }
const Layer* GdsStream::gdsToLayer ( uint16_t gdsLayer )
{ return (gdsLayer < _gdsLayerTable.size()) ? _gdsLayerTable[gdsLayer] : NULL; }
const Layer* GdsStream::gdsToLayer ( uint16_t gdsLayer, uint16_t datatype )
{
uint32_t gdsIndex = (gdsLayer << 16) + datatype;
auto ilayer = _gdsLayerTable.find( gdsIndex );
if (ilayer == _gdsLayerTable.end())
return NULL;
return (*ilayer).second;
}
inline bool GdsStream::isValidSyntax () const { return _validSyntax; }
@ -930,6 +941,45 @@ namespace {
}
const Layer* GdsStream::readLayerAndDatatype ()
{
uint16_t gdsLayer = 0;
uint16_t gdsDatatype = 0;
if (_record.isLAYER()) {
gdsLayer = (uint16_t)_record.getInt16s()[0];
_stream >> _record;
} else {
cerr << Error( "GdsStream::readLayerAndDatatype(): Expecting LAYER record, got %s."
, GdsRecord::toStrType(_record.getType()).c_str()
) << endl;
_validSyntax = false;
return NULL;;
}
if (_record.isDATATYPE()) {
gdsDatatype = (uint16_t)_record.getInt16s()[0];
_stream >> _record;
} else {
cerr << Error( "GdsStream::readLayerAndDatatype(): Expecting DATATYPE record, got %s."
, GdsRecord::toStrType(_record.getType()).c_str()
) << endl;
_validSyntax = false;
return NULL;;
}
const Layer* layer = gdsToLayer( gdsLayer, gdsDatatype );
cdebug_log(101,0) << "Layer id+datatype:" << gdsLayer << "+" << gdsDatatype << " " << layer << endl;
if (not layer) {
cerr << Error( "GdsStream::readLayerAndDatatype(): No BasicLayer id:%d+%d in GDS conversion table (skipped)."
, gdsLayer, gdsDatatype
) << endl;
}
return layer;
}
bool GdsStream::readText ()
{
const Layer* layer = NULL;
@ -938,7 +988,7 @@ namespace {
if (_record.isELFLAGS()) { _stream >> _record; }
if (_record.isPLEX ()) { _stream >> _record; }
if (_record.isLAYER ()) {
layer = gdsToLayer( (uint16_t)_record.getInt16s()[0] );
layer = gdsToLayer( (uint16_t)_record.getInt16s()[0], 0 );
if (not layer) {
cerr << Error( "GdsStream::readText(): No BasicLayer id:%d in GDS conversion table (skipped)."
, _record.getInt16s()[0]
@ -1045,29 +1095,11 @@ namespace {
{
cdebug_log(101,1) << "GdsStream::readBoundary()" << endl;
const Layer* layer = NULL;
if (_record.isELFLAGS()) { _stream >> _record; }
if (_record.isPLEX ()) { _stream >> _record; }
if (_record.isLAYER()) {
layer = gdsToLayer( (uint16_t)_record.getInt16s()[0] );
cdebug_log(101,0) << "Layer id:" << ((uint32_t)_record.getInt16s()[0]) << " " << layer << endl;
if (not layer) {
cerr << Error( "GdsStream::readBoundary(): No BasicLayer id:%d in GDS conversion table (skipped)."
, _record.getInt16s()[0]
) << endl;
}
_stream >> _record;
} else {
_validSyntax = false;
cdebug_tabw(101,-1);
return _validSyntax;
}
if (_record.isDATATYPE()) { _stream >> _record; }
else {
_validSyntax = false;
const Layer* layer = readLayerAndDatatype();
if (not _validSyntax) {
cdebug_tabw(101,-1);
return _validSyntax;
}
@ -1090,36 +1122,16 @@ namespace {
{
cdebug_log(101,1) << "GdsStream::readPath()" << endl;
const Layer* layer = NULL;
DbU::Unit width = 0;
uint16_t pathtype = 0;
DbU::Unit bgnextn = 0;
DbU::Unit endextn = 0;
DbU::Unit width = 0;
uint16_t pathtype = 0;
DbU::Unit bgnextn = 0;
DbU::Unit endextn = 0;
if (_record.isELFLAGS()) { _stream >> _record; }
if (_record.isPLEX ()) { _stream >> _record; }
if (_record.isLAYER()) {
layer = gdsToLayer( (uint16_t)_record.getInt16s()[0] );
if (not layer) {
cerr << Error( "GdsStream::readPath(): No BasicLayer id \"%d\" in GDS conversion table (skipped)."
, _record.getInt16s()[0]
) << endl;
}
_stream >> _record;
cdebug_log(101,0) << layer << endl;
} else {
_validSyntax = false;
cdebug_tabw(101,-1);
return _validSyntax;
}
if (_record.isDATATYPE()) { _stream >> _record; }
else {
cerr << Error( "GdsStream::readPath(): Expecting DATATYPE record, got %s."
, GdsRecord::toStrType(_record.getType()).c_str()
) << endl;
_validSyntax = false;
const Layer* layer = readLayerAndDatatype();
if (not layer) {
cdebug_tabw(101,-1);
return _validSyntax;
}
@ -1287,7 +1299,7 @@ namespace {
if (_record.isPLEX ()) { _stream >> _record; }
if (_record.isLAYER ()) {
layer = gdsToLayer( (uint16_t)_record.getInt16s()[0] );
layer = gdsToLayer( (uint16_t)_record.getInt16s()[0], 0 );
if (not layer) {
cerr << Error( "GdsStream::readNode(): No BasicLayer id \"%d\" in GDS conversion table (skipped)."
, _record.getInt16s()[0]
@ -1326,7 +1338,7 @@ namespace {
if (_record.isPLEX ()) { _stream >> _record; }
if (_record.isLAYER ()) {
layer = gdsToLayer( (uint16_t)_record.getInt16s()[0] );
layer = gdsToLayer( (uint16_t)_record.getInt16s()[0], 0 );
if (not layer) {
cerr << Error( "GdsStream::readNode(): No BasicLayer id \"%d\" in GDS conversion table (skipped)."
, _record.getInt16s()[0]

View File

@ -333,6 +333,22 @@ class Block ( object ):
.format(self.conf.cell.getName()) )
Block.LUT[ self.conf.cell ] = self
@staticmethod
def abPlace ( instance, transf ):
"""
Place an instance so it is it's abutment box which will be
placed at ``transf``. Incomplete implementation for now, only
Orientation::ID in ``transf`` is supported.
"""
ab = instance.getMasterCell().getAbutmentBox()
abTransf = Transformation( ab.getXMin(), ab.getYMin(), Transformation.Orientation.ID )
abTransf.invert()
abTransf.applyOn( transf )
instance.setTransformation( transf )
instance.setPlacementStatus( Instance.PlacementStatus.FIXED )
@staticmethod
def _getInstance ( cell, pattern, level=0 ):
"""

View File

@ -91,7 +91,7 @@ class ChipConf ( BlockConf ):
def __init__ ( self, cell, ioPins=[], ioPads=[] ):
trace( 550, ',+', 'ChipConf.__init__(): "{}"'.format(cell.getName()) )
super(ChipConf,self).__init__( cell, ioPins, ioPads )
# trace( 550, '\tONE LAMBDA = %s\n' % DbU.getValueString(DbU.fromLambda(1.0)) )
#trace( 550, '\tONE LAMBDA = %s\n' % DbU.getValueString(DbU.fromLambda(1.0)) )
self.validated = True
# Block Corona parameters (triggers loading from disk).
self.cfg.chip.padCoreSide = None
@ -111,6 +111,7 @@ class ChipConf ( BlockConf ):
self.coronaCks = []
self.blockageNet = None
self.padsHavePosition = False
self.chipLogos = []
trace( 550, '-' )
@property

View File

@ -22,7 +22,8 @@ from Hurricane import DbU, Point, Transformation, Interval, Box, \
Path, Occurrence, UpdateSession, Layer, \
BasicLayer, Net, Pin, Contact, Segment, Pad, \
Horizontal, Vertical, Diagonal, RoutingPad, \
Instance, DataBase, NetExternalComponents
Instance, DataBase, NetExternalComponents, \
Library
import CRL
from CRL import RoutingGauge, RoutingLayerGauge
import helpers
@ -30,11 +31,15 @@ from helpers import trace, l, u, n, onFGrid
from helpers.io import ErrorMessage, WarningMessage
from helpers.overlay import UpdateSession
import plugins.alpha.chip
from plugins.alpha.block.block import Block
from plugins.alpha.block.bigvia import BigVia
plugins.alpha.chip.importConstants( globals() )
af = CRL.AllianceFramework.get()
# --------------------------------------------------------------------
# Class : "pads.Corner"
@ -1295,6 +1300,7 @@ class Corona ( object ):
self.eastSide.doLayout()
self.westSide.doLayout()
self._placeInnerCorona()
self.doLogosLayout()
self.conf.chip.setRouted( True )
def doPowerLayout ( self ):
@ -1402,4 +1408,36 @@ class Corona ( object ):
# chipNet = chipPowerNet
# self._supplyToPad( chipNet, coronaNet, axis, North )
# self._supplyToPad( chipNet, coronaNet, axis, South )
def doLogosLayout ( self ):
"""
Add GDS logos layout in the bottom left corner of the chip, if any.
"""
global af
print( ' o Inserting chip logo(s).' )
if not len(self.conf.chipLogos): return
with UpdateSession():
rootLib = DataBase.getDB().getRootLibrary()
logosLib = rootLib.getLibrary( 'Logos' )
if not logosLib:
print( ' o Creating GDS Logos library.' )
logosLib = Library.create( rootLib, 'LogosLib' )
af.wrapLibrary( logosLib, 0 )
xLogo = 0
yLogo = 0
rowHeight = 0
count = 0
for logo in self.conf.chipLogos:
print( ' - GDS Logo "{0}.gds".'.format(logo) )
CRL.Gds.load( logosLib, './{}.gds'.format(logo) )
logoCell = logosLib.getCell( 'gds_{}'.format(logo) )
logoInstance = Instance.create( self.conf.chip, logo, logoCell )
Block.abPlace( logoInstance
, Transformation( xLogo, yLogo, Transformation.Orientation.ID ))
xLogo += logoCell.getAbutmentBox().getWidth()
rowHeight = max( rowHeight, logoCell.getAbutmentBox().getHeight() )
if count % 2:
xLogo = 0
yLogo += rowHeight
count += 1