35 #include "boost/format.hpp"
64 Estimator::Estimator() {
70 Estimator::~Estimator() {
87 return totalAreaOfFunctionUnits(
machine, machineImplementation) +
88 totalAreaOfRegisterFiles(
machine, machineImplementation) +
89 icArea(
machine, machineImplementation);
103 Estimator::totalAreaOfFunctionUnits(
109 for (
int i = 0; i < nav.
count(); ++i) {
115 fuArchitecture->
name())) {
117 fuArchitecture->
name());
121 functionUnitArea(*fuArchitecture, *fuImplementation);
126 <<
"Warning: gate count of FU '"
127 << fuArchitecture->
name() <<
"' was estimated as "
128 << areaFU << std::endl;
131 <<
"FU '" << fuArchitecture->
name()
132 <<
"' contributes " << areaFU <<
" gates" << std::endl;
162 Estimator::totalAreaOfRegisterFiles(
168 for (
int i = 0; i < nav.
count(); ++i) {
174 rfArchitecture->
name())) {
176 rfArchitecture->
name());
180 registerFileArea(*rfArchitecture, *rfImplementation);
185 <<
"Warning: gate count of RF '"
186 << rfArchitecture->
name() <<
"' was estimated as "
187 << areaRF << std::endl;
190 <<
"RF '" << rfArchitecture->
name()
191 <<
"' contributes " << areaRF <<
" gates" << std::endl;
214 "Missing IC&decoder plugin information.");
221 icDecoderEstimatorPluginRegistry_.plugin(
231 "The IC&decoder estimator plugin '%s' unable to estimate "
238 std::string(
"Error while using ICDecoder estimation plugin. ") +
244 <<
"IC contributes " << area <<
" gates"
260 Estimator::fuCostFunctionPluginOfImplementation(
262 std::string pluginFileName =
"";
263 std::string pluginName =
"";
277 "Function unit entry %d does not have cost "
278 "estimation plugin set.") %
279 implementationEntry.
id()).str());
284 pluginName = pluginData.
name();
287 return fuEstimatorPluginRegistry_.plugin(
288 pluginFileName, pluginName);
292 std::string(
"Unable to open FU estimation plugin '") +
312 Estimator::rfCostFunctionPluginOfImplementation(
314 std::string pluginFileName =
"";
315 std::string pluginName =
"";
329 "Register file entry %d does not have cost "
330 "estimation plugin set.") % implementationEntry.
id()).str());
335 pluginName = pluginData.
name();
338 return rfEstimatorPluginRegistry_.plugin(
339 pluginFileName, pluginName);
343 std::string(
"Unable to open RF estimation plugin '") +
364 Estimator::functionUnitArea(
370 implementationEntry.
hdbFile());
371 if (!fuCostFunctionPluginOfImplementation(implementationEntry).
372 estimateArea(architecture, implementationEntry, area, hdb)) {
376 "Plugin was unable to estimate area of function unit '") +
377 architecture.
name() +
".");
383 std::string(
"Unable to estimate area of function unit '") +
398 Estimator::registerFileArea(
404 implementationEntry.
hdbFile());
405 if (!rfCostFunctionPluginOfImplementation(implementationEntry).
406 estimateArea(architecture, implementationEntry, area, hdb)) {
409 std::string(
"Plugin was unable to estimate area."));
415 std::string(
"Unable to estimate area of register file '") +
433 Estimator::totalEnergy(
437 return totalEnergyOfFunctionUnits(
439 totalEnergyOfRegisterFiles(
465 "Missing IC&decoder plugin information.");
472 icDecoderEstimatorPluginRegistry_.plugin(
482 "The IC&decoder estimator plugin '%s' could not estimate "
490 std::string(
"Error while using ICDecoder estimation plugin. ") +
510 Estimator::functionUnitEnergy(
517 implementationEntry.
hdbFile());
518 if (!fuCostFunctionPluginOfImplementation(implementationEntry).
520 architecture, implementationEntry,
program, traceDB, area,
524 std::string(
"Plugin was unable to estimate energy."));
530 std::string(
"Unable to estimate energy of function unit '") +
551 Estimator::registerFileEnergy(
558 implementationEntry.
hdbFile());
559 if (!rfCostFunctionPluginOfImplementation(implementationEntry).
561 architecture, implementationEntry,
program, traceDB, area,
565 std::string(
"Plugin was unable to estimate energy."));
571 std::string(
"Unable to estimate energy of register file '") +
592 Estimator::totalEnergyOfFunctionUnits(
599 for (
int i = 0; i < nav.
count(); ++i) {
605 fuArchitecture->
name())) {
607 fuArchitecture->
name());
609 total += functionUnitEnergy(
610 *fuArchitecture, *fuImplementation,
program, traceDB);
645 Estimator::totalEnergyOfRegisterFiles(
652 for (
int i = 0; i < nav.
count(); ++i) {
658 rfArchitecture->
name())) {
660 rfArchitecture->
name());
662 total += registerFileEnergy(
663 *rfArchitecture, *rfImplementation,
program, traceDB);
679 Estimator::functionUnitPortWriteDelay(
685 implementationEntry.
hdbFile());
686 if (!fuCostFunctionPluginOfImplementation(implementationEntry).
687 estimatePortWriteDelay(port, implementationEntry, delay, hdb)) {
691 "Plugin was unable to estimate input delay of port "
700 "Input delay estimation could not be done for the given "
701 "function unit entry. ") +
718 Estimator::functionUnitPortReadDelay(
724 implementationEntry.
hdbFile());
725 if (!fuCostFunctionPluginOfImplementation(implementationEntry).
726 estimatePortReadDelay(port, implementationEntry, delay, hdb)) {
730 "Plugin was unable to estimate output delay of port "
739 "Output delay estimation could not be done for the given "
756 Estimator::registerFilePortWriteDelay(
762 implementationEntry.
hdbFile());
763 if (!rfCostFunctionPluginOfImplementation(implementationEntry).
764 estimatePortWriteDelay(port, implementationEntry, delay, hdb)) {
768 "Plugin was unable to estimate input delay of port "
777 "Input delay estimation could not be done for a "
793 Estimator::registerFilePortReadDelay(
799 implementationEntry.
hdbFile());
800 if (!rfCostFunctionPluginOfImplementation(implementationEntry).
801 estimatePortReadDelay(port, implementationEntry, delay, hdb)) {
805 "Plugin was unable to estimate output delay of port "
814 "Output delay estimation could not be done for the given "
834 Estimator::functionUnitMaximumComputationDelay(
840 implementationEntry.
hdbFile());
841 if (!fuCostFunctionPluginOfImplementation(implementationEntry).
842 estimateMaximumComputationDelay(
843 architecture, implementationEntry, delay, hdb)) {
847 "Plugin was unable to estimate computation delay of FU ") +
848 architecture.
name());
855 "Computation delay estimation could not be done for the given "
856 "function unit entry. ") +
876 Estimator::registerFileMaximumComputationDelay(
882 implementationEntry.
hdbFile());
883 if (!rfCostFunctionPluginOfImplementation(implementationEntry).
884 estimateMaximumComputationDelay(
885 architecture, implementationEntry, delay, hdb)) {
889 "Plugin was unable to estimate computation delay of RF ") +
890 architecture.
name());
897 "Computation delay estimation could not be done for the given "
898 "register file entry. ") +
915 Estimator::longestPath(
926 std::string fBusName =
"";
929 for (
int i = 0; i < busNav.
count(); ++i) {
935 fBusName = bus.
name();
941 for (TransportPathList::iterator i = icPaths->begin();
942 i != icPaths->end(); ++i) {
945 if (fBusName !=
"" && fBusName != (i->bus()).name()) {
966 "Implementation information missing for function unit "
967 "'%s'.") % fu.
name()).str());
970 readDelay = functionUnitPortReadDelay(
981 readDelay = registerFilePortReadDelay(
986 readDelay = registerFilePortReadDelay(
993 "Implementation information missing for register file "
994 "'%s'.") % rf.
name()).str());
997 &sourcePort) != NULL) {
1002 __FILE__, __LINE__,
__func__,
"Unsupported port type.");
1023 "Implementation information missing for function "
1024 "unit '%s'.") % fu.
name()).str());
1027 writeDelay = functionUnitPortWriteDelay(
1042 "Implementation information missing for register file "
1043 "'%s'.") % rf.
name()).str());
1047 writeDelay += registerFilePortWriteDelay(
1051 &destinationPort) != NULL) {
1056 __FILE__, __LINE__,
__func__,
"Unsupported port type.");
1065 "Missing IC&decoder plugin information.");
1073 sourceSocketImplementation =
1076 sourceSocketImplementation =
1084 destinationSocketImplementation =
1087 destinationSocketImplementation =
1102 estimateSocketToSocketDelayOfPath(
1106 machineImplementation,
1107 *sourceSocketImplementation,
1109 *destinationSocketImplementation);
1112 pathDelay = readDelay + busDelay + writeDelay;
1114 maximumICDelay = std::max(maximumICDelay, pathDelay);
1116 #ifdef LONGEST_PATH_DEBUGGING
1120 << sourcePort.
name() <<
" (" << readDelay <<
"), "
1121 << bus.
name() <<
" (" << busDelay <<
"), "
1123 << destinationPort.
name() <<
" (" << writeDelay <<
") = "
1124 << pathDelay << std::endl;
1135 for (
int i = 0; i < fuNav.
count(); ++i) {
1142 "Implementation information missing for function unit "
1143 "'%s'.") % fu.
name()).str());
1146 functionUnitMaximumComputationDelay(
1148 maximumFUDelay = std::max(maximumFUDelay, delay);
1150 #ifdef LONGEST_PATH_DEBUGGING
1152 <<
"maximum computation delay of " << fu.
name() <<
" = "
1153 << delay <<
" ns" << std::endl;
1189 for (
int i = 0; i < rfNav.
count(); ++i) {
1196 "Implementation information missing for register file "
1197 "'%s'.") % rf.
name()).str());
1201 registerFileMaximumComputationDelay(
1204 maximumRFDelay = std::max(maximumRFDelay, delay);
1206 #ifdef LONGEST_PATH_DEBUGGING
1208 <<
"maximum computation delay of " << rf.
name() <<
" = "
1209 << delay <<
" ns" << std::endl;
1216 return std::max(maximumICDelay, std::max(maximumFUDelay, maximumRFDelay));
1232 for (
int bi = 0; bi < busNav.
count(); ++bi) {
1233 typedef std::set<const TTAMachine::Socket*> SocketSet;
1234 SocketSet outputSockets, inputSockets;
1240 "Segmented buses not supported yet.");
1249 inputSockets.insert(&socket);
1251 outputSockets.insert(&socket);
1255 "Unsupported socket direction.");
1259 for (SocketSet::iterator osi = outputSockets.begin();
1260 osi != outputSockets.end(); ++osi) {
1264 for (
int opi = 0; opi < outputSocket.
portCount(); ++opi) {
1268 for (SocketSet::iterator isi = inputSockets.begin();
1269 isi != inputSockets.end(); ++isi) {
1273 for (
int ipi = 0; ipi < inputSocket.
portCount(); ++ipi) {
1277 outputPort, outputSocket, bus, inputSocket,
1279 paths->push_back(path);
1283 <<
"::" << outputPort.
name() <<
", "
1284 << outputSocket.
name() <<
", "
1285 << bus.
name() <<
", "
1286 << inputSocket.
name() <<
", "
1288 <<
"::" << inputPort.
name() <<
"}" << std::endl;
1316 Estimator::estimateSocketToSocketDelayOfPath(
1317 const std::string pluginPath,
const std::string pluginName,
1327 icDecoderEstimatorPluginRegistry_.plugin(
1328 pluginPath, pluginName);
1332 sourceSocketImplementation,
1333 busImplementation, destinationSocketImplementation, delay)) {
1337 "The IC&decoder estimator plugin '%s' could not estimate "
1338 "delay of a path.") % pluginName).str());
1343 std::string(
"Error while using ICDecoder estimation plugin. ") +