OpenASIP 2.2
Loading...
Searching...
No Matches
Functions | Variables
EstimatorCmdLineUI.cc File Reference
#include <iostream>
#include <cmath>
#include "EstimatorCmdLineOptions.hh"
#include "Machine.hh"
#include "ADFSerializer.hh"
#include "MachineImplementation.hh"
#include "IDFSerializer.hh"
#include "Program.hh"
#include "NullProgram.hh"
#include "Binary.hh"
#include "FileSystem.hh"
#include "BinaryStream.hh"
#include "BinaryReader.hh"
#include "TPEFProgramFactory.hh"
#include "ExecutionTrace.hh"
#include "Estimator.hh"
Include dependency graph for EstimatorCmdLineUI.cc:

Go to the source code of this file.

Functions

bool loadInputs (EstimatorCmdLineOptions &options)
 
void cleanup ()
 
int main (int argc, char *argv[])
 

Variables

bool energyEstimation = false
 this is set to true in case energy estimation can be performed with the given input files
 
TTAMachine::Machinemachine = NULL
 the architecture definition of the estimated processor
 
IDF::MachineImplementationimplementation = NULL
 the implementation definition of the estimated processor
 
TTAProgram::Programprogram = NULL
 the estimated program is stored in this variable (in case energy estimation is wanted
 
ExecutionTracetrace = NULL
 the execution trace database
 

Detailed Description

Implementation of estimate.

The command line user interface of cost estimator.

Author
Pekka Jääskeläinen 2005 (pjaaskel-no.spam-cs.tut.fi)
Note
rating: red

Definition in file EstimatorCmdLineUI.cc.

Function Documentation

◆ cleanup()

void cleanup ( )

Frees all allocated input resources.

Definition at line 179 of file EstimatorCmdLineUI.cc.

179 {
180
181 delete machine;
182 machine = NULL;
183 delete implementation;
184 implementation = NULL;
185
186 if (energyEstimation) {
187 delete program;
188 program = NULL;
189 delete trace;
190 trace = NULL;
191 }
192}
bool energyEstimation
this is set to true in case energy estimation can be performed with the given input files
TTAProgram::Program * program
the estimated program is stored in this variable (in case energy estimation is wanted
ExecutionTrace * trace
the execution trace database
IDF::MachineImplementation * implementation
the implementation definition of the estimated processor
TTAMachine::Machine * machine
the architecture definition of the estimated processor

References energyEstimation, implementation, machine, program, and trace.

Referenced by main().

◆ loadInputs()

bool loadInputs ( EstimatorCmdLineOptions options)

Loads the input files using the command line arguments.

Parameters
optionsThe command line arguments.
Returns
True in case there was no errors in the arguments.

Definition at line 75 of file EstimatorCmdLineUI.cc.

75 {
76
77 if (options.numberOfArguments() < 2) {
78 std::cerr << "ADF and IDF are required." << std::endl;
79 return false;
80 }
81 else if (options.numberOfArguments() > 2) {
82 std::cerr << "Illegal command line arguments." << std::endl;
83 return false;
84 }
85
86 std::string adfFile = options.argument(1);
87 std::string idfFile = options.argument(2);
88
89 try {
90 ADFSerializer serializer;
91 serializer.setSourceFile(adfFile);
92 machine = serializer.readMachine();
93 } catch (const Exception& e) {
94 std::cerr << "Error while loading ADF. " << e.errorMessage()
95 << std::endl;
96 return false;
97 }
98
99 try {
100 IDF::IDFSerializer serializer;
101 serializer.setSourceFile(idfFile);
103 } catch (const Exception& e) {
104 std::cerr << "Error while loading IDF. " << e.errorMessage()
105 << std::endl;
106 return false;
107 }
108
109 if (options.TPEF() != "") {
110
111 if (options.traceDB() == "") {
112 std::cerr << "Also TraceDB is required for energy estimation."
113 << std::endl;
114 return false;
115 }
116
117 TPEF::Binary* tpef = NULL;
118 try {
119 const std::string tpefFileName = options.TPEF();
120 if (!FileSystem::fileExists(tpefFileName)) {
121 std::cerr << "Error while loading TPEF. "
122 << "Cannot open file '" << tpefFileName << "'."
123 << std::endl;
124 delete machine;
125 machine = NULL;
126 delete implementation;
127 implementation = NULL;
128 return EXIT_FAILURE;
129 }
130 TPEF::BinaryStream binaryStream(tpefFileName);
131
132 // read first to a TPEF Handler Module
133 tpef = TPEF::BinaryReader::readBinary(binaryStream);
134
135 assert(tpef != NULL);
136 assert(machine != NULL);
137
138 // convert the loaded TPEF to POM
140 program = factory.build();
141 delete tpef;
142 tpef = NULL;
143 } catch (const Exception& e) {
144 std::cerr << "Error while loading TPEF. " << e.errorMessage()
145 << std::endl;
146 delete tpef;
147 tpef = NULL;
148 return false;
149 }
150 }
151
152 if (options.traceDB() != "") {
153
154 const std::string traceDBFileName = options.traceDB();
155 if (!FileSystem::fileExists(traceDBFileName)) {
156 std::cerr << "Error while loading TraceDB. "
157 << "Cannot open file '" << traceDBFileName << "'."
158 << std::endl;
159 return false;
160 }
161
162 try {
163 trace = ExecutionTrace::open(traceDBFileName);
164 } catch (const Exception& e) {
165 std::cerr << "Error while loading TraceDB. " << e.errorMessage()
166 << std::endl;
167 return false;
168 }
169 if (program == NULL)
171 energyEstimation = true;
172 }
173 return true;
174}
#define assert(condition)
static MachInfoCmdLineOptions options
Definition MachInfo.cc:46
TTAMachine::Machine * readMachine()
virtual std::string argument(int index) const
virtual int numberOfArguments() const
std::string errorMessage() const
Definition Exception.cc:123
static bool fileExists(const std::string fileName)
MachineImplementation * readMachineImplementation()
static Binary * readBinary(BinaryStream &stream)
static NullProgram & instance()
void setSourceFile(const std::string &fileName)

References CmdLineParser::argument(), assert, TTAProgram::TPEFProgramFactory::build(), energyEstimation, Exception::errorMessage(), FileSystem::fileExists(), implementation, TTAProgram::NullProgram::instance(), machine, CmdLineParser::numberOfArguments(), ExecutionTrace::open(), options, program, TPEF::BinaryReader::readBinary(), ADFSerializer::readMachine(), IDF::IDFSerializer::readMachineImplementation(), XMLSerializer::setSourceFile(), and trace.

Referenced by main().

Here is the call graph for this function:

◆ main()

int main ( int  argc,
char *  argv[] 
)

Main function.

Parses the command line and executes cost estimation functionality.

Parameters
argcThe command line argument count.
argvThe command line arguments (passed to the interpreter).
Returns
The return status.

Definition at line 204 of file EstimatorCmdLineUI.cc.

204 {
205
207
209 try {
210 options->parse(argv, argc);
212 } catch (ParserStopRequest const&) {
213 return EXIT_SUCCESS;
214 } catch (const IllegalCommandLine& i) {
215 std::cerr << i.errorMessage() << std::endl;
216 return EXIT_FAILURE;
217 }
218
219 if (!loadInputs(*options)) {
220 cleanup();
221 return EXIT_FAILURE;
222 }
223
224 Estimator estimator;
225 if (options->totalArea() || !options->runOnlyEstimations()) {
226 CostEstimator::AreaInGates totalArea = -1;
227 try {
228 totalArea = round(estimator.totalArea(*machine, *implementation));
229 } catch (const Exception& e) {
230 std::cerr << "estimation failed: " + e.errorMessage()
231 << std::endl;
232 }
233
234 if (totalArea >= 0) {
235 std::cout << "total area: " << totalArea << " gates"
236 << std::endl;
237 }
238 }
239
240 if (options->longestPath() || !options->runOnlyEstimations()) {
241 std::cout << "delay of the longest path: ";
242 try {
243 std::cout
244 << round(estimator.longestPath(*machine, *implementation))
245 << " ns" << std::endl;
246 } catch (const Exception& e) {
247 std::cerr << "estimation failed: " + e.errorMessage()
248 << std::endl;
249 }
250 }
251
252 if (energyEstimation &&
253 (options->totalEnergy() || !options->runOnlyEstimations())) {
254 std::cout << "total consumed energy: ";
255 try {
256 std::cout
257 << estimator.totalEnergy(
259 << " mJ" << std::endl;
260 } catch (const Exception& e) {
261 std::cerr << "estimation failed: " + e.errorMessage()
262 << std::endl;
263 }
264 }
265
266 cleanup();
267 return EXIT_SUCCESS;
268}
void cleanup()
bool loadInputs(EstimatorCmdLineOptions &options)
static void setCmdLineOptions(CmdLineOptions *options_)
static void initialize()
void parse(char *argv[], int argc)
AreaInGates totalArea(const TTAMachine::Machine &machine, const IDF::MachineImplementation &machineImplementation)
area estimation functions
Definition Estimator.cc:84
EnergyInMilliJoules totalEnergy(const TTAMachine::Machine &machine, const IDF::MachineImplementation &machineImplementation, const TTAProgram::Program &program, const ExecutionTrace &traceDB)
energy estimation functions
Definition Estimator.cc:433
DelayInNanoSeconds longestPath(const TTAMachine::Machine &machine, const IDF::MachineImplementation &machineImplementation)
delay estimation functions
Definition Estimator.cc:915
double AreaInGates
type for area values in equivalent gates

References cleanup(), energyEstimation, Exception::errorMessage(), implementation, Application::initialize(), loadInputs(), CostEstimator::Estimator::longestPath(), machine, options, CmdLineOptions::parse(), program, Application::setCmdLineOptions(), CostEstimator::Estimator::totalArea(), CostEstimator::Estimator::totalEnergy(), and trace.

Here is the call graph for this function:

Variable Documentation

◆ energyEstimation

bool energyEstimation = false

this is set to true in case energy estimation can be performed with the given input files

Definition at line 57 of file EstimatorCmdLineUI.cc.

Referenced by cleanup(), loadInputs(), and main().

◆ implementation

IDF::MachineImplementation* implementation = NULL

the implementation definition of the estimated processor

Definition at line 61 of file EstimatorCmdLineUI.cc.

Referenced by ProGe::NetlistGenerator::addBaseRFToNetlist(), HDB::HDBManager::addBlockImplementationFiles(), HDB::HDBManager::addBlockImplementationFiles(), IDF::MachineImplementation::addBusImplementation(), HDB::HDBManager::addDataPortsToImplementation(), HDB::HDBManager::addDataPortsToImplementation(), DSDBManager::addEnergyEstimate(), HDB::HDBManager::addFUExternalPortsToImplementation(), IDF::MachineImplementation::addFUImplementation(), HDB::HDBManager::addFUParametersToImplementation(), IDF::MachineImplementation::addIUImplementation(), HDB::HDBManager::addOpcodesToImplementation(), HDB::HDBManager::addRFExternalPortsToImplementation(), HDB::HDBManager::addRFImplementation(), IDF::MachineImplementation::addRFImplementation(), HDB::HDBManager::addRFParametersToImplementation(), IDF::MachineImplementation::addSocketImplementation(), DSDBManager::areaEstimate(), ProGe::ProcessorGenerator::checkIULatencies(), cleanup(), ProGe::BlockSourceCopier::copyBaseRFFiles(), ProGe::BlockSourceCopier::copyFiles(), HDB::HDBManager::createImplementationOfFU(), HDB::HDBManager::createImplementationOfRF(), DefaultICDecoderEstimator::delayOfBus(), DefaultICDecoderEstimator::delayOfSocket(), AddFUImplementationCmd::Do(), AddRFImplementationCmd::Do(), DSDBManager::energyEstimate(), StrictMatchRFEstimator::estimateArea(), StrictMatchFUEstimator::estimateArea(), StrictMatchRFEstimator::estimateEnergy(), InterpolatingFUEstimator::estimateEnergy(), StrictMatchFUEstimator::estimateEnergy(), StrictMatchRFEstimator::estimateMaximumComputationDelay(), StrictMatchFUEstimator::estimateMaximumComputationDelay(), StrictMatchFUEstimator::estimatePortReadDelay(), StrictMatchRFEstimator::estimatePortReadDelay(), StrictMatchFUEstimator::estimatePortWriteDelay(), StrictMatchRFEstimator::estimatePortWriteDelay(), IDF::MachineImplementation::findImplementation(), HDB::HDBManager::fuByEntryID(), ProGeTestBenchGenerator::generate(), DefaultICDecoderGenerator::generate(), ProGe::ProcessorGenerator::generateProcessor(), DSDBManager::hasEnergyEstimate(), PlatformIntegrator::loadFUExternalPorts(), loadInputs(), DSDBManager::longestPathDelayEstimate(), main(), ProGe::NetlistGenerator::opcodePortWidth(), readIdf(), IDF::IDFSerializer::readMachineImplementation(), IDF::MachineImplementation::removeBusImplementation(), IDF::MachineImplementation::removeFUImplementation(), IDF::MachineImplementation::removeIUImplementation(), IDF::MachineImplementation::removeRFImplementation(), IDF::MachineImplementation::removeSocketImplementation(), HDB::HDBManager::rfByEntryID(), DSDBManager::setAreaEstimate(), DSDBManager::setLongestPathDelayEstimate(), ImplementationTester::simulateTestbench(), and IDF::IDFSerializer::writeMachineImplementation().

◆ machine

TTAMachine::Machine* machine = NULL

the architecture definition of the estimated processor

Definition at line 59 of file EstimatorCmdLineUI.cc.

Referenced by RegisterCopyAdder::addCandidateSetAnnotations(), FullyConnectedCheck::attachSocketToAllBusses(), ResourceBuildDirector::build(), MachineStateBuilder::build(), MachineStateBuilder::build(), MachineStateBuilder::build(), SimulationController::buildFUResourceConflictDetectors(), MachineStateBuilder::buildMachineState(), MinimalOpSetCheck::buildMinimalOpSet(), BUMoveNodeSelector::BUMoveNodeSelector(), BUMoveNodeSelector::BUMoveNodeSelector(), BUMoveNodeSelector::BUMoveNodeSelector(), BFOptimization::canBeScheduled(), MachineConnectivityCheck::canTransportMove(), MinimalOpSetCheck::check(), MinimalOpSetCheck::check(), ProGe::ProcessorGenerator::checkIULatencies(), MinimalOpSetCheck::checkWithIgnore(), cleanup(), TTAMachine::FUPort::cleanupGuards(), CompiledSimCodeGenerator::CompiledSimCodeGenerator(), FullyConnectedCheck::connectFUPort(), ADFSerializer::convertToMachineFormat(), TTAMachine::Machine::copyFromMachine(), MachineEditPartFactory::createEditPart(), POMDisassembler::createGuard(), POMDisassembler::createRegister(), FullyConnectedCheck::createSocket(), createTerminalFUPort(), CriticalPathBBMoveNodeSelector::CriticalPathBBMoveNodeSelector(), CriticalPathBBMoveNodeSelector::CriticalPathBBMoveNodeSelector(), CriticalPathBBMoveNodeSelector::CriticalPathBBMoveNodeSelector(), AddFUArchFromADFCmd::Do(), AddBridgeCmd::Do(), BlocksConnectICCmd::Do(), CallExplorerPluginCmd::Do(), FullyConnectBussesCmd::Do(), ImplementMachineCmd::Do(), PasteComponentCmd::Do(), VerifyMachineCmd::Do(), VLIWConnectICCmd::Do(), DefaultICDecoderEstimator::estimateICArea(), DefaultICDecoderEstimator::estimateICEnergy(), CopyingDelaySlotFiller::fillDelaySlots(), CostEstimator::Estimator::findAllICPaths(), findBooleanGuard(), findBooleanRegisterFile(), findBus(), SimulationController::findExitPoints(), findFunctionUnit(), findFUPort(), MachineInfo::findLockUnits(), TTASimulationController::findProgramExitPoints(), findRegisterFile(), MachineInfo::findWidestOperand(), ProGe::ProcessorGenerator::generateGCUOpcodesPackage(), ProGe::ProcessorGenerator::generateGlobalsPackage(), generateHeader(), ProGe::ProcessorGenerator::generateProcessor(), MachineEditPartFactory::getBusChains(), getFunctionUnit(), getRegisterFile(), MachineEditPartFactory::getSockets(), BasicBlockScheduler::getTriggerOperand(), MachineEditPartFactory::getUnits(), CostEstimator::Estimator::icArea(), CostEstimator::Estimator::icEnergy(), FUGen::implement(), AddWatchDialog::initialize(), CopyingDelaySlotFiller::initialize(), ProGe::PortFactory::initializeContext(), initializeMachine(), ProGe::NetlistGenerator::instructionMemory(), ProGe::NetlistGenerator::instructionMemoryAddressWidth(), ProGe::NetlistGenerator::instructionMemoryWidth(), GenerateProcessor::listICDecPluginParameters(), loadInputs(), ProgramImageGenerator::loadMachine(), CostEstimator::Estimator::longestPath(), MachineAnalysis::MachineAnalysis(), main(), MinimalOpSetCheck::missingOperations(), MachineConnectivityCheck::needRegCopiesDueReadPortConflicts(), MachineInfo::numberOfRegisters(), AddFUFromHDBDialog::onAdd(), AddIUFromHDBDialog::onAdd(), AddRFFromHDBDialog::onAdd(), OTAFormatListDialog::onAddOTAFormat(), TemplateListDialog::onAddTemplate(), BridgeDialog::onOK(), SocketDialog::onOK(), AddressSpaceDialog::onOK(), FUDialog::onOK(), FUPortDialog::onOK(), GCUDialog::onOK(), IUDialog::onOK(), RFDialog::onOK(), SRPortDialog::onOK(), ProximMachineStateWindow::onProgramLoaded(), CallExplorerPluginWindow::onRun(), MDFView::OnUpdate(), printLatexAddressSpaceDescription(), printLatexFunctionUnitDescription(), ProgrammabilityValidator::ProgrammabilityValidator(), ProximMachineStateWindow::ProximMachineStateWindow(), MachineConnectivityCheck::raConnected(), RemoteController::RemoteController(), ProGe::ProcessorGenerator::removeUnconnectedSockets(), IDFValidator::removeUnknownImplementations(), MachineCheckSuite::run(), ProGe::RV32MicroCodeGenerator::RV32MicroCodeGenerator(), MachineCanvas::setMachine(), TTAMachine::ImmediateUnit::setName(), ProximMachineStateWindow::setUtilizationHighlights(), DesignSpaceExplorer::simulate(), SimulationController::SimulationController(), FullyConnectedCheck::socketAttachedToAllBusses(), MachineInfo::supportsBoolRegisterGuardedJumps(), MachineInfo::supportsPortGuardedJump(), MachineInfo::supportsPortGuardedJumps(), tandemSimulate(), MachineConnectivityCheck::tempRegisterFiles(), CostEstimator::Estimator::totalArea(), CostEstimator::Estimator::totalAreaOfFunctionUnits(), CostEstimator::Estimator::totalAreaOfRegisterFiles(), CostEstimator::Estimator::totalEnergy(), CostEstimator::Estimator::totalEnergyOfFunctionUnits(), CostEstimator::Estimator::totalEnergyOfRegisterFiles(), MachineInfo::triggerIndex(), TTAMachine::ImmediateUnit::unsetMachine(), validateIdf(), ProGe::ProcessorGenerator::validateMachine(), ADFSerializer::writeMachine(), and Model::~Model().

◆ program

TTAProgram::Program* program = NULL

the estimated program is stored in this variable (in case energy estimation is wanted

Definition at line 64 of file EstimatorCmdLineUI.cc.

Referenced by cleanup(), loadInputs(), and main().

◆ trace

ExecutionTrace* trace = NULL