OpenASIP  2.0
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
ProGe::CUOpcodeGenerator Class Reference

#include <CUOpcodeGenerator.hh>

Collaboration diagram for ProGe::CUOpcodeGenerator:
Collaboration graph

Public Types

typedef std::string OperationType
 
typedef size_t EncodingType
 
typedef std::map< OperationType, EncodingType, TCEString::ICLessOperationEncodingMapType
 

Public Member Functions

 CUOpcodeGenerator (const TTAMachine::Machine &mach, const std::string &entityName="tta0")
 
virtual ~CUOpcodeGenerator ()
 
OperationEncodingMapType encodings () const
 
size_t encoding (const std::string &operName) const
 
size_t opcodeWidth () const
 
void generateOpcodePackage (HDL language, std::ofstream &stream) const
 

Static Public Member Functions

static size_t gcuOpcodeWidth (const TTAMachine::Machine &mach)
 

Private Member Functions

 CUOpcodeGenerator ()
 
void WriteVhdlOpcodePackage (const OperationEncodingMapType &encodings, std::ofstream &stream) const
 
void WriteVerilogOpcodePackage (const OperationEncodingMapType &encodings, std::ofstream &stream) const
 

Private Attributes

const TTAMachine::Machinemach_
 
const std::string entityStr_
 

Detailed Description

Class that for given ADF generates encodings for Global Control Unit and RTL package that holds encoding information for CU RTL source codes.

Definition at line 57 of file CUOpcodeGenerator.hh.

Member Typedef Documentation

◆ EncodingType

Definition at line 61 of file CUOpcodeGenerator.hh.

◆ OperationEncodingMapType

Definition at line 63 of file CUOpcodeGenerator.hh.

◆ OperationType

Definition at line 60 of file CUOpcodeGenerator.hh.

Constructor & Destructor Documentation

◆ CUOpcodeGenerator() [1/2]

ProGe::CUOpcodeGenerator::CUOpcodeGenerator ( const TTAMachine::Machine mach,
const std::string &  entityName = "tta0" 
)

Definition at line 55 of file CUOpcodeGenerator.cc.

57  : mach_(&mach), entityStr_(entityName) {}

◆ ~CUOpcodeGenerator()

ProGe::CUOpcodeGenerator::~CUOpcodeGenerator ( )
virtual

Definition at line 61 of file CUOpcodeGenerator.cc.

61 {}

◆ CUOpcodeGenerator() [2/2]

ProGe::CUOpcodeGenerator::CUOpcodeGenerator ( )
private

Definition at line 59 of file CUOpcodeGenerator.cc.

59 : mach_(NULL), entityStr_() {}

Member Function Documentation

◆ encoding()

size_t ProGe::CUOpcodeGenerator::encoding ( const std::string &  operName) const

Definition at line 84 of file CUOpcodeGenerator.cc.

84  {
86  if (encMap.count(operName)) {
87  return encMap.at(operName);
88  } else {
90  InstanceNotFound, "CU does not have operation" + operName + ".");
91  }
92 }

References encodings(), and THROW_EXCEPTION.

Referenced by encodings(), and DefaultDecoderGenerator::opcode().

Here is the call graph for this function:

◆ encodings()

CUOpcodeGenerator::OperationEncodingMapType ProGe::CUOpcodeGenerator::encodings ( ) const

Definition at line 67 of file CUOpcodeGenerator.cc.

67  {
68  assert(mach_ != NULL);
69 
72  size_t encoding = 0;
74 
75  MachineInfo::OperationSet::iterator it;
76  for (it = gcuOps.begin(); it != gcuOps.end(); it++) {
77  encMap.insert(make_pair(StringTools::stringToLower(*it), encoding));
78  encoding++;
79  }
80  return encMap;
81 }

References assert, TTAMachine::Machine::controlUnit(), encoding(), MachineInfo::getOpset(), mach_, and StringTools::stringToLower().

Referenced by encoding(), generateOpcodePackage(), WriteVerilogOpcodePackage(), and WriteVhdlOpcodePackage().

Here is the call graph for this function:

◆ gcuOpcodeWidth()

size_t ProGe::CUOpcodeGenerator::gcuOpcodeWidth ( const TTAMachine::Machine mach)
static

Definition at line 140 of file CUOpcodeGenerator.cc.

140  {
141  const TTAMachine::ControlUnit* gcu = mach.controlUnit();
142  size_t opCount = gcu->operationCount();
143  if (opCount == 0) {
144  return 0;
145  } else {
146  return std::max(MathTools::requiredBits(opCount - 1), 1);
147  }
148 }

References TTAMachine::Machine::controlUnit(), TTAMachine::FunctionUnit::operationCount(), and MathTools::requiredBits().

Referenced by opcodeWidth().

Here is the call graph for this function:

◆ generateOpcodePackage()

void ProGe::CUOpcodeGenerator::generateOpcodePackage ( HDL  language,
std::ofstream &  stream 
) const

Definition at line 114 of file CUOpcodeGenerator.cc.

115  {
116  OperationEncodingMapType gcuEncodings = encodings();
117 
118  // Add dummy operations for missing CALL and JUMP operations since ifetch
119  // templates refers to them.
120  gcuEncodings.insert(
121  make_pair(OperationType("call"), gcuEncodings.size()));
122  gcuEncodings.insert(
123  make_pair(OperationType("jump"), gcuEncodings.size()));
124 
125  if (language == VHDL) {
126  WriteVhdlOpcodePackage(gcuEncodings, stream);
127  } else if (language == Verilog) {
128  WriteVerilogOpcodePackage(gcuEncodings, stream);
129  } else {
130  assert(false && "Unsupported HDL.");
131  }
132 }

References assert, encodings(), ProGe::Verilog, ProGe::VHDL, WriteVerilogOpcodePackage(), and WriteVhdlOpcodePackage().

Referenced by ProGe::ProcessorGenerator::generateGCUOpcodesPackage().

Here is the call graph for this function:

◆ opcodeWidth()

size_t ProGe::CUOpcodeGenerator::opcodeWidth ( ) const

Definition at line 98 of file CUOpcodeGenerator.cc.

98  {
100 }

References gcuOpcodeWidth(), and mach_.

Here is the call graph for this function:

◆ WriteVerilogOpcodePackage()

void ProGe::CUOpcodeGenerator::WriteVerilogOpcodePackage ( const OperationEncodingMapType encodings,
std::ofstream &  stream 
) const
private

Definition at line 173 of file CUOpcodeGenerator.cc.

174  {
175  if (encodings.empty()) {
176  return;
177  }
178 
179  OperationEncodingMapType::const_iterator it;
180  for (it = encodings.begin(); it != encodings.end(); it++) {
181  stream << "parameter IFE_" << StringTools::stringToUpper(it->first)
182  << "=" << Conversion::toString(it->second);
183  if (it != --encodings.end()) {
184  stream << "," << endl;
185  } else {
186  stream << endl;
187  }
188  }
189 }

References encodings(), StringTools::stringToUpper(), and Conversion::toString().

Referenced by generateOpcodePackage().

Here is the call graph for this function:

◆ WriteVhdlOpcodePackage()

void ProGe::CUOpcodeGenerator::WriteVhdlOpcodePackage ( const OperationEncodingMapType encodings,
std::ofstream &  stream 
) const
private

Definition at line 154 of file CUOpcodeGenerator.cc.

155  {
156  stream << "library IEEE;" << endl
157  << "use IEEE.std_logic_1164.all;" << endl
158  << endl
159  << "package " + entityStr_ + "_gcu_opcodes is" << endl;
160  OperationEncodingMapType::const_iterator it;
161  for (it = encodings.begin(); it != encodings.end(); it++) {
162  stream << " constant IFE_" << StringTools::stringToUpper(it->first)
163  << " : natural := " << Conversion::toString(it->second) << ";"
164  << endl;
165  }
166  stream << "end " + entityStr_ + "_gcu_opcodes;" << endl;
167 }

References encodings(), entityStr_, StringTools::stringToUpper(), and Conversion::toString().

Referenced by generateOpcodePackage().

Here is the call graph for this function:

Member Data Documentation

◆ entityStr_

const std::string ProGe::CUOpcodeGenerator::entityStr_
private

Definition at line 86 of file CUOpcodeGenerator.hh.

Referenced by WriteVhdlOpcodePackage().

◆ mach_

const TTAMachine::Machine* ProGe::CUOpcodeGenerator::mach_
private

Definition at line 85 of file CUOpcodeGenerator.hh.

Referenced by encodings(), and opcodeWidth().


The documentation for this class was generated from the following files:
ProGe::Verilog
@ Verilog
Verilog.
Definition: ProGeTypes.hh:42
ProGe::CUOpcodeGenerator::OperationType
std::string OperationType
Definition: CUOpcodeGenerator.hh:60
ProGe::CUOpcodeGenerator::WriteVerilogOpcodePackage
void WriteVerilogOpcodePackage(const OperationEncodingMapType &encodings, std::ofstream &stream) const
Definition: CUOpcodeGenerator.cc:173
Conversion::toString
static std::string toString(const T &source)
StringTools::stringToUpper
static std::string stringToUpper(const std::string &source)
Definition: StringTools.cc:143
assert
#define assert(condition)
Definition: Application.hh:86
ProGe::CUOpcodeGenerator::gcuOpcodeWidth
static size_t gcuOpcodeWidth(const TTAMachine::Machine &mach)
Definition: CUOpcodeGenerator.cc:140
TTAMachine::Machine::controlUnit
virtual ControlUnit * controlUnit() const
Definition: Machine.cc:345
ProGe::VHDL
@ VHDL
VHDL.
Definition: ProGeTypes.hh:41
TTAMachine::ControlUnit
Definition: ControlUnit.hh:50
THROW_EXCEPTION
#define THROW_EXCEPTION(exceptionType, message)
Exception wrapper macro that automatically includes file name, line number and function name where th...
Definition: Exception.hh:39
MachineInfo::getOpset
static OperationSet getOpset(const TTAMachine::Machine &mach)
Definition: MachineInfo.cc:65
ProGe::CUOpcodeGenerator::mach_
const TTAMachine::Machine * mach_
Definition: CUOpcodeGenerator.hh:85
TTAMachine::FunctionUnit::operationCount
virtual int operationCount() const
Definition: FunctionUnit.cc:419
MathTools::requiredBits
static int requiredBits(unsigned long int number)
ProGe::CUOpcodeGenerator::entityStr_
const std::string entityStr_
Definition: CUOpcodeGenerator.hh:86
ProGe::CUOpcodeGenerator::encoding
size_t encoding(const std::string &operName) const
Definition: CUOpcodeGenerator.cc:84
MachineInfo::OperationSet
TCETools::CIStringSet OperationSet
Definition: MachineInfo.hh:60
ProGe::CUOpcodeGenerator::WriteVhdlOpcodePackage
void WriteVhdlOpcodePackage(const OperationEncodingMapType &encodings, std::ofstream &stream) const
Definition: CUOpcodeGenerator.cc:154
ProGe::CUOpcodeGenerator::encodings
OperationEncodingMapType encodings() const
Definition: CUOpcodeGenerator.cc:67
ProGe::CUOpcodeGenerator::OperationEncodingMapType
std::map< OperationType, EncodingType, TCEString::ICLess > OperationEncodingMapType
Definition: CUOpcodeGenerator.hh:63
StringTools::stringToLower
static std::string stringToLower(const std::string &source)
Definition: StringTools.cc:160
InstanceNotFound
Definition: Exception.hh:304