Node:Utility Modules, Previous:System Time and Sequential Circuit Elements, Up:Introduction to libLCS
libLCS provides few off-the-shelf utility modules which a user can use in his/her simulations. Each of these modules is described in detail in this section.
The Buffer
template class can be used as a delay buffer for any bus. This class requires two template parameters.
The first parameter indicates the number of lines in the bus for which it acts as a buffer, and the second parameter
indicates the delay. The declaration of the Buffer
class is as follows:
template <unsigned int lines, unsigned int delay = 0> class Buffer;The
Buffer
class is defined in the header file lcs/buffer.h
. Note that the above declaration indicates a
default value of 0 for the delay of the buffer module. A small example illustrating its usage is as below. The buffer
class constructor requires the output bus as the first argument, and the input bus as the second argument.
#include <lcs/lcs.h> using namespace lcs; using namespace std; int main(void) { Bus<5> output, input; // Declaring a 5 input buffer with a delay of // 5 system time units. Buffer<5, 5> buffer(output, input); ChangeMonitor<5> cm(input, "input", DUMP_ON); ChangeMonitor<5> cb(output, "output", DUMP_ON); Tester<5> tester(input); Simulation::setStopTime(5000); Simulation::start(); return 0; }
The FanOut
template class (which requires two template parameters) encapsulates a module which takes a single
input and generates a user specified number of copies of the input as output. The desired number of outputs should be
specified as the first template parameter. The second template parameter specifies the input to output propogation
delay. The declaration of the FanOut
class is as follows:
template <unsigned int n = 1, unsigned int delay = 0> class FanOut;The
FanOut
class is defined in the header file lcs/fanout.h
. Note that the above declaration indicates a
default value of 1 output line, and a default value of 0 propogation delay of the fanout module. A small example
illustrating its usage is as below. The FanOut
class constructor requires the output bus as the first argument,
and the single-line input bus as the second argument.
#include <lcs/lcs.h> using namespace lcs; using namespace std; int main(void) { Bus<5> output; Clock clk = Clock::getClock(); // Initialising a FanOut object which takes the // system clock as input and generates 5 copies // of it. Also, the time delay between the new // copies and the input clock pulse is specified // through the second template parameter as 5 // system time units. FanOut<5, 5> fanout(output, clk); ChangeMonitor<1> cm(clk, "clk", DUMP_ON); ChangeMonitor<5> cb(output, "output", DUMP_ON); Simulation::setStopTime(5000); Simulation::start(); return 0; }