- A Logic Circuit Simulation Library in C++ |
#include <bus.h>
Inheritance diagram for lcs::Bus< bits >:
Bus
object is achieved through the lcs::InputBus::operator[]
function. There are overloaded operators provided which can be used to join two busses to form a wider composite bus.
Writing to bus lines should only be allowed for a module which is driving the bus. This sort of access control is provided through the inner class LineAccessor
, and the three member functions Bus::lock
, Bus::unLock
and Bus::getLineAccessor
.
bits | The number of data lines in the bus. |
Public Member Functions | |
Bus (void) | |
Bus (int val) | |
Bus (const Bus< bits > &bus) | |
virtual | ~Bus () |
template<int w> | |
const Bus< w > | partSelect (int s) const |
template<unsigned int delay, int exBits, ExprType Type, typename LExprType, typename RExprType> | |
void | cass (const Expression< exBits, Type, LExprType, RExprType > &expr) |
template<unsigned int delay, int width> | |
void | cass (const InputBus< width > &b) |
void | operator= (int a) |
void | operator= (const LineState &l) |
template<int w, ExprType Type, typename LExprType, typename RExprType> | |
void | operator= (const Expression< w, Type, LExprType, RExprType > &expr) |
template<int w, ExprType Type, typename LExprType, typename RExprType> | |
void | operator= (const DelayExprPair< w, Type, LExprType, RExprType > &dep) |
void | operator= (const DelayStatePair &dsp) |
Expression< 1, LINE_EXPR, void, void > | operator[] (int i) throw (OutOfRangeException<int>) |
template<int w> | |
const Bus< w+bits > | operator, (const Bus< w > &bus) const |
template<int w> | |
const InputBus< w+bits > | operator, (const InputBus< w > &bus) const |
const Bus< bits+1 > | operator, (const Line &line) const |
Private Member Functions | |
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>) |
Friends | |
class | Bus |
The default constructor. The data lines are all initialised to the lcs::UNKNOWN
state.
Line initialising constructor. The bus lines are initialised in the little-endian notation with the binary equivalent of a decimal integer. If the integer has excess bits than the bus width, then they are ignored.
val | The decimal integer with which the bus lines have to be initialised. |
void lcs::Bus< bits >::cass | ( | const InputBus< width > & | b | ) |
A template function to assign a continuous assignment to the bus from an lcs::InputBus
object. The template parameter width
is deduced from the width of the lcs::InputBus
object passed as an argument to the function. Hence, a call to this function will have to explicitly specify a single parameter which indicates the assignment delay.
void lcs::Bus< bits >::cass | ( | const Expression< exBits, Type, LExprType, RExprType > & | expr | ) |
A template function to assign a continuous assignment expression to the bus. All template parameters except the parameter delay
are deduced from the expression passed as an argument to the function. Hence, a call to this function will have to explicitly specify a single parameter which indicates the assignment delay.
void lcs::Bus< bits >::notify | ( | Module * | mod, | |
const LineEvent & | event, | |||
const int & | portId, | |||
const int & | line = -1 | |||
) | throw (OutOfRangeException<int>) [inline, private] |
Does nothing. This function is inherited from InputBus
. However, it has been declared private so that a lcs::Module derivative is prevented from using a lcs::Bus
object to register to drive a module.
Reimplemented from lcs::InputBus< bits >.
The overloaded operator to join a data line to a bus to form a new composite bus. The line to be joined will have to be the right operand. The joined line takes the MSB location in the resulting lcs::Bus
object.
line | The right operand lcs::Line object. |
Reimplemented from lcs::InputBus< bits >.
const InputBus< w+bits > lcs::Bus< 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 from lcs::InputBus< bits >.
const Bus< w+bits > lcs::Bus< bits >::operator, | ( | const Bus< w > & | bus | ) | const |
The overloaded operator to join data lines from two busses and form a new composite bus. The right operand bus takes the MSB locations.
bits | The width of the left-operand bus | |
w | The width of the right operand bus | |
bus | The right operand lcs::Bus object. |
void lcs::Bus< bits >::operator= | ( | const DelayStatePair & | dsp | ) |
Assignment operator for assignment with a delay-state pair. An example of usage of this overloaded assignment operator is as follows:
lcs::Bus<3> b1; b1 = (5, lcs::HIGH);
In the second line of the above code snippet, an assignment is being made to the lcs::Bus
object on the LHS with a delay-state pair in the RHS. The value of delay used here is 5 system time units. Note the use of the neccessary parentheses enclosing the delay-state pair.
void lcs::Bus< bits >::operator= | ( | const DelayExprPair< w, Type, LExprType, RExprType > & | dep | ) |
Assignment operator for assignment with a delay-expression pair. An example of usage of this overloaded assignment operator is as follows:
lcs::Bus<3> b1(0), b2(5), b3(7); b1 = (5, b2 ^ b3);
In the second line of the above code snippet, an assignment is being made to the lcs::Bus
object on the LHS with a delay-expression pair in the RHS. The value of delay used here is 5 system time units. Note the use of the neccessary parentheses enclosing the delay-expression pair.
void lcs::Bus< bits >::operator= | ( | const Expression< w, Type, LExprType, RExprType > & | expr | ) |
Assignment operator to facilitate assignment using an lcs::Expression
object. ie., the operator facilitates assignment with an expression of bitwise operations on the right hand side of the assignment operator.
Assigns a desired linestate to all the lines of the bus.
void lcs::Bus< bits >::operator= | ( | int | a | ) |
Assigns the binary bit equivalent of an integer to the bus lines.
Expression< 1, LINE_EXPR, void, void > lcs::Bus< bits >::operator[] | ( | int | i | ) | throw (OutOfRangeException<int>) [inline] |
Overloaded operator which returns a suitable expression object corresponding to the line at index i
. This is done so that bit-selects can be used in expressions of bitwise operations. An OutOfRangeException
is thrown if the index value i
is beyond the bus width.
Returns a part-bus formed from a set of consecutive lines of the original lcs::Bus
object. If s+w
goes beyond the range of the original bus width, then, only the lines within range are assigned lines of the new bus object.
w | The width of the part-bus. | |
s | The start bit from where the part-bus should be accumulated. |
Reimplemented from lcs::InputBus< bits >.
void lcs::Bus< bits >::stopNotification | ( | Module * | mod, | |
const LineEvent & | event, | |||
const int & | portId, | |||
const int & | line = -1 | |||
) | throw (OutOfRangeException<int>) [inline, private] |
Does nothing. This function is inherited from InputBus
. However, it has been declared private so that the user is prevented from using a Bus
object to de-register to drive (or un-drive) a module.
Reimplemented from lcs::InputBus< bits >.
friend class Bus [friend] |
Bus classes of different sizes are friends of each other.
Reimplemented from lcs::InputBus< bits >.