OpenASIP 2.2
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Types | Private Attributes | List of all members
HDB::FUImplementation Class Reference

#include <FUImplementation.hh>

Inheritance diagram for HDB::FUImplementation:
Inheritance graph
Collaboration diagram for HDB::FUImplementation:
Collaboration graph

Public Types

typedef HDB::Parameter Parameter
 Parameter of FU implementation.
 

Public Member Functions

 FUImplementation (const std::string &name, const std::string &opcodePort, const std::string &clkPort, const std::string &rstPort, const std::string &glockPort, const std::string &glockReqPort)
 
virtual ~FUImplementation ()
 
 FUImplementation (const FUImplementation &o)
 
void setOpcodePort (const std::string &name)
 
std::string opcodePort () const
 
void setGlockReqPort (const std::string &name)
 
std::string glockReqPort () const
 
void setOpcode (const std::string &operation, int opcode)
 
void unsetOpcode (const std::string &operation)
 
int opcodeCount () const
 
std::string opcodeOperation (int index) const
 
bool hasOpcode (const std::string &operation) const
 
int opcode (const std::string &operation) const
 
int maxOpcodeWidth () const
 
void addArchitecturePort (FUPortImplementation *port)
 
void deleteArchitecturePort (FUPortImplementation *port)
 
void addExternalPort (FUExternalPort *port)
 
void deleteExternalPort (FUExternalPort *port)
 
int architecturePortCount () const
 
int externalPortCount () const
 
FUPortImplementationarchitecturePort (int index) const
 
FUPortImplementationportImplementationByArchitectureName (const std::string &architectureName) const
 
FUExternalPortexternalPort (int index) const
 
void addParameter (const std::string &name, const std::string &type, const std::string &value)
 
void removeParameter (const std::string &name)
 
int parameterCount () const
 
Parameter parameter (int index) const
 
bool hasParameter (const std::string &name) const
 
- Public Member Functions inherited from HDB::HWBlockImplementation
 HWBlockImplementation (const std::string &moduleName, const std::string &clkPort, const std::string &rstPort, const std::string &glockPort)
 
 HWBlockImplementation (const HWBlockImplementation &b)
 
virtual ~HWBlockImplementation ()
 
bool hasID () const
 
void setID (RowID id)
 
RowID id () const
 
void setModuleName (const std::string &name)
 
std::string moduleName () const
 
void setClkPort (const std::string &name)
 
std::string clkPort () const
 
void setRstPort (const std::string &name)
 
std::string rstPort () const
 
void setGlockPort (const std::string &name)
 
std::string glockPort () const
 
void addImplementationFile (BlockImplementationFile *file)
 
void removeImplementationFile (const BlockImplementationFile &file)
 
int implementationFileCount () const
 
BlockImplementationFilefile (int index) const
 

Private Types

typedef std::vector< FUPortImplementation * > PortTable
 Vector type for FUPortImplementation.
 
typedef std::vector< FUExternalPort * > ExternalPortTable
 Vector type for FUExternalPort.
 
typedef std::map< std::string, int > OpcodeMap
 Map type for operation codes.
 
typedef std::vector< ParameterParameterTable
 Vector type for parameter names.
 

Private Attributes

std::string opcodePort_
 Name of the opcode port.
 
std::string glockReqPort_
 Name of the global lock request port.
 
PortTable ports_
 Contains the architectural ports.
 
ExternalPortTable externalPorts_
 Contains the external ports.
 
OpcodeMap opcodes_
 Contains the operation codes.
 
ParameterTable parameters_
 Contains the parameters.
 

Detailed Description

Represents the implementation specific properties of an FU in HDB.

Definition at line 53 of file FUImplementation.hh.

Member Typedef Documentation

◆ ExternalPortTable

Vector type for FUExternalPort.

Definition at line 112 of file FUImplementation.hh.

◆ OpcodeMap

typedef std::map<std::string, int> HDB::FUImplementation::OpcodeMap
private

Map type for operation codes.

