Flip-Flop

Ok, Lets start from simple designs. One of the most simple and basic designs we can try is a flip-flop!
  1. start by downloading dff.h and sc_main.cpp and study them carefully!
  2. fix the module in "dff.h" in order to move the input to the output at rigsing edge of the clock and add sensitivity to its cosntructor(SC_CTOR).
  3. study "sc_main.cpp" and see why it works and how it connects to the module and how it adds the signals to the VCD file.
  4. run the your code with the following comamnd (you might need to change the path to your library):
  5. g++ -I. -I$SYSTEMC_HOME/include -L. -L$SYSTEMC_HOME/lib-linux64 -Wl,-rpath=$SYSTEMC_HOME/lib-linux64 -o main sc_main.cpp -lsystemc -lm
  6. run your executable to genrate your VCD file
  7. if everything works ok, you should be able to see a waveform like this:
  8. Modify your design to use SC_THREAD instead of SC_METHOD. Can you get the same result?
  9. Well Done! you have made your first design in SystemC!

Questions!

  1. Can you make the flip-flop directly sensitive in the constructor?
  2. What is the difference between SC_THREAD and SC_METHOD?
  3. What are .read() and .write() methods do?
  4. what does dont_initialize() do?