README revision 13463
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)
2913463Sgabeblack@google.comwithout python.  When building the library, disable gem5's native SystemC
3013463Sgabeblack@google.comAPI support, as that will conflict with the external version.  Also build a
3113463Sgabeblack@google.comnormal gem5 (cxx-config not needed, Python needed):
3213372Sgabeblack@google.com
3313372Sgabeblack@google.com> cd ../../..
3413372Sgabeblack@google.com> scons build/ARM/gem5.opt
3513463Sgabeblack@google.com> scons --with-cxx-config --without-python USE_SYSTEMC=0 \
3613463Sgabeblack@google.com>       build/ARM/libgem5_opt.so
3713372Sgabeblack@google.com> cd util/systemc
3813372Sgabeblack@google.com
3913372Sgabeblack@google.comNote: For MAC / OSX this command should be used:
4013463Sgabeblack@google.com> scons --with-cxx-config --without-python USE_SYSTEMC=0 \
4113463Sgabeblack@google.com>       build/ARM/libgem5_opt.dylib
4213372Sgabeblack@google.com
4313372Sgabeblack@google.comSet a proper LD_LIBRARY_PATH e.g. for bash:
4413372Sgabeblack@google.com> export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/path/to/gem5/build/ARM/"
4513372Sgabeblack@google.com
4613372Sgabeblack@google.comor for MAC / OSX:
4713372Sgabeblack@google.com> export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:/path/to/gem5/build/ARM/"
4813372Sgabeblack@google.com
4913372Sgabeblack@google.com
5013372Sgabeblack@google.comThen edit the Makefile to set the paths for SystemC, e.g:
5113372Sgabeblack@google.com
5213372Sgabeblack@google.com    Linux:
5313372Sgabeblack@google.com    SYSTEMC_INC = /opt/systemc/include
5413372Sgabeblack@google.com    SYSTEMC_LIB = /opt/systemc/lib-linux64
5513372Sgabeblack@google.com
5613372Sgabeblack@google.com    MAC / OSX:
5713372Sgabeblack@google.com    SYSTEMC_INC = /opt/systemc/include
5813372Sgabeblack@google.com    SYSTEMC_LIB = /opt/systemc/lib-macosx64
5913372Sgabeblack@google.com
6013372Sgabeblack@google.comThen run make:
6113372Sgabeblack@google.com
6213372Sgabeblack@google.com> make
6313372Sgabeblack@google.com
6413372Sgabeblack@google.comMake a config file for the C++-configured gem5 using normal gem5
6513372Sgabeblack@google.com
6613372Sgabeblack@google.com> ../../../build/ARM/gem5.opt ../../../configs/example/se.py -c \
6713372Sgabeblack@google.com>       ../../../tests/test-progs/hello/bin/arm/linux/hello
6813372Sgabeblack@google.com
6913372Sgabeblack@google.comThe binary 'gem5.opt.cxx' can now be used to load in the generated config
7013372Sgabeblack@google.comfile from the previous normal gem5 run.
7113372Sgabeblack@google.com
7213372Sgabeblack@google.comTry:
7313372Sgabeblack@google.com
7413372Sgabeblack@google.com> ./gem5.opt.cxx m5out/config.ini
7513372Sgabeblack@google.com
7613372Sgabeblack@google.comThis should print:
7713372Sgabeblack@google.com
7813372Sgabeblack@google.com> Hello world!
7913372Sgabeblack@google.com
8013372Sgabeblack@google.comThe .ini file can also be read by the Python .ini file reader example:
8113372Sgabeblack@google.com
8213372Sgabeblack@google.com> ../../../build/ARM/gem5.opt ../../../configs/example/read_ini.py \
8313372Sgabeblack@google.com>       m5out/config.ini
8413372Sgabeblack@google.com
8513372Sgabeblack@google.comIf you are interested in SystemC Transaction Level Modeling (TLM2) please have
8613372Sgabeblack@google.coma look into /util/tlm.
87