Definition at line 114 of file FUImplementation.hh.

◆ Parameter

Parameter of FU implementation.

Definition at line 61 of file FUImplementation.hh.

◆ ParameterTable

typedef std::vector<Parameter> HDB::FUImplementation::ParameterTable
private

Vector type for parameter names.

Definition at line 116 of file FUImplementation.hh.

◆ PortTable

Vector type for FUPortImplementation.

Definition at line 110 of file FUImplementation.hh.

Constructor & Destructor Documentation

◆ FUImplementation() [1/2]

HDB::FUImplementation::FUImplementation ( const std::string &  name,
const std::string &  opcodePort,
const std::string &  clkPort,
const std::string &  rstPort,
const std::string &  glockPort,
const std::string &  glockReqPort 
)

The constructor.

Parameters
nameName of the module.
opcodePortName of the opcode port.
clkPortName of the clock port.
rstPortName of the reset port.
glockPortName of the global lock port.
glockReqPortName of the global lock request port.

Definition at line 62 of file FUImplementation.cc.

68 :
71}
std::string glockReqPort_
Name of the global lock request port.
std::string glockReqPort() const
std::string opcodePort_
Name of the opcode port.
std::string opcodePort() const
HWBlockImplementation(const std::string &moduleName, const std::string &clkPort, const std::string &rstPort, const std::string &glockPort)

◆ ~FUImplementation()

HDB::FUImplementation::~FUImplementation ( )
virtual

The destructor.

Deletes all the ports.

Definition at line 113 of file FUImplementation.cc.

113 {
116}
PortTable ports_
Contains the architectural ports.
ExternalPortTable externalPorts_
Contains the external ports.
static void deleteAllItems(SequenceType &aSequence)

References SequenceTools::deleteAllItems(), externalPorts_, and ports_.

Here is the call graph for this function:

◆ FUImplementation() [2/2]

HDB::FUImplementation::FUImplementation ( const FUImplementation original)

Copy constructor.

Parameters
originalFUImplementation to copy.

Definition at line 79 of file FUImplementation.cc.

79 :
80 HWBlockImplementation(original) {
81
82 opcodePort_ = original.opcodePort_;
83 glockReqPort_ = original.glockReqPort_;
84 opcodes_ = original.opcodes_;
85 parameters_ = original.parameters_;
86
87 // Deep copy architecture ports.
88 for (int i = 0; i < original.architecturePortCount(); i++) {
89
90 FUPortImplementation* portCopy =
91 new FUPortImplementation(original.architecturePort(i));
92
93 addArchitecturePort(portCopy);
94 }
95
96 // Deep copy external ports.
97 for (int i = 0; i < original.externalPortCount(); i++) {
98
99 FUExternalPort* portCopy =
100 new FUExternalPort(original.externalPort(i));
101
102 addExternalPort(portCopy);
103 }
104}
ParameterTable parameters_
Contains the parameters.
void addArchitecturePort(FUPortImplementation *port)
OpcodeMap opcodes_
Contains the operation codes.
void addExternalPort(FUExternalPort *port)

References addArchitecturePort(), addExternalPort(), architecturePort(), architecturePortCount(), externalPort(), externalPortCount(), glockReqPort_, opcodePort_, opcodes_, and parameters_.

Here is the call graph for this function:

Member Function Documentation

◆ addArchitecturePort()

void HDB::FUImplementation::addArchitecturePort ( FUPortImplementation port)

Adds the given architectural port.

Parameters
portThe port to be added.

Definition at line 274 of file FUImplementation.cc.

274 {
275 ports_.push_back(port);
276}

References ports_.

Referenced by FUImplementation(), and HDB::FUPortImplementation::FUPortImplementation().

◆ addExternalPort()

void HDB::FUImplementation::addExternalPort ( FUExternalPort port)

Adds the given external port.

Parameters
portThe port to be added.

Definition at line 300 of file FUImplementation.cc.

300 {
301 externalPorts_.push_back(port);
302}

References externalPorts_.

