Go to the documentation of this file.
75 const std::string& name,
int width,
int immWidth,
80 extensionMode_(extensionMode) {
81 if (
width <= 0 || immWidth < 0 || immWidth >
width) {
82 string procName =
"Bus::Bus";
83 throw OutOfRange(__FILE__, __LINE__, procName);
133 for (
int i = 0; i < busNav.
count(); i++) {
134 if (busNav.
item(i) ==
this) {
203 machine()->immediateSlotNavigator().hasItem(
name)) {
204 string procName =
"Bus::setName";
224 const string procName =
"Bus::setWidth";
227 throw OutOfRange(__FILE__, __LINE__, procName);
242 if (width < 0 || width > this->
width()) {
243 string procName =
"Bus::setImmediateWidth";
244 throw OutOfRange(__FILE__, __LINE__, procName);
285 SegmentTable::const_iterator iter =
segments_.begin();
287 if ((*iter)->name() ==
name) {
305 SegmentTable::const_iterator iter =
segments_.begin();
307 if ((*iter)->isConnectedTo(socket)) {
331 string procName =
"Bus::segment";
332 throw OutOfRange(__FILE__, __LINE__, procName);
337 SegmentTable::const_iterator iter =
segments_.begin();
348 Segment* nextSegment = firstSegment;
349 for (
int i = 0; i < index; i++) {
366 SegmentTable::const_iterator iter =
segments_.begin();
368 if ((*iter)->name() ==
name) {
375 string procName =
"Bus::segment";
394 for (GuardTable::const_iterator iter =
guards_.begin();
395 iter !=
guards_.end(); iter++) {
396 if ((*iter)->isEqual(
guard)) {
412 string procName =
"Bus::addGuard";
414 "Bus already has the given guard!");
457 if (index < 0 ||
static_cast<size_t>(index) >=
guards_.size()) {
458 string procName =
"Bus::guard";
459 throw OutOfRange(__FILE__, __LINE__, procName);
475 return prevBridge != NULL;
490 return nextBridge != NULL;
503 if (nextBridge != NULL) {
506 string procName =
"Bus::nextBus";
520 if (prevBridge != NULL) {
523 string procName =
"Bus::previousBus";
540 if ((*iter)->sourceBus() == &bus) {
561 if ((*iter)->destinationBus() == &bus) {
694 SegmentTable::iterator iter =
segments_.begin();
696 (*iter)->detachAllSockets();
702 for (
int i = 0; i < bNavigator.
count();) {
703 if (bNavigator.
item(i)->sourceBus() ==
this ||
704 bNavigator.
item(i)->destinationBus() ==
this) {
707 delete bNavigator.
item(i);
716 for (
int i = 0; i < itNav.
count(); i++) {
742 string procname =
"Bus::addSegment";
825 for (
int i = 0; i < state->
childCount(); i++) {
830 }
else if (childState->
name() ==
834 }
else if (childState->
name() ==
846 const string procName =
"Bus::loadState";
848 __FILE__, __LINE__, procName, exception.
errorMessage());
864 const string procName =
"Bus::loadStateWithoutReferences";
868 __FILE__, __LINE__, procName,
869 "Invalid XML object state for a bus, name: " + state->
name());
893 for (
int i = 0; i < state->
childCount(); i++) {
901 format errorMsg = textGen.
text(
906 __FILE__, __LINE__, procName, errorMsg.str());
949 if (prevBridge == NULL) {
967 if (nextBridge == NULL) {
984 BridgeTable::const_iterator iter = bridges.begin();
985 while (iter != bridges.end()) {
987 if (bridge->
nextBus() ==
this) {
1006 BridgeTable::const_iterator iter = bridges.begin();
1007 while (iter != bridges.end()) {
1028 const string procName =
"Bus::adjustSegmentChain";
1040 for (
int i = 0; i < busState->
childCount(); i++) {
1044 string lastSegmentName =
1046 lastSegment =
segment(lastSegmentName);
1052 if (lastSegment == NULL) {
1053 format errorMsg = textGenerator.
text(
1057 __FILE__, __LINE__, procName, errorMsg.str());
1060 Segment* destSegment = lastSegment;
1061 int modifications = 0;
1066 bool chainModified =
false;
1067 for (
int i = 0; i < busState->
childCount(); i++) {
1073 if (destName == destSegment->
name()) {
1074 string thisName = childState->
1078 destSegment = thisSegment;
1080 chainModified =
true;
1087 if (!chainModified && modifications <
segmentCount() - 1) {
1088 format errorMsg = textGenerator.
text(
1090 errorMsg %
name() % destSegment->
name();
1092 __FILE__, __LINE__, procName, errorMsg.str());
1097 __FILE__, __LINE__, procName, exception.
errorMessage());
1131 if (match ==
false) {
1147 Bus* newBus =
new Bus(newBusState);
bool hasGuard(const Guard &guard) const
int immediateWidth() const
virtual ObjectState * saveState() const
void internalUnsetMachine()
SegmentTable segments_
Contains all the segments of the bus.
bool hasAttribute(const std::string &name) const
virtual void setSignExtends()
static const std::string OSVALUE_SIGN
ObjectState attribute value for sign extension.
virtual void setName(const std::string &name)
virtual void setDestinationBridge(Bridge &bridge)
int immWidth_
Bit width of the inline immediate word.
virtual void setZeroExtends()
Bus * destinationBus() const
virtual TCEString name() const
virtual void setImmediateWidth(int width)
std::string stringAttribute(const std::string &name) const
Bridge * nextBridge() const
virtual bool isRegistered() const
static const std::string OSNAME_REGISTER_GUARD
ObjectState name for RegisterGuard.
virtual void setWidth(int width)
virtual void setSourceBridge(Bridge &bridge)
virtual void loadState(const ObjectState *state)
virtual bool isEqual(const Guard &guard) const =0
Bridge * previousBridge() const
virtual ObjectState * saveState() const
virtual bool canWrite(const Bus &bus) const
virtual void removeBus(Bus &bus)
Segment * destinationSegment() const
static const std::string OSKEY_NAME
ObjectState attribute key for segment name.
void addGuard(Guard &guard)
virtual boost::format text(int textId)
virtual Segment * segment(int index) const
void setName(const std::string &name)
virtual bool hasPreviousBus() const
GuardTable guards_
Contains all guards of the bus.
virtual void loadState(const ObjectState *state)
void internalSetMachine(Machine &machine)
void loadStateWithoutReferences(const ObjectState *state)
static const std::string OSNAME_SEGMENT
ObjectState name for Segment.
Machine::Extension extensionMode_
Extension mode applied to the inline immediate word.
virtual void addSegment(Segment &segment)
#define assert(condition)
static const std::string OSNAME_BUS
ObjectState name for Bus ObjectState.
virtual void unsetMachine()
virtual int position() const
BridgeTable destinationBridges_
Contains the destination bridges (max 2).
virtual void copyTo(Bus &parentBus) const =0
static const std::string OSKEY_IMMWIDTH
ObjectState attribute key for immediate width.
virtual bool canRead(const Bus &bus) const
virtual BridgeNavigator bridgeNavigator() const
virtual void clearSourceBridge(Bridge &bridge)
int width_
Bit width of the bus.
virtual void setName(const std::string &name)
virtual void loadState(const ObjectState *state)
virtual bool isArchitectureEqual(const Bus &bus) const
ObjectState * child(int index) const
void addChild(ObjectState *child)
virtual void setMachine(Machine &mach)
BridgeTable sourceBridges_
Contains the source bridges (max 2).
bool hasChild(const std::string &name) const
virtual bool hasSegment(const std::string &name) const
virtual bool isConnectedTo(const Socket &socket) const
virtual void addBus(Bus &bus)
void adjustSegmentChain(const ObjectState *busState)
bool hasSourceSegment() const
Guard * guard(int index) const
virtual ObjectState * saveState() const
std::string errorMessage() const
Bus * previousBus() const
virtual bool canReadWrite(const Bus &bus) const
virtual void clearDestinationBridge(Bridge &bridge)
virtual Bus * parentBus() const
virtual ObjectState * saveState() const
virtual bool hasNextBus() const
virtual void removeGuard(Guard &guard)
static const std::string OSKEY_WIDTH
ObjectState attribute key for bus width.
virtual void removeSegment(Segment &segment)
virtual Bus * previousBus() const
virtual Machine * machine() const
virtual void setExtensionMode(const Machine::Extension extension)
virtual BusNavigator busNavigator() const
void moveBefore(Segment &segment)
int intAttribute(const std::string &name) const
std::vector< Bridge * > BridgeTable
static const std::string OSKEY_DESTINATION
ObjectState attribute key for destination segment name.
@ TXT_SEGMENT_WITH_SAME_NAME
ComponentType * item(int index) const
static const std::string OSVALUE_ZERO
ObjectState attribute key for zero extension.
static const std::string OSNAME_PORT_GUARD
ObjectState name for PortGuard ObjectState.
virtual Bus * nextBus() const
virtual void removeSlot(const std::string &slotName)
virtual InstructionTemplateNavigator instructionTemplateNavigator() const
static const std::string OSNAME_UNCONDITIONAL_GUARD
ObjectState name for UnconditionalGuard.
static const std::string OSKEY_EXTENSION
ObjectState attribute key for extension mode.
virtual int segmentCount() const
void setAttribute(const std::string &name, const std::string &value)
virtual Bus * copy() const
Bus(const std::string &name, int width, int immWidth, Machine::Extension extensionMode)
virtual void copyGuardsTo(Bus &other) const