void act() { while (true) { cout << "MemAdaptor: waiting for requests..." << endl; // wait for a request to come while (req.read() != true) wait(); // request now accepted address_t memaddr = addr.read(); // read recipient address // SIZE request? if (memsize.read() == true) { // SIZE request! cout << "MemAdaptor: SIZE request income, processing..."; addr.write(memory->size()); cout << " done." << endl; goto act_oper_ok; } // READ request? if (r_w.read() == true) { // READ request! cout << "MemAdaptor: READ request income, processing..."; char val; try { memory->read(val, memaddr); } catch (std::runtime_error &e) { // an error occurred, reporting on the bus goto act_oper_err; } data.write(val); cout << " done." << endl; goto act_oper_ok; } // in any other case.. // WRITE request! cout << "MemAdaptor: WRITE request income, processing..."; try { memory->write(data.read(), memaddr); } catch (std::runtime_error &e) { // an error occurred, reporting on the bus goto act_oper_err; } cout << " done." << endl; goto act_oper_ok; act_oper_err: // an error happened operating the service err.write(true); while (req.read() != false) wait(); err.write(false); continue; act_oper_ok: // service went ok ack.write(true); // request served // wait for peer assertion while (req.read() != false) wait(); ack.write(false); // terminate the operation } }
//------------------------------------------------------------------------------ //"sc_reset_signal_is" // //------------------------------------------------------------------------------ void sc_reset::reset_signal_is( const sc_in<bool>& port, bool level ) { const sc_signal_in_if<bool>* iface_p; sc_process_b* process_p; process_p = (sc_process_b*)sc_get_current_process_handle(); assert( process_p ); switch ( process_p->proc_kind() ) { case SC_THREAD_PROC_: case SC_METHOD_PROC_: SC_REPORT_ERROR(SC_ID_RESET_SIGNAL_IS_NOT_ALLOWED_,""); break; case SC_CTHREAD_PROC_: process_p->m_reset_level = level; iface_p = DCAST<const sc_signal_in_if<bool>*>(port.get_interface()); if ( iface_p ) reset_signal_is( *iface_p, level ); else { new sc_reset_finder( &port, level, process_p ); } break; default: SC_REPORT_ERROR(SC_ID_UNKNOWN_PROCESS_TYPE_, process_p->name()); break; } }
Mod(const sc_module_name& name) : sc_module(name), a("a") { SC_METHOD(foo); sensitive << clk.pos(); dont_initialize(); sc_trace(sc_tf, a, a.name()); }
stimulus(sc_module_name name) : sc_module(name) { SC_THREAD(run); sensitive << clk.pos(); // dont_initialize(); }
void process() { if (isHead == false) { while (in.read() == false) { #ifdef KASCPAR wait(5, SC_NS); #else //sc_core::wait(5, SC_NS); #endif } } notified = true; out.write(true); }
void test::reset_loop() { sc_uint<16> tmp; sc_uint<8> inp; done = 0; dato = 0; tmp = 0; wait(); operational_loop : while (1 != 0) { inp = dati.read(); wait(); tc_mult_8x8( inp, -2, tmp); wait(); done_loop: while (1) { dato = tmp; done = 1; wait(); } } }
//------------------------------------------------------------------------------ //"sc_reset::reset_signal_is - ports" // // These overloads of the reset_signal_is() method will register the active // process with the sc_reset object instance associated with the supplied port. // If the port does not yet have a pointer to its sc_signal<bool> instance it // will create an sc_reset_finder class object instance that will be used // to set the process' reset information when the port has been bound. // // Arguments: // async = true if the reset signal is asynchronous, false if not. // port = port for sc_signal<bool> that will provide the reset signal. // level = level at which reset is active, either true or false. //------------------------------------------------------------------------------ void sc_reset::reset_signal_is( bool async, const sc_in<bool>& port, bool level) { const sc_signal_in_if<bool>* iface_p; sc_process_b* process_p; process_p = (sc_process_b*)sc_get_current_process_handle(); assert( process_p ); process_p->m_has_reset_signal = true; switch ( process_p->proc_kind() ) { case SC_THREAD_PROC_: case SC_METHOD_PROC_: case SC_CTHREAD_PROC_: iface_p = DCAST<const sc_signal_in_if<bool>*>(port.get_interface()); if ( iface_p ) reset_signal_is( async, *iface_p, level ); else new sc_reset_finder( async, &port, level, process_p ); break; default: SC_REPORT_ERROR(SC_ID_UNKNOWN_PROCESS_TYPE_, process_p->name()); break; } }
void run(){ while(true){ cout << " Output sequence is: " << z.read() << " @" << sc_time_stamp() << endl; wait(); } }
void foo::entry() { c = f(a.read(), b.read()); wait(); }