close

最近在老闆的指示下,我看了一些關於 OpenRISC, SystemC 和 TLM 的文件,

打算之後在這個部落格跟大家分享一些這方面的經驗,也當做是整理一下自己最近在做什麼。

 

OpenRISC是一個open source的CPU,目前有提供Instruction Set Simulator (ISS), 

RTL source code, tool chain, 以及SoC reference platform。

目前開發OpenRISC的公司,除了有提供OpenRISC這顆CPU,還有很多很實用的project,

可以在他們的網站找到,一直覺得這家公司真的是佛心來的,提供這麼多免費的資源,

有問題在他們的論壇上發問,還會有人回答XD

 

首先先跟大家介紹一下我前一陣子在看的application note:

"Building a Loosely Timed SoC Model with OSCI TLM 2.0 - A Case Study Using an Open Source ISS and Linux 2.6 Kernel"

這份文件在介紹如何將OpenRISC的ISS (or1ksim) 加上SystemC wrapper,

以及如何使用其他SystemC的module和這個ISS溝通,最後是如何在這個ISS上去boot Linux kernel。

在這之前必須要先將ISS和它的tool chain裝起來,關於怎麼安裝它的ISS和tool chain這方面的東西之後有機會再跟大家分享。

 

這份文件當初是針對or1ksim-0.4.0以下的版本而寫的,

而目前新版的ISS (or1ksim-0.5.0rc2)在它的API介面compiler部分做了一些程度的修改,

所以原本那份文件裡的範例程式和SystemC wrapper並不能直接套用在or1ksim-0.5.0rc2上。

今天就跟大家分享怎麼修改那份文件裡的範例程式和SystemC wrapper以套用在or1ksim-0.5.0rc2上

(這裡只分享我修改的部分,原本文件的內容就不再重覆列述)

其中有兩個部分需要修改,一個是ISS的SystemC wrapper,另一個是要在ISS上跑的測試程式的bootloader。

 

1. SystemC wrapper for or1ksim-0.5.0rc2 ISS:

    原本or1ksim-0.4.0以前的版本在initialize它的ISS時,是使用下面這個function:

    int or1ksim_init (const char *config_file, 

                              const char *image_file, 

                              void           *class_ptr, 

                              int             (*upr)  (void                          *class_ptr, 

                                                            unsigned long int     addr, 

                                                            unsigned char          mask[], 

                                                            unsigned char          rdata[], 

                                                            int                            data_len), 

                              int             (*upw) (void                          *class_ptr, 

                                                            unsigned long int     addr, 

                                                            unsigned char          mask[], 

                                                            unsigned char          wdata[], 

                                                            int                            data_len));

    裡面每個變數的意義就不在這裡做解釋了。在or1ksim-0.5.0rc2這個版本的ISS,

    要去initialize它的ISS時的API介面稍做了一些改變,以下是新版的API介面:

    int or1ksim_init (int             argc,

                              char           *argv, 

                              void           *class_ptr, 

                              int             (*upr)  (void                          *class_ptr, 

                                                            unsigned long int     addr, 

                                                            unsigned char          mask[], 

                                                            unsigned char          rdata[], 

                                                            int                            data_len), 

                              int             (*upw) (void                          *class_ptr, 

                                                            unsigned long int     addr, 

                                                            unsigned char          mask[], 

                                                            unsigned char          wdata[], 

                                                            int                            data_len));

    新版的API介面是直接將命令列參數傳入,因此在它的SystemC wrapper方面必須要做下面的修改:

    1.1 SystemC wrapper definition (Or1ksimSC.h):

          將constructor的定義改為

          Or1ksimSC (sc_core::sc_module_name name, 

                               int                                          argc, 

                               char                                       *argv[]);

          以將命令列參數傳入。

    1.2 SystemC wrapper implementation (Or1ksimSC.cpp):

          將constructor裡面呼叫or1ksim_init()的部分改為

          or1ksim_init(argc, argv, this, staticReadUpcall, staticWriteUpcall);

    1.3 SystemC top module (loggerMainSC.cpp):

          將instance Or1ksimSC的地方改成

          Or1ksimSC   iss("or1ksim", argc, argv);

 

2. Bootloader of the test program for or1ksim-0.5.0rc2 ISS:

    在or1ksim-0.4.0以前版本的tool chain中使用的compiler,

    會自動將compile出的code中的global symbol加上"_"這個prefix,

    但是在新版的ISS (or1ksim-0.5.0rc2之後) 將這個動作取消了,

    所以這份文件中範例程式所使用的bootloader就沒有辦法使用。

    不過其實只要將start.s中的"_main"用"main"來取代就可以了。

 

以上,只要做這些修改,就可以將原本的SystemC wrapper和範例程式套用到or1ksim-0.5.0rc2上來使用了。

arrow
arrow
    全站熱搜

    jylai1982 發表在 痞客邦 留言(0) 人氣()