⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sc_simcontext.cpp

📁 system C源码 一种替代verilog的语言
💻 CPP
📖 第 1 页 / 共 3 页
字号:
    return DCAST<sc_module*>( m_object_manager->hierarchy_curr() );}    sc_object*sc_simcontext::first_object(){    return m_object_manager->first_object();}sc_object*sc_simcontext::next_object(){    return m_object_manager->next_object();}sc_object*sc_simcontext::find_object( const char* name ){    static bool warn_find_object=true;    if ( warn_find_object )    {	warn_find_object = false;	SC_REPORT_INFO(SC_ID_IEEE_1666_DEPRECATION_,	    "sc_simcontext::find_object() is deprecated,\n" \            " use sc_find_object()" );    }    return m_object_manager->find_object( name );}// to generate unique names for objects in an MT-Safe wayconst char*sc_simcontext::gen_unique_name( const char* basename_, bool preserve_first ){    return m_name_gen->gen_unique_name( basename_, preserve_first );}sc_process_handle sc_simcontext::create_cthread_process(     const char* name_p, bool free_host, SC_ENTRY_FUNC method_p,             sc_process_host* host_p, const sc_spawn_options* opt_p ){    sc_cthread_handle handle =         new sc_cthread_process(name_p, free_host, method_p, host_p, opt_p);    if ( m_ready_to_simulate )     {	handle->prepare_for_simulation();    } else {	m_process_table->push_front( handle );    }    return sc_process_handle(handle);}sc_process_handle sc_simcontext::create_method_process(     const char* name_p, bool free_host, SC_ENTRY_FUNC method_p,             sc_process_host* host_p, const sc_spawn_options* opt_p ){    sc_method_handle handle =         new sc_method_process(name_p, free_host, method_p, host_p, opt_p);    if ( m_ready_to_simulate ) {	if ( !handle->dont_initialize() ) {	    push_runnable_method( handle );	}    } else {	m_process_table->push_front( handle );    }    return sc_process_handle(handle);}sc_process_handle sc_simcontext::create_thread_process(     const char* name_p, bool free_host, SC_ENTRY_FUNC method_p,             sc_process_host* host_p, const sc_spawn_options* opt_p ){    sc_thread_handle handle =         new sc_thread_process(name_p, free_host, method_p, host_p, opt_p);    if ( m_ready_to_simulate ) {	handle->prepare_for_simulation();	if ( !handle->dont_initialize() ) {	    push_runnable_thread( handle );	}    } else {	m_process_table->push_front( handle );    }    return sc_process_handle(handle);}voidsc_simcontext::add_trace_file( sc_trace_file* tf ){    m_trace_files.push_back( tf );    m_something_to_trace = true;}sc_cor*sc_simcontext::next_cor(){    if( m_error ) {	return m_cor;    }        sc_thread_handle thread_h = pop_runnable_thread();    while( thread_h != 0 ) {        if ( thread_h->ready_to_run() ) break;	thread_h = pop_runnable_thread();    }        if( thread_h != 0 ) {	return thread_h->m_cor_p;    } else {	return m_cor;    }}const ::std::vector<sc_object*>&sc_simcontext::get_child_objects() const{    static bool warn_get_child_objects=true;    if ( warn_get_child_objects )    {	warn_get_child_objects = false;	SC_REPORT_INFO(SC_ID_IEEE_1666_DEPRECATION_,	    "sc_simcontext::get_child_objects() is deprecated,\n" \            " use sc_get_top_level_objects()" );    }    return m_child_objects;}voidsc_simcontext::add_child_object( sc_object* object_ ){    // no check if object_ is already in the set    m_child_objects.push_back( object_ );}voidsc_simcontext::remove_child_object( sc_object* object_ ){    int size = m_child_objects.size();    for( int i = 0; i < size; ++ i ) {	if( object_ == m_child_objects[i] ) {	    m_child_objects[i] = m_child_objects[size - 1];	    m_child_objects.resize(size-1);	    return;	}    }    // no check if object_ is really in the set}sc_dt::uint64sc_simcontext::delta_count() const{    static bool warn_delta_count=true;    if ( warn_delta_count )    {	warn_delta_count = false;	SC_REPORT_INFO(SC_ID_IEEE_1666_DEPRECATION_,	    "sc_simcontext::delta_count() is deprecated, use sc_delta_count()" );    }    return m_delta_count;}boolsc_simcontext::is_running() const{    static bool warn_is_running=true;    if ( warn_is_running )    {	warn_is_running = false;	SC_REPORT_INFO(SC_ID_IEEE_1666_DEPRECATION_,	    "sc_simcontext::is_running() is deprecated, use sc_is_running()" );    }    return m_ready_to_simulate;}const sc_timesc_simcontext::next_time(){    while( m_timed_events->size() ) {	sc_event_timed* et = m_timed_events->top();	if( et->event() != 0 ) {	    return et->notify_time();	}	delete m_timed_events->extract_top();    }    return SC_ZERO_TIME;}voidsc_simcontext::remove_delta_event( sc_event* e ){    int i = e->m_delta_event_index;    int j = m_delta_events.size() - 1;    assert( i >= 0 && i <= j );    if( i != j ) {	sc_event** l_delta_events = &m_delta_events[0];	l_delta_events[i] = l_delta_events[j];	l_delta_events[i]->m_delta_event_index = i;    }    m_delta_events.resize(m_delta_events.size()-1);    e->m_delta_event_index = -1;}voidsc_simcontext::trace_cycle( bool delta_cycle ){    int size;    if( ( size = m_trace_files.size() ) != 0 ) {	sc_trace_file** l_trace_files = &m_trace_files[0];	int i = size - 1;	do {	    l_trace_files[i]->cycle( delta_cycle );	} while( -- i >= 0 );    }}// ----------------------------------------------------------------------------#if 1#ifdef PURIFY	static sc_simcontext sc_default_global_context;	sc_simcontext* sc_curr_simcontext = &sc_default_global_context;#else	sc_simcontext* sc_curr_simcontext = 0;	sc_simcontext* sc_default_global_context = 0;#endif#else// Not MT-safe!static sc_simcontext* sc_curr_simcontext = 0;sc_simcontext*sc_get_curr_simcontext(){    if( sc_curr_simcontext == 0 ) {#ifdef PURIFY        static sc_simcontext sc_default_global_context;        sc_curr_simcontext = &sc_default_global_context;#else        static sc_simcontext* sc_default_global_context = new sc_simcontext;        sc_curr_simcontext = sc_default_global_context;#endif    }    return sc_curr_simcontext;}#endif // 0// Generates unique names within each module.const char*sc_gen_unique_name( const char* basename_, bool preserve_first ){    sc_simcontext* simc = sc_get_curr_simcontext();    sc_module* curr_module = simc->hierarchy_curr();    if( curr_module != 0 ) {	return curr_module->gen_unique_name( basename_, preserve_first );    } else {        sc_process_b* curr_proc_p = sc_get_current_process_b();	if ( curr_proc_p )	{	    return curr_proc_p->gen_unique_name( basename_, preserve_first );	}	else	{	    return simc->gen_unique_name( basename_, preserve_first );	}    }}// Get a handle for the current process//// Note that this method should not be called if the current process is// in the act of being deleted, it will mess up the reference count management// of sc_process_b instance the handle represents. Instead, use the a // pointer to the raw sc_process_b instance, which may be acquired via// sc_get_current_process_b().sc_process_handlesc_get_current_process_handle(){    return ( sc_is_running() ) ?	sc_process_handle(sc_get_current_process_b()) : 	sc_get_last_created_process_handle();}// THE FOLLOWING FUNCTION IS DEPRECATED IN 2.1sc_process_b*sc_get_curr_process_handle(){    static bool warn=true;    if ( warn )    {        warn = false;        SC_REPORT_INFO(SC_ID_IEEE_1666_DEPRECATION_,       "sc_get_curr_process_handle deprecated use sc_get_current_process_handle"       );    }    return sc_get_curr_simcontext()->get_curr_proc_info()->process_handle;}// Return indication if there are more processes to execute in this delta phaseboolsc_pending_activity_at_current_time(){    sc_simcontext* c_p = sc_get_curr_simcontext();    return (c_p->m_delta_events.size() != 0) ||    	    !c_p->m_runnable->is_empty() ||	    c_p->m_prim_channel_registry->pending_updates();}// Set the random seed for controlled randomization -- not yet implementedvoidsc_set_random_seed( unsigned int ){    SC_REPORT_WARNING( SC_ID_NOT_IMPLEMENTED_,		       "void sc_set_random_seed( unsigned int )" );}voidsc_start( const sc_time& duration ){    sc_simcontext* context;    int status;    context = sc_get_curr_simcontext();    status = context->sim_status();    if( status != SC_SIM_OK )     {	if ( status == SC_SIM_USER_STOP )	{	    SC_REPORT_ERROR(SC_ID_SIMULATION_START_AFTER_STOP_, "");        	}        return;    }    context->simulate( duration );}voidsc_start()  {	sc_start( sc_time(~sc_dt::UINT64_ZERO, false) - sc_time_stamp() );}// for backward compatibility with 1.0voidsc_start( double duration )  // in default time units{    static bool warn_sc_start=true;    if ( warn_sc_start )    {	warn_sc_start = false;	SC_REPORT_INFO(SC_ID_IEEE_1666_DEPRECATION_,	    "sc_start(double) deprecated, use sc_start(sc_time) or sc_start()");    }    if( duration == -1 )  // simulate forever    {        sc_start(             sc_time(~sc_dt::UINT64_ZERO, false) - sc_time_stamp() );    }    else    {        sc_start( sc_time( duration, true ) );    }}voidsc_stop(){    sc_get_curr_simcontext()->stop();}// The following function is deprecated in favor of sc_start(SC_ZERO_TIME):voidsc_initialize(){    static bool warning_initialize = true;    if ( warning_initialize )    {        warning_initialize = false;        SC_REPORT_INFO(SC_ID_IEEE_1666_DEPRECATION_,	    "sc_initialize() is deprecated: use sc_start(SC_ZERO_TIME)" );    }    sc_get_curr_simcontext()->initialize();}// The following function has been deprecated in favor of sc_start(duration):voidsc_cycle( const sc_time& duration ){    static bool warning_cycle = true;    if ( warning_cycle )    {        warning_cycle = false;        SC_REPORT_INFO(SC_ID_IEEE_1666_DEPRECATION_,	    "sc_cycle is deprecated: use sc_start(sc_time)" );    }    sc_get_curr_simcontext()->cycle( duration );}sc_object* sc_find_object( const char* name, sc_simcontext* simc_p ){    return simc_p->get_object_manager()->find_object( name );}const sc_time&sc_time_stamp(){    return sc_get_curr_simcontext()->time_stamp();}doublesc_simulation_time(){    static bool warn_simulation_time=true;    if ( warn_simulation_time )    {        warn_simulation_time=false;        SC_REPORT_INFO(SC_ID_IEEE_1666_DEPRECATION_,	    "sc_simulation_time() is deprecated use sc_time_stamp()" );    }    return sc_get_curr_simcontext()->time_stamp().to_default_time_units();}voidsc_defunct_process_function( sc_module* ){    // This function is pointed to by defunct sc_thread_process'es and    // sc_cthread_process'es. In a correctly constructed world, this    // function should never be called; hence the assert.    assert( false );}//------------------------------------------------------------------------------//"sc_set_stop_mode"//// This function sets the mode of operation when sc_stop() is called.//     mode = SC_STOP_IMMEDIATE or SC_STOP_FINISH_DELTA.//------------------------------------------------------------------------------void sc_set_stop_mode(sc_stop_mode mode){    if ( sc_is_running() )    {        SC_REPORT_WARNING(SC_ID_STOP_MODE_AFTER_START_,"");    }    else    {        switch( mode )        {          case SC_STOP_IMMEDIATE:          case SC_STOP_FINISH_DELTA:              stop_mode = mode;              break;          default:              break;        }    }}sc_stop_modesc_get_stop_mode(){    return stop_mode;}} // namespace sc_core// Taf!

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -