gem5/util/systemc
Andrew Bardsley e5e5b80690 config: Fix to SystemC example's event handling
This patch fixes checkpoint restore in the SystemC hosting example by handling
early PollEvent events correctly before any EventQueue events are posted.

The SystemC event queue handler (SCEventQueue) reports an error if the event
loop is entered with no Events posted.  It is possible for this to happen
after instantiate due to PollEvent events.  This patch separates out
`external' events into a different handler in sc_module.cc to prevent the
error from occurring.

This fix also improves the event handling of asynchronous events by:

    1) Making asynchronous events 'catch up' gem5 time to SystemC
        time to avoid the appearance that events have been lost
        while servicing an asynchronous event that schedules an
        event loop exit event

    2) Add an in_simulate data member to Module to allow the event
        loop to check whether events should be processed or deferred
        until the next time Module::simulate is entered

    3) Cancel pending events around the entry/exit of the event loop
        in Module::simulate

    4) Moving the state initialisation of the example entirely into
        run to correct a problem with early events in checkpoint
        restore.

It is still possible to schedule asynchronous events (and talk PollQueue
actions) while simulate is not running.  This behaviour may stil cause
some problems.
2014-12-02 06:08:09 -05:00
..
main.cc config: Fix to SystemC example's event handling 2014-12-02 06:08:09 -05:00
Makefile config: Fix to SystemC example's event handling 2014-12-02 06:08:09 -05:00
README sim: SystemC hosting 2014-10-16 05:49:54 -04:00
sc_gem5_control.cc config: Fix to SystemC example's event handling 2014-12-02 06:08:09 -05:00
sc_gem5_control.hh config: SystemC Gem5Control top level additions 2014-12-02 06:08:06 -05:00
sc_logger.cc config: Fix to SystemC example's event handling 2014-12-02 06:08:09 -05:00
sc_logger.hh sim: SystemC hosting 2014-10-16 05:49:54 -04:00
sc_module.cc config: Fix to SystemC example's event handling 2014-12-02 06:08:09 -05:00
sc_module.hh config: Fix to SystemC example's event handling 2014-12-02 06:08:09 -05:00
stats.cc sim: SystemC hosting 2014-10-16 05:49:54 -04:00
stats.hh sim: SystemC hosting 2014-10-16 05:49:54 -04:00

This directory contains a demo of C++ configuration of gem5.  The intention
is to provide a mechanism to allow pre-generated config.ini files generated
by Python-based gem5 to be reloaded in library-base versions of gem5
embedded in other systems using C++ calls for simulation control.

This directory contain a demo of hosting a C++ configured version of gem5
onto SystemC's event loop.  The hosting is achieved by replacing 'simulate'
with a SystemC object which implements an event loop using SystemC scheduler
mechanisms.

The sc_... files here should probably be hosted in a diferent directory and
buildable as a library.

Files:

    main.cc                 -- demonstration top level
    sc_logger.{cc,hh}       -- rehosting of DPRINTF onto SC_REPORT
    sc_module.{cc,hh}       -- SystemC simulation loop base class
    sc_gem5_control.{cc,hh} -- Alternative extra wrapping to allow gem5
                                Systems to be instantiated as single
                                sc_module objects.
    stats.{cc,hh}           -- Stats dumping (copied from util/cxx_config)

Read main.cc for more details of the implementation and sc_... files for

To build:

First build gem5 as a library with cxx-config support and (optionally)
without python.  Also build a normal gem5 (cxx-config not needed, Python
needed):

> cd ../..
> scons build/ARM/gem5.opt
> scons --with-cxx-config --without-python build/ARM/libgem5_opt.so
> cd util/cxx_config

Then edit Makefile to set the paths for SystemC and run make

> make

Make a config file for the C++-configured gem5 using normal gem5

> ../../build/ARM/gem5.opt ../../configs/example/se.py -c \
>       ../../tests/test-progs/hello/bin/arm/linux/hello

The binary 'gem5.opt.cxx' can now be used to load in the generated config
file from the previous normal gem5 run.

Try:

> ./gem5.opt.cxx m5out/config.ini

This should print:

> Hello world!

The .ini file can also be read by the Python .ini file reader example:

> ../../build/ARM/gem5.opt ../../configs/example/read_ini.py m5out/config.ini