From 4a33fa12b38c0a1decaf0449a112e5ce4e078d03 Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Wed, 4 Dec 2013 01:54:20 +0000 Subject: [PATCH] * ./knik/src: - Change: In LoadSolution check for missing global routing on nets. Nets with more than one pad, a BB greater than a GCell and no GContacts. --- knik/src/LoadSolution.cpp | 195 ++++++++++++++++++++------------------ knik/src/MatrixVertex.cpp | 2 +- 2 files changed, 105 insertions(+), 92 deletions(-) diff --git a/knik/src/LoadSolution.cpp b/knik/src/LoadSolution.cpp index a503961f..65e70ac6 100644 --- a/knik/src/LoadSolution.cpp +++ b/knik/src/LoadSolution.cpp @@ -2,14 +2,9 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2009, All Rights Reserved +// Copyright (c) UPMC 2008-2013, All Rights Reserved // -// =================================================================== -// -// $Id$ -// -// x-----------------------------------------------------------------x -// | | +// +-----------------------------------------------------------------+ // | C O R I O L I S | // | K n i k - Global Router | // | | @@ -17,36 +12,30 @@ // | E-mail : Damien.Dupuis@lip6.fr | // | =============================================================== | // | C++ Module : "./LoadSolution.cpp" | -// | *************************************************************** | -// | U p d a t e s | -// | | -// x-----------------------------------------------------------------x +// +-----------------------------------------------------------------+ -#include - -#include "hurricane/Error.h" -#include "hurricane/DataBase.h" -#include "hurricane/Technology.h" -#include "hurricane/Layer.h" -#include "hurricane/Contact.h" -#include "hurricane/Vertical.h" -#include "hurricane/Horizontal.h" -#include "hurricane/RoutingPad.h" -#include "hurricane/Cell.h" -#include "hurricane/UpdateSession.h" - -#include "crlcore/Utilities.h" -#include "crlcore/Measures.h" - -#include "knik/Configuration.h" -#include "knik/Graph.h" -#include "knik/KnikEngine.h" +#include +#include "hurricane/Error.h" +#include "hurricane/Warning.h" +#include "hurricane/DataBase.h" +#include "hurricane/Technology.h" +#include "hurricane/Layer.h" +#include "hurricane/Contact.h" +#include "hurricane/Vertical.h" +#include "hurricane/Horizontal.h" +#include "hurricane/RoutingPad.h" +#include "hurricane/Cell.h" +#include "hurricane/UpdateSession.h" +#include "crlcore/Utilities.h" +#include "crlcore/Measures.h" +#include "knik/Configuration.h" +#include "knik/Graph.h" +#include "knik/KnikEngine.h" namespace { - using std::string; using std::cerr; using std::endl; @@ -58,6 +47,7 @@ namespace { using Hurricane::ForEachIterator; using Hurricane::Error; + using Hurricane::Warning; using Hurricane::DbU; using Hurricane::Point; using Hurricane::Box; @@ -293,117 +283,140 @@ namespace { void SolutionParser::load () { - UpdateSession::open (); + UpdateSession::open(); + try { cmess1 << " o Loading solution: \"" << _fileName << "\"." << endl; CRL::IoFile fileStream ( _fileName ); - fileStream.open ( "r" ); - if ( !fileStream.isOpen() ) - throw Error ("Can't open/read file: %s.",_fileName.c_str()); + fileStream.open( "r" ); + if (not fileStream.isOpen()) + throw Error( "Can't open/read file: %s.", _fileName.c_str() ); - unsigned int contactCount = 0; - unsigned int segmentCount = 0; - GContactMap contactMap ( _knik, _gmetalh, _gmetalv ); + unsigned int missingGlobalRouting = 0; + unsigned int contactCount = 0; + unsigned int segmentCount = 0; + GContactMap contactMap ( _knik, _gmetalh, _gmetalv ); - while ( !fileStream.eof() ) { - fileStream.readLine ( _rawLine, RawLineSize ); + while ( not fileStream.eof() ) { + fileStream.readLine( _rawLine, RawLineSize ); _lineNumber++; - if ( _rawLine[0] == '\0' ) break; - if ( _rawLine[0] == '\n' ) continue; + if (_rawLine[0] == '\0') break; + if (_rawLine[0] == '\n') continue; - vector fields = _splitString ( _rawLine ); + vector fields = _splitString( _rawLine ); if ( fields.size() != 3 ) - throw Error ( LoadError, "Malformed Net Line", _fileName.c_str(), _lineNumber ); + throw Error( LoadError, "Malformed Net Line", _fileName.c_str(), _lineNumber ); else { - Name netName = Name ( fields[0] ); - unsigned nbPins = _getLong ( fields[2] ); - Net* net = _knik->getCell()->getNet ( netName ); + Name netName = Name ( fields[0] ); + unsigned int nbPins = _getLong( fields[2] ); + unsigned int nbSegments = 0; + unsigned int nbRoutingPad = 0; + Net* net = _knik->getCell()->getNet( netName ); - if ( !net ) { + if (not net) { string message = "Cell has no Net: "; message += getString(netName); - throw Error ( LoadError, message.c_str(), _fileName.c_str(), _lineNumber ); + throw Error( LoadError, message.c_str(), _fileName.c_str(), _lineNumber ); } - contactMap.setNet ( net ); + contactMap.setNet( net ); for ( unsigned i = 0 ; i < nbPins ; i++ ) { - fileStream.readLine ( _rawLine, RawLineSize ); + fileStream.readLine( _rawLine, RawLineSize ); _lineNumber++; - fields = _splitSegmentString ( _rawLine ); - if ( fields.size() != 6 ) - throw Error ( LoadError, "Malformed Net Line", _fileName.c_str(), _lineNumber ); + fields = _splitSegmentString( _rawLine ); + if (fields.size() != 6) + throw Error( LoadError, "Malformed Net Line", _fileName.c_str(), _lineNumber ); else { - DbU::Unit xSource = DbU::lambda(_getLong(fields[0])); - DbU::Unit ySource = DbU::lambda(_getLong(fields[1])); - unsigned zSource = (unsigned) (_getLong(fields[2])); - DbU::Unit xTarget = DbU::lambda(_getLong(fields[3])); - DbU::Unit yTarget = DbU::lambda(_getLong(fields[4])); - unsigned zTarget = (unsigned) (_getLong(fields[5])); + DbU::Unit xSource = DbU::lambda( _getLong(fields[0]) ); + DbU::Unit ySource = DbU::lambda( _getLong(fields[1]) ); + unsigned int zSource = (unsigned) ( _getLong(fields[2]) ); + DbU::Unit xTarget = DbU::lambda( _getLong(fields[3]) ); + DbU::Unit yTarget = DbU::lambda( _getLong(fields[4]) ); + unsigned int zTarget = (unsigned) ( _getLong(fields[5]) ); - Contact* source = contactMap.find ( xSource, ySource, zSource ); - Contact* target = contactMap.find ( xTarget, yTarget, zTarget ); - Segment* segment = NULL; + Contact* source = contactMap.find( xSource, ySource, zSource ); + Contact* target = contactMap.find( xTarget, yTarget, zTarget ); + Segment* segment = NULL; unsigned int type = ((ySource == yTarget)?1:0) + ((xSource == xTarget)?2:0); switch ( type ) { case 0: - throw Error(NotManhattan - ,DbU::getValueString(xSource).c_str() - ,DbU::getValueString(ySource).c_str() - ,DbU::getValueString(xTarget).c_str() - ,DbU::getValueString(yTarget).c_str() - ,_fileName.c_str() - ,_lineNumber + throw Error( NotManhattan + , DbU::getValueString(xSource).c_str() + , DbU::getValueString(ySource).c_str() + , DbU::getValueString(xTarget).c_str() + , DbU::getValueString(yTarget).c_str() + , _fileName.c_str() + , _lineNumber ); case 1: - segment = Horizontal::create ( source, target, _gmetalh, ySource, DbU::lambda(2.0) ); - segmentCount++; + segment = Horizontal::create( source, target, _gmetalh, ySource, DbU::lambda(2.0) ); + ++nbSegments; break; case 2: - segment = Vertical::create ( source, target, _gmetalv, xSource, DbU::lambda(2.0) ); - segmentCount++; + segment = Vertical::create( source, target, _gmetalv, xSource, DbU::lambda(2.0) ); + ++nbSegments; break; case 3: break; } - if ( segment ) _knik->insertSegment ( segment ); + if (segment) _knik->insertSegment( segment ); } } - fileStream.readLine ( _rawLine, RawLineSize ); + fileStream.readLine( _rawLine, RawLineSize ); _lineNumber++; - if ( _rawLine[0] != '!' ) - throw Error("KnikEngine::loadSolution(): Tu t'es vu quand t'as bu! (%ld)." - ,getString(_lineNumber).c_str()); + if (_rawLine[0] != '!') + throw Error( "KnikEngine::loadSolution(): Tu t'es vu quand t'as bu! (%ld)." + , getString(_lineNumber).c_str()); - RoutingPad* previousRp = NULL; - forEach ( RoutingPad*, rp, net->getComponents().getSubSet() ) { - Contact* gcontact = contactMap.findVertexContact ( rp->getBoundingBox() ); - if ( gcontact ) { - rp->getBodyHook()->attach ( gcontact->getBodyHook() ); + Box rpBox; + RoutingPad* previousRp = NULL; + forEach ( RoutingPad*, rp, net->getRoutingPads() ) { + rpBox.merge( rp->getBoundingBox() ); + Contact* gcontact = contactMap.findVertexContact( rp->getBoundingBox() ); + if (gcontact) { + rp->getBodyHook()->attach( gcontact->getBodyHook() ); } else { - if ( previousRp ) - rp->getBodyHook()->attach ( previousRp->getBodyHook() ); + if (previousRp) + rp->getBodyHook()->attach( previousRp->getBodyHook() ); } previousRp = *rp; + ++nbRoutingPad; //cerr << rp->_getString() << " should be attached to " << gcontact << endl; } - contactCount += contactMap.size (); - contactMap.clear (); + if ( (nbRoutingPad > 1) + and (not contactMap.size()) + and ( (rpBox.getHeight() > DbU::fromLambda(50.0)) + or (rpBox.getWidth () > DbU::fromLambda(50.0)) ) ) { + ++missingGlobalRouting; + cerr << Warning( "Net <%s> is missing global routing." + , getString(net->getName()).c_str() ) << endl; + } + + segmentCount += nbSegments; + contactCount += contactMap.size(); + contactMap.clear(); } } - fileStream.close (); + fileStream.close(); + + if (missingGlobalRouting) + throw Error( "At least %d nets are missing global routing. Maybe a corrupted <.kgr> file?" + , missingGlobalRouting + ); } catch ( Error& e ) { - cerr << e << endl; + UpdateSession::close (); + //cerr << e << endl; + throw; } - UpdateSession::close (); } diff --git a/knik/src/MatrixVertex.cpp b/knik/src/MatrixVertex.cpp index c375a634..cda27293 100644 --- a/knik/src/MatrixVertex.cpp +++ b/knik/src/MatrixVertex.cpp @@ -1,4 +1,4 @@ -#include +#include #include "hurricane/Cell.h" #include "hurricane/Box.h"