OpenASIP  2.0
Classes | Public Member Functions | Private Types | Private Attributes | List of all members
HDB::FUArchitecture Class Reference

#include <FUArchitecture.hh>

Inheritance diagram for HDB::FUArchitecture:
Inheritance graph
Collaboration diagram for HDB::FUArchitecture:
Collaboration graph

Classes

struct  PipelineElementUsage
 Struct PipelineElementUsage. More...
 

Public Member Functions

 FUArchitecture (TTAMachine::FunctionUnit *fu)
 
 FUArchitecture (const FUArchitecture &o)
 
virtual ~FUArchitecture ()
 
bool hasParameterizedWidth (const std::string &port) const
 
void setParameterizedWidth (const std::string &port)
 
bool hasGuardSupport (const std::string &port) const
 
void setGuardSupport (const std::string &port)
 
TTAMachine::FunctionUnitarchitecture () const
 
HDB::Direction portDirection (const std::string &port) const
 
bool operator== (const FUArchitecture &rightHand) const
 
- Public Member Functions inherited from HWBlockArchitecture
virtual ~HWBlockArchitecture ()
 
bool hasID () const
 
void setID (RowID id)
 
RowID id () const
 

Private Types

typedef std::vector< PipelineElementUsagePipelineElementUsageTable
 typedef for PipelineElemetnUsageTable More...
 
typedef std::set< std::string > PortSet
 Set type for port names. More...
 

Private Attributes

TTAMachine::FunctionUnitfu_
 The function unit. More...
 
PortSet parameterizedPorts_
 Parameterized ports. More...
 
PortSet guardedPorts_
 Port that support guard. More...
 

Additional Inherited Members

- Protected Member Functions inherited from HWBlockArchitecture
 HWBlockArchitecture ()
 

Detailed Description

Represents architecture of an FU in HDB.

Definition at line 55 of file FUArchitecture.hh.

Member Typedef Documentation

◆ PipelineElementUsageTable

typedef for PipelineElemetnUsageTable

Definition at line 78 of file FUArchitecture.hh.

◆ PortSet

typedef std::set<std::string> HDB::FUArchitecture::PortSet
private

Set type for port names.

Definition at line 81 of file FUArchitecture.hh.

Constructor & Destructor Documentation

◆ FUArchitecture() [1/2]

HDB::FUArchitecture::FUArchitecture ( TTAMachine::FunctionUnit fu)

The constructor.

Parameters
fuThe function unit of which architecture is represented. Becomes property of the FUArchitecture object.

Definition at line 55 of file FUArchitecture.cc.

55  : fu_(fu) {
56 }

◆ FUArchitecture() [2/2]

HDB::FUArchitecture::FUArchitecture ( const FUArchitecture original)

Copy constructor.

Parameters
originalFUArchitecture to copy.

Definition at line 63 of file FUArchitecture.cc.

63  :
64  HWBlockArchitecture(original) {
65 
66  fu_ = original.fu_->copy();
67  parameterizedPorts_ = original.parameterizedPorts_;
68  guardedPorts_ = original.guardedPorts_;
69 }

References TTAMachine::FunctionUnit::copy(), fu_, guardedPorts_, and parameterizedPorts_.

Here is the call graph for this function:

◆ ~FUArchitecture()

HDB::FUArchitecture::~FUArchitecture ( )
virtual

The destructor.

Definition at line 74 of file FUArchitecture.cc.

74  {
75  delete fu_;
76 }

References fu_.

Member Function Documentation

◆ architecture()

TTAMachine::FunctionUnit & HDB::FUArchitecture::architecture ( ) const

◆ hasGuardSupport()

bool HDB::FUArchitecture::hasGuardSupport ( const std::string &  port) const

Tells whether the given port is guarded.

Parameters
portName of the port.
Returns
True if the port is guarded, otherwise false.

Definition at line 109 of file FUArchitecture.cc.

