OpenASIP 2.2
Loading...
Searching...
No Matches
Classes | Public Member Functions | Private Attributes | List of all members
ComponentImplementationSelector Class Reference

#include <ComponentImplementationSelector.hh>

Collaboration diagram for ComponentImplementationSelector:
Collaboration graph

Classes

struct  implComp
 

Public Member Functions

 ComponentImplementationSelector ()
 
virtual ~ComponentImplementationSelector ()
 
void addHDB (const HDB::HDBManager &hdb)
 
void addCase (const TTAProgram::Program &program, const ExecutionTrace &traceDB)
 
std::map< const IDF::FUImplementationLocation *, CostEstimates * > fuImplementations (const TTAMachine::FunctionUnit &fu, double frequencyMHz=0, double maxArea=0)
 
std::list< TTAMachine::FunctionUnit * > fuArchsByOpSetWithMinLatency (const std::set< std::string > &operationSet, int width=0) const
 
std::map< const IDF::RFImplementationLocation *, CostEstimates * > rfImplementations (const TTAMachine::RegisterFile &rf, bool guarded=false, double frequencyMHz=0, double maxArea=0)
 
std::map< const IDF::IUImplementationLocation *, CostEstimates * > iuImplementations (const TTAMachine::ImmediateUnit &iu, double frequencyMHz=0, double maxArea=0)
 
void selectComponentsToConf (DSDBManager::MachineConfiguration &conf, DSDBManager &dsdb, TTAMachine::Machine *mach=NULL, const std::string &icDecoder="ic_hdb", const std::string &icDecoderHDB="asic_130nm_1.5V.hdb", const double &frequency=0, const double &maxArea=0)
 
IDF::MachineImplementationselectComponents (const TTAMachine::Machine *mach, const std::string &icDecoder="ic_hdb", const std::string &icDecoderHDB="asic_130nm_1.5V.hdb", const double &frequency=0, const double &maxArea=0)
 
void selectFUs (const TTAMachine::Machine *mach, IDF::MachineImplementation *idf, const double &frequency=0, const double &maxArea=0, const bool &filterLongestPathDelay=true)
 
void selectRFs (const TTAMachine::Machine *mach, IDF::MachineImplementation *idf, const double &frequency=0, const double &maxArea=0)
 
void selectIUs (const TTAMachine::Machine *mach, IDF::MachineImplementation *idf, const double &frequency=0, const double &maxArea=0)
 

Private Attributes

std::set< std::string > usedHDBs_
 HDBs from which implementations are serched are stored in this set.
 
CostEstimator::Estimator estimator_
 Cost estimator to estimate the unit costs.
 

Detailed Description

Purpose of the component implementation selector class is to select suitable implementations to architecture components. The component implementation selector uses HDB to look for implementations and returns set of suitable implementations that fulfill the given cost requirements. Class uses cost estimator to estimate the costs of suitable implementations. Cost estimation data includes energy estimations of all program cases that are set.

Definition at line 74 of file ComponentImplementationSelector.hh.

Constructor & Destructor Documentation

◆ ComponentImplementationSelector()

ComponentImplementationSelector::ComponentImplementationSelector ( )

The constructor.

Definition at line 67 of file ComponentImplementationSelector.cc.

67 {
68}

◆ ~ComponentImplementationSelector()

ComponentImplementationSelector::~ComponentImplementationSelector ( )
virtual

The destructor

Definition at line 73 of file ComponentImplementationSelector.cc.

73 {
74}

Member Function Documentation

◆ addCase()

void ComponentImplementationSelector::addCase ( const TTAProgram::Program program,
const ExecutionTrace traceDB 
)

Adds new traceDB and corresponding program.

Parameters
programTest case program to be used.
traceDBSimulation trace of the program.

Definition at line 94 of file ComponentImplementationSelector.cc.

95 {
96
97}

◆ addHDB()

void ComponentImplementationSelector::addHDB ( const HDB::HDBManager hdb)

Adds new HDB to look for components.

Parameters
hdbThe HDB file name to be added.
Exceptions
Exceptionin case there was a problem while opening the HDB.

Definition at line 83 of file ComponentImplementationSelector.cc.

83 {
84 usedHDBs_.insert(hdb.fileName());
85}
std::set< std::string > usedHDBs_
HDBs from which implementations are serched are stored in this set.
std::string fileName() const

References HDB::HDBManager::fileName(), and usedHDBs_.

Referenced by AutoSelectImplementationsDialog::findFUImplementations(), AutoSelectImplementationsDialog::findIUImplementations(), AutoSelectImplementationsDialog::findRFImplementations(), selectComponents(), and ImplementationSelector::setupSelector().

Here is the call graph for this function:

◆ fuArchsByOpSetWithMinLatency()

list< TTAMachine::FunctionUnit * > ComponentImplementationSelector::fuArchsByOpSetWithMinLatency ( const std::set< std::string > &  operationSet,
int  width = 0 
) const

Finds the minimum set of Function units that is needed to satisfy all the wanted operations.

Function units are selected so that the number of needed units would be as low as possible and smaller latency is preferred. If there are units with same latency then units with smaller amount of operations is preferred. If there still are units with equal operations then the unit with the widest triggering port is preferred.

Parameters
operationSetSet of operation names the resultig set of function units must include.
widthBitwidth of the funtion unit ports. Not used if left as default.
Returns
Minimal set of function units that have all the asked operations. Returns an empty set if all operations cannot be supported by any set of function units.

Definition at line 212 of file ComponentImplementationSelector.cc.

214 {
215
216 // Convert operation names to lower case.
217 set<string> operations;
218 set<string>::const_iterator oper = operationSet.begin();
219 for (; oper != operationSet.end(); oper++) {
220 operations.insert(StringTools::stringToLower((*oper)));
221 }
222
223 // Get all function unit architectures.
224 list<pair<TTAMachine::FunctionUnit*, int> >functionUnits;
225 for (set<string>::const_iterator i = usedHDBs_.begin();
226 i != usedHDBs_.end(); i++) {
227
228 set<RowID> fuArchIDs =
230 operations);
231 set<RowID>::const_iterator iter = fuArchIDs.begin();
232 for (;iter != fuArchIDs.end(); iter++) {
233 FUArchitecture* fuArch =
235
236 // check the fu port widths if the width is given as parameter
237 if (width) {
238 bool portsDiffer = false;
239 for (int p = 0; p < fuArch->architecture().portCount(); p++) {
240 if (fuArch->architecture().port(p)->width() != width) {
241 portsDiffer = true;
242 }
243 }
244 if (portsDiffer) {
245 continue;
246 }
247 }
248 pair<FunctionUnit*, int> fuIntPair(&fuArch->architecture(), 0);
249 functionUnits.push_back(fuIntPair);
250 }
251 }
252
253 list<TTAMachine::FunctionUnit*> results;
254
255 // Find the best set of function units
256 while (operations.size() != 0) {
257 list<pair<TTAMachine::FunctionUnit*, int> >::iterator fu =
258 functionUnits.begin();
259 for (; fu != functionUnits.end(); fu++) {
260 int neededOperations = 0;
261 set<string>::iterator operation = operations.begin();
262 while (operation != operations.end()) {
263 if ((*fu).first->hasOperation(*operation)) {
264 neededOperations++;
265 }
266 operation++;
267 }
268 (*fu).second = neededOperations;
269 }
270
271 list<TTAMachine::FunctionUnit*> bestMatches;
272 int bestFU = 0;
273
274 // Find out which FU:s implement most needed operations
275 for (fu = functionUnits.begin(); fu != functionUnits.end(); fu++) {
276 if ((*fu).second > bestFU) {
277 bestMatches.clear();
278 bestMatches.push_back((*fu).first);
279 bestFU = (*fu).second;
280 } else if ((*fu).second == bestFU) {
281 bestMatches.push_back((*fu).first);
282 }
283 }
284
285 // if found set
286 if (bestMatches.size() != 0) {
287 TTAMachine::FunctionUnit* bestFU = NULL;
288 int minLatency = -1;
289 int minOperations = -1;
290 int maxPortWidth = -1;
291 // Select one of the best FU:s
292 list<TTAMachine::FunctionUnit*>::const_iterator bestMatchFU =
293 bestMatches.begin();
294 for (; bestMatchFU != bestMatches.end(); bestMatchFU++) {
295 int fuMaxLatency = (*bestMatchFU)->maxLatency();
296 if (fuMaxLatency < minLatency) {
297 minLatency = fuMaxLatency;
298 minOperations = (*bestMatchFU)->operationCount();
299 bestFU = (*bestMatchFU);
300 } else if (minLatency == -1) {
301 minLatency = fuMaxLatency;
302 minOperations = (*bestMatchFU)->operationCount();
303 bestFU = (*bestMatchFU);
304 } else if (fuMaxLatency == minLatency) {
305 int fuOperations = (*bestMatchFU)->operationCount();
306 if (fuOperations < minOperations) {
307 minOperations = fuOperations;
308 bestFU = (*bestMatchFU);
309 } else if (minOperations == -1) {
310 minOperations = fuOperations;
311 bestFU = (*bestMatchFU);
312 } else if (fuOperations == minOperations) {
313 int bestFUPortWidth = 0;
314 for (int i = 0;
315 i < (*bestMatchFU)->operationPortCount();
316 i++) {
317
318 FUPort* port = (*bestMatchFU)->operationPort(i);
319 if (port->isTriggering()) {
320 if (bestFUPortWidth < port->width()) {
321 bestFUPortWidth = port->width();
322 }
323 }
324 }
325 if (maxPortWidth < bestFUPortWidth) {
326 maxPortWidth = bestFUPortWidth;
327 bestFU = (*bestMatchFU);
328 }
329 }
330 }
331 }
332 for (int oper = 0; oper < bestFU->operationCount(); oper++) {
333 operations.erase(
335 bestFU->operation(oper)->name()));
336 }
337 results.push_back(bestFU);
338
339 // remove the best suitable fu from the set of function untis.
340 list<pair<FunctionUnit*, int> >::iterator fuIntIter =
341 functionUnits.begin();
342 for (; fuIntIter != functionUnits.end(); fuIntIter++) {
343 if ((*fuIntIter).first == bestFU) {
344 functionUnits.erase(fuIntIter);
345 break;
346 }
347 }
348 } else {
349 break;
350 }
351 }
352 if (operations.size() != 0) {
353 results.clear();
354 }
355 return results;
356}
virtual FUArchitecture * fuArchitectureByID(RowID id) const
TTAMachine::FunctionUnit & architecture() const
std::set< RowID > fuArchitectureIDsByOperationSet(const std::set< std::string > &operationNames) const
static HDBRegistry & instance()
CachedHDBManager & hdb(const std::string fileName)
static std::string stringToLower(const std::string &source)
virtual int width() const
virtual bool isTriggering() const
Definition FUPort.cc:182
virtual HWOperation * operation(const std::string &name) const
virtual int operationCount() const
virtual int maxLatency() const
virtual BaseFUPort * port(const std::string &name) const
const std::string & name() const

References HDB::FUArchitecture::architecture(), HDB::CachedHDBManager::fuArchitectureByID(), HDB::HDBManager::fuArchitectureIDsByOperationSet(), HDB::HDBRegistry::hdb(), HDB::HDBRegistry::instance(), TTAMachine::FUPort::isTriggering(), TTAMachine::FunctionUnit::maxLatency(), TTAMachine::HWOperation::name(), TTAMachine::FunctionUnit::operation(), TTAMachine::FunctionUnit::operationCount(), TTAMachine::FunctionUnit::port(), StringTools::stringToLower(), usedHDBs_, and TTAMachine::BaseFUPort::width().

Here is the call graph for this function:

◆ fuImplementations()

map< const IDF::FUImplementationLocation *, CostEstimates * > ComponentImplementationSelector::fuImplementations ( const TTAMachine::FunctionUnit fu,
double  frequencyMHz = 0,
double  maxArea = 0 
)

Finds set of possible function unit implementations.

Finds out which function unit implementations fulfill the frequency and area requirements. The implementations are selected by estimating costs of different function unit implementations that match the given funtion unit architecture. All implementations that fulfill the given frequency and area requirements are returned including the estimated cost data of those implementations.

Parameters
fuFunction unit architecture.
frequencyMHzTarget frequency (MHz) of the function unit.
maxAreaMaximum area (in gates) of the function unit.
Returns
Set of FU implementations with cost estimation data. Returns an empty set if none found.

Definition at line 116 of file ComponentImplementationSelector.cc.

117 {
118
119 // Get all fu entries matching the given architecture from all available
120 // HDBs and create implementation locations of them.
121 set<const IDF::FUImplementationLocation*> fuImplementations;
122 for (set<string>::const_iterator i = usedHDBs_.begin();
123 i != usedHDBs_.end(); i++) {
124
126 set<RowID> fuEntryIDs = hdb.fuEntriesByArchitecture(fu);
127 set<RowID>::const_iterator id = fuEntryIDs.begin();
128 for (; id != fuEntryIDs.end(); id++) {
131 hdb.fileName(), *id,
132 fu.name());
135 machIDF->addFUImplementation(fuIDF);
136 fuImplementations.insert(fuIDF);
137 }
138 }
139 map<const IDF::FUImplementationLocation*, CostEstimates*> results;
140 set<const IDF::FUImplementationLocation*>::const_iterator iter =
141 fuImplementations.begin();
142
143 // in case we are not limiting the costs, return all matching
144 // implementations
145 if (static_cast<int>(frequencyMHz) <= 0 &&
146 static_cast<int>(maxArea) <= 0) {
147
148 for (; iter != fuImplementations.end(); iter++) {
149 results.insert(
150 pair<const IDF::FUImplementationLocation*, CostEstimates*>(
151 (*iter), NULL));
152 }
153 return results;
154 }
155
156 // Estimate costs the the implementations
157 while (iter != fuImplementations.end()) {
158 auto rmIt = iter;
159 try {
160 double area = estimator_.functionUnitArea(fu, *(*iter));
161 if (area > maxArea && static_cast<int>(maxArea) > 0) {
162 // FU area too large
163 iter++;
164 fuImplementations.erase(rmIt);
165 continue;
166 }
167 double delayInNanoSeconds =
169
170 // 1000/ns = MHz
171 if (delayInNanoSeconds > 0 && (static_cast<double>(1000) / static_cast<double>(delayInNanoSeconds)) < static_cast<double>(frequencyMHz)) {
172 // FU too slow
173 iter++;
174 fuImplementations.erase(rmIt);
175 continue;
176 }
177 CostEstimates* estimates = new CostEstimates();
178 estimates->setArea(area);
179 estimates->setLongestPathDelay(delayInNanoSeconds);
180 results.insert(
181 pair<const IDF::FUImplementationLocation*, CostEstimates*>(
182 (*iter), estimates));
183 } catch (CannotEstimateCost& e) {
184 // Couldn't estimate the fu.
185 iter++;
186 fuImplementations.erase(rmIt);
187 continue;
188 }
189 iter++;
190 }
191 return results;
192}
std::map< const IDF::FUImplementationLocation *, CostEstimates * > fuImplementations(const TTAMachine::FunctionUnit &fu, double frequencyMHz=0, double maxArea=0)
CostEstimator::Estimator estimator_
Cost estimator to estimate the unit costs.
void setLongestPathDelay(double delay)
void setArea(double area)
DelayInNanoSeconds functionUnitMaximumComputationDelay(const TTAMachine::FunctionUnit &architecture, const IDF::FUImplementationLocation &implementation)
Definition Estimator.cc:834
AreaInGates functionUnitArea(const TTAMachine::FunctionUnit &architecture, const IDF::FUImplementationLocation &implementationEntry)
Definition Estimator.cc:364
std::set< RowID > fuEntriesByArchitecture(const TTAMachine::FunctionUnit &fu) const
void addFUImplementation(FUImplementationLocation *implementation)
virtual TCEString name() const
UnitImplementationLocation FUImplementationLocation

References IDF::MachineImplementation::addFUImplementation(), estimator_, HDB::HDBManager::fileName(), HDB::HDBManager::fuEntriesByArchitecture(), fuImplementations(), CostEstimator::Estimator::functionUnitArea(), CostEstimator::Estimator::functionUnitMaximumComputationDelay(), HDB::HDBRegistry::hdb(), HDB::HDBRegistry::instance(), TTAMachine::Component::name(), CostEstimates::setArea(), CostEstimates::setLongestPathDelay(), and usedHDBs_.

Referenced by AutoSelectImplementationsDialog::findFUImplementations(), fuImplementations(), and selectFUs().

Here is the call graph for this function:

◆ iuImplementations()

map< const IDF::IUImplementationLocation *, CostEstimates * > ComponentImplementationSelector::iuImplementations ( const TTAMachine::ImmediateUnit iu,
double  frequencyMHz = 0,
double  maxArea = 0 
)

Finds set of possible immediate unit implementations.

Finds out which immediate unit implementations fulfill the frequency and area requirements. The implementations are selected by estimating costs of different immediate unit implementations that match the given immediate unit architecture. All implementations that fulfill the given frequency and area requirements are returned including the estimated cost data of those implementations.

