- A Logic Circuit Simulation Library in C++ |
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.
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, "Output 1"); ChangeMonitor<> output2(s2, "Output 2"); 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