README revision 13463
1This directory contains a demo of C++ configuration of gem5.  The intention
2is to provide a mechanism to allow pre-generated config.ini files generated
3by Python-based gem5 to be reloaded in library-base versions of gem5
4embedded in other systems using C++ calls for simulation control.
5
6This directory contain a demo of hosting a C++ configured version of gem5
7onto SystemC's event loop.  The hosting is achieved by replacing 'simulate'
8with a SystemC object which implements an event loop using SystemC scheduler
9mechanisms.
10
11The sc_... files here should probably be hosted in a diferent directory and
12buildable as a library.
13
14Files:
15
16    main.cc                 -- demonstration top level
17    sc_logger.{cc,hh}       -- rehosting of DPRINTF onto SC_REPORT
18    sc_module.{cc,hh}       -- SystemC simulation loop base class
19    sc_gem5_control.{cc,hh} -- Alternative extra wrapping to allow gem5
20                                Systems to be instantiated as single
21                                sc_module objects.
22    stats.{cc,hh}           -- Stats dumping (copied from util/cxx_config)
23
24Read main.cc for more details of the implementation and sc_... files for
25
26To build:
27
28First build gem5 as a library with cxx-config support and (optionally)
29without python.  When building the library, disable gem5's native SystemC
30API support, as that will conflict with the external version.  Also build a
31normal gem5 (cxx-config not needed, Python needed):
32
33> cd ../../..
34> scons build/ARM/gem5.opt
35> scons --with-cxx-config --without-python USE_SYSTEMC=0 \
36>       build/ARM/libgem5_opt.so
37> cd util/systemc
38
39Note: For MAC / OSX this command should be used:
40> scons --with-cxx-config --without-python USE_SYSTEMC=0 \
41>       build/ARM/libgem5_opt.dylib
42
43Set a proper LD_LIBRARY_PATH e.g. for bash:
44> export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/path/to/gem5/build/ARM/"
45
46or for MAC / OSX:
47> export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:/path/to/gem5/build/ARM/"
48
49
50Then edit the Makefile to set the paths for SystemC, e.g:
51
52    Linux:
53    SYSTEMC_INC = /opt/systemc/include
54    SYSTEMC_LIB = /opt/systemc/lib-linux64
55
56    MAC / OSX:
57    SYSTEMC_INC = /opt/systemc/include
58    SYSTEMC_LIB = /opt/systemc/lib-macosx64
59
60Then run make:
61
62> make
63
64Make a config file for the C++-configured gem5 using normal gem5
65
66> ../../../build/ARM/gem5.opt ../../../configs/example/se.py -c \
67>       ../../../tests/test-progs/hello/bin/arm/linux/hello
68
69The binary 'gem5.opt.cxx' can now be used to load in the generated config
70file from the previous normal gem5 run.
71
72Try:
73
74> ./gem5.opt.cxx m5out/config.ini
75
76This should print:
77
78> Hello world!
79
80The .ini file can also be read by the Python .ini file reader example:
81
82> ../../../build/ARM/gem5.opt ../../../configs/example/read_ini.py \
83>       m5out/config.ini
84
85If you are interested in SystemC Transaction Level Modeling (TLM2) please have
86a look into /util/tlm.
87