Parameters
iuImmediate unit architecture.
frequencyMHzTarget frequency (MHz) of the immediate unit.
maxAreaMaximum area (in gates) of the immediate unit.
Returns
Set of IU implementations with cost evaluation data. Returns an empty set if none found.

Definition at line 494 of file ComponentImplementationSelector.cc.

495 {
496
497 // Get all iu entries matching the given architecture from all available
498 // HDBs and create implementation locations of them.
499 set<const IDF::IUImplementationLocation*> iuImplementations;
500 for (set<string>::const_iterator i = usedHDBs_.begin();
501 i != usedHDBs_.end(); i++) {
502
504 int readPorts = iu.portCount();
505
506 set<RowID> iuEntryIDs =
508 readPorts,
509 1, // writePorts in iu is always 1, not visible in adf
510 0, // bidirPorts
511 0, // maxReads
512 0, // maxWrites
513 1, // latency always 1
514 false, // guard support always false
515 0, // guard latency
516 iu.width(),
517 iu.numberOfRegisters());
518
519 set<RowID>::const_iterator id = iuEntryIDs.begin();
520 for (; id != iuEntryIDs.end(); id++) {
523 hdb.fileName(), *id, iu.name());
526 machIDF->addIUImplementation(iuIDF);
527 iuImplementations.insert(iuIDF);
528 }
529 }
530 map<const IDF::IUImplementationLocation*, CostEstimates*> results;
531 set<const IDF::IUImplementationLocation*>::const_iterator iter =
532 iuImplementations.begin();
533
534 // in case we are not limiting the costs, return all matching
535 // implementations
536 if (static_cast<int>(frequencyMHz) <= 0 &&
537 static_cast<int>(maxArea) <= 0) {
538
539 for (; iter != iuImplementations.end(); iter++) {
540 results.insert(
541 pair<const IDF::IUImplementationLocation*, CostEstimates*>(
542 (*iter), NULL));
543 }
544 return results;
545 }
546
547 while (iter != iuImplementations.end()) {
548 auto rmIt = iter;
549 try {
550 double area = estimator_.registerFileArea(iu, *(*iter));
551 if (area > maxArea && static_cast<int>(maxArea) > 0) {
552 // IU area too large
553 iter++;
554 iuImplementations.erase(rmIt);
555 continue;
556 }
557 double delayInNanoSeconds =
559
560 // 1000/ns = MHz
561 if ((1000/delayInNanoSeconds) < frequencyMHz) {
562 // RF too slow
563 iter++;
564 iuImplementations.erase(rmIt);
565 continue;
566 }
567 CostEstimates* estimates = new CostEstimates();
568 estimates->setArea(area);
569 estimates->setLongestPathDelay(delayInNanoSeconds);
570 results.insert(
571 pair<const IDF::IUImplementationLocation*, CostEstimates*>(
572 (*iter), estimates));
573 } catch (CannotEstimateCost& e) {
574 // Couldn't estimate the iu.
575 iter++;
576 iuImplementations.erase(rmIt);
577 continue;
578 }
579 iter++;
580 }
581 return results;
582}
std::map< const IDF::IUImplementationLocation *, CostEstimates * > iuImplementations(const TTAMachine::ImmediateUnit &iu, double frequencyMHz=0, double maxArea=0)
DelayInNanoSeconds registerFileMaximumComputationDelay(const TTAMachine::BaseRegisterFile &architecture, const IDF::RFImplementationLocation &implementationEntry)
Definition Estimator.cc:876
AreaInGates registerFileArea(const TTAMachine::BaseRegisterFile &architecture, const IDF::RFImplementationLocation &implementationEntry)
Definition Estimator.cc:398
std::set< RowID > rfEntriesByArchitecture(int readPorts, int writePorts, int bidirPorts, int maxReads, int maxWrites, int latency, bool guardSupport, int guardLatency=0, int width=0, int size=0, bool zeroRegister=false) const
void addIUImplementation(RFImplementationLocation *implementation)
virtual int numberOfRegisters() const
virtual int width() const
virtual int portCount() const
Definition Unit.cc:135
UnitImplementationLocation IUImplementationLocation

References IDF::MachineImplementation::addIUImplementation(), estimator_, HDB::HDBManager::fileName(), HDB::HDBRegistry::hdb(), HDB::HDBRegistry::instance(), iuImplementations(), TTAMachine::Component::name(), TTAMachine::BaseRegisterFile::numberOfRegisters(), TTAMachine::Unit::portCount(), CostEstimator::Estimator::registerFileArea(), CostEstimator::Estimator::registerFileMaximumComputationDelay(), HDB::HDBManager::rfEntriesByArchitecture(), CostEstimates::setArea(), CostEstimates::setLongestPathDelay(), usedHDBs_, and TTAMachine::BaseRegisterFile::width().

Referenced by AutoSelectImplementationsDialog::findIUImplementations(), iuImplementations(), and selectIUs().

Here is the call graph for this function:

◆ rfImplementations()

map< const IDF::RFImplementationLocation *, CostEstimates * > ComponentImplementationSelector::rfImplementations ( const TTAMachine::RegisterFile rf,
bool  guarded = false,
double  frequencyMHz = 0,
double  maxArea = 0 
)

Finds set of possible register file implementations.

Finds out which register file implementations fulfill the frequency and area requirements. The implementations are selected by estimating costs of different register file implementations that match the given register file architecture. All implementations that fulfill the given frequency and area requirements are returned including the estimated cost data of those implementations.

Parameters
rfRegister file architecture.
guardedFlag indicating if the register file is guarded, defaults to false.
frequencyMHzTarget frequency (MHz) of the register file.
maxAreaMaximum area (in gates) of the register file.
Returns
Set of RF implementations with cost evaluation data. Returns an empty set if none found.

Definition at line 377 of file ComponentImplementationSelector.cc.

