2016-05-23 09:15:25 -05:00
|
|
|
// -*- mode: C++; explicit-buffer-name: "Matrix.cpp<anabatic>" -*-
|
|
|
|
//
|
|
|
|
// This file is part of the Coriolis Software.
|
|
|
|
// Copyright (c) UPMC 2016-2016, All Rights Reserved
|
|
|
|
//
|
|
|
|
// +-----------------------------------------------------------------+
|
|
|
|
// | C O R I O L I S |
|
|
|
|
// | A n a b a t i c - Global Routing Toolbox |
|
|
|
|
// | |
|
|
|
|
// | Author : Jean-Paul CHAPUT |
|
|
|
|
// | E-mail : Jean-Paul.Chaput@lip6.fr |
|
|
|
|
// | =============================================================== |
|
|
|
|
// | C++ Module : "./Matrix.cpp" |
|
|
|
|
// +-----------------------------------------------------------------+
|
|
|
|
|
|
|
|
|
|
|
|
#include <sstream>
|
|
|
|
#include <iostream>
|
2016-06-03 10:29:22 -05:00
|
|
|
#include <iomanip>
|
2016-05-23 09:15:25 -05:00
|
|
|
#include "hurricane/Cell.h"
|
|
|
|
#include "anabatic/Matrix.h"
|
|
|
|
#include "anabatic/GCell.h"
|
|
|
|
|
|
|
|
|
|
|
|
namespace Anabatic {
|
|
|
|
|
|
|
|
using std::cout;
|
|
|
|
using std::cerr;
|
|
|
|
using std::endl;
|
2016-06-03 10:29:22 -05:00
|
|
|
using std::setw;
|
|
|
|
using std::setfill;
|
2016-05-23 09:15:25 -05:00
|
|
|
using std::ostringstream;
|
|
|
|
using Hurricane::Error;
|
|
|
|
|
|
|
|
|
|
|
|
Matrix::Matrix ()
|
|
|
|
: _area ()
|
|
|
|
, _side (1)
|
|
|
|
, _gcells()
|
|
|
|
, _imax (0)
|
|
|
|
, _jmax (0)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
|
|
Matrix::Matrix ( Box area, DbU::Unit side )
|
|
|
|
: _area (area)
|
|
|
|
, _side (side)
|
|
|
|
, _gcells()
|
|
|
|
, _imax (0)
|
|
|
|
, _jmax (0)
|
|
|
|
{
|
2016-06-03 10:29:22 -05:00
|
|
|
_imax = _area.getWidth () / side + ((_area.getWidth () % side) ? 1 : 0);
|
|
|
|
_jmax = _area.getHeight() / side + ((_area.getHeight() % side) ? 1 : 0);
|
2016-05-23 09:15:25 -05:00
|
|
|
_gcells.resize( _imax*_jmax );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Matrix::~Matrix ()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
|
|
void Matrix::setCell ( Cell* cell, DbU::Unit side )
|
|
|
|
{
|
|
|
|
_area = cell->getAbutmentBox();
|
|
|
|
_side = side;
|
2016-06-03 10:29:22 -05:00
|
|
|
_imax = _area.getWidth () / side + ((_area.getWidth () % side) ? 1 : 0);
|
|
|
|
_jmax = _area.getHeight() / side + ((_area.getHeight() % side) ? 1 : 0);
|
2016-05-23 09:15:25 -05:00
|
|
|
_gcells.resize( _imax*_jmax );
|
2016-06-03 10:29:22 -05:00
|
|
|
|
|
|
|
cdebug.log(110) << "Matrix::setCell(): " << this << endl;
|
2016-05-23 09:15:25 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-05-26 06:56:16 -05:00
|
|
|
GCell* Matrix::getUnder ( DbU::Unit x, DbU::Unit y ) const
|
2016-06-03 10:29:22 -05:00
|
|
|
{
|
|
|
|
int index = xy2maxIndex(x,y);
|
|
|
|
cdebug.log(110) << "Matrix::getUnder() ("
|
|
|
|
<< DbU::getValueString(x) << " "
|
Anabatic transient commit 6 "Somatoline, ca marche!".
* Bug: In Anabatic:
- In Dijktra::load(), do not create Contact while looping over the Net's
components (for RoutingPads).
- In Dijkstra::propagate(), reset the connexId of reached Vertexes
on updating the stamp to avoid using connexId from previous runs.
Push the vertexes on the queue while backtracking (with a distance
of 0.0). Do not reset the "_from" as we need it in Dijkstra::toWires()
to know how were the routing is.
- In Edge::getDistance(), convert to float more early so the normalisation
do not always end up in zero.
- In GCell::_add(), when the axis of the new edge is equal to one already
on the given side, adds it *after* the existing edge and not before.
(to be coherent with the way GCells are split in two)
- In GCell::hcut() and GCell::vcut(), create an Edge if is equal to X/Y Max,
*but* the new chunk is flat. The new chunk is then expected to expand
"below".
- In GraphicsAnabaticEngine::drawGCell(), display the id of the GCell in
a small box at the center of it's bounding box. Nothing displayed for
flat GCells, to avoid cluttering.
2016-06-05 11:38:09 -05:00
|
|
|
<< DbU::getValueString(y) << ") index:" << index << endl;
|
2016-06-03 10:29:22 -05:00
|
|
|
return (index < 0) ? NULL : _gcells[index]->getUnder(x,y);
|
|
|
|
}
|
2016-05-26 06:56:16 -05:00
|
|
|
|
|
|
|
|
2016-05-23 09:15:25 -05:00
|
|
|
void Matrix::updateLookup ( GCell* gcell )
|
|
|
|
{
|
2016-06-03 10:29:22 -05:00
|
|
|
cdebug.log(110,1) << "Matrix::updateLookup(): " << gcell << endl;
|
2016-05-26 06:56:16 -05:00
|
|
|
|
2016-06-03 10:29:22 -05:00
|
|
|
if (gcell->isFlat()) {
|
|
|
|
cdebug.log(110) << " GCell is flat, no update." << endl;
|
|
|
|
cdebug.tabw(110,-1);
|
|
|
|
return;
|
|
|
|
}
|
2016-05-23 09:15:25 -05:00
|
|
|
|
|
|
|
Box gcellBb = gcell->getBoundingBox();
|
|
|
|
Box updateArea = _area.getIntersection( gcellBb );
|
|
|
|
|
2016-06-03 10:29:22 -05:00
|
|
|
cdebug.log(110) << "_side " << _side << endl;
|
|
|
|
cdebug.log(110) << "_area.getXMin() " << _area.getXMin() << endl;
|
|
|
|
cdebug.log(110) << "_area.getYMin() " << _area.getYMin() << endl;
|
|
|
|
cdebug.log(110) << "_area.getXMax() " << _area.getXMax() << endl;
|
|
|
|
cdebug.log(110) << "_area.getYMax() " << _area.getYMax() << endl;
|
|
|
|
cdebug.log(110) << "updateArea.getXMin() " << updateArea.getXMin() << endl;
|
|
|
|
cdebug.log(110) << "updateArea.getYMin() " << updateArea.getYMin() << endl;
|
|
|
|
cdebug.log(110) << "updateArea.getXMax() " << updateArea.getXMax() << endl;
|
|
|
|
cdebug.log(110) << "updateArea.getYMax() " << updateArea.getYMax() << endl;
|
|
|
|
|
2016-05-23 09:15:25 -05:00
|
|
|
if (updateArea.isEmpty()) {
|
|
|
|
cerr << Error( "Matrix::updateLookup(): %s is not under area of %s."
|
|
|
|
, getString(gcell).c_str()
|
|
|
|
, getString(this).c_str()
|
|
|
|
) << endl;
|
|
|
|
}
|
|
|
|
|
2016-06-03 10:29:22 -05:00
|
|
|
Index indexMin = Index::asMin( this, updateArea.getXMin(), updateArea.getYMin() );
|
|
|
|
Index indexMax = Index::asMax( this, updateArea.getXMax(), updateArea.getYMax() );
|
2016-05-23 09:15:25 -05:00
|
|
|
int xspan = indexMax.i() - indexMin.i();
|
|
|
|
|
2016-06-03 10:29:22 -05:00
|
|
|
DbU::Unit dx = updateArea.getXMin() - _area.getXMin();
|
|
|
|
DbU::Unit dy = updateArea.getYMin() - _area.getYMin();
|
|
|
|
|
|
|
|
cdebug.log(110) << "raw_i:" << (dx / _side + ((dx%_side) ? 1 : 0))
|
|
|
|
<< " raw_j:" << (dy / _side + ((dy%_side) ? 1 : 0)) << endl;
|
|
|
|
cdebug.log(110) << "indexMin:" << indexMin << endl;
|
|
|
|
cdebug.log(110) << "indexMax:" << indexMax << endl;
|
|
|
|
cdebug.log(110) << "xspan: " << xspan << endl;
|
|
|
|
|
|
|
|
if (not indexMin.valid() or not indexMax.valid()) { cdebug.tabw(110,-1); return; }
|
2016-05-23 09:15:25 -05:00
|
|
|
|
|
|
|
int index = indexMin.index();
|
|
|
|
while ( index <= indexMax.index() ) {
|
2016-05-26 06:56:16 -05:00
|
|
|
if (updateArea.contains(getGridPoint(index))) _gcells[index] = gcell;
|
2016-05-23 09:15:25 -05:00
|
|
|
|
|
|
|
if (index <= indexMax.j()) ++index;
|
|
|
|
else index += _imax - xspan;
|
|
|
|
}
|
|
|
|
|
2016-06-03 10:29:22 -05:00
|
|
|
cdebug.tabw(110,-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Matrix::show () const
|
|
|
|
{
|
|
|
|
cdebug.log(111) << this << endl;
|
|
|
|
for ( size_t i=0 ; i<_gcells.size() ; ++i ) {
|
|
|
|
cdebug.log(111) << "[" << setw(3) << setfill('0') << i << setfill(' ') << "] ("
|
|
|
|
<< setw(3) << index2i(i) << ","
|
|
|
|
<< setw(3) << index2j(i) << ") " << _gcells[i] << endl;
|
|
|
|
}
|
2016-05-23 09:15:25 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string Matrix::_getTypeName () const
|
|
|
|
{ return "Matrix"; }
|
|
|
|
|
|
|
|
|
|
|
|
string Matrix::_getString () const
|
|
|
|
{
|
|
|
|
ostringstream os;
|
|
|
|
os << "<" << _getTypeName() << " " << _imax << "x" << _jmax
|
|
|
|
<< " " << _area << "/" << DbU::getValueString(_side) << ">";
|
|
|
|
return os.str();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Record* Matrix::_getRecord () const
|
|
|
|
{
|
|
|
|
Record* record = new Record( _getString() );
|
|
|
|
record->add( getSlot ("_area" , _area ) );
|
|
|
|
record->add( DbU::getValueSlot("_side" , &_side ) );
|
|
|
|
record->add( getSlot ("_imax" , _imax ) );
|
|
|
|
record->add( getSlot ("_jmax" , _jmax ) );
|
|
|
|
record->add( getSlot ("_gcells", &_gcells) );
|
|
|
|
return record;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} // Anabatic namespace;
|