109  {
111 }

References AssocTools::containsKey(), and guardedPorts_.

Referenced by HDB::HDBManager::addFUArchitecture(), HDBToHtml::fuArchToHtml(), and FUArchitectureDialog::update().

Here is the call graph for this function:

◆ hasParameterizedWidth()

bool HDB::FUArchitecture::hasParameterizedWidth ( const std::string &  port) const

Tells whether the given port has parameterized width.

Parameters
portName of the port.
Returns
True if the port is parameterized, otherwise false.

Definition at line 86 of file FUArchitecture.cc.

86  {
88 }

References AssocTools::containsKey(), and parameterizedPorts_.

Referenced by HDB::HDBManager::addFUArchitecture(), CostDatabase::buildFunctionUnits(), HDBToHtml::fuArchToHtml(), HDB::HDBManager::isMatchingArchitecture(), ProGe::NetlistGenerator::isParameterizable(), BlockImplementationDialog::onHDBSelection(), operator==(), and FUArchitectureDialog::update().

Here is the call graph for this function:

◆ operator==()

bool HDB::FUArchitecture::operator== ( const FUArchitecture rightHand) const

Checks whether the given FU has a mathing architecture with the given FU architecture instance.

Parameters
rightHandRight hand operand.
Returns
True if the architectures match, otherwise false.

Definition at line 196 of file FUArchitecture.cc.

196  {
197 
198  if (rightHand.architecture().operationCount() !=
199  this->architecture().operationCount()) {
200  return false;
201  }
202 
203  std::map<const FUPort*, const FUPort*> portMap;
204  for (int i = 0; i < rightHand.architecture().operationPortCount(); i++) {
205  portMap.insert(
206  std::pair<const FUPort*, const FUPort*>(
207  rightHand.architecture().operationPort(i), NULL));
208  }
209 
210  PipelineElementUsageTable plineElementUsages;
211 
212  for (int i = 0; i < rightHand.architecture().operationCount(); i++) {
213  HWOperation* rightHandOp = rightHand.architecture().operation(i);
214  if (!architecture().hasOperation(rightHandOp->name())) {
215  return false;
216  }
217  HWOperation* thisOp = architecture().operation(
218  rightHandOp->name());
219  if (rightHandOp->latency() != thisOp->latency()) {
220  return false;
221  }
222 
223  // check operand bindings
224  for (int i = 0;
225  i < rightHand.architecture().operationPortCount();
226  i++) {
227 
228  FUPort* port = rightHand.architecture().operationPort(i);
229  if (rightHandOp->isBound(*port)) {
230  int io = rightHandOp->io(*port);
231  FUPort* samePort = thisOp->port(io);
232  if (samePort == NULL) {
233  return false;
234  }
235  const FUPort* existingSamePort =
236  MapTools::valueForKey<const FUPort*>(portMap, port);
237  if (existingSamePort != NULL &&
238  existingSamePort != samePort) {
239  return false;
240  }
241 
242  // check the width of the ports
243  // widths must equal
244  if (hasParameterizedWidth(samePort->name()) !=
245  rightHand.hasParameterizedWidth(port->name())) {
246  return false;
247  }
248 
249  // if the FUArchitectures have parameterized port width
250  // those ports widths are not needed to check
251  if (!hasParameterizedWidth(samePort->name()) &&
252  samePort->width() != port->width()) {
253  return false;
254  }
255 
256  if (port->isOpcodeSetting() != samePort->isOpcodeSetting() ||
257  port->isTriggering() != samePort->isTriggering()) {
258  return false;
259  }
260  portMap.erase(port);
261  portMap.insert(
262  std::pair<const FUPort*, const FUPort*>(port, samePort));
263  }
264  }
265 
266  // check operation pipeline
267  ExecutionPipeline* opPipeline = rightHandOp->pipeline();
268  ExecutionPipeline* thisOpPipeline = thisOp->pipeline();
269  for (int cycle = 0; cycle < rightHandOp->latency(); cycle++) {
271  opPipeline->writtenOperands(cycle);
273  thisOpPipeline->writtenOperands(cycle);
274  if (written1 != written2) {
275  return false;
276  }
278  opPipeline->readOperands(cycle);
280  thisOpPipeline->readOperands(cycle);
281  if (read1 != read2) {
282  return false;
283  }
284 
285  PipelineElementUsage usage;
286  for (int i = 0;
287  i < rightHand.architecture().pipelineElementCount();
288  i++) {
289 
290  const PipelineElement* elem =
291  rightHand.architecture().pipelineElement(i);
292  if (opPipeline->isResourceUsed(elem->name(),cycle)) {
293  usage.usage1.insert(elem);
294  }
295  }
296 
297  for (int i = 0; i < architecture().pipelineElementCount(); i++) {
298  const PipelineElement* elem =
300  if (thisOpPipeline->isResourceUsed(elem->name(), cycle)) {
301  usage.usage2.insert(elem);
302  }
303  }
304  plineElementUsages.push_back(usage);
305  }
306  }
307 
308  std::set<const TTAMachine::PipelineElement*> difference;
309  for (size_t i = 0; i < plineElementUsages.size(); i++) {
310  AssocTools::difference(plineElementUsages[i].usage1,
311  plineElementUsages[i].usage2,
312  difference);
313  }
314  if (!difference.empty()) {
315  return false;
316  }
317  return true;
318 }

