- A Logic Circuit Simulation Library in C++





lcs::Bus< bits > Class Template Reference

#include <bus.h>

Inheritance diagram for lcs::Bus< bits >:

lcs::InputBus< bits > lcs::Array1D< T, len > lcs::InOutBus< bits > List of all members.

Detailed Description

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

This is a class encapsulating a set of data lines to be used as a generic bus in logic circuit systems. The data lines are conceptially organised in the little endian format. A user can set the bus line data through access control mechanism. Reading the individual data lines of a 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.

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


Public Member Functions

 Bus (void)
 Bus (int val)
 Bus (const Bus< bits > &bus)
 Bus (const Line &line) throw (OutOfRangeException<int>)
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)
Bus< 1 > operator[] (unsigned int i) throw (OutOfRangeException<unsigned 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


Constructor & Destructor Documentation

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

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

template<int bits>
lcs::Bus< bits >::Bus ( int  val  ) 

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.

Parameters:
val The decimal integer with which the bus lines have to be initialised.

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

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

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

template<int bits>
lcs::Bus< bits >::Bus ( const Line line  )  throw (OutOfRangeException<int>)

Creates a single-line bus object containing the line object which is passed as the argument. One can only use 1 as the class template argument. Other numbers will lead to an lcs::OutOfRangeException<int>

Parameters:
line The line object which is encapsulated in the resultant bus object.

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

Destructor.


Member Function Documentation

template<int bits>
template<unsigned int delay, int width>
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.

template<int bits>
template<unsigned int delay, int exBits, ExprType Type, typename LExprType, typename RExprType>
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.

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

template<int bits>
const Bus< bits+1 > lcs::Bus< bits >::operator, ( const Line line  )  const

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.

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

Reimplemented from lcs::InputBus< bits >.

Reimplemented in lcs::InOutBus< bits >.

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

Parameters:
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 >.

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

Parameters:
bits The width of the left-operand bus
w The width of the right operand bus
bus The right operand lcs::Bus object.

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

Reimplemented in lcs::InOutBus< bits >.

template<int bits>
template<int w, ExprType Type, typename LExprType, typename RExprType>
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.

Reimplemented in lcs::InOutBus< bits >.

template<int bits>
template<int w, ExprType Type, typename LExprType, typename RExprType>
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.

Reimplemented in lcs::InOutBus< bits >.

template<int bits>
void lcs::Bus< bits >::operator= ( const LineState l  ) 

Assigns a desired linestate to all the lines of the bus.

Reimplemented in lcs::InOutBus< bits >.

template<int bits>
void lcs::Bus< bits >::operator= ( int  a  ) 

Assigns the binary bit equivalent of an integer to the bus lines.

Reimplemented in lcs::InOutBus< bits >.

template<int bits>
Bus< 1 > lcs::Bus< bits >::operator[] ( unsigned int  i  )  throw (OutOfRangeException<unsigned 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.

Reimplemented from lcs::Array1D< T, len >.

Reimplemented in lcs::InOutBus< bits >.

template<int bits>
template<int w>
const Bus< w > lcs::Bus< bits >::partSelect ( int  s  )  const

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.

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

Reimplemented from lcs::InputBus< bits >.

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


Friends And Related Function Documentation

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

Bus classes of different sizes are friends of each other.

Reimplemented from lcs::InputBus< bits >.


Copyright © 2006, 2007 Siva Chandra