//This program:MULTIPLIES A VARIABLE "A" BY 2 //through the use of 2 concurrently interacting //SystemC software-based modules. One might consider this //a beginning to HW/SW partitioning and co-simulation. In this case, //the calculations(multiplication) done in this program //has been "partitioned" into another software module. #include "systemc.h" SC_MODULE (mult_p1) { sc_in done; sc_in > a_in; sc_out > a_out; sc_out start; unsigned int a; SC_CTOR (mult_p1) { SC_THREAD (process); } void process() { //Allow the 2nd Thread to "Start" and Run Concurrently //with this one. wait(1,SC_NS); //Set-up the data going to the 2nd module //by simply assigning the variable's value //to the output port a = 10; a_out = a; cout << "Begin::\t (a):" << a << endl; //Assert the Start Signal Here to Initiate Handshake //Check to See if Done has been asserted: if //not, continue loop. while( ) { wait(1,SC_NS); } //De-Assert the Start Signal to Complete Handshake //Since, Handshake if Finished, data from port is ready //to be read. Assign port's value to variable a = a_in.read(); cout << "End ::\t (a):" << a << endl; } }; SC_MODULE (mult_p2) { sc_in start; sc_in > a_in; sc_out > a_out; sc_out done; SC_CTOR (mult_p2) { SC_THREAD (process); } void process() { while(1) { //Check to see if start is asserted //If so write software(C/C++)-type code //to multipy input if() { //Here: Write Software Code To Multiply input //Assert done signal Here } else { //If start isn't asserted, then de-assert //the done signal here } wait(1,SC_NS); } } }; int sc_main(int argc, char* argv[]) { sc_signal start_s,done_s; sc_signal > a_in,a_out; start_s = 0; done_s = 0; mult_p1 part1("Part1"); part1 << done_s << a_in << a_out << start_s ; mult_p2 part2("Part2"); part2 << start_s << a_out << a_in << done_s; sc_start(50,SC_NS); return(0); }