安装gem5:

  1. 打开终端,输入以下命令安装依赖库:

    sudo apt-get install build-essential git m4 scons zlib1g zlib1g-dev libprotobuf-dev protobuf-compiler libprotoc-dev libgoogle-perftools-dev python-dev python
    
  2. 在终端中输入以下命令下载gem5:

    git clone https://gem5.googlesource.com/public/gem5
    
  3. 进入gem5目录:

    cd gem5
    
  4. 输入以下命令编译gem5:

    scons build/X86/gem5.opt -j4
    

    说明:-j4参数代表使用4个线程进行编译,可以根据自己的电脑配置进行调整。

编译运行gem5:

  1. 创建一个配置文件:

    mkdir my_gem5_configs
    cd my_gem5_configs
    cp ../configs/example/se.py .
    
  2. 修改配置文件:

    vim se.py
    

    用vim等编辑器打开配置文件,修改参数为:

    import m5
    from m5.objects import *
    
    m5.util.addToPath('../')
    m5.util.addToPath('../../')
    
    binary = '../tests/test-progs/hello/bin/x86/linux/hello'
    cpu_type = 'AtomicSimpleCPU'
    caches = 'no'
    mem_mode = 'atomic'
    
    m5.ticks.setGlobalFrequency('1GHz')
    
    system = System(cpu = globals()[cpu_type]())
    
    system.membus = SystemXBar()
    
    system.cpu.icache = Cache(size='64kB')
    system.cpu.dcache = Cache(size='64kB')
    
    system.cpu.icache.connectCPU(system.cpu)
    system.cpu.dcache.connectCPU(system.cpu)
    
    system.cpu.icache.connectBus(system.membus)
    system.cpu.dcache.connectBus(system.membus)
    
    system.membus = SystemXBar()
    
    system.mem_ctrl = DDR3_1600_8x8()
    system.mem_ctrl.range = system.mem_ranges[0]
    system.mem_ctrl.port = system.membus.master
    
    system.cpu.workload = SEWorkload.init_compatible(binary)
    system.cpu.createThreads()
    
    root = Root(full_system = False, system = system)
    
    m5.instantiate()
    
    print('Beginning simulation!')
    exit_event = m5.simulate()
    print('Exiting @ tick {} because {}'.format(m5.curTick(), exit_event.getCause()))
    

    说明:这个配置文件的作用是加载一个测试程序,该程序输出"Hello World"。其中cpu_type指定使用的CPU类型,caches指定是否启用缓存,mem_mode指定内存模式。

  3. 运行gem5:

    ../build/X86/gem5.opt --debug-flags=ProtocolTrace configs/example/se.py
    

    说明:该命令将启动gem5,并使用配置文件se.py进行模拟,--debug-flags=ProtocolTrace参数表示启用协议跟踪功能,可以输出更详细的模拟信息

Ubuntu怎样安装gem5怎样编译运行

原文地址: http://www.cveoy.top/t/topic/gKE1 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录