- A Logic Circuit Simulation Library in C++ |
#include <inbus.h>
Inheritance diagram for lcs::InputBus< bits >:
lcs::Module
object. A client can only read the data lines and cannot set/modify them. Use the class lcs::Bus
in order to obtain encapsulated lines whose levels can be set.
bits | The number of data lines in the bus. |
Public Member Functions | |
InputBus (void) | |
InputBus (const InputBus< bits > &bus) | |
virtual | ~InputBus () |
int | width (void) |
void | notify (Module *mod, const LineEvent &event, const int &portId, const int &line=-1) throw (OutOfRangeException<int>) |
void | stopNotification (Module *mod, const LineEvent &event, const int &portId, const int &line=-1) throw (OutOfRangeException<int>) |
const LineState | operator[] (int i) const throw (OutOfRangeException<int>) |
template<int w> | |
const InputBus< w+bits > | operator, (const InputBus< w > &bus) const |
const InputBus< bits+1 > | operator, (const Line &line) const |
void | operator>> (int &intVal) const |
Protected Attributes | |
DataPtr< Line > * | dataPtr |
Friends | |
class | InputBus |
class | Bus |
lcs::InputBus< bits >::InputBus | ( | void | ) |
The default constructor. The data lines are all initialised to the lcs::UNKNOWN state.
lcs::InputBus< bits >::InputBus | ( | const InputBus< bits > & | bus | ) |
lcs::InputBus< bits >::~InputBus | ( | ) | [virtual] |
Destructor.
void lcs::InputBus< bits >::notify | ( | Module * | mod, | |
const LineEvent & | event, | |||
const int & | portId, | |||
const int & | line = -1 | |||
) | throw (OutOfRangeException<int>) |
Registers the module which has to be notified about an occurance of a line event. A module can request notification at the occurance of one of the three different kinds of line events. These line events are enumerated as lcs::LineEvent
members. Every module which intends to be driven by an InputBus
will have to register itself using this function. Also, the module should be an object of a class which is a derivate of the lcs::Module
class.
This function typically needs to be used only by module implementers in the constructors of their lcs::Module
derivatives. Other users will never need to use this function.
mod | Pointer to the lcs::Module object which has to be notified about a line event. | |
event | The event type whose occurance the module will be notified of. For example, if lcs::LINE_POS_EDGE is used, then the module will notified at the occurance of a positive edge on the line. | |
portId | The id of the module port to which the bus is connected. The bus will use this id while notifying the module. | |
line | The index of the bus line whose line events the module seeks to be notified of. The default value is -1. In general, a negetive value indicates that the module should be notified of the event occuring on all lines of the bus. |
Reimplemented in lcs::Bus< bits >, lcs::Bus< inBits >, and lcs::Bus< 1 >.
const InputBus< bits+1 > lcs::InputBus< bits >::operator, | ( | const Line & | line | ) | const |
The overloaded operator to join a data line to a bus to form a new bus. The line to be joined will have to be the right operand. The joined line takes the MSB location in the resulting InputBus
object.
line | The right operand lcs::Line object. |
Reimplemented in lcs::Bus< bits >, lcs::Bus< inBits >, and lcs::Bus< 1 >.
const InputBus< w+bits > lcs::InputBus< bits >::operator, | ( | const InputBus< w > & | bus | ) | const |
The overloaded operator to join data lines from two busses and form a new bus from these. The right operand bus takes the MSB locations of the new InputBus
object.
bits | The width of the left-operand bus | |
w | The width of the right operand bus | |
bus | The right operand Bus object. |
Reimplemented in lcs::Bus< bits >, lcs::Bus< inBits >, and lcs::Bus< 1 >.
void lcs::InputBus< bits >::operator>> | ( | int & | intVal | ) | const |
Writes the decimal value of the binary line values into an int
variable.
intVal The decimal equivalent of the line states is written into this argument.
const LineState lcs::InputBus< bits >::operator[] | ( | int | i | ) | const throw (OutOfRangeException<int>) |
Overloaded operator which returns a const lcs::LineState variable corresponding to the state of the line at index i
. An OutOfRangeException
is thrown if the index value i
is beyond the bus width. The returned value is only a copy of the line state.
void lcs::InputBus< bits >::stopNotification | ( | Module * | mod, | |
const LineEvent & | event, | |||
const int & | portId, | |||
const int & | line = -1 | |||
) | throw (OutOfRangeException<int>) |
De-registers a module from the list of modules which have to be notified. See InputBus::notify
for more details.
This function typically needs to be used only by module implementers in the destructors of their lcs::Module
derivatives. Other users will never need to use this function.
mod | Pointer to the lcs::Module object which has to be de-registered. | |
event | The event type whose occurance the module was be notified. | |
portId | The id of the module port to which the bus is connected. | |
line | The index of the bus line whose line events the module sought to be notified of. The default value is -1. In general, a negetive value indicates that the module should de-registered from being notified by all lines of the bus. |
Reimplemented in lcs::Bus< bits >, lcs::Bus< inBits >, and lcs::Bus< 1 >.
int lcs::InputBus< bits >::width | ( | void | ) | [inline] |
Returns the bus width. Bus width is the same as the number of data lines in the bus.
friend class Bus [friend] |
InputBus classes of different sizes are friends of each other.
Reimplemented in lcs::Bus< bits >, lcs::Bus< inBits >, and lcs::Bus< 1 >.
friend class InputBus [friend] |
InputBus classes of different sizes are friends of each other.
DataPtr<Line>* lcs::InputBus< bits >::dataPtr [protected] |