README revision 13372
113372Sgabeblack@google.comThis directory contains a demo of C++ configuration of gem5. The intention 213372Sgabeblack@google.comis to provide a mechanism to allow pre-generated config.ini files generated 313372Sgabeblack@google.comby Python-based gem5 to be reloaded in library-base versions of gem5 413372Sgabeblack@google.comembedded in other systems using C++ calls for simulation control. 513372Sgabeblack@google.com 613372Sgabeblack@google.comThis directory contain a demo of hosting a C++ configured version of gem5 713372Sgabeblack@google.comonto SystemC's event loop. The hosting is achieved by replacing 'simulate' 813372Sgabeblack@google.comwith a SystemC object which implements an event loop using SystemC scheduler 913372Sgabeblack@google.commechanisms. 1013372Sgabeblack@google.com 1113372Sgabeblack@google.comThe sc_... files here should probably be hosted in a diferent directory and 1213372Sgabeblack@google.combuildable as a library. 1313372Sgabeblack@google.com 1413372Sgabeblack@google.comFiles: 1513372Sgabeblack@google.com 1613372Sgabeblack@google.com main.cc -- demonstration top level 1713372Sgabeblack@google.com sc_logger.{cc,hh} -- rehosting of DPRINTF onto SC_REPORT 1813372Sgabeblack@google.com sc_module.{cc,hh} -- SystemC simulation loop base class 1913372Sgabeblack@google.com sc_gem5_control.{cc,hh} -- Alternative extra wrapping to allow gem5 2013372Sgabeblack@google.com Systems to be instantiated as single 2113372Sgabeblack@google.com sc_module objects. 2213372Sgabeblack@google.com stats.{cc,hh} -- Stats dumping (copied from util/cxx_config) 2313372Sgabeblack@google.com 2413372Sgabeblack@google.comRead main.cc for more details of the implementation and sc_... files for 2513372Sgabeblack@google.com 2613372Sgabeblack@google.comTo build: 2713372Sgabeblack@google.com 2813372Sgabeblack@google.comFirst build gem5 as a library with cxx-config support and (optionally) 2913372Sgabeblack@google.comwithout python. Also build a normal gem5 (cxx-config not needed, Python 3013372Sgabeblack@google.comneeded): 3113372Sgabeblack@google.com 3213372Sgabeblack@google.com> cd ../../.. 3313372Sgabeblack@google.com> scons build/ARM/gem5.opt 3413372Sgabeblack@google.com> scons --with-cxx-config --without-python build/ARM/libgem5_opt.so 3513372Sgabeblack@google.com> cd util/systemc 3613372Sgabeblack@google.com 3713372Sgabeblack@google.comNote: For MAC / OSX this command should be used: 3813372Sgabeblack@google.com> scons --with-cxx-config --without-python build/ARM/libgem5_opt.dylib 3913372Sgabeblack@google.com 4013372Sgabeblack@google.comSet a proper LD_LIBRARY_PATH e.g. for bash: 4113372Sgabeblack@google.com> export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/path/to/gem5/build/ARM/" 4213372Sgabeblack@google.com 4313372Sgabeblack@google.comor for MAC / OSX: 4413372Sgabeblack@google.com> export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:/path/to/gem5/build/ARM/" 4513372Sgabeblack@google.com 4613372Sgabeblack@google.com 4713372Sgabeblack@google.comThen edit the Makefile to set the paths for SystemC, e.g: 4813372Sgabeblack@google.com 4913372Sgabeblack@google.com Linux: 5013372Sgabeblack@google.com SYSTEMC_INC = /opt/systemc/include 5113372Sgabeblack@google.com SYSTEMC_LIB = /opt/systemc/lib-linux64 5213372Sgabeblack@google.com 5313372Sgabeblack@google.com MAC / OSX: 5413372Sgabeblack@google.com SYSTEMC_INC = /opt/systemc/include 5513372Sgabeblack@google.com SYSTEMC_LIB = /opt/systemc/lib-macosx64 5613372Sgabeblack@google.com 5713372Sgabeblack@google.comThen run make: 5813372Sgabeblack@google.com 5913372Sgabeblack@google.com> make 6013372Sgabeblack@google.com 6113372Sgabeblack@google.comMake a config file for the C++-configured gem5 using normal gem5 6213372Sgabeblack@google.com 6313372Sgabeblack@google.com> ../../../build/ARM/gem5.opt ../../../configs/example/se.py -c \ 6413372Sgabeblack@google.com> ../../../tests/test-progs/hello/bin/arm/linux/hello 6513372Sgabeblack@google.com 6613372Sgabeblack@google.comThe binary 'gem5.opt.cxx' can now be used to load in the generated config 6713372Sgabeblack@google.comfile from the previous normal gem5 run. 6813372Sgabeblack@google.com 6913372Sgabeblack@google.comTry: 7013372Sgabeblack@google.com 7113372Sgabeblack@google.com> ./gem5.opt.cxx m5out/config.ini 7213372Sgabeblack@google.com 7313372Sgabeblack@google.comThis should print: 7413372Sgabeblack@google.com 7513372Sgabeblack@google.com> Hello world! 7613372Sgabeblack@google.com 7713372Sgabeblack@google.comThe .ini file can also be read by the Python .ini file reader example: 7813372Sgabeblack@google.com 7913372Sgabeblack@google.com> ../../../build/ARM/gem5.opt ../../../configs/example/read_ini.py \ 8013372Sgabeblack@google.com> m5out/config.ini 8113372Sgabeblack@google.com 8213372Sgabeblack@google.comIf you are interested in SystemC Transaction Level Modeling (TLM2) please have 8313372Sgabeblack@google.coma look into /util/tlm. 84