#include"Three_processes.h"
int sc_main(int sc_argc, char* sc_argv[]) {
//create an instance of the SystemC module
sc_clock clk("clock", 10, SC_NS);
Three_Processes U_Three_Processes("U_Three_Processes");
U_Three_Processes.clk(clk);
sc_start(100, SC_NS); // invoke the simulator
return 0;
}
#include <systemc.h>
SC_MODULE(Three_Processes) { // declare module class
sc_in <bool> clk;
SC_CTOR(Three_Processes) { // create a constructor
SC_THREAD(first_thread);// register the process
sensitive << clk.pos();
SC_THREAD(second_thread);// register the proces
sensitive << clk.pos();
SC_THREAD(third_thread);// register the process
sensitive << clk.pos();
std::cout << "Simulation Start!!" << std::endl;
}//end constructor
void first_thread(void);
void second_thread(void);
void third_thread(void);
};
#include "Three_processes.h"
void Three_Processes::first_thread(void) {
while (1) {
wait();
std::cout << sc_time_stamp() << ": I'm first thread!" << std::endl;
}
}
void Three_Processes::second_thread(void) {
while (1) {
wait();
//wait(SC_ZERO_TIME);
std::cout << sc_time_stamp() << ": I'm second thread!" << std::endl;
}
}
void Three_Processes::third_thread(void) {
while (1) {
wait();
//wait(SC_ZERO_TIME);
//wait(SC_ZERO_TIME);
std::cout << sc_time_stamp() << ": I'm third thread!" << std::endl;
}
}