379 {
380
381 // Get all rf entries matching the given architecture from all available
382 // HDBs and create implementation locations of them.
383 set<const IDF::RFImplementationLocation*> rfImplementations;
384 for (set<string>::const_iterator i = usedHDBs_.begin();
385 i != usedHDBs_.end(); i++) {
386
388 int readPorts = 0;
389 int writePorts = 0;
390 int bidirPorts = 0;
391 for (int p = 0; p < rf.portCount(); p++) {
392 const TTAMachine::RFPort* port = rf.port(p);
393 if (port->inputSocket() != NULL && port->outputSocket() != NULL) {
394 bidirPorts++;
395 } else if (port->inputSocket() != NULL) {
396 writePorts++;
397 } else if (port->outputSocket() != NULL) {
398 readPorts++;
399 }
400 }
401 set<RowID> rfEntryIDs = hdb.rfEntriesByArchitecture(
402 readPorts, writePorts, bidirPorts, rf.maxReads(), rf.maxWrites(),
403 // latency always 1
404 1,
405 // guard support
406 guarded,
407 // guard latency
408 rf.guardLatency(), rf.width(), rf.numberOfRegisters(),
409 rf.zeroRegister());
410
411 set<RowID>::const_iterator id = rfEntryIDs.begin();
412 for (; id != rfEntryIDs.end(); id++) {
415 hdb.fileName(), *id, rf.name());
418 machIDF->addRFImplementation(rfIDF);
419 rfImplementations.insert(rfIDF);
420 }
421 }
422 map<const IDF::RFImplementationLocation*, CostEstimates*> results;
423 set<const IDF::RFImplementationLocation*>::const_iterator iter =
424 rfImplementations.begin();
425
426 // in case we are not limiting the costs, return all matching
427 // implementations
428 if (static_cast<int>(frequencyMHz) <= 0 &&
429 static_cast<int>(maxArea) <= 0) {
430
431 for (; iter != rfImplementations.end(); iter++) {
432 results.insert(
433 pair<const IDF::RFImplementationLocation*, CostEstimates*>(
434 (*iter), NULL));
435 }
436 return results;
437 }
438
439 while (iter != rfImplementations.end()) {
440 auto rmIt = iter;
441 try {
442 double area = estimator_.registerFileArea(rf, *(*iter));
443 if (area > maxArea && static_cast<int>(maxArea) > 0) {
444 // RF area too large
445 iter++;
446 rfImplementations.erase(rmIt);
447 continue;
448 }
449 double delayInNanoSeconds =
451
452 // 1000/ns = MHz
453 if ((1000/delayInNanoSeconds) < frequencyMHz) {
454 // RF too slow
455 iter++;
456 rfImplementations.erase(rmIt);
457 continue;
458 }
459 CostEstimates* estimates = new CostEstimates();
460 estimates->setArea(area);
461 estimates->setLongestPathDelay(delayInNanoSeconds);
462 results.insert(
463 pair<const IDF::RFImplementationLocation*, CostEstimates*>(
464 (*iter), estimates));
465 } catch (CannotEstimateCost& e) {
466 // Couldn't estimate the rf.
467 iter++;
468 rfImplementations.erase(rmIt);
469 continue;
470 }
471 iter++;
472 }
473 return results;
474}
std::map< const IDF::RFImplementationLocation *, CostEstimates * > rfImplementations(const TTAMachine::RegisterFile &rf, bool guarded=false, double frequencyMHz=0, double maxArea=0)
void addRFImplementation(RFImplementationLocation *implementation)
virtual RFPort * port(const std::string &name) const
virtual Socket * outputSocket() const
Definition Port.cc:281
virtual Socket * inputSocket() const
Definition Port.cc:261
virtual int maxReads() const
virtual bool zeroRegister() const
virtual int guardLatency() const
virtual int maxWrites() const
UnitImplementationLocation RFImplementationLocation

References IDF::MachineImplementation::addRFImplementation(), estimator_, HDB::HDBManager::fileName(), TTAMachine::RegisterFile::guardLatency(), HDB::HDBRegistry::hdb(), TTAMachine::Port::inputSocket(), HDB::HDBRegistry::instance(), TTAMachine::RegisterFile::maxReads(), TTAMachine::RegisterFile::maxWrites(), TTAMachine::Component::name(), TTAMachine::BaseRegisterFile::numberOfRegisters(), TTAMachine::Port::outputSocket(), TTAMachine::BaseRegisterFile::port(), TTAMachine::Unit::portCount(), CostEstimator::Estimator::registerFileArea(), CostEstimator::Estimator::registerFileMaximumComputationDelay(), HDB::HDBManager::rfEntriesByArchitecture(), rfImplementations(), CostEstimates::setArea(), CostEstimates::setLongestPathDelay(), usedHDBs_, TTAMachine::BaseRegisterFile::width(), and TTAMachine::RegisterFile::zeroRegister().

Referenced by AutoSelectImplementationsDialog::findRFImplementations(), rfImplementations(), and selectRFs().

Here is the call graph for this function:

◆ selectComponents()

IDF::MachineImplementation * ComponentImplementationSelector::selectComponents ( const TTAMachine::Machine mach,
const std::string &  icDecoder = "ic_hdb",
const std::string &  icDecoderHDB = "asic_130nm_1.5V.hdb",
const double &  frequency = 0,
const double &  maxArea = 0 
)

Selects the implementations for the machine configuration.

Parameters
configurationMachineConfiguration of which architecture is used.
frequencyThe minimum frequency of the implementations.
icDecoderThe name of the ic decoder plugin for idf.
icDecoderHDBThe name of the hdb used by ic decoder plugin.
Returns
RowID of the new machine configuration having adf and idf.
Exceptions
ExceptionNo suitable implementations found.

Definition at line 645 of file ComponentImplementationSelector.cc.

648 {
649 HDBRegistry& hdbRegistry = HDBRegistry::instance();
650 for (int i = 0; i < hdbRegistry.hdbCount(); i++) {
651 addHDB(hdbRegistry.hdb(i));
652 }
653
655
656 // select implementations for funtion units
657 selectFUs(mach, idf, frequency, maxArea);
658
659 // select implementations for register files
660 selectRFs(mach, idf);
661
662 // select implementations for immediate units
663 selectIUs(mach, idf, frequency, maxArea);
664
665 // add the ic decoder plugin
666 std::vector<std::string> icDecPaths =
668 idf->setICDecoderPluginName(icDecoder);
669 idf->setICDecoderHDB(icDecoderHDB);
670 std::vector<std::string>::const_iterator iter = icDecPaths.begin();
671 for (; iter != icDecPaths.end(); iter++) {
672 std::string path = *iter;
673 std::string file =
674 path + FileSystem::DIRECTORY_SEPARATOR + icDecoder + "Plugin.so";
675 if (FileSystem::fileExists(file)) {
676 idf->setICDecoderPluginFile(file);
677 break;
678 }
679 }
680
681 return idf;
682}
void selectRFs(const TTAMachine::Machine *mach, IDF::MachineImplementation *idf, const double &frequency=0, const double &maxArea=0)
void selectFUs(const TTAMachine::Machine *mach, IDF::MachineImplementation *idf, const double &frequency=0, const double &maxArea=0, const bool &filterLongestPathDelay=true)
void selectIUs(const TTAMachine::Machine *mach, IDF::MachineImplementation *idf, const double &frequency=0, const double &maxArea=0)
static std::vector< std::string > icDecoderPluginPaths(bool libraryPathsOnly=false)
static const std::string DIRECTORY_SEPARATOR
static bool fileExists(const std::string fileName)
void setICDecoderHDB(const std::string &file)
void setICDecoderPluginFile(const std::string &file)
void setICDecoderPluginName(const std::string &name)

References addHDB(), FileSystem::DIRECTORY_SEPARATOR, FileSystem::fileExists(), HDB::HDBRegistry::hdb(), HDB::HDBRegistry::hdbCount(), Environment::icDecoderPluginPaths(), HDB::HDBRegistry::instance(), selectFUs(), selectIUs(), selectRFs(), IDF::MachineImplementation::setICDecoderHDB(), IDF::MachineImplementation::setICDecoderPluginFile(), and IDF::MachineImplementation::setICDecoderPluginName().

Referenced by ImplementationSelector::explore(), DesignSpaceExplorer::selectComponents(), and selectComponentsToConf().

Here is the call graph for this function:

◆ selectComponentsToConf()

void ComponentImplementationSelector::selectComponentsToConf ( DSDBManager::MachineConfiguration conf,
DSDBManager dsdb,
TTAMachine::Machine mach = NULL,
const std::string &  icDecoder = "ic_hdb",
const std::string &  icDecoderHDB = "asic_130nm_1.5V.hdb",
const double &  frequency = 0,
const double &  maxArea = 0 
)

Selects the implementations for machine configuration.

Stores created idf to the given configuration and the configuration hold information in the given dsdb. If no machine is given then read the machine from dsdb through given configuration.

Parameters
confMachine configuration.
dsdbDSDB where implementation is added.
machMachine for what the implementation is generated.
icDecoderThe name of the ic decoder plugin for idf.
icDecoderHDBThe name of the hdb used by ic decoder plugin.
frequencyThe minimum frequency of the implementations.
maxAreaThe maximum area of the implementations.

Definition at line 601 of file ComponentImplementationSelector.cc.

605 {
606 if (mach == NULL) {
607 try {
608 mach = dsdb.architecture(conf.architectureID);
609 } catch (const Exception& e) {
610 Exception error(__FILE__, __LINE__, __func__,
611 e.errorMessage());
612 error.setCause(e);
613 throw error;
614 }
615 }
616
617 IDF::MachineImplementation* idf = NULL;
618 try {
619 // building the idf
620 idf = selectComponents(
621 mach, icDecoder, icDecoderHDB, frequency, maxArea);
622 } catch (const Exception& e) {
623 Exception error(__FILE__, __LINE__, __func__,
624 e.errorMessage());
625 error.setCause(e);
626 conf.hasImplementation = false;
627 throw error;
628 }
629
630 conf.implementationID = dsdb.addImplementation(*idf, 0, 0);
631 conf.hasImplementation = true;
632}
#define __func__
IDF::MachineImplementation * selectComponents(const TTAMachine::Machine *mach, const std::string &icDecoder="ic_hdb", const std::string &icDecoderHDB="asic_130nm_1.5V.hdb", const double &frequency=0, const double &maxArea=0)
TTAMachine::Machine * architecture(RowID id) const
RowID addImplementation(const IDF::MachineImplementation &impl, double longestPathDelay, CostEstimator::AreaInGates area)
std::string errorMessage() const
Definition Exception.cc:123

References __func__, DSDBManager::addImplementation(), DSDBManager::architecture(), DSDBManager::MachineConfiguration::architectureID, Exception::errorMessage(), DSDBManager::MachineConfiguration::hasImplementation, DSDBManager::MachineConfiguration::implementationID, selectComponents(), and Exception::setCause().

Referenced by ADFCombiner::explore(), and ComponentAdder::explore().

Here is the call graph for this function:

◆ selectFUs()

void ComponentImplementationSelector::selectFUs ( const TTAMachine::Machine mach,
IDF::MachineImplementation idf,
const double &  frequency = 0,
const double &  maxArea = 0,
const bool &  filterLongestPathDelay = true 
)

Selects the implementations for FUs in the machine configuration.

frequency and maxArea to zero by default. TODO: throw more appropriate exceptions

Definition at line 691 of file ComponentImplementationSelector.cc.

