OpenASIP 2.2
Loading...
Searching...
No Matches
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) {}
const TTAMachine::Machine * mach_

◆ ~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}
#define THROW_EXCEPTION(exceptionType, message)
Exception wrapper macro that automatically includes file name, line number and function name where th...
Definition Exception.hh:39
std::map< OperationType, EncodingType, TCEString::ICLess > OperationEncodingMapType
OperationEncodingMapType encodings() const

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}
#define assert(condition)
TCETools::CIStringSet OperationSet
static OperationSet getOpset(const TTAMachine::Machine &mach)
size_t encoding(const std::string &operName) const
static std::string stringToLower(const std::string &source)
virtual ControlUnit * controlUnit() const
Definition Machine.cc:345

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}
static int requiredBits(unsigned long int number)
virtual int operationCount() const

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

Referenced by DefaultICDecoderGenerator::generate(), and 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}
void WriteVhdlOpcodePackage(const OperationEncodingMapType &encodings, std::ofstream &stream) const
void WriteVerilogOpcodePackage(const OperationEncodingMapType &encodings, std::ofstream &stream) const
@ Verilog
Verilog.
Definition ProGeTypes.hh:42
@ VHDL
VHDL.
Definition ProGeTypes.hh:41

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}
static size_t gcuOpcodeWidth(const TTAMachine::Machine &mach)

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}
static std::string toString(const T &source)
static std::string stringToUpper(const std::string &source)

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: