468Lec20_SC_DynamicProcesses

Writesclogic0 wait10 scns clocksigwritesclogic1

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: th, this, true) ); while(true) { clock_sig.write(SC_LOGIC_0); wait(10, SC_NS); clock_sig.write(SC_LOGIC_1); wait(10, SC_NS); } } }; ECEN 468 Lecture 20 9 Another Example of sc_spawn int global_th(const bool& din, int& dout) { cout << "spawned: " << din << ", " << dout << endl; if (din) { dout++; return 0; } else return 1; } class imodule: public sc_module { public: sc_signal clock_sig; SC_HAS_PROCESS(imodule); imodule(sc_module_name nm):sc_module(nm) { SC_THREAD(run); } void run() { int return_v, int_arg = 9; bool bool_arg = true; sc_spawn( &return_v, sc_bind(&global_th, sc_cref(bool_arg), sc_ref(int_arg) ) ); while(true) { clock_sig.write(0); wait(10, SC_NS); clock_sig.write(1); wait(10, SC_NS); } } }; //By default, arguments are passed by value ECEN 468 Lecture 20 10 Handle of Spawned Process sc_spawn() returns a handle of the spawned process It can monitor the termination of the process sc_process_handle h = sc_spawn(sc_bind(&spawned_thread)); …… wait(h.terminated_event()); ECEN 468 Lecture 20 11 SC_FORK and SC_JOIN p1 p3 p4 AXI USB2 PCI DUT HT2 HT1 p2 p5 DataStream d1, d2; SC_FORK sc_spawn( sc_bind(&dut::AXI_xmt, this, sc_ref(d1)), “p1” , sc_spawn( sc_bind(&dut::PCI_rcv, this, sc_ref(d1)), “p2” , sc_spawn( sc_bind(&dut::USB2, this, sc_ref(d1)), “p3” ) , sc_spawn( sc_bind(&dut::HT1_xmt, this, sc_ref(d2)), “p4” , sc_spawn( sc_bind(&dut::HT2_rcv, this, sc_ref(d2)), “p5” SC_JOIN ) ) ) ) Process name ECEN 468 Lecture 20 12 Another Example of SC_FORK and SC_JOIN SC_MODULE(Fork) { sc_fifo<double> wheel_L, wheel_R; SC_CTOR(Fork) { … }...
View Full Document

This note was uploaded on 09/07/2012 for the course ECEN 468 taught by Professor Jianghu during the Spring '08 term at Texas A&M.

Ask a homework question - tutors are online