- A Logic Circuit Simulation Library in C++





(libLCS Example) Delay Example - 4


This example illustrates the propogation delay through the off-the-shelf XOR gates provided in libLCS. Two XOR gates, one with delay more than the clock pulse width, and the other with delay less than the clock pulse width are initialised. The program is as follows.

#include <lcs/xor.h>
#include <lcs/simul.h>
#include <lcs/tester.h>
#include <lcs/changeMonitor.h>

using namespace lcs;

int main()
{
    Bus<1> a, b, s1, s2;
    Clock clk = Clock::getClock();
    Clock::setPulseWidth(5);

    // Initialising an XOR gate with a propogation delay of 
    // seven system time units. This delay is more than the 
    // pulse width of the input clock signal.
    Xor<2, 7> xorGate1(s1, (a,b));

    // Initialising an XOR gate with a propogation delay of 
    // three system time units. This delay is less than the 
    // pulse width of the input clock signal.
    Xor<2, 3> xorGate2(s2, (a,b));

    // Initialising change monitors to monitor the output of
    // the two XOR gates.
    ChangeMonitor<> output1(s1, "Output1", DUMP_ON);
    ChangeMonitor<> output2(s2, "Output2", DUMP_ON);

    Tester<2> tester((a,b));

    Simulation::setStopTime(50);
    Simulation::start();

    return 0;
}

The output when the above program is compiled and run is as follows.

At time: 3,     Output 2: 0
At time: 7,     Output 1: 0
At time: 13,    Output 2: 1
At time: 17,    Output 1: 1
At time: 23,    Output 2: 0
At time: 27,    Output 1: 0

Below is the screenshot of the gtkwave plot of the generated VCD file.

delay_example_4.jpg

Copyright © 2006, 2007 Siva Chandra