References architecture(), AssocTools::difference(), hasParameterizedWidth(), TTAMachine::HWOperation::io(), TTAMachine::HWOperation::isBound(), TTAMachine::FUPort::isOpcodeSetting(), TTAMachine::ExecutionPipeline::isResourceUsed(), TTAMachine::FUPort::isTriggering(), TTAMachine::HWOperation::latency(), TTAMachine::PipelineElement::name(), TTAMachine::HWOperation::name(), TTAMachine::Port::name(), TTAMachine::FunctionUnit::operation(), TTAMachine::FunctionUnit::operationCount(), TTAMachine::FunctionUnit::operationPort(), TTAMachine::HWOperation::pipeline(), TTAMachine::FunctionUnit::pipelineElement(), TTAMachine::FunctionUnit::pipelineElementCount(), TTAMachine::HWOperation::port(), TTAMachine::ExecutionPipeline::readOperands(), HDB::FUArchitecture::PipelineElementUsage::usage1, HDB::FUArchitecture::PipelineElementUsage::usage2, TTAMachine::BaseFUPort::width(), and TTAMachine::ExecutionPipeline::writtenOperands().

Here is the call graph for this function:

◆ portDirection()

HDB::Direction HDB::FUArchitecture::portDirection ( const std::string &  portName) const

Tells the direction of the given port.

Parameters
portNameName of the port in the FU architecture.
Exceptions
InstanceNotFoundIf the FU architecture does not have the given port.
InvalidDataIf the given port is not used by any pipeline.

Definition at line 145 of file FUArchitecture.cc.

145  {
146  FunctionUnit& fu = architecture();
147  if (!fu.hasOperationPort(portName)) {
148  throw InstanceNotFound(__FILE__, __LINE__, __func__);
149  }
150 
151  FUPort* port = fu.operationPort(portName);
152  bool read = false;
153  bool written = false;
154 
155  int operationCount = fu.operationCount();
156  for (int i = 0; i < operationCount; i++) {
157  HWOperation* operation = fu.operation(i);
158  ExecutionPipeline* pLine = operation->pipeline();
159  int latency = operation->latency();
160  for (int cycle = 0; cycle < latency; cycle++) {
161  if (!read) {
162  if (pLine->isPortRead(*port, cycle)) {
163  read = true;
164  }
165  }
166  if (!written) {
167  if (pLine->isPortWritten(*port, cycle)) {
168  written = true;
169  }
170  }
171  }
172  if (read && written) {
173  break;
174  }
175  }
176 
177  if (read && written) {
178  return HDB::BIDIR;
179  } else if (read) {
180  return HDB::IN;
181  } else if (written) {
182  return HDB::OUT;
183  } else {
184  throw InvalidData(__FILE__, __LINE__, __func__);
185  }
186 }

References __func__, architecture(), HDB::BIDIR, TTAMachine::FunctionUnit::hasOperationPort(), HDB::IN, TTAMachine::ExecutionPipeline::isPortRead(), TTAMachine::ExecutionPipeline::isPortWritten(), TTAMachine::HWOperation::latency(), TTAMachine::FunctionUnit::operation(), TTAMachine::FunctionUnit::operationCount(), TTAMachine::FunctionUnit::operationPort(), HDB::OUT, and TTAMachine::HWOperation::pipeline().

Referenced by ProGe::NetlistGenerator::addFUToNetlist().

Here is the call graph for this function:

◆ setGuardSupport()

void HDB::FUArchitecture::setGuardSupport ( const std::string &  port)

Sets guard support for the given port.

Parameters
portName of the port.

Definition at line 120 of file FUArchitecture.cc.

120  {
121  guardedPorts_.insert(port);
122 }

References guardedPorts_.

Referenced by HDB::HDBManager::addPortsAndBindingsToFUArchitecture(), and FUArchitectureDialog::onOK().

◆ setParameterizedWidth()

void HDB::FUArchitecture::setParameterizedWidth ( const std::string &  port)

Sets parameterized width for the given port.

Parameters
portName of the port.

Definition at line 97 of file FUArchitecture.cc.

97  {
98  parameterizedPorts_.insert(port);
99 }

References parameterizedPorts_.

Referenced by HDB::HDBManager::addPortsAndBindingsToFUArchitecture(), and FUArchitectureDialog::onOK().

Member Data Documentation

◆ fu_

TTAMachine::FunctionUnit* HDB::FUArchitecture::fu_
private

The function unit.

Definition at line 84 of file FUArchitecture.hh.

Referenced by architecture(), FUArchitecture(), and ~FUArchitecture().

◆ guardedPorts_

PortSet HDB::FUArchitecture::guardedPorts_
private

Port that support guard.

Definition at line 88 of file FUArchitecture.hh.

Referenced by FUArchitecture(), hasGuardSupport(), and setGuardSupport().

◆ parameterizedPorts_

PortSet HDB::FUArchitecture::parameterizedPorts_
private

Parameterized ports.

Definition at line 86 of file FUArchitecture.hh.

Referenced by FUArchitecture(), hasParameterizedWidth(), and setParameterizedWidth().


The documentation for this class was generated from the following files:
AssocTools::difference
static void difference(const ContainerType &firstContainer, const ContainerType &secondContainer, ContainerType &difference)
HWBlockArchitecture::HWBlockArchitecture
HWBlockArchitecture()
Definition: HWBlockArchitecture.cc:38
HDB::FUArchitecture::fu_
TTAMachine::FunctionUnit * fu_
The function unit.
Definition: FUArchitecture.hh:84
HDB::FUArchitecture::hasParameterizedWidth
bool hasParameterizedWidth(const std::string &port) const
Definition: FUArchitecture.cc:86
TTAMachine::FUPort::isOpcodeSetting
virtual bool isOpcodeSetting() const
Definition: FUPort.cc:195
TTAMachine::HWOperation
Definition: HWOperation.hh:52
AssocTools::containsKey
static bool containsKey(const ContainerType &aContainer, const KeyType &aKey)
HDB::FUArchitecture::architecture
TTAMachine::FunctionUnit & architecture() const
Definition: FUArchitecture.cc:131
HDB::FUArchitecture::PipelineElementUsageTable
std::vector< PipelineElementUsage > PipelineElementUsageTable
typedef for PipelineElemetnUsageTable
Definition: FUArchitecture.hh:78
TTAMachine::ExecutionPipeline::writtenOperands
OperandSet writtenOperands(int cycle) const
Definition: ExecutionPipeline.cc:429
TTAMachine::PipelineElement::name
const std::string & name() const
TTAMachine::ExecutionPipeline::readOperands
OperandSet readOperands(int cycle) const
Definition: ExecutionPipeline.cc:408
TTAMachine::FUPort::isTriggering
virtual bool isTriggering() const
Definition: FUPort.cc:182
HDB::FUArchitecture::parameterizedPorts_
PortSet parameterizedPorts_
Parameterized ports.
Definition: FUArchitecture.hh:86
TTAMachine::FunctionUnit
Definition: FunctionUnit.hh:55
TTAMachine::HWOperation::port
virtual FUPort * port(int operand) const
Definition: HWOperation.cc:320
TTAMachine::FUPort
Definition: FUPort.hh:46
TTAMachine::HWOperation::io
int io(const FUPort &port) const
Definition: HWOperation.cc:364
TTAMachine::HWOperation::name
const std::string & name() const
Definition: HWOperation.cc:141
InvalidData
Definition: Exception.hh:149
TTAMachine::FunctionUnit::pipelineElement
virtual PipelineElement * pipelineElement(int index) const
Definition: FunctionUnit.cc:523
HDB::BIDIR
@ BIDIR
Bidirectional port.
Definition: HDBTypes.hh:43
TTAMachine::ExecutionPipeline::isPortWritten
bool isPortWritten(const FUPort &port, int cycle) const
Definition: ExecutionPipeline.cc:386
TTAMachine::HWOperation::isBound
bool isBound(const FUPort &port) const
Definition: HWOperation.cc:338
__func__
#define __func__
Definition: Application.hh:67
TTAMachine::FunctionUnit::operationCount
virtual int operationCount() const
Definition: FunctionUnit.cc:419
TTAMachine::ExecutionPipeline::OperandSet
std::set< int > OperandSet
Set for operand indexes.
Definition: ExecutionPipeline.hh:58
TTAMachine::FunctionUnit::pipelineElementCount
virtual int pipelineElementCount() const
Definition: FunctionUnit.cc:507
TTAMachine::ExecutionPipeline::isPortRead
bool isPortRead(const FUPort &port, int cycle) const
Definition: ExecutionPipeline.cc:362
TTAMachine::FunctionUnit::hasOperationPort
virtual bool hasOperationPort(const std::string &name) const
Definition: FunctionUnit.cc:204
TTAMachine::PipelineElement
Definition: PipelineElement.hh:46
TTAMachine::Port::name
virtual std::string name() const
Definition: Port.cc:141
HDB::IN
@ IN
Input port.
Definition: HDBTypes.hh:41
TTAMachine::HWOperation::pipeline
ExecutionPipeline * pipeline() const
Definition: HWOperation.cc:201
TTAMachine::ExecutionPipeline
Definition: ExecutionPipeline.hh:55
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
TTAMachine::FunctionUnit::operationPort
virtual FUPort * operationPort(const std::string &name) const
Definition: FunctionUnit.cc:224
TTAMachine::FunctionUnit::copy
virtual FunctionUnit * copy() const
Definition: FunctionUnit.cc:103
HDB::FUArchitecture::guardedPorts_
PortSet guardedPorts_
Port that support guard.
Definition: FUArchitecture.hh:88
HDB::OUT
@ OUT
Output port.
Definition: HDBTypes.hh:42
TTAMachine::BaseFUPort::width
virtual int width() const
Definition: BaseFUPort.cc:109
InstanceNotFound
Definition: Exception.hh:304
TTAMachine::ExecutionPipeline::isResourceUsed
bool isResourceUsed(const std::string &name, int cycle) const
Definition: ExecutionPipeline.cc:300