From 7c85835c8f2fd60f6b4e5e6c0b1946bf58d2d332 Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Thu, 27 Oct 2022 19:42:13 +0200 Subject: [PATCH] Added partial support for Pad (component) in RoutinPad. * New: In Hurricane::RoutingPad, added support if the supporting component is a Pad. The source/target positions are computed according to the most likely direction. Change the _getEntityAsComponent() function into an inline template _getEntityAs(). Change the flags from an enum to static const uint32_t. * Change: In Anabatic::Configuration, use _getEntityAs. * Change: In Anabatic::Dijkstra, use _getEntityAs. * Change: In Anabatic::NetBuilder, use _getEntityAs. * Change: In Katabatic::LoadGrByNet, use _getEntityAs. * Change: In Katana::ProtectRoutingPads, use _getEntityAs. * Change: In Bora::AnalogDistance, use _getEntityAs. * Change: In Etesian::EtesianEngine, use _getEntityAs. --- anabatic/src/Configuration.cpp | 6 +- anabatic/src/Dijkstra.cpp | 8 +- anabatic/src/NetBuilder.cpp | 2 +- bora/src/bora/AnalogDistance.h | 8 +- etesian/src/EtesianEngine.cpp | 2 +- hurricane/src/hurricane/RoutingPad.cpp | 93 +++++++++---------- .../src/hurricane/hurricane/RoutingPad.h | 37 ++++---- katabatic/src/LoadGrByNet.cpp | 2 +- katana/src/Manipulator.cpp | 6 +- katana/src/ProtectRoutingPads.cpp | 2 +- kite/src/ProtectRoutingPads.cpp | 2 +- 11 files changed, 86 insertions(+), 82 deletions(-) diff --git a/anabatic/src/Configuration.cpp b/anabatic/src/Configuration.cpp index c8fe0fee..9857062b 100644 --- a/anabatic/src/Configuration.cpp +++ b/anabatic/src/Configuration.cpp @@ -26,6 +26,7 @@ #include "hurricane/RegularLayer.h" #include "hurricane/RoutingPad.h" #include "hurricane/Pin.h" +#include "hurricane/Pad.h" #include "hurricane/NetExternalComponents.h" #include "hurricane/Cell.h" #include "crlcore/Utilities.h" @@ -56,6 +57,7 @@ namespace Anabatic { using Hurricane::BasicLayer; using Hurricane::RegularLayer; using Hurricane::Segment; + using Hurricane::Pad; using Hurricane::Pin; using Hurricane::Plug; using Hurricane::Path; @@ -497,10 +499,12 @@ namespace Anabatic { break; } - Component* candidate = dynamic_cast(component); + Component* candidate = dynamic_cast( component ); if (not candidate or (candidate->getLayer()->getMask() != metal1->getMask()) ) candidate = dynamic_cast(component); + if (not candidate) + candidate = dynamic_cast( component ); if (not candidate) continue; Box bb = transformation.getBox( candidate->getBoundingBox() ); diff --git a/anabatic/src/Dijkstra.cpp b/anabatic/src/Dijkstra.cpp index 5223250a..94f74b17 100644 --- a/anabatic/src/Dijkstra.cpp +++ b/anabatic/src/Dijkstra.cpp @@ -265,7 +265,7 @@ namespace Anabatic { } } if (rp) { - Vertical* v = dynamic_cast(rp->_getEntityAsSegment()); + Vertical* v = dynamic_cast(rp->_getEntityAs()); if (v) { return true; } } } @@ -285,7 +285,7 @@ namespace Anabatic { } } if (rp) { - Horizontal* h = dynamic_cast(rp->_getEntityAsSegment()); + Horizontal* h = dynamic_cast(rp->_getEntityAs()); if (h) { return true; } } } @@ -2873,8 +2873,8 @@ namespace Anabatic { { cdebug_log(112,0) << "void Dijkstra::_setSourcesGRAData() : " << seed << endl; GCell* gseed = seed->getGCell(); - Horizontal* h = dynamic_cast(rp->_getEntityAsSegment()); - Vertical* v = dynamic_cast (rp->_getEntityAsSegment()); + Horizontal* h = dynamic_cast(rp->_getEntityAs()); + Vertical* v = dynamic_cast (rp->_getEntityAs()); if (h) { cdebug_log(112,0) << "case H " << endl; seed->unsetFlags(Vertex::iHorizontal); diff --git a/anabatic/src/NetBuilder.cpp b/anabatic/src/NetBuilder.cpp index 4f5357c0..67e94c5c 100644 --- a/anabatic/src/NetBuilder.cpp +++ b/anabatic/src/NetBuilder.cpp @@ -491,7 +491,7 @@ namespace Anabatic { cdebug_log(145,0) << "| " << gcell << endl; } } else { - if (rp and AllianceFramework::get()->isPad(rp->_getEntityAsComponent()->getCell())) { + if (rp and AllianceFramework::get()->isPad(rp->_getEntityAs()->getCell())) { _connexity.fields.Pad++; } else { const Layer* layer = anchor->getLayer(); diff --git a/bora/src/bora/AnalogDistance.h b/bora/src/bora/AnalogDistance.h index bf2601d2..8443d356 100644 --- a/bora/src/bora/AnalogDistance.h +++ b/bora/src/bora/AnalogDistance.h @@ -130,8 +130,8 @@ namespace Bora { if (rp) break; } if (rp) { - Horizontal* h = dynamic_cast( rp->_getEntityAsSegment() ); - Vertical* v = dynamic_cast( rp->_getEntityAsSegment() ); + Horizontal* h = dynamic_cast( rp->_getEntityAs() ); + Vertical* v = dynamic_cast( rp->_getEntityAs() ); cdebug_log(112,0) << "Current: isDevice, "; if (h) { cdebug_log(112,0) << " rp: Horizontal and "; @@ -212,8 +212,8 @@ namespace Bora { } if (rp) { cdebug_log(112,0) << "Case: Next is a Device and "; - Horizontal* h = dynamic_cast( rp->_getEntityAsSegment() ); - Vertical* v = dynamic_cast( rp->_getEntityAsSegment() ); + Horizontal* h = dynamic_cast( rp->_getEntityAs() ); + Vertical* v = dynamic_cast( rp->_getEntityAs() ); if (h) { if (gcurr->isNorth(gnext) or gcurr->isSouth(gnext)) { cdebug_log(112,0) << "COST." << std::endl; diff --git a/etesian/src/EtesianEngine.cpp b/etesian/src/EtesianEngine.cpp index 95d6fb15..28a3dcc8 100644 --- a/etesian/src/EtesianEngine.cpp +++ b/etesian/src/EtesianEngine.cpp @@ -137,7 +137,7 @@ namespace { Point extractRpOffset ( const RoutingPad* rp ) { Cell* masterCell = rp->getOccurrence().getMasterCell(); - Component* component = rp->_getEntityAsComponent(); + Component* component = rp->_getEntityAs(); // TODO: verify that it doesn't assume that the orientation is North Box masterBox = masterCell->getAbutmentBox(); diff --git a/hurricane/src/hurricane/RoutingPad.cpp b/hurricane/src/hurricane/RoutingPad.cpp index d86865ca..c01f1b01 100644 --- a/hurricane/src/hurricane/RoutingPad.cpp +++ b/hurricane/src/hurricane/RoutingPad.cpp @@ -159,72 +159,85 @@ namespace Hurricane { Box RoutingPad::getBoundingBox () const { - Component* component = _getEntityAsComponent(); - if ( component ) - return _occurrence.getPath().getTransformation().getBox ( component->getBoundingBox() ); - - return Box(getPosition()); + Component* component = _getEntityAs(); + if (component) + return _occurrence.getPath().getTransformation().getBox( component->getBoundingBox() ); + return Box( getPosition() ); } Box RoutingPad::getBoundingBox ( const BasicLayer* basicLayer ) const { - Component* component = _getEntityAsComponent(); - if ( component ) { - return _occurrence.getPath().getTransformation().getBox ( component->getBoundingBox(basicLayer) ); - } - - return Box(getPosition()); + Component* component = _getEntityAs(); + if (component) + return _occurrence.getPath().getTransformation().getBox( component->getBoundingBox(basicLayer) ); + return Box( getPosition() ); } const Layer* RoutingPad::getLayer () const { - Component* component = _getEntityAsComponent(); - if (component) return component->getLayer (); - - return NULL; + Component* component = _getEntityAs(); + if (not component) return nullptr; + return component->getLayer (); } Point RoutingPad::getPosition () const { - Component* component = _getEntityAsComponent(); - if (component) { + Component* component = _getEntityAs(); + if (component) return _occurrence.getPath().getTransformation().getPoint( component->getCenter() ); - } - return Point(); } Point RoutingPad::getSourcePosition () const { - Segment* segment = _getEntityAsSegment(); - if ( segment ) { - return _occurrence.getPath().getTransformation().getPoint ( segment->getSourcePosition() ); + Segment* segment = _getEntityAs(); + if (segment) + return _occurrence.getPath().getTransformation().getPoint( segment->getSourcePosition() ); + Pad* pad = _getEntityAs(); + if (pad) { + Box bb = pad->getBoundingBox(); + Point position; + if (bb.getWidth() > bb.getHeight()) + position = Point( bb.getXMin() + bb.getHeight()/2, bb.getYCenter() ); + else + position = Point( bb.getYCenter(), bb.getYMin() + bb.getWidth()/2 ); + return _occurrence.getPath().getTransformation().getPoint( position ); } - return getPosition(); } Point RoutingPad::getTargetPosition() const { - Segment* segment = _getEntityAsSegment(); - if ( segment ) - return _occurrence.getPath().getTransformation().getPoint ( segment->getTargetPosition() ); - + Segment* segment = _getEntityAs(); + if (segment) + return _occurrence.getPath().getTransformation().getPoint( segment->getTargetPosition() ); + Pad* pad = _getEntityAs(); + if (pad) { + Box bb = pad->getBoundingBox(); + Point position; + if (bb.getWidth() > bb.getHeight()) + position = Point( bb.getXMax() - bb.getHeight()/2, bb.getYCenter() ); + else + position = Point( bb.getYCenter(), bb.getYMax() - bb.getWidth()/2 ); + return _occurrence.getPath().getTransformation().getPoint( position ); + } return getPosition(); } Point RoutingPad::getCenter() const { - Segment* segment = _getEntityAsSegment(); - if ( segment ) - return _occurrence.getPath().getTransformation().getPoint ( segment->getCenter() ); - + Segment* segment = _getEntityAs(); + if (segment) + return _occurrence.getPath().getTransformation().getPoint( segment->getCenter() ); + Pad* pad = _getEntityAs(); + if (pad) + return _occurrence.getPath().getTransformation().getPoint( pad->getCenter() ); return getPosition(); } @@ -275,24 +288,6 @@ namespace Hurricane { } - Component* RoutingPad::_getEntityAsComponent () const - { - if ( _occurrence.isValid() ) - return dynamic_cast( _occurrence.getEntity() ); - - return NULL; - } - - - Segment* RoutingPad::_getEntityAsSegment () const - { - if ( _occurrence.isValid() ) - return dynamic_cast( _occurrence.getEntity() ); - - return NULL; - } - - void RoutingPad::setExternalComponent ( Component* component ) { if (isMaterialized()) invalidate( false ); diff --git a/hurricane/src/hurricane/hurricane/RoutingPad.h b/hurricane/src/hurricane/hurricane/RoutingPad.h index 10563483..aa81e8bd 100644 --- a/hurricane/src/hurricane/hurricane/RoutingPad.h +++ b/hurricane/src/hurricane/hurricane/RoutingPad.h @@ -29,9 +29,7 @@ // +-----------------------------------------------------------------+ -#ifndef HURRICANE_ROUTINGPAD_H -#define HURRICANE_ROUTINGPAD_H - +#pragma once #include "hurricane/Component.h" #include "hurricane/Occurrence.h" #include "hurricane/Pin.h" @@ -48,18 +46,19 @@ namespace Hurricane { class RoutingPad : public Component { public: typedef Component Inherit; - enum Flags { BiggestArea = (1 << 0) - , HighestLayer = (1 << 1) - , LowestLayer = (1 << 2) - , ComponentSelection= BiggestArea|HighestLayer|LowestLayer - , ShowWarning = (1 << 4) - }; + static const uint32_t BiggestArea = (1 << 0); + static const uint32_t HighestLayer = (1 << 1); + static const uint32_t LowestLayer = (1 << 2); + static const uint32_t ShowWarning = (1 << 3); + static const uint32_t IsOnSegment = (1 << 4); + static const uint32_t IsOnPad = (1 << 5); + static const uint32_t ComponentSelection = BiggestArea|HighestLayer|LowestLayer; public: - static RoutingPad* create ( Net*, Occurrence, unsigned int flags=0 ); + static RoutingPad* create ( Net*, Occurrence, uint32_t flags=0 ); static RoutingPad* create ( Pin* ); public: // Accessors. - bool isPlacedOccurrence ( unsigned int flags ) const; + bool isPlacedOccurrence ( uint32_t flags ) const; inline bool isAtTopLevel () const; inline Occurrence getOccurrence () const; Occurrence getPlugOccurrence (); @@ -79,11 +78,11 @@ namespace Hurricane { // Mutators. virtual void translate ( const DbU::Unit& dx, const DbU::Unit& dy ); void setExternalComponent ( Component* ); - Component* setOnBestComponent ( unsigned int flags ); + Component* setOnBestComponent ( uint32_t flags ); void restorePlugOccurrence (); // Miscellaeous. - Component* _getEntityAsComponent () const; - Segment* _getEntityAsSegment () const; + template + T* _getEntityAs () const; virtual void _toJson ( JsonWriter* ) const; virtual std::string _getTypeName () const {return _TName("RoutingPad");}; virtual std::string _getString () const; @@ -103,6 +102,14 @@ namespace Hurricane { inline Occurrence RoutingPad::getOccurrence () const { return _occurrence; }; + template + inline T* RoutingPad::_getEntityAs () const + { + if (not _occurrence.isValid()) return nullptr; + return dynamic_cast( _occurrence.getEntity() ); + } + + // ------------------------------------------------------------------- // Class : "JsonRoutingPad". @@ -119,5 +126,3 @@ namespace Hurricane { INSPECTOR_P_SUPPORT(Hurricane::RoutingPad); - -#endif // HURRICANE_ROUTINGPAD_H diff --git a/katabatic/src/LoadGrByNet.cpp b/katabatic/src/LoadGrByNet.cpp index 2f59b0c1..57077056 100644 --- a/katabatic/src/LoadGrByNet.cpp +++ b/katabatic/src/LoadGrByNet.cpp @@ -870,7 +870,7 @@ namespace { throw Error( mismatchGCell ); } } else { - if (rp and AllianceFramework::get()->isPad(rp->_getEntityAsComponent()->getCell())) { + if (rp and AllianceFramework::get()->isPad(rp->_getEntityAs()->getCell())) { _connexity.fields.Pad++; } else { const Layer* layer = anchor->getLayer(); diff --git a/katana/src/Manipulator.cpp b/katana/src/Manipulator.cpp index 1d5f5250..1aed3380 100644 --- a/katana/src/Manipulator.cpp +++ b/katana/src/Manipulator.cpp @@ -1,14 +1,14 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC 2008-2018, All Rights Reserved +// Copyright (c) Sorbonne Université 2008-2022, All Rights Reserved // // +-----------------------------------------------------------------+ // | C O R I O L I S | -// | K i t e - D e t a i l e d R o u t e r | +// | K a t a n a - D e t a i l e d R o u t e r | // | | // | Author : Jean-Paul CHAPUT | -// | E-mail : Jean-Paul.Chaput@asim.lip6.fr | +// | E-mail : Jean-Paul.Chaput@lip6.fr | // | =============================================================== | // | C++ Module : "./Manipulator.cpp" | // +-----------------------------------------------------------------+ diff --git a/katana/src/ProtectRoutingPads.cpp b/katana/src/ProtectRoutingPads.cpp index d3366c0c..5b6a1426 100644 --- a/katana/src/ProtectRoutingPads.cpp +++ b/katana/src/ProtectRoutingPads.cpp @@ -76,7 +76,7 @@ namespace { cdebug_log(145,1) << "::protectRoutingPad() " << rp << endl; Name padNetName = "pad"; - Component* usedComponent = rp->_getEntityAsComponent(); + Component* usedComponent = rp->_getEntityAs(); Path path = rp->getOccurrence().getPath(); Net* masterNet = usedComponent->getNet(); Transformation transformation = path.getTransformation(); diff --git a/kite/src/ProtectRoutingPads.cpp b/kite/src/ProtectRoutingPads.cpp index 96f549e6..fb1364f3 100644 --- a/kite/src/ProtectRoutingPads.cpp +++ b/kite/src/ProtectRoutingPads.cpp @@ -71,7 +71,7 @@ namespace { void protectRoutingPad ( RoutingPad* rp ) { Name padNetName = "pad"; - Component* usedComponent = rp->_getEntityAsComponent(); + Component* usedComponent = rp->_getEntityAs(); Path path = rp->getOccurrence().getPath(); Net* masterNet = usedComponent->getNet(); Transformation transformation = path.getTransformation();