Referenced by HDB::FUExternalPort::FUExternalPort(), and FUImplementation().

◆ addParameter()

void HDB::FUImplementation::addParameter ( const std::string &  name,
const std::string &  type,
const std::string &  value 
)

Adds the given parameter for the implementation.

Parameters
nameName of the parameter.
typeType of the parameter.
valueValue of the parameter.
Exceptions
IllegalParametersIf the FU implementation contains a parameter with the same name already.

Definition at line 409 of file FUImplementation.cc.

411 {
412 if (hasParameter(name)) {
413 throw IllegalParameters(__FILE__, __LINE__, __func__);
414 } else {
415 Parameter param = {name, type, value};
416 parameters_.push_back(param);
417 }
418}
#define __func__
HDB::Parameter Parameter
Parameter of FU implementation.
bool hasParameter(const std::string &name) const

References __func__, hasParameter(), and parameters_.

Referenced by FUImplementationDialog::onAddParameter(), FUImplementationDialog::onEditParameter(), and FUImplementationDialog::onParameterActivation().

Here is the call graph for this function:

◆ architecturePort()

FUPortImplementation & HDB::FUImplementation::architecturePort ( int  index) const

Returns the architectural port implementation at the given position.

Parameters
indexThe position index.
Returns
The port implementation.
Exceptions
OutOfRangeIf the given index is negative or not smaller the number of architectural ports.

Definition at line 351 of file FUImplementation.cc.

351 {
352 if (index < 0 || index >= architecturePortCount()) {
353 const string procName = "FUImplementation::architecturePort";
354 throw OutOfRange(__FILE__, __LINE__, procName);
355 }
356
357 return *ports_[index];
358}

References architecturePortCount(), and ports_.

Referenced by HDB::HDBManager::addFUImplementation(), ProGe::NetlistGenerator::addFUToNetlist(), FUTestbenchGenerator::createTbInstantiation(), FUImplementation(), HDBToHtml::fuImplToHtml(), ProGe::NetlistGenerator::isParameterizable(), FUImplementationDialog::onOK(), portImplementationByArchitectureName(), FUImplementationDialog::selectedArchPort(), and FUImplementationDialog::update().

Here is the call graph for this function:

◆ architecturePortCount()

int HDB::FUImplementation::architecturePortCount ( ) const

◆ deleteArchitecturePort()

void HDB::FUImplementation::deleteArchitecturePort ( FUPortImplementation port)

Deletes the given architectural port.

Parameters
portThe port to delete.
Exceptions
InstanceNotFoundIf the given port is not in this FU implementation.

Definition at line 287 of file FUImplementation.cc.

287 {
288 bool removed = ContainerTools::deleteValueIfExists(ports_, port);
289 if (!removed) {
290 throw InstanceNotFound(__FILE__, __LINE__, __func__);
291 }
292}
static bool deleteValueIfExists(ContainerType &aContainer, const ElementType &aKey)

References __func__, ContainerTools::deleteValueIfExists(), and ports_.

Here is the call graph for this function:

◆ deleteExternalPort()

void HDB::FUImplementation::deleteExternalPort ( FUExternalPort port)

Deletes the given external port.

Parameters
portThe port to delete.
Exceptions
InstanceNotFoundIf the given port is not in this FU implementation.

Definition at line 313 of file FUImplementation.cc.

313 {
315 if (!removed) {
316 throw InstanceNotFound(__FILE__, __LINE__, __func__);
317 }
318}

References __func__, ContainerTools::deleteValueIfExists(), and externalPorts_.

Referenced by FUImplementationDialog::onAddExternalPort(), and FUImplementationDialog::onDeleteExternalPort().

Here is the call graph for this function:

◆ externalPort()

FUExternalPort & HDB::FUImplementation::externalPort ( int  index) const

Returns the external port at the given position.

Parameters
indexThe position index.
Returns
The port.
Exceptions
OutOfRangeIf the given index is negative or not smaller the number of external ports.

Definition at line 390 of file FUImplementation.cc.

