README revision 11971:9573d7d7811a
110152Satgutier@umich.eduThis directory contains a demo of a coupling between gem5 and SystemC-TLM. It 210152Satgutier@umich.eduis based on the gem5-systemc implementation in utils/systemc. This Readme gives 310152Satgutier@umich.eduan overall overview (I), describes the source files in this directory (II), 410152Satgutier@umich.eduexplains the build steps (III), shows how to run example simulations (IV-VI) 510152Satgutier@umich.eduand lists known issues (VII). 610152Satgutier@umich.edu 710152Satgutier@umich.edu 810152Satgutier@umich.eduI. Overview 910152Satgutier@umich.edu=========== 1010152Satgutier@umich.edu 1110152Satgutier@umich.eduThe sources in this directory provide three SystemC modules that manage the 1210152Satgutier@umich.eduSystemC/gem5 co-simulation: Gem5SimControl, Gem5MasterTransactor, and 1310152Satgutier@umich.eduGem5SlaveTransactor. They also implement gem5's ExternalMaster::Port interface 1410152Satgutier@umich.edu(SCMasterPort) and ExternalSlave::Port interface (SCSlavePort). 1510152Satgutier@umich.edu 1610152Satgutier@umich.edu**SCMasterPort** and **Gem5MasterTransactor** together form a TLM-to-gem5 1710152Satgutier@umich.edubridge. SCMasterPort implements gem5's ExternalMaster::Port interface and forms 1810152Satgutier@umich.eduthe gem5 end of the bridge. Gem5MasterTransactor is a SystemC module that 1910152Satgutier@umich.eduprovides a target socket and represents the TLM side of the bridge. All TLM 2010152Satgutier@umich.edurequests send to this target socket, are translated to gem5 requests and 2110152Satgutier@umich.eduforwarded to the gem5 world through the SCMasterPort. Then the gem5 world 2210152Satgutier@umich.eduhandles the request and eventually issues a response. When the response arrives 2310152Satgutier@umich.eduat the SCMasterPort it gets translated back into a TLM response and forwarded 2410152Satgutier@umich.eduto the TLM world through target socket of the Gem5MasterTransactor. 2510152Satgutier@umich.eduSCMasterPort and Gem5MasterTransactor are bound to each other by configuring 2610152Satgutier@umich.eduthem for the same port name. 2710152Satgutier@umich.edu 2810152Satgutier@umich.edu**SCSlavePort** and **Gem5SlaveTransactor** together form a gem5-to-TLM bridge. 2910152Satgutier@umich.eduGem5SlaveTransactor is a SystemC module that provides a initiator socket and 3010152Satgutier@umich.edurepresents the TLM end of the bridge. SCSlavePort implements gem5's 3110152Satgutier@umich.eduExternalSlave::Port interface and forms the gem5 side of the bridge. All gem5 3210152Satgutier@umich.edurequests sent to the SCSlavePort, are translated to TLM requests and forwarded 3310152Satgutier@umich.eduto the TLM world through the initiator socket of the Gem5SlaveTransactor. Then 3410152Satgutier@umich.eduthe TLM world handles the request and eventually issues a response. When the 3510152Satgutier@umich.eduresponse arrives at the Gem5SlaveTransactor it gets translated back into a 3610152Satgutier@umich.edugem5 response and forwarded to the gem5 world through the SCSlavePort. SCSLavePort 3710152Satgutier@umich.eduand Gem5SlaveTransactor are bound to each other by configuring them for the 3810152Satgutier@umich.edusame port name. 3910152Satgutier@umich.edu 4010152Satgutier@umich.edu**Gem5SimControl** is the central SystemC module that represents the complete 4110152Satgutier@umich.edugem5 world. It is responsible for instantiating all gem5 objects according to a 4210152Satgutier@umich.edugiven configuration file, for configuring the simulation and for maintaining 4310152Satgutier@umich.eduthe gem5 event queue. It also keeps track of all SCMasterPort and SCSlavePort 4410152Satgutier@umich.eduand responsible for connecting all Gem5MasterTransactor and Gem5SlaveTransactor 4510152Satgutier@umich.edumodules to their gem5 counterparts. This module must be instantiated exactly 4610152Satgutier@umich.eduonce in order to run a gem5 simulation from within an SystemC environment. 4710152Satgutier@umich.edu 4810152Satgutier@umich.edu 4910152Satgutier@umich.eduII. Files 5010152Satgutier@umich.edu========= 5110152Satgutier@umich.edu 5210152Satgutier@umich.edu sc_slave_port.{cc,hh} -- Implements SCSlavePort 5310152Satgutier@umich.edu sc_master_port.{cc,hh} -- Implements SCMasterPort 5410152Satgutier@umich.edu sc_mm.{cc,hh} -- Implementation of a TLM memory manager 5510152Satgutier@umich.edu sc_ext.{cc,hh} -- TLM extension that carries a gem5 packet 5610152Satgutier@umich.edu sc_peq.{cc,hh} -- TLM PEQ for scheduling gem5 events 5710152Satgutier@umich.edu sim_control.{cc,hh} -- Implements Gem5SimControl 5810152Satgutier@umich.edu slave_transactor.{cc,hh} -- Implements Gem5SlaveTransactor 5910152Satgutier@umich.edu master_transactor.{cc,hh} -- Implements Gem5MasterTransactor 6010152Satgutier@umich.edu 6110152Satgutier@umich.edu example/common/cli_parser.{cc,hh} -- Simple cli argument parser 6210152Satgutier@umich.edu example/common/report_hanlder.{cc,hh} -- Custom SystemC report handler 6310152Satgutier@umich.edu 6410152Satgutier@umich.edu example/slave_port/main.cc -- demonstration of the slave port 6510152Satgutier@umich.edu example/slave_port/sc_target.{cc,hh} -- an example TLM LT/AT memory module 6610152Satgutier@umich.edu example/slave_port/tlm.py -- simple gem5 configuration 6710152Satgutier@umich.edu example/slave_port/tlm_elastic.py -- gem5 configuration with an elastic 6810152Satgutier@umich.edu trace replayer 6910152Satgutier@umich.edu example/slave_port/tgen.cfg -- elastic traceplayer configuration 7010152Satgutier@umich.edu 7110152Satgutier@umich.edu example/master_port/main.cc -- demonstration of the master port 7210152Satgutier@umich.edu example/master_port/traffic_generator.{cc/hh} 7310152Satgutier@umich.edu -- an example traffic generator module 7410152Satgutier@umich.edu example/master_port/tlm.py -- simple gem5 configuration 7510152Satgutier@umich.edu 7610152Satgutier@umich.eduOther Files will be used from utils/systemc example: 7710152Satgutier@umich.edu 7810152Satgutier@umich.edu sc_logger.{cc,hh}, 7910152Satgutier@umich.edu sc_module.{cc,hh}, 8010152Satgutier@umich.edu sc_gem5_control.{cc,hh}, 8110152Satgutier@umich.edu stats.{cc,hh} 8210152Satgutier@umich.edu 8310152Satgutier@umich.edu 8410152Satgutier@umich.eduIII. Build 8510152Satgutier@umich.edu========== 8610152Satgutier@umich.edu 8710152Satgutier@umich.eduFirst build a normal gem5 (cxx-config not needed, Python needed). 8810152Satgutier@umich.eduSecond build gem5 as a library with cxx-config support and (optionally) 8910152Satgutier@umich.eduwithout python. 9010152Satgutier@umich.edu 9110152Satgutier@umich.edu> cd ../.. 9210152Satgutier@umich.edu> scons build/ARM/gem5.opt 9310152Satgutier@umich.edu> scons --with-cxx-config --without-python --without-tcmalloc \ 9410152Satgutier@umich.edu> build/ARM/libgem5_opt.so 9510152Satgutier@umich.edu> cd util/tlm 9610152Satgutier@umich.edu 9710152Satgutier@umich.eduNote: For MAC / OSX this command should be used: 9810152Satgutier@umich.edu> scons --with-cxx-config --without-python --without-tcmalloc \ 9910152Satgutier@umich.edu> build/ARM/libgem5_opt.dylib 10010152Satgutier@umich.edu 10110152Satgutier@umich.eduSet a proper LD_LIBRARY_PATH e.g. for bash: 10210152Satgutier@umich.edu> export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/path/to/gem5/build/ARM/" 10310152Satgutier@umich.edu 10410152Satgutier@umich.eduor for MAC / OSX: 10510152Satgutier@umich.edu> export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:/path/to/gem5/build/ARM/" 10610152Satgutier@umich.edu 10710152Satgutier@umich.eduThe build system finds your SystemC installation using pkg-config. Make sure 10810152Satgutier@umich.eduthat pkg-config is installed and your systemc.pc is within your 10910152Satgutier@umich.eduPKG_CONFIG_PATH. You can add SystemC to the PKG_CONFIG_PATH using the following 11010152Satgutier@umich.educommand: 11110152Satgutier@umich.edu> export PKG_CONFIG_PATH="/path/to/systemc/lib-<arch>/pkgconfig/:$PKG_CONFIG_PATH" 11210152Satgutier@umich.edu 11310152Satgutier@umich.eduTo build one of the examples: 11410152Satgutier@umich.edu 11510152Satgutier@umich.edu> cd examples/{master,slave}_port 11610152Satgutier@umich.edu> scons 11710152Satgutier@umich.edu> cd ../../ 11810152Satgutier@umich.edu 11910152Satgutier@umich.edu 12010152Satgutier@umich.eduIV. Simple Examples 12110152Satgutier@umich.edu=================== 12210152Satgutier@umich.edu 12310152Satgutier@umich.edu> cd examples/{master,slave}_port 12410152Satgutier@umich.edu 12510152Satgutier@umich.eduIn order to run our example simulation, we first need to create a config.ini 12610152Satgutier@umich.eduthat represents the gem5 configuration. We do so by starting gem5 with the 12710152Satgutier@umich.edudesired python configuration script. 12810152Satgutier@umich.edu 12910152Satgutier@umich.edu> ../../../../build/ARM/gem5.opt ./tlm.py 13010152Satgutier@umich.edu 13110152Satgutier@umich.eduThe message "fatal: Can't find port handler type 'tlm_{master,slave}'" is okay. 13210152Satgutier@umich.eduThe configuration will be stored in the m5out/ directory 13310152Satgutier@umich.edu 13410152Satgutier@umich.eduThe build step creates a binary gem5.opt.sc in the example directory. It can 13510152Satgutier@umich.edunow be used to load in the generated configuration file from the previous 13610152Satgutier@umich.edunormal gem5 run. 13710152Satgutier@umich.edu 13810152Satgutier@umich.eduTry: 13910152Satgutier@umich.edu 14010152Satgutier@umich.edu> ./gem5.opt.sc m5out/config.ini -e 1000000 14110152Satgutier@umich.edu 14210152Satgutier@umich.eduIt should run a simulation for 1us. 14310152Satgutier@umich.edu 14410152Satgutier@umich.eduTo see more information what happens inside the TLM modules use the -v flag: 14510152Satgutier@umich.edu 14610152Satgutier@umich.edu> ./gem5.opt.sc m5out/config.ini -e 1000000 -v 14710152Satgutier@umich.edu 14810152Satgutier@umich.eduTo see more information about the port coupling use: 14910152Satgutier@umich.edu 15010152Satgutier@umich.edu> ./gem5.opt.sc m5out/config.ini -e 1000000 -d ExternalPort 15110152Satgutier@umich.edu 15210152Satgutier@umich.edu 15310152Satgutier@umich.eduV. Full System Setup 15410152Satgutier@umich.edu===================== 15510152Satgutier@umich.edu 15610152Satgutier@umich.eduApart from the simple examples, there is a full system example that uses 15710152Satgutier@umich.eduthe gem5-to-TLM bridge. 15810152Satgutier@umich.edu 15910152Satgutier@umich.edu>cd examples/slave_port 16010152Satgutier@umich.edu 16110152Satgutier@umich.eduBuild gem5 as described in Section III. Then, make a config file for the 16210152Satgutier@umich.eduC++-configured gem5 using normal gem5 16310152Satgutier@umich.edu 16410152Satgutier@umich.edu> ../../../../build/ARM/gem5.opt ../../../../configs/example/fs.py \ 16510152Satgutier@umich.edu --tlm-memory=transactor --cpu-type=timing --num-cpu=1 \ 16610152Satgutier@umich.edu --mem-type=SimpleMemory --mem-size=512MB --mem-channels=1 --caches \ 16710152Satgutier@umich.edu --l2cache --machine-type=VExpress_EMM \ 16810152Satgutier@umich.edu --dtb-filename=vexpress.aarch32.ll_20131205.0-gem5.1cpu.dtb \ 16910152Satgutier@umich.edu --kernel=vmlinux.aarch32.ll_20131205.0-gem5 \ 17010152Satgutier@umich.edu --disk-image=linux-aarch32-ael.img 17110152Satgutier@umich.edu 17210152Satgutier@umich.eduThe message "fatal: Can't find port handler type 'tlm_slave'" is okay. 17310152Satgutier@umich.eduThe configuration will be stored in the m5out/ directory 17410152Satgutier@umich.edu 17510152Satgutier@umich.eduThe binary 'gem5.opt.sc' can now be used to load in the generated config 17610152Satgutier@umich.edufile from the previous normal gem5 run. 17710152Satgutier@umich.edu 17810152Satgutier@umich.eduTry: 17910152Satgutier@umich.edu 18010152Satgutier@umich.edu> ./gem5.opt.sc m5out/config.ini -o 2147483648 18110152Satgutier@umich.edu 18210152Satgutier@umich.eduThe parameter -o specifies the begining of the memory region (0x80000000). 18310152Satgutier@umich.eduThe system should boot now. 18410152Satgutier@umich.edu 18510152Satgutier@umich.eduFor convenience a run_gem5.sh file holds all those commands 18610152Satgutier@umich.edu 18710152Satgutier@umich.edu 18810152Satgutier@umich.eduVI. Elastic Trace Setup 18910152Satgutier@umich.edu======================== 19010152Satgutier@umich.edu 19110152Satgutier@umich.eduElastic traces can also be replayed into the SystemC world. 19210152Satgutier@umich.eduFor more information on elastic traces please refer to: 19310152Satgutier@umich.edu 19410152Satgutier@umich.edu - http://www.gem5.org/TraceCPU 19510152Satgutier@umich.edu 19610152Satgutier@umich.edu - Exploring System Performance using Elastic Traces: 19710152Satgutier@umich.edu Fast, Accurate and Portable 19810152Satgutier@umich.edu R. Jagtap, S. Diestelhorst, A. Hansson, M. Jung, N. Wehn. 19910152Satgutier@umich.edu IEEE International Conference on Embedded Computer Systems Architectures 20010152Satgutier@umich.edu Modeling and Simulation (SAMOS), July, 2016, Samos Island, Greece. 20110152Satgutier@umich.edu 20210152Satgutier@umich.eduSimilar IV. the simulation can be set up with this command: 20310152Satgutier@umich.edu 20410152Satgutier@umich.edu> ../../../../build/ARM/gem5.opt ./tlm_elastic.py 20510152Satgutier@umich.edu 20610152Satgutier@umich.eduThen: 20710152Satgutier@umich.edu 20810152Satgutier@umich.edu> ./gem5.opt.sc m5out/config.ini 20910152Satgutier@umich.edu 21010152Satgutier@umich.edu 21110152Satgutier@umich.eduVII. Knwon issues 21210152Satgutier@umich.edu================= 21310152Satgutier@umich.edu 21410152Satgutier@umich.edu* For some toolchains, compiling libgem5 with tcmalloc leads to errors 21510152Satgutier@umich.edu ('tcmalloc Attempt to free invalid pointer xxx') when linking libgem5 into a 21610152Satgutier@umich.edu SystemC application. 21710152Satgutier@umich.edu* When SystemC was build with --enable-pthreads, SystemC applications linked 21810152Satgutier@umich.edu