* ./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.
This commit is contained in:
Jean-Paul Chaput 2013-12-04 01:54:20 +00:00
parent b4887b1180
commit 4a33fa12b3
2 changed files with 105 additions and 92 deletions

View File

@ -2,14 +2,9 @@
// -*- C++ -*- // -*- C++ -*-
// //
// This file is part of the Coriolis Software. // 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 | // | C O R I O L I S |
// | K n i k - Global Router | // | K n i k - Global Router |
// | | // | |
@ -17,15 +12,12 @@
// | E-mail : Damien.Dupuis@lip6.fr | // | E-mail : Damien.Dupuis@lip6.fr |
// | =============================================================== | // | =============================================================== |
// | C++ Module : "./LoadSolution.cpp" | // | C++ Module : "./LoadSolution.cpp" |
// | *************************************************************** | // +-----------------------------------------------------------------+
// | U p d a t e s |
// | |
// x-----------------------------------------------------------------x
#include <iostream> #include <iostream>
#include "hurricane/Error.h" #include "hurricane/Error.h"
#include "hurricane/Warning.h"
#include "hurricane/DataBase.h" #include "hurricane/DataBase.h"
#include "hurricane/Technology.h" #include "hurricane/Technology.h"
#include "hurricane/Layer.h" #include "hurricane/Layer.h"
@ -35,10 +27,8 @@
#include "hurricane/RoutingPad.h" #include "hurricane/RoutingPad.h"
#include "hurricane/Cell.h" #include "hurricane/Cell.h"
#include "hurricane/UpdateSession.h" #include "hurricane/UpdateSession.h"
#include "crlcore/Utilities.h" #include "crlcore/Utilities.h"
#include "crlcore/Measures.h" #include "crlcore/Measures.h"
#include "knik/Configuration.h" #include "knik/Configuration.h"
#include "knik/Graph.h" #include "knik/Graph.h"
#include "knik/KnikEngine.h" #include "knik/KnikEngine.h"
@ -46,7 +36,6 @@
namespace { namespace {
using std::string; using std::string;
using std::cerr; using std::cerr;
using std::endl; using std::endl;
@ -58,6 +47,7 @@ namespace {
using Hurricane::ForEachIterator; using Hurricane::ForEachIterator;
using Hurricane::Error; using Hurricane::Error;
using Hurricane::Warning;
using Hurricane::DbU; using Hurricane::DbU;
using Hurricane::Point; using Hurricane::Point;
using Hurricane::Box; using Hurricane::Box;
@ -293,117 +283,140 @@ namespace {
void SolutionParser::load () void SolutionParser::load ()
{ {
UpdateSession::open (); UpdateSession::open();
try { try {
cmess1 << " o Loading solution: \"" << _fileName << "\"." << endl; cmess1 << " o Loading solution: \"" << _fileName << "\"." << endl;
CRL::IoFile fileStream ( _fileName ); CRL::IoFile fileStream ( _fileName );
fileStream.open ( "r" ); fileStream.open( "r" );
if ( !fileStream.isOpen() ) if (not fileStream.isOpen())
throw Error ("Can't open/read file: %s.",_fileName.c_str()); throw Error( "Can't open/read file: %s.", _fileName.c_str() );
unsigned int missingGlobalRouting = 0;
unsigned int contactCount = 0; unsigned int contactCount = 0;
unsigned int segmentCount = 0; unsigned int segmentCount = 0;
GContactMap contactMap ( _knik, _gmetalh, _gmetalv ); GContactMap contactMap ( _knik, _gmetalh, _gmetalv );
while ( !fileStream.eof() ) { while ( not fileStream.eof() ) {
fileStream.readLine ( _rawLine, RawLineSize ); fileStream.readLine( _rawLine, RawLineSize );
_lineNumber++; _lineNumber++;
if ( _rawLine[0] == '\0' ) break; if (_rawLine[0] == '\0') break;
if ( _rawLine[0] == '\n' ) continue; if (_rawLine[0] == '\n') continue;
vector<char*> fields = _splitString ( _rawLine ); vector<char*> fields = _splitString( _rawLine );
if ( fields.size() != 3 ) 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 { else {
Name netName = Name ( fields[0] ); Name netName = Name ( fields[0] );
unsigned nbPins = _getLong ( fields[2] ); unsigned int nbPins = _getLong( fields[2] );
Net* net = _knik->getCell()->getNet ( netName ); 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: "; string message = "Cell has no Net: ";
message += getString(netName); 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++ ) { for ( unsigned i = 0 ; i < nbPins ; i++ ) {
fileStream.readLine ( _rawLine, RawLineSize ); fileStream.readLine( _rawLine, RawLineSize );
_lineNumber++; _lineNumber++;
fields = _splitSegmentString ( _rawLine ); fields = _splitSegmentString( _rawLine );
if ( fields.size() != 6 ) if (fields.size() != 6)
throw Error ( LoadError, "Malformed Net Line", _fileName.c_str(), _lineNumber ); throw Error( LoadError, "Malformed Net Line", _fileName.c_str(), _lineNumber );
else { else {
DbU::Unit xSource = DbU::lambda(_getLong(fields[0])); DbU::Unit xSource = DbU::lambda( _getLong(fields[0]) );
DbU::Unit ySource = DbU::lambda(_getLong(fields[1])); DbU::Unit ySource = DbU::lambda( _getLong(fields[1]) );
unsigned zSource = (unsigned) (_getLong(fields[2])); unsigned int zSource = (unsigned) ( _getLong(fields[2]) );
DbU::Unit xTarget = DbU::lambda(_getLong(fields[3])); DbU::Unit xTarget = DbU::lambda( _getLong(fields[3]) );
DbU::Unit yTarget = DbU::lambda(_getLong(fields[4])); DbU::Unit yTarget = DbU::lambda( _getLong(fields[4]) );
unsigned zTarget = (unsigned) (_getLong(fields[5])); unsigned int zTarget = (unsigned) ( _getLong(fields[5]) );
Contact* source = contactMap.find ( xSource, ySource, zSource ); Contact* source = contactMap.find( xSource, ySource, zSource );
Contact* target = contactMap.find ( xTarget, yTarget, zTarget ); Contact* target = contactMap.find( xTarget, yTarget, zTarget );
Segment* segment = NULL; Segment* segment = NULL;
unsigned int type = ((ySource == yTarget)?1:0) + ((xSource == xTarget)?2:0); unsigned int type = ((ySource == yTarget)?1:0) + ((xSource == xTarget)?2:0);
switch ( type ) { switch ( type ) {
case 0: case 0:
throw Error(NotManhattan throw Error( NotManhattan
,DbU::getValueString(xSource).c_str() , DbU::getValueString(xSource).c_str()
,DbU::getValueString(ySource).c_str() , DbU::getValueString(ySource).c_str()
,DbU::getValueString(xTarget).c_str() , DbU::getValueString(xTarget).c_str()
,DbU::getValueString(yTarget).c_str() , DbU::getValueString(yTarget).c_str()
,_fileName.c_str() , _fileName.c_str()
,_lineNumber , _lineNumber
); );
case 1: case 1:
segment = Horizontal::create ( source, target, _gmetalh, ySource, DbU::lambda(2.0) ); segment = Horizontal::create( source, target, _gmetalh, ySource, DbU::lambda(2.0) );
segmentCount++; ++nbSegments;
break; break;
case 2: case 2:
segment = Vertical::create ( source, target, _gmetalv, xSource, DbU::lambda(2.0) ); segment = Vertical::create( source, target, _gmetalv, xSource, DbU::lambda(2.0) );
segmentCount++; ++nbSegments;
break; break;
case 3: case 3:
break; break;
} }
if ( segment ) _knik->insertSegment ( segment ); if (segment) _knik->insertSegment( segment );
} }
} }
fileStream.readLine ( _rawLine, RawLineSize ); fileStream.readLine( _rawLine, RawLineSize );
_lineNumber++; _lineNumber++;
if ( _rawLine[0] != '!' ) if (_rawLine[0] != '!')
throw Error("KnikEngine::loadSolution(): Tu t'es vu quand t'as bu! (%ld)." throw Error( "KnikEngine::loadSolution(): Tu t'es vu quand t'as bu! (%ld)."
,getString(_lineNumber).c_str()); , getString(_lineNumber).c_str());
Box rpBox;
RoutingPad* previousRp = NULL; RoutingPad* previousRp = NULL;
forEach ( RoutingPad*, rp, net->getComponents().getSubSet<RoutingPad*>() ) { forEach ( RoutingPad*, rp, net->getRoutingPads() ) {
Contact* gcontact = contactMap.findVertexContact ( rp->getBoundingBox() ); rpBox.merge( rp->getBoundingBox() );
if ( gcontact ) { Contact* gcontact = contactMap.findVertexContact( rp->getBoundingBox() );
rp->getBodyHook()->attach ( gcontact->getBodyHook() ); if (gcontact) {
rp->getBodyHook()->attach( gcontact->getBodyHook() );
} else { } else {
if ( previousRp ) if (previousRp)
rp->getBodyHook()->attach ( previousRp->getBodyHook() ); rp->getBodyHook()->attach( previousRp->getBodyHook() );
} }
previousRp = *rp; previousRp = *rp;
++nbRoutingPad;
//cerr << rp->_getString() << " should be attached to " << gcontact << endl; //cerr << rp->_getString() << " should be attached to " << gcontact << endl;
} }
contactCount += contactMap.size (); if ( (nbRoutingPad > 1)
contactMap.clear (); 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 ) { catch ( Error& e ) {
cerr << e << endl; UpdateSession::close ();
//cerr << e << endl;
throw;
} }
UpdateSession::close (); UpdateSession::close ();
} }

View File

@ -1,4 +1,4 @@
#include <ext/algorithm> #include <algorithm>
#include "hurricane/Cell.h" #include "hurricane/Cell.h"
#include "hurricane/Box.h" #include "hurricane/Box.h"