OpenASIP  2.0
Bus.hh
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2009 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file Bus.hh
26  *
27  * Declaration of Bus class.
28  *
29  * @author Lasse Laasonen 2004 (lasse.laasonen-no.spam-tut.fi)
30  * @note reviewed 11 Jun 2004 by am, pj, jn, ll
31  * @note rating: red
32  */
33 
34 #ifndef TTA_BUS_HH
35 #define TTA_BUS_HH
36 
37 #include <string>
38 #include <vector>
39 
40 #include "MachinePart.hh"
41 #include "Machine.hh"
42 #include "Exception.hh"
43 
44 namespace TTAMachine {
45 
46 class Guard;
47 class Machine;
48 class Segment;
49 
50 /**
51  * Represents a bus in TTA-processor.
52  */
53 class Bus : public Component {
54 public:
55  Bus(const std::string& name, int width, int immWidth,
56  Machine::Extension extensionMode);
57  Bus(const ObjectState* state);
58  virtual ~Bus();
59  virtual Bus* copy() const;
60  virtual void copyGuardsTo(Bus& other) const;
61 
62  operator Segment&() { return *this->segment(0); }
63 
64  virtual int position() const;
65 
66  int width() const;
67  int immediateWidth() const;
68  bool signExtends() const;
69  bool zeroExtends() const;
70 
71  virtual void setName(const std::string& name);
72  virtual void setWidth(int width);
73  virtual void setImmediateWidth(int width);
74  virtual void setZeroExtends();
75  virtual void setSignExtends();
76  virtual void setExtensionMode(const Machine::Extension extension);
77 
78  virtual void addSegment(Segment& segment);
79  virtual void removeSegment(Segment& segment);
80  virtual bool hasSegment(const std::string& name) const;
81  virtual Segment* segment(int index) const;
82  virtual Segment* segment(const std::string& name) const;
83  virtual int segmentCount() const;
84 
85  virtual bool isConnectedTo(const Socket& socket) const;
86 
87  bool hasGuard(const Guard& guard) const;
88  void addGuard(Guard& guard);
89  virtual void removeGuard(Guard& guard);
90  int guardCount() const;
91  Guard* guard(int index) const;
92 
93  virtual bool hasNextBus() const;
94  virtual bool hasPreviousBus() const;
95  virtual Bus* nextBus() const;
96  virtual Bus* previousBus() const;
97 
98  virtual bool canRead(const Bus& bus) const;
99  virtual bool canWrite(const Bus& bus) const;
100  virtual bool canReadWrite(const Bus& bus) const;
101 
102  virtual void setSourceBridge(Bridge& bridge);
103  virtual void setDestinationBridge(Bridge& bridge);
104  virtual void clearSourceBridge(Bridge& bridge);
105  virtual void clearDestinationBridge(Bridge& bridge);
106 
107  virtual void setMachine(Machine& mach);
108  virtual void unsetMachine();
109 
110  virtual ObjectState* saveState() const;
111  virtual void loadState(const ObjectState* state);
112 
113  virtual bool isArchitectureEqual(const Bus& bus) const;
114 
115  /// ObjectState name for Bus ObjectState.
116  static const std::string OSNAME_BUS;
117  /// ObjectState attribute key for bus width.
118  static const std::string OSKEY_WIDTH;
119  /// ObjectState attribute key for immediate width.
120  static const std::string OSKEY_IMMWIDTH;
121  /// ObjectState attribute key for extension mode.
122  static const std::string OSKEY_EXTENSION;
123  /// ObjectState attribute value for sign extension.
124  static const std::string OSVALUE_SIGN;
125  /// ObjectState attribute key for zero extension.
126  static const std::string OSVALUE_ZERO;
127 
128 private:
129  /// Vector of Guard pointers.
130  typedef std::vector<Guard*> GuardTable;
131  /// Vector of Segment pointers.
132  typedef std::vector<Segment*> SegmentTable;
133  // Vector of Bridge pointers.
134  typedef std::vector<Bridge*> BridgeTable;
135 
136  /// Assingment forbidden.
137  Bus& operator=(const Bus&);
138  void loadStateWithoutReferences(const ObjectState* state);
139  void deleteAllSegments();
140  void deleteAllGuards();
141  Bridge* previousBridge() const;
142  Bridge* nextBridge() const;
143  Bridge* previousBridge(const BridgeTable& bridges) const;
144  Bridge* nextBridge(const BridgeTable& bridges) const;
145  void adjustSegmentChain(const ObjectState* busState);
146 
147  /// Bit width of the bus.
148  int width_;
149  /// Bit width of the inline immediate word.
151  /// Extension mode applied to the inline immediate word.
153 
154  /// Contains all guards of the bus.
156  /// Contains all the segments of the bus.
158 
159  /// Contains the source bridges (max 2).
161  /// Contains the destination bridges (max 2).
163 };
164 }
165 
166 #endif
TTAMachine::Bus::hasGuard
bool hasGuard(const Guard &guard) const
Definition: Bus.cc:393
TTAMachine::Bus::immediateWidth
int immediateWidth() const
Definition: Bus.cc:160
TTAMachine::Guard
Definition: Guard.hh:55
TTAMachine::Bus::segments_
SegmentTable segments_
Contains all the segments of the bus.
Definition: Bus.hh:157
TTAMachine::Bus::setSignExtends
virtual void setSignExtends()
Definition: Bus.cc:262
TTAMachine::Bus::OSVALUE_SIGN
static const std::string OSVALUE_SIGN
ObjectState attribute value for sign extension.
Definition: Bus.hh:124
TTAMachine::Bus::setDestinationBridge
virtual void setDestinationBridge(Bridge &bridge)
Definition: Bus.cc:613
TTAMachine::Bus::immWidth_
int immWidth_
Bit width of the inline immediate word.
Definition: Bus.hh:150
TTAMachine::Bus::setZeroExtends
virtual void setZeroExtends()
Definition: Bus.cc:253
TTAMachine::Component::name
virtual TCEString name() const
Definition: MachinePart.cc:125
TTAMachine::Bus::setImmediateWidth
virtual void setImmediateWidth(int width)
Definition: Bus.cc:241
TTAMachine::Bus::nextBridge
Bridge * nextBridge() const
Definition: Bus.cc:965
TTAMachine::Bus::setWidth
virtual void setWidth(int width)
Definition: Bus.cc:223
Exception.hh
TTAMachine::Bus::zeroExtends
bool zeroExtends() const
Definition: Bus.cc:182
TTAMachine::Bridge
Definition: Bridge.hh:51
TTAMachine::Bus::setSourceBridge
virtual void setSourceBridge(Bridge &bridge)
Definition: Bus.cc:594
TTAMachine::Segment
Definition: Segment.hh:54
TTAMachine::Bus::width
int width() const
Definition: Bus.cc:149
TTAMachine::Bus::loadState
virtual void loadState(const ObjectState *state)
Definition: Bus.cc:816
TTAMachine::Bus
Definition: Bus.hh:53
TTAMachine::Bus::previousBridge
Bridge * previousBridge() const
Definition: Bus.cc:947
TTAMachine::Bus::canWrite
virtual bool canWrite(const Bus &bus) const
Definition: Bus.cc:558
TTAMachine::Bus::~Bus
virtual ~Bus()
Definition: Bus.cc:113
ObjectState
Definition: ObjectState.hh:59
TTAMachine::Bus::addGuard
void addGuard(Guard &guard)
Definition: Bus.cc:410
TTAMachine::Bus::segment
virtual Segment * segment(int index) const
Definition: Bus.cc:329
TTAMachine::Bus::hasPreviousBus
virtual bool hasPreviousBus() const
Definition: Bus.cc:473
TTAMachine::Bus::guards_
GuardTable guards_
Contains all guards of the bus.
Definition: Bus.hh:155
MachinePart.hh
TTAMachine::Bus::signExtends
bool signExtends() const
Definition: Bus.cc:171
TTAMachine::Bus::loadStateWithoutReferences
void loadStateWithoutReferences(const ObjectState *state)
Definition: Bus.cc:863
TTAMachine::Bus::extensionMode_
Machine::Extension extensionMode_
Extension mode applied to the inline immediate word.
Definition: Bus.hh:152
TTAMachine::Bus::addSegment
virtual void addSegment(Segment &segment)
Definition: Bus.cc:737
TTAMachine::Bus::OSNAME_BUS
static const std::string OSNAME_BUS
ObjectState name for Bus ObjectState.
Definition: Bus.hh:116
TTAMachine::Bus::unsetMachine
virtual void unsetMachine()
Definition: Bus.cc:683
TTAMachine::Bus::operator=
Bus & operator=(const Bus &)
Assingment forbidden.
TTAMachine::Bus::position
virtual int position() const
Definition: Bus.cc:127
TTAMachine::Bus::destinationBridges_
BridgeTable destinationBridges_
Contains the destination bridges (max 2).
Definition: Bus.hh:162
TTAMachine::Bus::OSKEY_IMMWIDTH
static const std::string OSKEY_IMMWIDTH
ObjectState attribute key for immediate width.
Definition: Bus.hh:120
TTAMachine::Bus::canRead
virtual bool canRead(const Bus &bus) const
Definition: Bus.cc:537
TTAMachine::Bus::clearSourceBridge
virtual void clearSourceBridge(Bridge &bridge)
Definition: Bus.cc:632
TTAMachine::Bus::width_
int width_
Bit width of the bus.
Definition: Bus.hh:148
TTAMachine::Bus::setName
virtual void setName(const std::string &name)
Definition: Bus.cc:196
TTAMachine::Bus::isArchitectureEqual
virtual bool isArchitectureEqual(const Bus &bus) const
Definition: Bus.cc:1111
TTAMachine::Bus::SegmentTable
std::vector< Segment * > SegmentTable
Vector of Segment pointers.
Definition: Bus.hh:132
TTAMachine::Component
Definition: MachinePart.hh:90
TTAMachine::Socket
Definition: Socket.hh:53
TTAMachine::Bus::deleteAllGuards
void deleteAllGuards()
Definition: Bus.cc:930
TTAMachine::Bus::setMachine
virtual void setMachine(Machine &mach)
Definition: Bus.cc:671
TTAMachine::Bus::sourceBridges_
BridgeTable sourceBridges_
Contains the source bridges (max 2).
Definition: Bus.hh:160
Machine.hh
TTAMachine::Bus::hasSegment
virtual bool hasSegment(const std::string &name) const
Definition: Bus.cc:284
TTAMachine::Bus::deleteAllSegments
void deleteAllSegments()
Definition: Bus.cc:918
TTAMachine::Bus::isConnectedTo
virtual bool isConnectedTo(const Socket &socket) const
Definition: Bus.cc:303
TTAMachine::Bus::adjustSegmentChain
void adjustSegmentChain(const ObjectState *busState)
Definition: Bus.cc:1027
TTAMachine::Bus::guardCount
int guardCount() const
Definition: Bus.cc:441
TTAMachine::Bus::guard
Guard * guard(int index) const
Definition: Bus.cc:456
TTAMachine::Bus::canReadWrite
virtual bool canReadWrite(const Bus &bus) const
Definition: Bus.cc:580
TTAMachine::Bus::clearDestinationBridge
virtual void clearDestinationBridge(Bridge &bridge)
Definition: Bus.cc:652
TTAMachine::Bus::GuardTable
std::vector< Guard * > GuardTable
Vector of Guard pointers.
Definition: Bus.hh:130
TTAMachine::Bus::saveState
virtual ObjectState * saveState() const
Definition: Bus.cc:773
TTAMachine::Bus::hasNextBus
virtual bool hasNextBus() const
Definition: Bus.cc:488
TTAMachine::Bus::removeGuard
virtual void removeGuard(Guard &guard)
Definition: Bus.cc:428
TTAMachine::Bus::OSKEY_WIDTH
static const std::string OSKEY_WIDTH
ObjectState attribute key for bus width.
Definition: Bus.hh:118
TTAMachine::Bus::removeSegment
virtual void removeSegment(Segment &segment)
Definition: Bus.cc:757
TTAMachine::Bus::previousBus
virtual Bus * previousBus() const
Definition: Bus.cc:518
TTAMachine::Bus::setExtensionMode
virtual void setExtensionMode(const Machine::Extension extension)
Definition: Bus.cc:271
TTAMachine::Bus::BridgeTable
std::vector< Bridge * > BridgeTable
Definition: Bus.hh:134
TTAMachine::Machine::Extension
Extension
Definition: Machine.hh:80
TTAMachine::Bus::OSVALUE_ZERO
static const std::string OSVALUE_ZERO
ObjectState attribute key for zero extension.
Definition: Bus.hh:126
TTAMachine
Definition: Assembler.hh:48
TTAMachine::Bus::nextBus
virtual Bus * nextBus() const
Definition: Bus.cc:501
TTAMachine::Bus::OSKEY_EXTENSION
static const std::string OSKEY_EXTENSION
ObjectState attribute key for extension mode.
Definition: Bus.hh:122
TTAMachine::Bus::segmentCount
virtual int segmentCount() const
Definition: Bus.cc:385
TTAMachine::Machine
Definition: Machine.hh:73
TTAMachine::Bus::copy
virtual Bus * copy() const
Definition: Bus.cc:1145
TTAMachine::Bus::Bus
Bus(const std::string &name, int width, int immWidth, Machine::Extension extensionMode)
Definition: Bus.cc:74
TTAMachine::Bus::copyGuardsTo
virtual void copyGuardsTo(Bus &other) const
Definition: Bus.cc:1155