2012年4月18日 星期三

Install TRAP (TRansaction level Automatic Processor generator)

安裝完 SystemC-2.2.0 and TLM 後,
在來安裝 TRAP 來玩玩看,這裡有詳細的安裝步驟說明。

一些準備工作
請先確認系統是否已安裝以下的 Library or Tools
libELF, SystemC, TLM, Boots, Python, networkx

Checkout TRAP Source Code

% svn checkout http://trap-gen.googlecode.com/svn/trunk/ trap-gen


Compile and Install TRAP

% cd trap-gen
% ./waf configure --with-systemc=/opt/systemc/systemc-2.2.0 --prefix=/opt/systemc/trap
% ./waf
% ./waf install


Compile LEON3 Processor

% cd processors/LEON3
% python LEON3Arch.py
% cd processors
% ./waf configure --with-systemc=/opt/systemc/systemc-2.2.0 --with-tlm=/opt/systemc/TLM-2009-07-15 --with-trap=/opt/systemc/trap
% ./waf

TRAP 產生的 CPU Simulator 可以有四種類型:funcLT, funcAT, accLT, accAT

    funcLT : Instruction-Accurate with loosely-timed TLM interfaces
    funcAT : Instruction-Accurate with accurate-timed TLM interfaces
    accLT : Cycle-Accurate with loosely-timed TLM interfaces
    accAT : Cycle-Accurate with accurate-timed TLM interfaces

但這次編譯,只會生出 funcLT and funcAT。

Install cross compiler
有已經做好的 sparc-elf, arm-elf compiler,替我省下不少時間!
若要自己做 cross compiler,要記得 compiler 安裝完後要將 BSP 檔案 copy 到 compiler 安裝目錄,以 sparc-elf 為例:

% cp $(TRAP_SRC_DIR)/BSP_and_Compiler/sparc/* $(SPARC_ELF_INSTALL_DIR)/sparc-elf/lib
% sparc-elf-gcc -c exceptionTrap.S -o exceptionTrap.o
% sparc-elf-gcc -c libcStub.c -o libcStub.o
% sparc-elf-gcc -c osemu-crt0.S -o osemu-crt0.o


run Hello-World
hello.c

#include "stdio.h"
int main(void) {
printf("Hello World\n");
}

Compile hello.c

% sparc-elf-gcc -specs=osemu.specs -g -O2 hello.c -o hello

Simulate with funcAT

% $(TRAP-SRC-DIR)/processors/LEON3/processor/_build_/funcAT/funcAT -a hello

SystemC 2.2.0 --- Apr 17 2012 12:05:44
Copyright (c) 1996-2006 by all Contributors
ALL RIGHTS RESERVED


_/ _/_/_/_/ _/_/ _/ _/ _/_/_/
_/ _/ _/ _/ _/_/ _/ _/
_/ _/_/_/ _/ _/ _/ _/ _/ _/_/
_/ _/ _/ _/ _/ _/_/ _/
_/_/_/_/ _/_/_/_/ _/_/ _/ _/ _/_/_/



Luca Fossati - email: fossati.l@gmail.com




Loading the application and initializing the tools ...
... tools initialized

Hello World

Program exited with value 10

SystemC: simulation stopped by user.

Elapsed 0 sec. (real time)
Executed 1924 instructions
Execution Speed: inf MIPS
Simulated time: 2330 us
Elapsed 2330 cycles

Simulate with funcCT

% $(TRAP-SRC-DIR)/processors/LEON3/processor/_build_/funcAT/funcAT -a hello

SystemC 2.2.0 --- Apr 17 2012 12:05:44
Copyright (c) 1996-2006 by all Contributors
ALL RIGHTS RESERVED


_/ _/_/_/_/ _/_/ _/ _/ _/_/_/
_/ _/ _/ _/ _/_/ _/ _/
_/ _/_/_/ _/ _/ _/ _/ _/ _/_/
_/ _/ _/ _/ _/ _/_/ _/
_/_/_/_/ _/_/_/_/ _/_/ _/ _/ _/_/_/



Luca Fossati - email: fossati.l@gmail.com




Loading the application and initializing the tools ...
... tools initialized

Hello World

Program exited with value 10

SystemC: simulation stopped by user.

Elapsed 0.01 sec. (real time)
Executed 1924 instructions
Execution Speed: 0.1924 MIPS
Simulated time: 2330 us
Elapsed 2330 cycles
%


run Testsuite

% cd $(TRAP-SRC-DIR)/testsuite
% setenv CC_CROSS sparc-elf-gcc
% setenv CFLAGS "-DBIG_TARGET -specs=osemu.specs"
% setenv SIMULATOR "../processors/LEON3/processor/_build_/funcAT/funcAT"
% make test


run Benchmark

% cd $(TRAP-SRC-DIR)/benchmarks
% setenv CC_CROSS sparc-elf-gcc
% setenv CFLAGS "-DBIG_TARGET -specs=osemu.specs"
% setenv SIMULATOR "../processors/LEON3/processor/_build_/funcAT/funcAT"
% make run

沒有留言: