Allow to enable/disable minimal size checking in Contact CTOR.

This commit is contained in:
Jean-Paul Chaput 2021-05-25 14:56:07 +02:00
parent 1bff74a56e
commit 39231d5191
2 changed files with 52 additions and 23 deletions

View File

@ -103,6 +103,9 @@ class Contact_Hooks : public Collection<Hook*> {
// Contact implementation
// ****************************************************************************************************
bool Contact::_checkMinSize = true;
Contact::Contact(Net* net, const Layer* layer, DbU::Unit x, DbU::Unit y, DbU::Unit width, DbU::Unit height)
// ********************************************************************************************************
: Inherit(net),
@ -169,12 +172,13 @@ Contact* Contact::create(Component* anchor, const Layer* layer, DbU::Unit dx, Db
bool Contact::_postCheck ()
// *************************
{
DbU::Unit twoGrid = DbU::fromGrid( 2 );
bool rvalue = true;
if (_layer->isSymbolic()) {
if (not _width ) _width = _layer->getMinimalSize();
if (not _height) _height = _layer->getMinimalSize();
} else {
if ((_width) and (_width < _layer->getMinimalSize())) {
if ((_width) and _checkMinSize and (_width < _layer->getMinimalSize())) {
cerr << Warning( "Contact::_postCheck(): Width %s is inferior to layer minimal size %s, bumping.\n"
" (on %s)"
, DbU::getValueString(_width).c_str()
@ -184,7 +188,7 @@ Contact* Contact::create(Component* anchor, const Layer* layer, DbU::Unit dx, Db
_width = _layer->getMinimalSize();
rvalue = false;
}
if ((_height) and (_height < _layer->getMinimalSize())) {
if ((_height) and _checkMinSize and (_height < _layer->getMinimalSize())) {
cerr << Warning( "Contact::_postCheck(): Height %s is inferior to layer minimal size %s, bumping.\n"
" (on %s)"
, DbU::getValueString(_height).c_str()
@ -194,6 +198,24 @@ Contact* Contact::create(Component* anchor, const Layer* layer, DbU::Unit dx, Db
_height = _layer->getMinimalSize();
rvalue = false;
}
if ((_width % twoGrid) and _checkMinSize) {
cerr << Warning( "Contact::_postCheck(): Width %s is not a multiple of 2*%s, shrinking.\n"
" (on %s)"
, DbU::getValueString(_width).c_str()
, DbU::getValueString(DbU::fromGrid(1)).c_str()
, getString(this).c_str() )
<< endl;
_width -= (_width % twoGrid);
}
if ((_height % twoGrid) and _checkMinSize) {
cerr << Warning( "Contact::_postCheck(): Height %s is not a multiple of 2*%s, shrinking.\n"
" (on %s)"
, DbU::getValueString(_height).c_str()
, DbU::getValueString(DbU::fromGrid(1)).c_str()
, getString(this).c_str() )
<< endl;
_height -= (_height % twoGrid);
}
}
return rvalue;
}

View File

@ -75,6 +75,8 @@ namespace Hurricane {
, DbU::Unit height
);
public:
static inline void enableCheckMinSize ();
static inline void disableCheckMinSize ();
static Contact* create ( Net* net
, const Layer* layer
, DbU::Unit x
@ -128,6 +130,7 @@ namespace Hurricane {
virtual std::string _getString () const;
virtual Record* _getRecord () const;
private:
static bool _checkMinSize;
AnchorHook _anchorHook;
const Layer* _layer;
DbU::Unit _dx;
@ -138,8 +141,12 @@ namespace Hurricane {
};
inline void Contact::enableCheckMinSize () { _checkMinSize=true; }
inline void Contact::disableCheckMinSize () { _checkMinSize=false; }
// -------------------------------------------------------------------
// Class : "Hurricane::Contact".
// Class : "Hurricane::JsonContact".
class JsonContact : public JsonComponent {
public: