- A Logic Circuit Simulation Library in C++





lcs::InputBus< bits > Class Template Reference

#include <inbus.h>

Inheritance diagram for lcs::InputBus< bits >:

lcs::Bus< bits > lcs::Expression< bits, BUS_EXPR, void, void > List of all members.

Detailed Description

template<int bits = 1>
class lcs::InputBus< bits >

A class encapsulating a set of data lines to be used as an input to a 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.

Parameters:
bits The number of data lines in the bus.


Public Member Functions

 InputBus (void)
 InputBus (const InputBus< bits > &bus)
virtual ~InputBus ()
int width (void) const
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
template<int w>
const InputBus< w > partBus (int s) const
const InputBus< 1 > operator() (int index) const

Protected Attributes

DataPtr< Line > * dataPtr

Friends

class InputBus
class Bus


Constructor & Destructor Documentation

template<int bits>
lcs::InputBus< bits >::InputBus ( void   ) 

The default constructor. The data lines are all initialised to the lcs::UNKNOWN state.

template<int bits>
lcs::InputBus< bits >::InputBus ( const InputBus< bits > &  bus  ) 

Copy constructor. Performs only a shallow copy. The new InputBus object and bus share the same set of lines.

Parameters:
bus The InputBus object whose lines are used to create a new InputBus object.

template<int bits>
lcs::InputBus< bits >::~InputBus (  )  [virtual]

Destructor.


Member Function Documentation

template<int bits>
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.

Parameters:
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< outbits >, lcs::Bus< inBits >, and lcs::Bus< 1 >.

template<int bits>
const InputBus< 1 > lcs::InputBus< bits >::operator() ( int  index  )  const

An overloaded operator to obtain a single line bus of type lcs::InputBus which has one of the lines (inidicated using the parameter index) of the original bus.

Reimplemented in lcs::Bus< bits >, lcs::Bus< outbits >, lcs::Bus< inBits >, and lcs::Bus< 1 >.

template<int bits>
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.

Parameters:
line The right operand lcs::Line object.

Reimplemented in lcs::Bus< bits >, lcs::Bus< outbits >, lcs::Bus< inBits >, and lcs::Bus< 1 >.

template<int bits>
template<int w>
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.

Parameters:
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< outbits >, lcs::Bus< inBits >, and lcs::Bus< 1 >.

template<int bits>
void lcs::InputBus< bits >::operator>> ( int &  intVal  )  const

Writes the decimal value of the binary line values into an int variable.

Parameters:
intVal The decimal equivalent of the line states is written into this argument.

template<int bits>
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.

template<int bits>
template<int w>
const InputBus< w > lcs::InputBus< bits >::partBus ( int  s  )  const

Returns a part-bus formed from a set of consecutive lines of the original lcs::InputBus 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.

Parameters:
w The width of the part-bus.
s The start bit from where the part-bus should be accumulated.

Reimplemented in lcs::Bus< bits >, lcs::Bus< outbits >, lcs::Bus< inBits >, and lcs::Bus< 1 >.

template<int bits>
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.

Parameters:
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< outbits >, lcs::Bus< inBits >, and lcs::Bus< 1 >.

template<int bits = 1>
int lcs::InputBus< bits >::width ( void   )  const [inline]

Returns the bus width. Bus width is the same as the number of data lines in the bus.


Friends And Related Function Documentation

template<int bits = 1>
friend class Bus [friend]

InputBus classes of different sizes are friends of each other.

Reimplemented in lcs::Bus< bits >, lcs::Bus< outbits >, lcs::Bus< inBits >, and lcs::Bus< 1 >.

template<int bits = 1>
friend class InputBus [friend]

InputBus classes of different sizes are friends of each other.


Member Data Documentation

template<int bits = 1>
DataPtr<Line>* lcs::InputBus< bits >::dataPtr [protected]

A pointer to the array of lcs::Line objects encapsulated in an InputBus.


Copyright © 2006, 2007 Siva Chandra