Ok, Lets start from simple designs. One of the most simple and basic designs we can try is a flip-flop!
- start by downloading dff.h and sc_main.cpp and study them carefully!
- 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).
- 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.
- run the your code with the following comamnd (you might need to change the path to your library):
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
- run your executable to genrate your VCD file
- if everything works ok, you should be able to see a waveform like this:
- Modify your design to use SC_THREAD instead of SC_METHOD. Can you get the same result?
- Well Done! you have made your first design in SystemC!
Questions!
- Can you make the flip-flop directly sensitive in the constructor?
- What is the difference between SC_THREAD and SC_METHOD?
- What are .read() and .write() methods do?
- what does dont_initialize() do?
Related Readings