694 {
696
697 // select implementations for funtion units
698 for (int i = 0; i < fuNav.count(); i++) {
699 FunctionUnit* fu = fuNav.item(i);
700
701 map<const IDF::FUImplementationLocation*, CostEstimates*> fuMap =
702 fuImplementations(*fu, frequency, maxArea);
703 // Create an id ordered set of idf entries to ensure
704 // deterministic behaviour
705 set<std::pair<const IDF::FUImplementationLocation*, CostEstimates*>,
706 implComp> fuSet;
707 for (map<const IDF::FUImplementationLocation*,
708 CostEstimates*>::iterator i = fuMap.begin();
709 i != fuMap.end(); i++) {
710 fuSet.insert(
711 std::make_pair(i->first, i->second));
712 }
713
714 set<std::pair<const IDF::FUImplementationLocation*, CostEstimates*> >::
715 const_iterator iter = fuSet.begin();
716 if (fuMap.size() != 0) {
717 set<std::pair<const IDF::FUImplementationLocation*,
718 CostEstimates*> >::const_iterator wanted = iter;
719 if (filterLongestPathDelay && maxArea > 0 && frequency > 0) {
720 double longestPathDelay = 0;
721 double area = 0;
722 bool first = true;
723 while (iter != fuSet.end()) {
724 CostEstimates* estimate = iter->second;
725 if (estimate == NULL) {
726 std::string errorMsg = "When selecting FUs regarding"
727 " longest path delay, no cost estimates were"
728 " found for FU: " + fu->name();
730 __FILE__, __LINE__, __func__, errorMsg, 1);
731 break;
732 }
733 if (first) {
734 area = estimate->area();
735 longestPathDelay = estimate->longestPathDelay();
736 wanted = iter;
737 first = false;
738 } else if (longestPathDelay <
739 estimate->longestPathDelay()) {
740 longestPathDelay = estimate->longestPathDelay();
741 area = estimate->area();
742 wanted = iter;
743 } else if (longestPathDelay ==
744 estimate->longestPathDelay() &&
745 area < estimate->area()) {
746 area = estimate->area();
747 wanted = iter;
748 }
749 iter++;
750 }
751 }
752
753 const IDF::FUImplementationLocation* fuImpl = (*wanted).first;
754
755 ObjectState* state = fuImpl->saveState();
758
759 try {
760 idf->addFUImplementation(newFUImpl);
761 } catch (const Exception& e) {
762 Exception error(
763 __FILE__, __LINE__, __func__,
764 e.errorMessage());
765 error.setCause(e);
766 throw error;
767 }
768 } else {
769 throw Exception(
770 __FILE__, __LINE__, __func__,
771 "no implementations found for FU: " + fu->name());
772 }
773 }
774}
static void writeToErrorLog(const std::string fileName, const int lineNumber, const std::string functionName, const std::string message, const int neededVerbosity=0)
double area() const
double longestPathDelay() const
ComponentType * item(int index) const
virtual FunctionUnitNavigator functionUnitNavigator() const
Definition Machine.cc:380

References __func__, IDF::MachineImplementation::addFUImplementation(), CostEstimates::area(), TTAMachine::Machine::Navigator< ComponentType >::count(), Exception::errorMessage(), fuImplementations(), TTAMachine::Machine::functionUnitNavigator(), TTAMachine::Machine::Navigator< ComponentType >::item(), CostEstimates::longestPathDelay(), TTAMachine::Component::name(), IDF::UnitImplementationLocation::saveState(), Exception::setCause(), and Application::writeToErrorLog().

Referenced by selectComponents().

Here is the call graph for this function:

◆ selectIUs()

void ComponentImplementationSelector::selectIUs ( const TTAMachine::Machine mach,
IDF::MachineImplementation idf,
const double &  frequency = 0,
const double &  maxArea = 0 
)

Selects the implementations for IUs in the machine configuration.

Definition at line 867 of file ComponentImplementationSelector.cc.

869 {
871
872 // select implementations for immediate units
873 for (int index = 0; index < iuNav.count(); index++) {
874 TTAMachine::ImmediateUnit* iu = iuNav.item(index);
875
876 map<const IDF::IUImplementationLocation*, CostEstimates*> iuMap =
877 iuImplementations(*iu, frequency, maxArea);
878
879 // Create an id ordered set of idf entries to ensure the deterministic behaviour
880 set<std::pair<const IDF::IUImplementationLocation*, CostEstimates*>, implComp> iuSet;
881 for (map<const IDF::IUImplementationLocation*, CostEstimates*>::const_iterator i =
882 iuMap.begin(); i != iuMap.end(); i++) {
883 iuSet.insert(std::make_pair(i->first, i->second));
884 }
885 set<std::pair<const IDF::IUImplementationLocation*,
886 CostEstimates*> >::const_iterator iter = iuSet.begin();
887 if (iuMap.size() != 0) {
888 double longestPathDelay = 0;
889 double area = 0;
890 bool first = true;
891 set<std::pair<const IDF::RFImplementationLocation*, CostEstimates*> >::const_iterator wanted = iter;
892
893 while (iter != iuSet.end()) {
894 CostEstimates* estimate = iter->second;
895 if (estimate == NULL) {
896 std::string errorMsg = "When selecting IUs regarding"
897 " longest path delay, no cost estimates were"
898 " found for IU: " + iu->name();
900 __FILE__, __LINE__, __func__, errorMsg, 1);
901 break;
902 }
903 if (first) {
904 area = estimate->area();
905 longestPathDelay = estimate->longestPathDelay();
906 wanted = iter;
907 first = false;
908 } else if (longestPathDelay < estimate->longestPathDelay()) {
909 longestPathDelay = estimate->longestPathDelay();
910 area = estimate->area();
911 wanted = iter;
912 } else if (longestPathDelay == estimate->longestPathDelay() && area < estimate->area()) {
913 area = estimate->area();
914 wanted = iter;
915 }
916 iter++;
917 }
918
919 const IDF::IUImplementationLocation* iuImpl = (*wanted).first;
920 ObjectState* state = iuImpl->saveState();
923 try {
924 idf->addIUImplementation(newIUImpl);
925 } catch (const Exception& e) {
926 Exception error(__FILE__, __LINE__, __func__,
927 e.errorMessage());
928 error.setCause(e);
929 throw error;
930 }
931 } else {
932 throw Exception(
933 __FILE__, __LINE__, __func__,
934 "no implementations found for IU: " + iu->name());
935 }
936 }
937}
virtual ImmediateUnitNavigator immediateUnitNavigator() const
Definition Machine.cc:416

References __func__, IDF::MachineImplementation::addIUImplementation(), CostEstimates::area(), TTAMachine::Machine::Navigator< ComponentType >::count(), Exception::errorMessage(), TTAMachine::Machine::immediateUnitNavigator(), TTAMachine::Machine::Navigator< ComponentType >::item(), iuImplementations(), CostEstimates::longestPathDelay(), TTAMachine::Component::name(), IDF::UnitImplementationLocation::saveState(), Exception::setCause(), and Application::writeToErrorLog().

Referenced by selectComponents().

Here is the call graph for this function:

◆ selectRFs()

void ComponentImplementationSelector::selectRFs ( const TTAMachine::Machine mach,
IDF::MachineImplementation idf,
const double &  frequency = 0,
const double &  maxArea = 0 
)

Selects the implementations for RFs in the machine configuration.

Selects the the RF that has biggest longest path delay.

Definition at line 783 of file ComponentImplementationSelector.cc.

785 {
787
788 // selects the register that has biggest longest path delay
789 for (int i = 0; i < rfNav.count(); i++) {
790 RegisterFile* rf = rfNav.item(i);
791 map<const IDF::RFImplementationLocation*, CostEstimates*> rfMap;
792
793 // check if the register is boolean register.
794 if (rf->isUsedAsGuard()) {
795 // select from guarded registers
796 rfMap = rfImplementations(*rf, true, frequency, maxArea);
797 } else {
798 // select from non guarded registers
799 rfMap = rfImplementations(*rf, false, frequency, maxArea);
800 }
801 // Create an id ordered set of idf entries to ensure the deterministic behaviour
802 set<std::pair<const IDF::RFImplementationLocation*, CostEstimates*>, implComp> rfSet;
803 for ( map<const IDF::RFImplementationLocation*, CostEstimates*>::const_iterator i = rfMap.begin();
804 i != rfMap.end(); i++) {
805 rfSet.insert(std::make_pair(i->first, i->second));
806 }
807 set<std::pair<const IDF::RFImplementationLocation*, CostEstimates*> >::const_iterator iter = rfSet.begin();
808 if (rfMap.size() != 0) {
809 double longestPathDelay = 0;
810 double area = 0;
811 bool first = true;
812 set<std::pair<const IDF::RFImplementationLocation*,
813 CostEstimates*> >::const_iterator wanted = iter;
814 if (maxArea > 0 && frequency > 0) {
815 while (iter != rfSet.end()) {
816 CostEstimates* estimate = iter->second;
817 if (estimate == NULL) {
818 std::string errorMsg = "When selecting RFs regarding"
819 " longest path delay, no cost estimates were"
820 " found for RF: " + rf->name();
822 __FILE__, __LINE__, __func__, errorMsg, 1);
823 break;
824 }
825 if (first) {
826 area = estimate->area();
827 longestPathDelay = estimate->longestPathDelay();
828 wanted = iter;
829 first = false;
830 } else if (longestPathDelay < estimate->longestPathDelay()) {
831 longestPathDelay = estimate->longestPathDelay();
832 area = estimate->area();
833 wanted = iter;
834 } else if (longestPathDelay == estimate->longestPathDelay() && area < estimate->area()) {
835 area = estimate->area();
836 wanted = iter;
837 }
838
839 iter++;
840 }
841 }
842 const IDF::RFImplementationLocation* rfImpl = (*wanted).first;
843 ObjectState* state = rfImpl->saveState();
846 try {
847 idf->addRFImplementation(newRFImpl);
848 } catch (const Exception& e) {
849 Exception error(__FILE__, __LINE__, __func__,
850 e.errorMessage());
851 error.setCause(e);
852 throw error;
853 }
854 } else {
855 throw Exception(
856 __FILE__, __LINE__, __func__,
857 "no implementations found for RF: " + rf->name());
858 }
859 }
860}
virtual RegisterFileNavigator registerFileNavigator() const
Definition Machine.cc:450
virtual bool isUsedAsGuard() const

References __func__, IDF::MachineImplementation::addRFImplementation(), CostEstimates::area(), TTAMachine::Machine::Navigator< ComponentType >::count(), Exception::errorMessage(), TTAMachine::RegisterFile::isUsedAsGuard(), TTAMachine::Machine::Navigator< ComponentType >::item(), CostEstimates::longestPathDelay(), TTAMachine::Component::name(), TTAMachine::Machine::registerFileNavigator(), rfImplementations(), IDF::UnitImplementationLocation::saveState(), Exception::setCause(), and Application::writeToErrorLog().

Referenced by selectComponents().

Here is the call graph for this function:

Member Data Documentation

◆ estimator_

CostEstimator::Estimator ComponentImplementationSelector::estimator_
private

Cost estimator to estimate the unit costs.

Definition at line 131 of file ComponentImplementationSelector.hh.

Referenced by fuImplementations(), iuImplementations(), and rfImplementations().

◆ usedHDBs_

std::set<std::string> ComponentImplementationSelector::usedHDBs_
private

HDBs from which implementations are serched are stored in this set.

Definition at line 129 of file ComponentImplementationSelector.hh.

Referenced by addHDB(), fuArchsByOpSetWithMinLatency(), fuImplementations(), iuImplementations(), and rfImplementations().


The documentation for this class was generated from the following files: