SystemC 初始化步驟

來源:互聯網
上載者:User

環境:VC toolkit 2003 + SystemC 2.0.1

  為了找出SystemC定義了哪些全域變數/靜態變數,我在crt/src/crt0dat.c的

void _initterm(_PVFV * pfbegin, _PVFV * pfend)

函數中設下斷點,at Line 598:

        if ( *pfbegin != NULL )
            (**pfbegin)();        // 此處中斷

然後單步跟蹤程式,就得到了SystemC的大致初始化順序:(C++標準不保證各轉譯單元(translation unit)之間全域變數的初始化順序,因此這裡列出的可看作某種典型情況)

  據我觀察,SystemC定義了15處全域/靜態變數,其中7處形如:

    static int forty_two = initialize();

散見於communication/sc_communication_ids.cpp、datatypes/bit/sc_bit_ids.cpp、datatypes/fx/sc_fx_ids.cpp、datatypes/int/sc_int_ids.cpp、kernel/sc_kernel_ids.cpp、utils/sc_report.cpp、utils/sc_utils_ids.cpp。

  其餘8個初始化點分別是:

1. kernel/sc_time.cpp, L355

    const sc_time SC_ZERO_TIME;

2. communication/sc_interface.cpp, L78

    sc_event sc_interface::m_never_notified;

    // 此處會轉而調用 kernel/sc_simcontext.cpp,L835:
    // sc_get_curr_simcontext()
    // 從而初始化全域的 sc_simcontext 對象,大事件!

3. kernel/sc_module.cpp,L136

    const sc_bind_proxy SC_BIND_PROXY_NIL;

4. kernel/sc_cor_fiber.cpp,L49

    static sc_cor_fiber main_cor;

    // 此處與平台相關,如果是UNIX like平台,那麼“Coroutine class implemented with 
    // QuickThreads.”;若是Win32平台,那麼“Coroutine implementation with fibers.”
    // 不過程式中的注釋似乎寫錯了

5. utils/sc_report_handler.cpp,L205

    static HANDLER_GC_NAME gc;

6. kernel/sc_lambda.cpp,L59

    sc_lambda
    sc_lambda::dummy_lambda;

7. datatypes/bit/sc_logic.cpp,L154,初始化4個邏輯值常數

    const sc_logic sc_logic_0( Log_0 );
    const sc_logic sc_logic_1( Log_1 );
    const sc_logic sc_logic_Z( Log_Z );
    const sc_logic sc_logic_X( Log_X );

    const sc_logic SC_LOGIC_0( Log_0 );
    const sc_logic SC_LOGIC_1( Log_1 );
    const sc_logic SC_LOGIC_Z( Log_Z );
    const sc_logic SC_LOGIC_X( Log_X );

8. datatypes/fx/scfx_rep.cpp,L57

    static scfx_pow10 pow10_fx;

以後,我將繼續分析這些初始化到底做了些什麼工作,重頭戲當然是 sc_simcontext 對象的初始化。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.