- A Logic Circuit Simulation Library in C++ |
In this example, we will use feedback around a NOT gate which has a propogation delay. This results in a pulse at the output of the NOT gate with time period twice the propogation delay.
#include <lcs/not.h> #include <lcs/simul.h> #include <lcs/changeMonitor.h> using namespace lcs; int main() { Bus<> b(0); Not<5> notGate(b, b); ChangeMonitor<> s1m(b, "Output", DUMP_ON); Simulation::setStopTime(50); Simulation::start(); return 0; }
The following is the output when the above program is compiled and run.
At time: 5, Output: 1 At time: 10, Output: 0 At time: 15, Output: 1 At time: 20, Output: 0 At time: 25, Output: 1 At time: 30, Output: 0 At time: 35, Output: 1 At time: 40, Output: 0 At time: 45, Output: 1 At time: 50, Output: 0
Below is the screenshot of the gtkwave plot of the generated VCD file.