Gem5的编译及运行测试程序

来源:互联网 发布:淘宝自动提交订单 编辑:程序博客网 时间:2024/05/22 03:08

原文地址:http://blog.csdn.net/qianlong4526888/article/details/8233643

原文有小错,已改。

1、编译之前,首先安装库文件:

以ubuntu1201系统为例,安装库文件如下:

$:sudo apt-get install mercurial scons swig gcc m4 python python-dev libgoogle-perftools-dev g++ libprotobuf-dev

此外,还需要安装好编译环境:

sudo apt-get install build-essential

2、然后下载gem5源码:

$: hg clone http://repo.gem5.org/gem5

3、编译gem5的各个架构:

在根目录下运行:$:scons build/ARM/gem5.opt

 其中ARM可以换成X86,MIPS等等,编译完成后就可以运行测试程序。

4、运行测试程序:

$: cd ~/gem5      //进入gem5源码根目录

$:build/ARM/gem5.opt configs/example/se.py -c tests/test-progs/hello/bin/arm/linux/hello 

打印出如下信息:
gem5 Simulator System.  http://gem5.org
gem5 is copyrighted software; use the --copyright option for details.

gem5 compiled Nov 16 2012 10:27:19
gem5 started Nov 28 2012 14:36:59
gem5 executing on slave0
command line: build/ARM/gem5.opt configs/example/se.py -c tests/test-progs/hello/bin/arm/linux/hello
Global frequency set at 1000000000000 ticks per second
0: system.remote_gdb.listener: listening for remote gdb #0 on port 7002
**** REAL SIMULATION ****
info: Entering event queue @ 0.  Starting simulation...
Hello world!
hack: be nice to actually delete the event here
Exiting @ tick 3107500 because target called exit()

以上红色部分就是程序执行的结果。

5、看下测试程序的源码:

$:cd ~/gem5

$: gedit  tests/test-progs/hello/src/hello.c

打开可以看到,就是一个helloworld测试程序。

NOTE:如果你想重新写个测试程序,注意想在什么架构下运行,如果在ARM架构下运行,需要用ARM toolchain ,如果想运行MIPS架构的测试程序,需要用MIPS的交叉工具链编译测试程序。


原创粉丝点击