OpenASIP 2.2
Loading...
Searching...
No Matches
Functions | Variables
MachInfo.cc File Reference
#include "Machine.hh"
#include "ControlUnit.hh"
#include "MachInfoCmdLineOptions.hh"
#include "OperationPool.hh"
#include "HWOperation.hh"
#include "Operation.hh"
#include "Conversion.hh"
#include "FUPort.hh"
#include <iostream>
#include <fstream>
#include <stdlib.h>
Include dependency graph for MachInfo.cc:

Go to the source code of this file.

Functions

TCEString operandBindingsString (TTAMachine::HWOperation &hwop)
 
void printLatexFunctionUnitDescription (const TTAMachine::Machine &machine, std::ofstream &output)
 
void printLatexAddressSpaceDescription (const TTAMachine::Machine &machine, std::ofstream &output)
 
int main (int argc, char *argv[])
 

Variables

static MachInfoCmdLineOptions options
 

Detailed Description

MachInfo tool prints out information of a given processor design, for documentation purposes.

Author
Pekka Jääskeläinen 2014

Definition in file MachInfo.cc.

Function Documentation

◆ main()

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

Definition at line 198 of file MachInfo.cc.

198 {
199 try {
200 options.parse(argv, argc);
201 } catch (const ParserStopRequest&) {
202 // In case --help was asked, or illegal command line parameters.
203 return EXIT_SUCCESS;
204 } catch (const IllegalCommandLine& exception) {
205 std::cerr << exception.errorMessage() << std::endl;
206 return EXIT_FAILURE;
207 }
208
209 if (options.numberOfArguments() != 1) {
210 std::cerr << "Single ADF file required." << std::endl;
211 return EXIT_FAILURE;
212 }
213 TCEString ADFFile = options.argument(1);
214
215 if (options.outputFormat() != "latex") {
216 std::cerr << "Unsupported output format." << std::endl;
217 return EXIT_FAILURE;
218 }
219
220 const TTAMachine::Machine* mach = NULL;
221 try {
222 mach = TTAMachine::Machine::loadFromADF(ADFFile);
223 } catch (const Exception& e) {
224 std::cerr << e.errorMessage() << std::endl;
225 return EXIT_FAILURE;
226 }
227 std::ofstream fuDescOutput;
228 std::ofstream asDescOutput;
229 try {
230 fuDescOutput.open(
231 (options.outputFileNameSuffix() + ".fu_table.tex").c_str(),
232 std::ios::trunc);
233 asDescOutput.open(
234 (options.outputFileNameSuffix() + ".as_table.tex").c_str(),
235 std::ios::trunc);
236
237 } catch (std::exception& e) {
238 std::cerr << e.what() << std::endl;
239 return EXIT_FAILURE;
240 }
241 if (options.outputFormat() == "latex") {
242 printLatexFunctionUnitDescription(*mach, fuDescOutput);
243 printLatexAddressSpaceDescription(*mach, asDescOutput);
244 }
245 fuDescOutput.close();
246 asDescOutput.close();
247 return EXIT_SUCCESS;
248}
void printLatexAddressSpaceDescription(const TTAMachine::Machine &machine, std::ofstream &output)
Definition MachInfo.cc:149
void printLatexFunctionUnitDescription(const TTAMachine::Machine &machine, std::ofstream &output)
Definition MachInfo.cc:72
static MachInfoCmdLineOptions options
Definition MachInfo.cc:46
void parse(char *argv[], int argc)
virtual std::string argument(int index) const
virtual int numberOfArguments() const
std::string errorMessage() const
Definition Exception.cc:123
TCEString outputFileNameSuffix() const
static Machine * loadFromADF(const std::string &adfFileName)
Definition Machine.cc:899

References CmdLineParser::argument(), Exception::errorMessage(), TTAMachine::Machine::loadFromADF(), CmdLineParser::numberOfArguments(), options, MachInfoCmdLineOptions::outputFileNameSuffix(), MachInfoCmdLineOptions::outputFormat(), CmdLineOptions::parse(), printLatexAddressSpaceDescription(), and printLatexFunctionUnitDescription().

Here is the call graph for this function:

◆ operandBindingsString()

TCEString operandBindingsString ( TTAMachine::HWOperation hwop)

Definition at line 49 of file MachInfo.cc.

49 {
50 OperationPool OSAL;
51 Operation* osalOp = &OSAL.operation(hwop.name().c_str());
52 if (osalOp == &NullOperation::instance()) {
53 return TCEString("");
54 }
55 TCEString operandBindings = "";
56 for (int i = 1; i < osalOp->operandCount() + 1; i++) {
57 if (hwop.port(i) == NULL) {
58 std::cerr << "Warning: Operand " << i << " of " << hwop.name()
59 << " was not bound to any port." << std::endl;
60 continue;
61 }
62 if (i > 1) {
63 operandBindings += ", ";
64 }
65 operandBindings += Conversion::toString(i) + ": "
66 + hwop.port(i)->name();
67 }
68 return operandBindings;
69}
static std::string toString(const T &source)
static NullOperation & instance()
Operation & operation(const char *name)
virtual int operandCount() const
Definition Operation.cc:212
virtual FUPort * port(int operand) const
const std::string & name() const
virtual std::string name() const
Definition Port.cc:141

References NullOperation::instance(), TTAMachine::HWOperation::name(), TTAMachine::Port::name(), Operation::operandCount(), OperationPool::operation(), TTAMachine::HWOperation::port(), and Conversion::toString().

Referenced by printLatexFunctionUnitDescription().

Here is the call graph for this function:

◆ printLatexAddressSpaceDescription()

void printLatexAddressSpaceDescription ( const TTAMachine::Machine machine,
std::ofstream &  output 
)

Definition at line 149 of file MachInfo.cc.

150 {
151
152 output << "\\begin{tabular}{|l|l|l|l|l|}" << std::endl;
153
154 output << "\\hline" << std::endl;
155
156 output << "name & start address & end address & width (b) & "
157 << "numerical id(s) \\\\"
158 << std::endl;
159
160 output << "\\hline" << std::endl;
161
164 for (int i = 0; i < nav.count(); ++i) {
165 TTAMachine::AddressSpace& as = *nav.item(i);
166 if (&as == machine.controlUnit()->addressSpace())
167 continue;
168 output << as.name() << " & " << as.start() << " & " << as.end()
169 << " & " << as.width() << " & ";
170 std::set<unsigned> ids = as.numericalIds();
171 for (std::set<unsigned>::iterator i = ids.begin(), e = ids.end();
172 i != e; ++i) {
173 output << *i << " ";
174 }
175 output << "\\\\" << std::endl;
176 }
177
178 output << "\\hline" << std::endl;
179 output << "\\hline" << std::endl;
180
182
183 output << as.name() << " & " << as.start() << " & " << as.end() << " & "
184 << as.width() << " & ";
185 std::set<unsigned> ids = as.numericalIds();
186 for (std::set<unsigned>::iterator i = ids.begin(), e = ids.end(); i != e;
187 ++i) {
188 output << *i << " ";
189 }
190 output << "\\\\" << std::endl;
191
192 output << "\\hline" << std::endl;
193
194 output << "\\end{tabular}" << std::endl;
195}
TTAMachine::Machine * machine
the architecture definition of the estimated processor
virtual ULongWord end() const
std::set< unsigned > numericalIds() const
virtual int width() const
virtual ULongWord start() const
virtual TCEString name() const
virtual AddressSpace * addressSpace() const
ComponentType * item(int index) const
virtual AddressSpaceNavigator addressSpaceNavigator() const
Definition Machine.cc:392
virtual ControlUnit * controlUnit() const
Definition Machine.cc:345

References TTAMachine::FunctionUnit::addressSpace(), TTAMachine::Machine::addressSpaceNavigator(), TTAMachine::Machine::controlUnit(), TTAMachine::Machine::Navigator< ComponentType >::count(), TTAMachine::AddressSpace::end(), TTAMachine::Machine::Navigator< ComponentType >::item(), machine, TTAMachine::Component::name(), TTAMachine::AddressSpace::numericalIds(), TTAMachine::AddressSpace::start(), and TTAMachine::AddressSpace::width().

Referenced by main().

Here is the call graph for this function:

◆ printLatexFunctionUnitDescription()

void printLatexFunctionUnitDescription ( const TTAMachine::Machine machine,
std::ofstream &  output 
)

Definition at line 72 of file MachInfo.cc.

73 {
74
75 OperationPool OSAL;
76
77 output << "\\begin{longtable}{|l|p{7cm}|p{3.5cm}|}" << std::endl;
78
81 for (int i = 0; i < nav.count(); ++i) {
82 TTAMachine::FunctionUnit& fu = *nav.item(i);
83 output << "\\hline" << std::endl;
84 // TODO: print description here
85 TCEString fuDescription;
86 if (fu.hasAddressSpace()) {
87 fuDescription << " Accesses address space \\textbf{"
88 << fu.addressSpace()->name() << "}.\n";
89 }
90 output << fu.name() << "\t& \\multicolumn{2}{p{10cm}|}{"
91 << fuDescription << "} \\\\" << std::endl;
92 output << "\\hline" << std::endl;
93 for (int op = 0; op < fu.operationCount(); ++op) {
94 TTAMachine::HWOperation& hwop = *fu.operation(op);
95 Operation* osalOp = NULL;
96 TCEString description;
97 TCEString operandBindings;
98 if (&OSAL.operation(hwop.name().c_str())
100 osalOp = &OSAL.operation(hwop.name().c_str());
101 description = osalOp->description();
102 operandBindings = operandBindingsString(hwop);
103 } else {
104 std::cerr << "warning: Could not find OSAL data for operation '"
105 << hwop.name() << "." << std::endl;
106 }
107
108 TCEString opname = hwop.name();
109 opname = opname.replaceString("_", "\\_");
110 operandBindings = operandBindings.replaceString("_", "\\_");
111 output << "\\footnotesize{" << opname << " (" << hwop.latency() - 1
112 << ")} & \\footnotesize{" << description
113 << "} & \\footnotesize{" << operandBindings << "}\\\\"
114 << std::endl;
115 }
116 }
117 output << "\\hline" << std::endl;
118 output << "\\hline" << std::endl;
119
121 output << fu.name() << "\t & control unit & \t \\\\" << std::endl;
122
123 output << "\\hline" << std::endl;
124 for (int op = 0; op < fu.operationCount(); ++op) {
125 TTAMachine::HWOperation& hwop = *fu.operation(op);
126 Operation* osalOp = NULL;
127 TCEString description;
128 if (&OSAL.operation(hwop.name().c_str())
130 osalOp = &OSAL.operation(hwop.name().c_str());
131 description = osalOp->description();
132 } else {
133 std::cerr << "warning: Could not find OSAL data for operation '"
134 << hwop.name() << "." << std::endl;
135 }
136 TCEString opname = hwop.name();
137 opname = opname.replaceString("_", "\\_");
138 output << opname << " (" << hwop.latency() - 1 << ") & \\small{"
139 << description << "} & \\\\" << std::endl;
140 }
141
142 output << "\\hline" << std::endl;
143
144 output << "\\end{longtable}" << std::endl;
145
146}
TCEString operandBindingsString(TTAMachine::HWOperation &hwop)
Definition MachInfo.cc:49
virtual TCEString description() const
Definition Operation.cc:103
TCEString & replaceString(const std::string &old, const std::string &newString)
Definition TCEString.cc:94
virtual HWOperation * operation(const std::string &name) const
virtual int operationCount() const
virtual bool hasAddressSpace() const
virtual FunctionUnitNavigator functionUnitNavigator() const
Definition Machine.cc:380

References TTAMachine::FunctionUnit::addressSpace(), TTAMachine::Machine::controlUnit(), TTAMachine::Machine::Navigator< ComponentType >::count(), Operation::description(), TTAMachine::Machine::functionUnitNavigator(), TTAMachine::FunctionUnit::hasAddressSpace(), NullOperation::instance(), TTAMachine::Machine::Navigator< ComponentType >::item(), TTAMachine::HWOperation::latency(), machine, TTAMachine::HWOperation::name(), TTAMachine::Component::name(), operandBindingsString(), OperationPool::operation(), TTAMachine::FunctionUnit::operation(), TTAMachine::FunctionUnit::operationCount(), and TCEString::replaceString().

Referenced by main().

Here is the call graph for this function:

Variable Documentation

◆ options

MachInfoCmdLineOptions options
static

Definition at line 46 of file MachInfo.cc.

Referenced by ProGe::NetlistGenerator::addIUToNetlist(), GUIOptionsSerializer::addKeyboardShortcut(), llvm::TCEPassConfig::addPreISel(), ProGe::NetlistGenerator::addRFToNetlist(), ProGeTools::checkForGeneratableFU(), Automagic::checkForGeneratableFU(), ProGeTools::checkForSelectableFU(), Automagic::checkForSelectableFU(), ProGeTools::checkForSelectableIU(), Automagic::checkForSelectableIU(), ProGeTools::checkForSelectableRF(), Automagic::checkForSelectableRF(), llvm::LLVMTCEIRBuilder::compileOptimized(), GUIOptionsSerializer::convertToConfigFileFormat(), ProDeOptionsSerializer::convertToConfigFileFormat(), GUIOptionsSerializer::convertToOptionsObjectFormat(), ProDeOptionsSerializer::convertToOptionsObjectFormat(), ProGeTools::createFUGeneratableOperationInfos(), Automagic::createFUGeneratableOperationInfos(), llvm::TCETargetMachine::createMachine(), ProximMainFrame::createToolbar(), MainFrame::createToolbar(), DataDependenceGraphBuilder::DataDependenceGraphBuilder(), OSEdModifyBehaviorCmd::Do(), ProximOptionsCmd::Do(), ProximQuitCmd::Do(), EditOptionsCmd::Do(), QuitCmd::Do(), SaveOptionsCmd::Do(), llvm::TCERegisterInfo::eliminateFrameIndex(), ProGe::NetlistGenerator::generate(), ProGe::ProGeUI::generateIDF(), ProGe::ProcessorGenerator::generateProcessor(), ProGe::ProGeUI::generateProcessor(), GenerateProcessor::generateProcessor(), GenerateProcessor::getOutputDir(), llvm::TCERegisterInfo::getReservedRegs(), BBSchedulerController::handleBasicBlock(), FUGen::implement(), llvm::TCETTIImpl::isHardwareLoopProfitable(), llvm::LLVMTCEScheduler::LLVMTCEScheduler(), loadInputs(), loadPluginParameters(), main(), ProximMainFrame::menuAccelerator(), MainFrame::menuAccelerator(), GenerateProcessorDialog::onOK(), OperationPropertyDialog::onOpen(), ResultDialog::onOpen(), OSEdOptionsDialog::onSave(), MainFrame::onToggleToolbar(), CmdLineParser::parse(), Model::pushToStack(), GUIOptionsSerializer::readOptions(), DesignSpaceExplorer::schedule(), Application::setCmdLineOptions(), ProgramImageGenerator::setDataStartOptions(), GUIOptionsSerializer::setToolbarProperties(), GUIOptionsSerializer::setWindowProperties(), SimpleBrokerDirector::SimpleBrokerDirector(), CmdLineParser::storeOptions(), OSEdOptionsDialog::TransferDataToWindow(), MainFrame::updateUI(), GenerateProcessor::validIntegratorParameters(), GUIOptionsSerializer::writeOptions(), and llvm::LLVMTCEIRBuilder::~LLVMTCEIRBuilder().