OpenASIP  2.0
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 }

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 }

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 }

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())
129  != &NullOperation::instance()) {
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 }

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(), Automagic::checkForSelectableFU(), ProGeTools::checkForSelectableFU(), Automagic::checkForSelectableIU(), ProGeTools::checkForSelectableIU(), Automagic::checkForSelectableRF(), ProGeTools::checkForSelectableRF(), llvm::LLVMTCEIRBuilder::compileOptimized(), ProDeOptionsSerializer::convertToConfigFileFormat(), GUIOptionsSerializer::convertToConfigFileFormat(), ProDeOptionsSerializer::convertToOptionsObjectFormat(), GUIOptionsSerializer::convertToOptionsObjectFormat(), ProGeTools::createFUGeneratableOperationInfos(), Automagic::createFUGeneratableOperationInfos(), MainFrame::createToolbar(), ProximMainFrame::createToolbar(), DataDependenceGraphBuilder::DataDependenceGraphBuilder(), QuitCmd::Do(), EditOptionsCmd::Do(), SaveOptionsCmd::Do(), ProximOptionsCmd::Do(), ProximQuitCmd::Do(), OSEdModifyBehaviorCmd::Do(), llvm::TCERegisterInfo::eliminateFrameIndex(), ProGe::NetlistGenerator::generate(), ProGe::ProGeUI::generateIDF(), GenerateProcessor::generateProcessor(), ProGe::ProGeUI::generateProcessor(), ProGe::ProcessorGenerator::generateProcessor(), GenerateProcessor::getOutputDir(), llvm::TCERegisterInfo::getReservedRegs(), BBSchedulerController::handleBasicBlock(), FUGen::implement(), llvm::TCETTIImpl::isHardwareLoopProfitable(), llvm::LLVMTCEScheduler::LLVMTCEScheduler(), loadInputs(), loadPluginParameters(), main(), MainFrame::menuAccelerator(), ProximMainFrame::menuAccelerator(), GenerateProcessorDialog::onOK(), ResultDialog::onOpen(), OperationPropertyDialog::onOpen(), OSEdOptionsDialog::onSave(), MainFrame::onToggleToolbar(), CmdLineParser::parse(), Model::pushToStack(), GUIOptionsSerializer::readOptions(), DesignSpaceExplorer::schedule(), Application::setCmdLineOptions(), GUIOptionsSerializer::setToolbarProperties(), GUIOptionsSerializer::setWindowProperties(), SimpleBrokerDirector::SimpleBrokerDirector(), CmdLineParser::storeOptions(), OSEdOptionsDialog::TransferDataToWindow(), MainFrame::updateUI(), GenerateProcessor::validIntegratorParameters(), GUIOptionsSerializer::writeOptions(), and llvm::LLVMTCEIRBuilder::~LLVMTCEIRBuilder().

OperationPool::operation
Operation & operation(const char *name)
Definition: OperationPool.cc:99
TTAMachine::Component::name
virtual TCEString name() const
Definition: MachinePart.cc:125
ParserStopRequest
Definition: Exception.hh:491
TTAMachine::FunctionUnit::hasAddressSpace
virtual bool hasAddressSpace() const
Definition: FunctionUnit.cc:608
machine
TTAMachine::Machine * machine
the architecture definition of the estimated processor
Definition: EstimatorCmdLineUI.cc:59
TTAMachine::HWOperation
Definition: HWOperation.hh:52
TTAMachine::AddressSpace::numericalIds
std::set< unsigned > numericalIds() const
Definition: AddressSpace.cc:393
TTAMachine::AddressSpace
Definition: AddressSpace.hh:51
CmdLineParser::numberOfArguments
virtual int numberOfArguments() const
printLatexFunctionUnitDescription
void printLatexFunctionUnitDescription(const TTAMachine::Machine &machine, std::ofstream &output)
Definition: MachInfo.cc:72
operandBindingsString
TCEString operandBindingsString(TTAMachine::HWOperation &hwop)
Definition: MachInfo.cc:49
IllegalCommandLine
Definition: Exception.hh:438
TTAMachine::FunctionUnit::addressSpace
virtual AddressSpace * addressSpace() const
Definition: FunctionUnit.cc:580
TTAMachine::Machine::Navigator::count
int count() const
NullOperation::instance
static NullOperation & instance()
Conversion::toString
static std::string toString(const T &source)
TTAMachine::FunctionUnit
Definition: FunctionUnit.hh:55
TTAMachine::HWOperation::port
virtual FUPort * port(int operand) const
Definition: HWOperation.cc:320
TTAMachine::Machine::controlUnit
virtual ControlUnit * controlUnit() const
Definition: Machine.cc:345
TTAMachine::HWOperation::name
const std::string & name() const
Definition: HWOperation.cc:141
MachInfoCmdLineOptions::outputFileNameSuffix
TCEString outputFileNameSuffix() const
Definition: MachInfoCmdLineOptions.cc:63
TTAMachine::Machine::functionUnitNavigator
virtual FunctionUnitNavigator functionUnitNavigator() const
Definition: Machine.cc:380
TTAMachine::FunctionUnit::operationCount
virtual int operationCount() const
Definition: FunctionUnit.cc:419
Exception
Definition: Exception.hh:54
TTAMachine::Machine::addressSpaceNavigator
virtual AddressSpaceNavigator addressSpaceNavigator() const
Definition: Machine.cc:392
Operation
Definition: Operation.hh:59
Exception::errorMessage
std::string errorMessage() const
Definition: Exception.cc:123
Operation::operandCount
virtual int operandCount() const
Definition: Operation.cc:212
CmdLineOptions::parse
void parse(char *argv[], int argc)
Definition: CmdLineOptions.cc:107
TCEString::replaceString
TCEString & replaceString(const std::string &old, const std::string &newString)
Definition: TCEString.cc:94
MachInfoCmdLineOptions::outputFormat
TCEString outputFormat() const
Definition: MachInfoCmdLineOptions.cc:71
options
static MachInfoCmdLineOptions options
Definition: MachInfo.cc:46
Operation::description
virtual TCEString description() const
Definition: Operation.cc:103
TTAMachine::AddressSpace::width
virtual int width() const
Definition: AddressSpace.cc:155
TTAMachine::Port::name
virtual std::string name() const
Definition: Port.cc:141
TCEString
Definition: TCEString.hh:53
printLatexAddressSpaceDescription
void printLatexAddressSpaceDescription(const TTAMachine::Machine &machine, std::ofstream &output)
Definition: MachInfo.cc:149
TTAMachine::Machine::Navigator::item
ComponentType * item(int index) const
TTAMachine::FunctionUnit::operation
virtual HWOperation * operation(const std::string &name) const
Definition: FunctionUnit.cc:363
TTAMachine::HWOperation::latency
int latency() const
Definition: HWOperation.cc:216
OperationPool
Definition: OperationPool.hh:52
CmdLineParser::argument
virtual std::string argument(int index) const
TTAMachine::AddressSpace::start
virtual ULongWord start() const
Definition: AddressSpace.cc:166
TTAMachine::Machine::Navigator
Definition: Machine.hh:186
TTAMachine::AddressSpace::end
virtual ULongWord end() const
Definition: AddressSpace.cc:177
TTAMachine::Machine
Definition: Machine.hh:73
TTAMachine::Machine::loadFromADF
static Machine * loadFromADF(const std::string &adfFileName)
Definition: Machine.cc:905