OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
ProGe::NetlistPort Class Reference

#include <NetlistPort.hh>

Inheritance diagram for ProGe::NetlistPort:
Inheritance graph
Collaboration diagram for ProGe::NetlistPort:
Collaboration graph

Public Member Functions

 NetlistPort (const std::string &name, const std::string &widthFormula, int realWidth, DataType dataType, Direction direction, BaseNetlistBlock &parent, Signal signal=Signal())
 
 NetlistPort (const std::string &name, int realWidth, DataType dataType, Direction direction, BaseNetlistBlock &parent, Signal signal=Signal())
 
 NetlistPort (const std::string &name, const std::string &widthFormula, DataType dataType, Direction direction, BaseNetlistBlock &parent, Signal signal=Signal())
 
 NetlistPort (const std::string &name, const std::string &widthFormula, DataType dataType, Direction direction, Signal signal=Signal())
 
virtual ~NetlistPort ()
 
bool resolveRealWidth (int &width) const
 
NetlistPortcopyTo (BaseNetlistBlock &newParent, std::string newName="") const
 
virtual NetlistPortclone (bool asMirrored=false) const
 
std::string name () const
 
void rename (const std::string &newname)
 
std::string widthFormula () const
 
void setWidthFormula (const std::string &newFormula)
 
bool realWidthAvailable () const
 
int realWidth () const
 
DataType dataType () const
 
Direction direction () const
 
void setDirection (Direction direction)
 
bool hasParentBlock () const
 
const BaseNetlistBlockparentBlock () const
 
BaseNetlistBlockparentBlock ()
 
void setToStatic (StaticSignal value) const
 
void unsetStatic () const
 
bool hasStaticValue () const
 
StaticSignal staticValue () const
 
void assignSignal (Signal signal)
 
Signal assignedSignal () const
 

Private Member Functions

void setParent (BaseNetlistBlock *parent)
 
 NetlistPort (const NetlistPort &other, bool asMirrored=false)
 

Private Attributes

std::string name_
 Name of the port.
 
std::string widthFormula_
 Formula for the width of the port.
 
int realWidth_
 Real width of the port.
 
DataType dataType_
 Data type of the port.
 
Direction direction_
 Direction of the port.
 
BaseNetlistBlockparentBlock_
 The parent netlist block.
 
bool hasStaticValue_
 Indicates if port is connected to vcc or gnd.
 
StaticSignal staticValue_
 Static signal value.
 
Signal signal_
 Assigned port usage.
 

Friends

class BaseNetlistBlock
 

Detailed Description

Represents a port in the netlist. Ports are the vertices of the graph that represents the netlist. From the ports, it is possible to reach the parent netlist blocks.

Definition at line 70 of file NetlistPort.hh.

Constructor & Destructor Documentation

◆ NetlistPort() [1/5]

ProGe::NetlistPort::NetlistPort ( const std::string &  name,
const std::string &  widthFormula,
int  realWidth,
DataType  dataType,
Direction  direction,
BaseNetlistBlock parent,
Signal  signal = Signal() 
)

Constructor. Creates a netlist port with a defined bit width.

Creates a port that has a known bit width. Adds the port automatically to the parent block. If a formula for calculating the bit width is given, it should match the actual bit width (an integer number). No check is performed, however, to make sure that the formula is compatible with the actual width. In case of mismatch, the error can be detected only after generation (for example, in a logic synthesis tool).

Parameters
nameName of the port.
widthFormulaFormula for calculating the width.
realWidthActual width of the port.
dataTypeType of the data.
directionDirection of the port.
parentThe parent netlist block.
Exceptions
OutOfRangeIf the actual width is not positive ( <0 ).

Definition at line 64 of file NetlistPort.cc.

72 : name_(name),
77 parentBlock_(&parent),
78 hasStaticValue_(false),
80 signal_(signal) {
81
82 // TODO: there might still be possible regressions from changing realWidth
83 // check to "< 0" from "< 1"
84 // RF (and IU?) opcode ports may have width 0
85 if (realWidth_ < 0 ) {
86 TCEString msg = "Port ";
87 msg << name << " has a negative width.";
88 throw OutOfRange(__FILE__, __LINE__, __func__, msg);
89 }
90
91 parent.addPort(this);
92}
#define __func__
DataType dataType_
Data type of the port.
BaseNetlistBlock * parentBlock_
The parent netlist block.
std::string widthFormula() const
DataType dataType() const
std::string widthFormula_
Formula for the width of the port.
int realWidth_
Real width of the port.
bool hasStaticValue_
Indicates if port is connected to vcc or gnd.
StaticSignal staticValue_
Static signal value.
Direction direction_
Direction of the port.
Signal signal_
Assigned port usage.
Direction direction() const
std::string name_
Name of the port.
std::string name() const
int realWidth() const
@ GND
All port signals set to low.

References __func__, ProGe::BaseNetlistBlock::addPort(), name(), and realWidth_.

Here is the call graph for this function:

◆ NetlistPort() [2/5]

ProGe::NetlistPort::NetlistPort ( const std::string &  name,
int  realWidth,
DataType  dataType,
Direction  direction,
BaseNetlistBlock parent,
Signal  signal = Signal() 
)

Constructor. Creates a netlist port with a defined bit width, and derive formula from the integer value

Parameters
nameName of the port.
realWidthActual width of the port.
dataTypeType of the data.
directionDirection of the port.
parentThe parent netlist block.
Exceptions
OutOfRangeIf the actual width is not positive ( <0 ).

Definition at line 105 of file NetlistPort.cc.

112 : name_(name),
117 parentBlock_(&parent),
118 hasStaticValue_(false),
120 signal_(signal) {
121
122 // TODO: there might still be possible regressions from changing realWidth
123 // check to "< 0" from "< 1"
124 // RF (and IU?) opcode ports may have width 0
125 if (realWidth_ < 0 ) {
126 TCEString msg = "Port ";
127 msg << name << " has a negative width.";
128 throw OutOfRange(__FILE__, __LINE__, __func__, msg);
129 }
130
131 parent.addPort(this);
132}
static std::string toString(const T &source)

References __func__, ProGe::BaseNetlistBlock::addPort(), name(), and realWidth_.

Here is the call graph for this function:

◆ NetlistPort() [3/5]

ProGe::NetlistPort::NetlistPort ( const std::string &  name,
const std::string &  widthFormula,
DataType  dataType,
Direction  direction,
BaseNetlistBlock parent,
Signal  signal = Signal() 
)

Constructor. Creates a new netlist port.

Creates a port that has its bit width defined symbolically, by an expression (formula). Adds the port automatically to the parent block.

Parameters
nameName of the port.
widthFormulaFormula for calculating the width.
dataTypeType of the data.
directionDirection of the port.
parentThe parent netlist block.

Definition at line 146 of file NetlistPort.cc.

153 : name_(name),
155 realWidth_(-1),
158 parentBlock_(&parent),
159 hasStaticValue_(false),
161 signal_(signal) {
162
163 parent.addPort(this);
164}

References ProGe::BaseNetlistBlock::addPort().

Here is the call graph for this function:

◆ NetlistPort() [4/5]

ProGe::NetlistPort::NetlistPort ( const std::string &  name,
const std::string &  widthFormula,
DataType  dataType,
Direction  direction,
Signal  signal = Signal() 
)

Definition at line 186 of file NetlistPort.cc.

192 : name_(name),
194 realWidth_(-1),
197 parentBlock_(nullptr),
198 hasStaticValue_(false),
200 signal_(signal) {
201}

◆ ~NetlistPort()

ProGe::NetlistPort::~NetlistPort ( )
virtual

Destructor.

Removes itself from the parent netlist block.

Definition at line 270 of file NetlistPort.cc.

270 {
271 if (hasParentBlock()) {
273 }
274}
void removePort(NetlistPort *port)
bool hasParentBlock() const

References hasParentBlock(), parentBlock_, and ProGe::BaseNetlistBlock::removePort().

Here is the call graph for this function:

◆ NetlistPort() [5/5]

ProGe::NetlistPort::NetlistPort ( const NetlistPort other,
bool  asMirrored = false 
)
private

Copy constructor. Copies everything except parent block reference since one NetlistBlock may not have ports with identical names.

Definition at line 170 of file NetlistPort.cc.

171 : name_(other.name_),
172 widthFormula_(other.widthFormula_),
173 realWidth_(other.realWidth_),
174 dataType_(other.dataType_),
175 direction_(other.direction_),
176 parentBlock_(nullptr),
177 hasStaticValue_(other.hasStaticValue_),
178 staticValue_(other.staticValue_),
179 signal_(other.signal_) {
180
181 if (asMirrored) {
182 direction_ = NetlistTools::mirror(other.direction_);
183 }
184}
static Direction mirror(Direction direction)

References direction_, and ProGe::NetlistTools::mirror().

Here is the call graph for this function:

Member Function Documentation

◆ assignedSignal()

Signal ProGe::NetlistPort::assignedSignal ( ) const

◆ assignSignal()

void ProGe::NetlistPort::assignSignal ( Signal  signal)

Assign signal to signify usage of the port.

Definition at line 447 of file NetlistPort.cc.

447 {
448 signal_ = signal;
449}

References signal_.

◆ clone()

NetlistPort * ProGe::NetlistPort::clone ( bool  asMirrored = false) const
virtual

Definition at line 258 of file NetlistPort.cc.

258 {
259 NetlistPort* newPort = new NetlistPort(*this, asMirrored);
260 assert(newPort->assignedSignal().type() == this->assignedSignal().type());
261 return newPort;
262}
#define assert(condition)
NetlistPort(const std::string &name, const std::string &widthFormula, int realWidth, DataType dataType, Direction direction, BaseNetlistBlock &parent, Signal signal=Signal())

References assert, assignedSignal(), and ProGe::Signal::type().

Referenced by ProGe::PortFactory::clockPort(), ProGe::PortFactory::createPort(), ProGe::ProcessorWrapperBlock::handleUnconnectedPorts(), ProGe::NetlistPortGroup::NetlistPortGroup(), and ProGe::PortFactory::resetPort().

Here is the call graph for this function:

◆ copyTo()

NetlistPort * ProGe::NetlistPort::copyTo ( BaseNetlistBlock newParent,
std::string  newName = "" 
) const

DEPRECATED

Definition at line 231 of file NetlistPort.cc.

233 {
234 if (newName == "")
235 newName = this->name();
236
237 if (realWidthAvailable()) {
238 return new NetlistPort(
239 newName, widthFormula(), realWidth(), dataType(), direction(),
240 newParent, assignedSignal());
241 } else {
242 int width = 0;
243 if (resolveRealWidth(width)) {
244 return new NetlistPort(
245 newName, widthFormula(), width, dataType(), direction(),
246 newParent, assignedSignal());
247 } else {
248 return new NetlistPort(
249 newName, widthFormula(), dataType(), direction(), newParent,
251 }
252 }
253 return NULL;
254}
bool resolveRealWidth(int &width) const
bool realWidthAvailable() const
Signal assignedSignal() const

References assignedSignal(), dataType(), direction(), name(), realWidth(), realWidthAvailable(), resolveRealWidth(), and widthFormula().

Referenced by ProGe::NetlistBlock::shallowCopy(), and ProGe::BaseNetlistBlock::shallowCopy().

Here is the call graph for this function:

◆ dataType()

DataType ProGe::NetlistPort::dataType ( ) const

◆ direction()

Direction ProGe::NetlistPort::direction ( ) const

◆ hasParentBlock()

bool ProGe::NetlistPort::hasParentBlock ( ) const

Returns true if ports is attached to some netlist block. Otherwise, returns false.

Definition at line 390 of file NetlistPort.cc.

390 {
391 return parentBlock_ != NULL;
392}

References parentBlock_.

Referenced by ProGe::BaseNetlistBlock::addPort(), rename(), and ~NetlistPort().

◆ hasStaticValue()

bool ProGe::NetlistPort::hasStaticValue ( ) const

◆ name()

std::string ProGe::NetlistPort::name ( ) const

Returns the name of the port.

Returns
The name of the port.

Definition at line 283 of file NetlistPort.cc.

283 {
284 return name_;
285}

References name_.

Referenced by ProGe::GeneratableFUNetlistBlock::addInOperand(), AvalonMMMasterInterface::addIrqInterface(), ProGe::GeneratableFUNetlistBlock::addOutOperand(), AvalonMMMasterInterface::addPort(), ProGe::BaseNetlistBlock::addPort(), ProGe::NetlistTools::addPrefixToPortName(), AlteraHibiDpRamGenerator::connectPorts(), PlatformIntegrator::connectToplevelPort(), copyTo(), MemoryGenerator::corePortName(), SOPCBuilderFileGenerator::countAvalonMMMasters(), SOPCBuilderFileGenerator::createInterfaces(), SOPCBuilderFileGenerator::exportSignal(), ProGe::NetlistGenerator::fuGuardPort(), SOPCBuilderFileGenerator::handleAvalonSignal(), AlmaIFIntegrator::integrateCore(), AvalonMMMasterInterface::isValidPort(), ProGe::NetlistVisualization::listConnections(), ProGe::NetlistVisualization::listNetlistDescriptors(), ProGe::NetlistGenerator::loadPort(), IPXactClkInterface::mapPortsToInterface(), IPXactHibiInterface::mapPortsToInterface(), IPXactResetInterface::mapPortsToInterface(), Stratix2DSPBoardIntegrator::mapToplevelPorts(), Stratix3DevKitIntegrator::mapToplevelPorts(), NetlistPort(), NetlistPort(), ProGe::VerilogNetlistWriter::portSignalName(), ProGe::VHDLNetlistWriter::portSignalName(), ProGe::NetlistVisualization::printPort(), realWidth(), rename(), ProGe::NetlistGenerator::rfOpcodePort(), ProGe::NetlistBlock::shallowCopy(), ProGe::BaseNetlistBlock::shallowCopy(), ProGe::VHDLNetlistWriter::writeComponentDeclarations(), ProGe::VHDLNetlistWriter::writeConnection(), ProGe::VerilogNetlistWriter::writePortDeclaration(), ProGe::VHDLNetlistWriter::writePortDeclaration(), ProGe::VerilogNetlistWriter::writePortMappings(), and ProGe::VHDLNetlistWriter::writePortMappings().

◆ parentBlock() [1/2]

BaseNetlistBlock & ProGe::NetlistPort::parentBlock ( )

Definition at line 405 of file NetlistPort.cc.

405 {
406 return *parentBlock_;
407}

References parentBlock_.

◆ parentBlock() [2/2]

const BaseNetlistBlock & ProGe::NetlistPort::parentBlock ( ) const

◆ realWidth()

int ProGe::NetlistPort::realWidth ( ) const

◆ realWidthAvailable()

bool ProGe::NetlistPort::realWidthAvailable ( ) const

Tells whether the actual bit width of the port is known.

Returns
True if the width is known, otherwise false.

Definition at line 334 of file NetlistPort.cc.

334 {
335 // TODO: there might still be possible regressions from changing realWidth
336 // check to allow zero.
337 return realWidth_ >= 0;
338}

References realWidth_.

Referenced by AvalonMMMasterInterface::addIrqInterface(), AvalonMMMasterInterface::addPort(), PlatformIntegrator::connectToplevelPort(), copyTo(), SOPCBuilderFileGenerator::exportSignal(), HDLPort::HDLPort(), ProGe::VerilogNetlistWriter::portSignalType(), ProGe::VHDLNetlistWriter::portSignalType(), ProGe::NetlistVisualization::portWidthToString(), realWidth(), ProGe::VerilogNetlistWriter::writeSignalDeclarations(), and ProGe::VHDLNetlistWriter::writeSignalDeclarations().

◆ rename()

void ProGe::NetlistPort::rename ( const std::string &  newname)

Sets new name of the port.

Returns
The name of the port.

Definition at line 294 of file NetlistPort.cc.

294 {
295 if (hasParentBlock()) {
296 if(parentBlock_->port(newname, false) == nullptr ||
297 parentBlock_->port(newname, false) == this) {
298 name_ = newname;
299 } else {
300 THROW_EXCEPTION(ObjectAlreadyExists, "Port to be renamed ("
301 + name() +") to " + newname +
302 " is not unique within the block.");
303 }
304 } else {
305 name_ = newname;
306 }
307}
#define THROW_EXCEPTION(exceptionType, message)
Exception wrapper macro that automatically includes file name, line number and function name where th...
Definition Exception.hh:39
virtual const NetlistPort & port(size_t index) const

References hasParentBlock(), name(), name_, parentBlock_, ProGe::BaseNetlistBlock::port(), and THROW_EXCEPTION.

Referenced by ProGe::NetlistTools::addPrefixToPortName(), and ProGe::LoopBufferBlock::LoopBufferBlock().

Here is the call graph for this function:

◆ resolveRealWidth()

bool ProGe::NetlistPort::resolveRealWidth ( int &  width) const

Definition at line 204 of file NetlistPort.cc.

204 {
205
206 std::string formula = widthFormula();
207 // check if it is a parameter
208 for (size_t i = 0; i < parentBlock().netlist().parameterCount(); i++) {
209 Parameter param = parentBlock().netlist().parameter(i);
210 if (param.name() == formula) {
211 width = Conversion::toInt(param.value());
212 return true;
213 }
214 }
215
216 // check if formula is a plain number
217 bool success = false;
218 try {
219 width = Conversion::toInt(formula);
220 success = true;
221 } catch (Exception& e) {
222 success = false;
223 }
224 return success;
225}
static int toInt(const T &source)
virtual const Netlist & netlist() const
const BaseNetlistBlock & parentBlock() const
size_t parameterCount() const
Definition Netlist.cc:422
Parameter parameter(size_t index) const
Definition Netlist.cc:434

References ProGe::Parameter::name(), ProGe::BaseNetlistBlock::netlist(), ProGe::Netlist::parameter(), ProGe::Netlist::parameterCount(), parentBlock(), Conversion::toInt(), ProGe::Parameter::value(), and widthFormula().

Referenced by copyTo().

Here is the call graph for this function:

◆ setDirection()

void ProGe::NetlistPort::setDirection ( Direction  direction)

Sets direction of the port.

Definition at line 381 of file NetlistPort.cc.

381 {
383}

References direction(), and direction_.

Referenced by ProGe::NetlistTools::mirror().

Here is the call graph for this function:

◆ setParent()

void ProGe::NetlistPort::setParent ( BaseNetlistBlock parent)
private

Set parent block of this port.

Parameters
newParentThe new parent. Can be NULL too.

Definition at line 439 of file NetlistPort.cc.

439 {
440 parentBlock_ = parent;
441}

References parentBlock_.

Referenced by ProGe::BaseNetlistBlock::addPort(), and ProGe::BaseNetlistBlock::removePort().

◆ setToStatic()

void ProGe::NetlistPort::setToStatic ( StaticSignal  value) const

Definition at line 410 of file NetlistPort.cc.

410 {
411
412 hasStaticValue_ = true;
413 staticValue_ = value;
414}

References hasStaticValue_, and staticValue_.

Referenced by DefaultICDecoderGenerator::addDummyIfetchDebugPorts(), and HDLPort::convertToNetlistPort().

◆ setWidthFormula()

void ProGe::NetlistPort::setWidthFormula ( const std::string &  newFormula)

Changes port's width formula.

Definition at line 324 of file NetlistPort.cc.

324 {
325 widthFormula_ = newFormula;
326}

References widthFormula_.

Referenced by DefaultICDecoderGenerator::addRV32MicroCode().

◆ staticValue()

StaticSignal ProGe::NetlistPort::staticValue ( ) const

Definition at line 429 of file NetlistPort.cc.

429 {
430 return staticValue_;
431}

References staticValue_.

Referenced by ProGe::VerilogNetlistWriter::portSignalName(), and ProGe::VHDLNetlistWriter::portSignalName().

◆ unsetStatic()

void ProGe::NetlistPort::unsetStatic ( ) const

Definition at line 417 of file NetlistPort.cc.

417 {
418
419 hasStaticValue_ = false;
420}

References hasStaticValue_.

Referenced by DefaultICDecoderGenerator::generateDebuggerCode().

◆ widthFormula()

std::string ProGe::NetlistPort::widthFormula ( ) const

Friends And Related Symbol Documentation

◆ BaseNetlistBlock

friend class BaseNetlistBlock
friend

Definition at line 72 of file NetlistPort.hh.

Member Data Documentation

◆ dataType_

DataType ProGe::NetlistPort::dataType_
private

Data type of the port.

Definition at line 144 of file NetlistPort.hh.

Referenced by dataType().

◆ direction_

Direction ProGe::NetlistPort::direction_
private

Direction of the port.

Definition at line 146 of file NetlistPort.hh.

Referenced by direction(), NetlistPort(), and setDirection().

◆ hasStaticValue_

bool ProGe::NetlistPort::hasStaticValue_
mutableprivate

Indicates if port is connected to vcc or gnd.

Definition at line 150 of file NetlistPort.hh.

Referenced by hasStaticValue(), setToStatic(), and unsetStatic().

◆ name_

std::string ProGe::NetlistPort::name_
private

Name of the port.

Definition at line 138 of file NetlistPort.hh.

Referenced by name(), and rename().

◆ parentBlock_

BaseNetlistBlock* ProGe::NetlistPort::parentBlock_
private

The parent netlist block.

Definition at line 148 of file NetlistPort.hh.

Referenced by hasParentBlock(), parentBlock(), parentBlock(), rename(), setParent(), and ~NetlistPort().

◆ realWidth_

int ProGe::NetlistPort::realWidth_
private

Real width of the port.

Definition at line 142 of file NetlistPort.hh.

Referenced by NetlistPort(), NetlistPort(), realWidth(), and realWidthAvailable().

◆ signal_

Signal ProGe::NetlistPort::signal_
private

Assigned port usage.

Definition at line 154 of file NetlistPort.hh.

Referenced by assignedSignal(), and assignSignal().

◆ staticValue_

StaticSignal ProGe::NetlistPort::staticValue_
mutableprivate

Static signal value.

Definition at line 152 of file NetlistPort.hh.

Referenced by setToStatic(), and staticValue().

◆ widthFormula_

std::string ProGe::NetlistPort::widthFormula_
private

Formula for the width of the port.

Definition at line 140 of file NetlistPort.hh.

Referenced by setWidthFormula(), and widthFormula().


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