390 {
391 if (index < 0 || index >= externalPortCount()) {
392 const string procName = "FUImplementation::externalPort";
393 throw OutOfRange(__FILE__, __LINE__, procName);
394 }
395
396 return *externalPorts_[index];
397}

References externalPortCount(), and externalPorts_.

Referenced by ProGe::NetlistGenerator::addFUExternalPortsToNetlist(), HDB::HDBManager::addFUImplementation(), FUImplementation(), HDBToHtml::fuImplToHtml(), ProGeTestBenchGenerator::generate(), FUImplementationDialog::onDeleteParameter(), FUImplementationDialog::onEditParameter(), FUImplementationDialog::onParameterActivation(), FUImplementationDialog::selectedExternalPort(), and FUImplementationDialog::update().

Here is the call graph for this function:

◆ externalPortCount()

int HDB::FUImplementation::externalPortCount ( ) const

◆ glockReqPort()

std::string HDB::FUImplementation::glockReqPort ( ) const

Returns the name of the global lock request port.

Returns
The name of the global lock request port.

Definition at line 157 of file FUImplementation.cc.

157 {
158 return glockReqPort_;
159}

References glockReqPort_.

Referenced by HDB::HDBManager::addFUImplementation(), ProGe::NetlistGenerator::addFUToNetlist(), and HDBToHtml::fuImplToHtml().

◆ hasOpcode()

bool HDB::FUImplementation::hasOpcode ( const std::string &  operation) const

Tells whether there is an opcode defined for the given operation.

Parameters
operationName of the operation.
Returns
True if there is an opcode, otherwise false.

Definition at line 227 of file FUImplementation.cc.

227 {
228 string opName = StringTools::stringToUpper(operation);
229 return MapTools::containsKey(opcodes_, opName);
230}
static bool containsKey(const MapType &aMap, const KeyType &aKey)
static std::string stringToUpper(const std::string &source)

References MapTools::containsKey(), opcodes_, and StringTools::stringToUpper().

Referenced by HDB::HDBManager::addFUImplementation(), FUImplementationDialog::onOK(), FUImplementationDialog::onOpcodeSelection(), FUImplementationDialog::onSetOpcode(), and FUImplementationDialog::update().

Here is the call graph for this function:

◆ hasParameter()

bool HDB::FUImplementation::hasParameter ( const std::string &  name) const

Tells whether the implementation has the given parameter.

Parameters
nameName of the parameter.
Returns
True if the implementation has the parameter, otherwise false.

Definition at line 472 of file FUImplementation.cc.

472 {
473 for (ParameterTable::const_iterator iter = parameters_.begin();
474 iter != parameters_.end(); iter++) {
475 if (iter->name == name) {
476 return true;
477 }
478 }
479 return false;
480}

References parameters_.

Referenced by addParameter().

◆ maxOpcodeWidth()

int HDB::FUImplementation::maxOpcodeWidth ( ) const

Returns the maximum bitwidth of an opcode in this FU implementation.

The bitwidth is not stored explicitly in HDB, this method is provided only for convenience.

Returns
The maximum bitwidth needed by an opcode in this FU.

Definition at line 257 of file FUImplementation.cc.

257 {
258 int maxFound = 0;
259 for (OpcodeMap::const_iterator i = opcodes_.begin(); i != opcodes_.end();
260 ++i) {
261 maxFound = std::max(MathTools::requiredBits((*i).second), maxFound);
262 }
263 return maxFound;
264}
static int requiredBits(unsigned long int number)

References opcodes_, and MathTools::requiredBits().

Referenced by FUTestbenchGenerator::createStimulusArrays(), and FUTestbenchGenerator::createTbInstantiation().

Here is the call graph for this function:

◆ opcode()

int HDB::FUImplementation::opcode ( const std::string &  operation) const

Returns the opcode of the given operation.

Parameters
operationThe operation.
Returns
The operation code.
Exceptions
KeyNotFoundIf there is no opcode defined for the given operation.

Definition at line 242 of file FUImplementation.cc.

242 {
243 string opName = StringTools::stringToUpper(operation);
244 return MapTools::valueForKey<int>(opcodes_, opName);
245}
static KeyType keyForValue(const MapType &aMap, const ValueType &aValue)

References MapTools::keyForValue(), opcodes_, and StringTools::stringToUpper().

Referenced by HDB::HDBManager::addFUImplementation(), FUTestbenchGenerator::createStimulusArrays(), HDBToHtml::fuImplToHtml(), FUImplementationDialog::onSetOpcode(), setOpcode(), and FUImplementationDialog::update().

Here is the call graph for this function:

◆ opcodeCount()

int HDB::FUImplementation::opcodeCount ( ) const

Returns the number of opcodes in the FU.

Returns
The number of opcodes.

Definition at line 194 of file FUImplementation.cc.

194 {
195 return opcodes_.size();
196}

References opcodes_.

Referenced by HDBToHtml::fuImplToHtml(), and opcodeOperation().

◆ opcodeOperation()

std::string HDB::FUImplementation::opcodeOperation ( int  index) const

By the given index, returns an operation that has an opcode.

Parameters
indexThe index.
Exceptions
OutOfRangeIf the given index is negative or not smaller than the number of opcodes.

Definition at line 207 of file FUImplementation.cc.

207 {
208 if (index < 0 || index >= opcodeCount()) {
209 throw OutOfRange(__FILE__, __LINE__, __func__);
210 }
211
212 OpcodeMap::const_iterator iter = opcodes_.begin();
213 for (int i = 0; i < index; i++) {
214 iter++;
215 }
216
217 return iter->first;
218}

References __func__, opcodeCount(), and opcodes_.

Referenced by HDBToHtml::fuImplToHtml().

Here is the call graph for this function:

◆ opcodePort()

std::string HDB::FUImplementation::opcodePort ( ) const

◆ parameter()

FUImplementation::Parameter HDB::FUImplementation::parameter ( int  index) const

Returns a parameter by the given index.

Parameters
indexThe index.
Returns
The parameter.
Exceptions
OutOfRangeIf the index is negative or not smaller than the number of parameters.

Definition at line 457 of file FUImplementation.cc.

457 {
458 if (index < 0 || index >= parameterCount()) {
459 throw OutOfRange(__FILE__, __LINE__, __func__);
460 }
461
462 return parameters_[index];
463}

References __func__, parameterCount(), and parameters_.

Referenced by HDB::HDBManager::addFUImplementation(), ProGe::NetlistGenerator::addFUToNetlist(), HDBToHtml::fuImplToHtml(), ProGeTestBenchGenerator::generate(), FUExternalPortDialog::initialize(), FUImplementationDialog::selectedParameter(), and FUImplementationDialog::update().

Here is the call graph for this function:

◆ parameterCount()

int HDB::FUImplementation::parameterCount ( ) const

◆ portImplementationByArchitectureName()

FUPortImplementation & HDB::FUImplementation::portImplementationByArchitectureName ( const std::string &  architectureName) const

Returns the implementation of a port for the given port architecture name.

Parameters
architectureNameName of the port in architecture table.
Returns
The port implementation.
Exceptions
InstanceNotFoundIf no port with the given architecture name is found.

Definition at line 370 of file FUImplementation.cc.

371 {
372 for (int i = 0; i < architecturePortCount(); ++i) {
373 if (ports_[i]->architecturePort() == architectureName)
374 return *ports_[i];
375 }
376 throw InstanceNotFound(
377 __FILE__, __LINE__, __func__,
378 "No port implementation with the given architecture name found.");
379}
FUPortImplementation & architecturePort(int index) const

References __func__, architecturePort(), architecturePortCount(), and ports_.

Referenced by FUTestbenchGenerator::createStimulusArrays(), and FUTestbenchGenerator::createTbCode().

Here is the call graph for this function:

◆ removeParameter()

void HDB::FUImplementation::removeParameter ( const std::string &  name)

Removes the parameter of the given name.

Parameters
nameName of the parameter.

Definition at line 426 of file FUImplementation.cc.

426 {
427 for (ParameterTable::iterator iter = parameters_.begin();
428 iter != parameters_.end(); iter++) {
429 if (iter->name == name) {
430 parameters_.erase(iter);
431 return;
432 }
433 }
434}

References parameters_.

Referenced by FUImplementationDialog::onDeleteParameter(), FUImplementationDialog::onEditParameter(), and FUImplementationDialog::onParameterActivation().

◆ setGlockReqPort()

void HDB::FUImplementation::setGlockReqPort ( const std::string &  name)

Sets the name of the global lock request port.

Parameters
nameName of the port.

Definition at line 146 of file FUImplementation.cc.

146 {
147 glockReqPort_ = name;
148}

References glockReqPort_.

Referenced by FUImplementationDialog::onOK().

◆ setOpcode()

void HDB::FUImplementation::setOpcode ( const std::string &  operation,
int  opcode 
)

Sets operation code for the given operation.

Parameters
operationName of the operation.
opcodeThe operation code.

Definition at line 169 of file FUImplementation.cc.

169 {
170 unsetOpcode(operation);
171 string opName = StringTools::stringToUpper(operation);
172 opcodes_.insert(std::pair<std::string, int>(opName, opcode));
173}
void unsetOpcode(const std::string &operation)
int opcode(const std::string &operation) const

References opcode(), opcodes_, StringTools::stringToUpper(), and unsetOpcode().

Referenced by FUImplementationDialog::onSetOpcode(), and FUImplementationDialog::update().

Here is the call graph for this function:

◆ setOpcodePort()

void HDB::FUImplementation::setOpcodePort ( const std::string &  name)

Sets the name of the opcode port.

Parameters
nameName of the port.

Definition at line 124 of file FUImplementation.cc.

124 {
125 opcodePort_ = name;
126}

References opcodePort_.

Referenced by FUImplementationDialog::onOK().

◆ unsetOpcode()

void HDB::FUImplementation::unsetOpcode ( const std::string &  operation)

Unsets the opcode of the given operation.

Parameters
operationName of the operation.

Definition at line 182 of file FUImplementation.cc.

182 {
183 string opName = StringTools::stringToUpper(operation);
184 opcodes_.erase(opName);
185}

References opcodes_, and StringTools::stringToUpper().

Referenced by FUImplementationDialog::onClearOpcode(), and setOpcode().

Here is the call graph for this function:

Member Data Documentation

◆ externalPorts_

ExternalPortTable HDB::FUImplementation::externalPorts_
private

Contains the external ports.

Definition at line 126 of file FUImplementation.hh.

Referenced by addExternalPort(), deleteExternalPort(), externalPort(), externalPortCount(), and ~FUImplementation().

◆ glockReqPort_

std::string HDB::FUImplementation::glockReqPort_
private

Name of the global lock request port.

Definition at line 121 of file FUImplementation.hh.

Referenced by FUImplementation(), glockReqPort(), and setGlockReqPort().

◆ opcodePort_

std::string HDB::FUImplementation::opcodePort_
private

Name of the opcode port.

Definition at line 119 of file FUImplementation.hh.

Referenced by FUImplementation(), opcodePort(), and setOpcodePort().

◆ opcodes_

OpcodeMap HDB::FUImplementation::opcodes_
private

Contains the operation codes.

Definition at line 128 of file FUImplementation.hh.

Referenced by FUImplementation(), hasOpcode(), maxOpcodeWidth(), opcode(), opcodeCount(), opcodeOperation(), setOpcode(), and unsetOpcode().

◆ parameters_

ParameterTable HDB::FUImplementation::parameters_
private

Contains the parameters.

Definition at line 130 of file FUImplementation.hh.

Referenced by addParameter(), FUImplementation(), hasParameter(), parameter(), parameterCount(), and removeParameter().

◆ ports_

PortTable HDB::FUImplementation::ports_
private

The documentation for this class was generated from the following files: