void uvm_phase_controller::do_run(void) { sc_process_handle run_handle; sc_spawn_options o; MARK_THREAD_INVISIBLE(o); // spawn thread that will wait for m_global_timeout to expire sc_spawn(sc_bind(&uvm_phase_controller::wait_for_global_timeout, this), "uvm_wait_for_global_timeout", &o ); // spawn UVM runtime schedules for (unsigned int i = 0; i < m_schedules.size(); i++) { run_handle = sc_spawn(sc_bind(&uvm_schedule::do_run, m_schedules[i])); m_join_run.add_process(run_handle); } // spawn thread that will wait for active runtime schedules to complete sc_spawn(sc_bind(&uvm_phase_controller::wait_for_run_phases, this), "uvm_wait_for_run_phases", &o ); // TODO - spawn check for runtime fatal errors here (try/catch?) // Note: Needs to work in ML as well... }
void proc_tree( unsigned depth, unsigned width, bool as_method, bool spawn_only ) { unsigned w = width; if (sc_time_stamp() == SC_ZERO_TIME || spawn_only ) while( depth && w --> 0 ) { sc_spawn_options sp; sp.set_sensitivity( &clk.pos() ); if(as_method) // we are spawned as method, spawn a thread { sc_spawn( sc_bind( &top::proc_tree, this, depth-1, width, !as_method, false ) , sc_gen_unique_name("thread"), &sp ); } else // we are spawned as thread, spawn a method { sp.spawn_method(); sc_spawn( sc_bind( &top::proc_tree, this, depth-1, width, !as_method, false ) , sc_gen_unique_name("method"), &sp ); } } if(spawn_only) return; std::cout << sc_get_current_process_handle().name() << " triggered " << "(" << sc_time_stamp() << " @ " << sc_delta_count() << ")" << std::endl; // start thread if( !as_method ) thread_loop(); }
void abc() { for ( int i = 0; i < 3; i++ ) { cout << "Time Spawn Start Stop " << endl; cout << "----- ----- ----- ----" << endl; int ii = 2; int spawn_i; int spawn_n = 8; sc_spawn_options options; sc_join join; options.set_sensitivity(&m_clk.pos()); for ( spawn_i = 0; spawn_i < spawn_n; spawn_i++ ) { int process_i = spawn_i + i * spawn_n; cout << sc_time_stamp() << " " << process_i << endl; join.add_process(sc_spawn( sc_bind(&TB::process, this, sc_ref(process_i)), sc_gen_unique_name("pipe"), &options ) ); sc_core::wait(ii); } cout << sc_time_stamp() << " waiting for termination of " << join.process_count() << " processes" << endl; join.wait(); cout << sc_time_stamp() << " back from termination wait " << endl; } }
Multiplexer::Multiplexer(sc_module_name nm , int mux_outputPortSize, int mux_inputPortSize, pfp::core::PFPObject* parent, std::string configfile) :MultiplexerSIM(nm, mux_outputPortSize, mux_inputPortSize, parent, configfile), next_write_port(0) { /*sc_spawn threads*/ ThreadHandles.push_back(sc_spawn(sc_bind(&Multiplexer::MultiplexerThread, this, 0))); }
void main() { int r; sc_event e1, e2, e3, e4; cout << endl; e1.notify(100, SC_NS); // Spawn several threads that co-operatively execute in round robin order SC_FORK sc_spawn(&r, sc_bind(&top::round_robin, this, "1", sc_ref(e1), sc_ref(e2), 3), "1") , sc_spawn(&r, sc_bind(&top::round_robin, this, "2", sc_ref(e2), sc_ref(e3), 3), "2") , sc_spawn(&r, sc_bind(&top::round_robin, this, "3", sc_ref(e3), sc_ref(e4), 3), "3") , sc_spawn(&r, sc_bind(&top::round_robin, this, "4", sc_ref(e4), sc_ref(e1), 3), "4") , SC_JOIN cout << "Returned int is " << r << endl; cout << endl << endl; // Test that threads in thread pool are successfully reused ... for (int i = 0 ; i < 10; i++) sc_spawn(&r, sc_bind(&top::wait_and_end, this, i)); wait(20, SC_NS); // Show how to use sc_spawn_options sc_spawn_options o; o.set_stack_size(0); // Demo of a function rather than method call, & use return value ... wait( sc_spawn(&r, sc_bind(&test_function, 3.14159)).terminated_event()); cout << "Returned int is " << r << endl; sc_process_handle handle1 = sc_spawn(sc_bind(&void_function, 1.2345)); wait(handle1.terminated_event()); double d = 9.8765; wait( sc_spawn(&r, sc_bind(&ref_function, sc_cref(d))).terminated_event() ); cout << "Returned int is " << r << endl; cout << endl << "Done." << endl; }
void static_method() { int r; cout << endl << sc_time_stamp() << ": static_method, Before spawning function_method " << endl; sc_spawn_options o1; o1.spawn_method(); o1.dont_initialize(); o1.set_sensitivity(&ev); sc_process_handle h4 = sc_spawn(&r, sc_bind(&function_method, 1.2345), "event_sensitive_method", &o1); wait(h4.terminated_event()); }
void FrSimIfaceSysc::wait(FrSimCond c) { // Need to spawn an sysc dynamic thread // Sysc Thread does: // 1) wait for value_change_event of signal in c // 2) test condition, if not met return to 1) // 3) trigger FrSim thread passed in // do a wait on the FrSim thread FrSimThread *thr = FrSimThread::getSelf(); sc_spawn(sc_bind(&FrSimIfaceSysc::syscSignalEvent, sc_reg(&c), sc_ref(thr))); thr->wait(); }
void waiting() { SC_FORK sc_spawn( sc_bind( &X::sync, this, 3 ) ), sc_spawn( sc_bind( &X::sync, this, 4 ) ), sc_spawn( sc_bind( &X::sync, this, 5 ) ), sc_spawn( sc_bind( &X::sync, this, 5 ) ), sc_spawn( sc_bind( &X::sync, this, 7 ) ), sc_spawn( sc_bind( &X::sync, this, 11) ), sc_spawn( sc_bind( &X::sync, this, 21) ) SC_JOIN cout << sc_time_stamp() << ": waiting waking" << endl; }
uvm_component::uvm_component(sc_module_name nm) : sc_module(nm) { uvm_common_schedule* pcommon_schedule = get_uvm_common_schedule(); pcommon_schedule->register_callback(this); // TODO: should all component default to be part of UVM schedule? uvm_common_schedule* puvm_schedule = get_uvm_schedule(); puvm_schedule->register_callback(this); if (!global_timeout_spawned_) { // spawn thread that will wait for m_global_timeout to expire sc_spawn_options o; MARK_THREAD_INVISIBLE(o); sc_spawn(sc_bind(&uvm_manager::wait_for_global_timeout, get_uvm_manager()), "uvm_wait_for_global_timeout", &o ); global_timeout_spawned_ = true; } }
PacketSink::PacketSink(sc_module_name nm, pfp::core::PFPObject* parent,std::string configfile ):PacketSinkSIM(nm,parent,configfile) { // NOLINT /*sc_spawn threads*/ sc_spawn(sc_bind(&PacketSink::PacketSink_PortServiceThread, this)); }