| title | Example SystemC code |
|---|---|
| author | Doulos Inc |
This is a set of example SystemC code mini-projects. Following briefly describes each project.
hellosc: Simply displaysHello Worldfrom within a process. This is the simplest of examples.main: Contains an extensive main.cpp with debugging enhancements suitable for production. Replaceminimal_top.?ppwith your own version.thread-method: A simple illustration of the differences betweenSC_THREAD's vsSC_METHOD'sthread_vs_method: A more complicated illustration of the behavior ofSC_THREAD's vsSC_METHOD'snonblocking: Explains blocking vs non-blocking signal assignment in SystemC.netlist: Displays the design hierchy. Use in your designs.report_handler: Replace the default report handler with your own.reporting: Friendlier versions of reporting macrostimer: Illustrates two very different types of "timers". One is for measuring execution performance of C++ code itself. The other is a hardware model that does not usesc_core::sc_clock.debug_fifo: A debug fifo with built-in read/write monitoringfixed: Illustrates use of SystemC fixed-point data typeslogic: Illustrates use of SystemC logic data typesscdataperf: Illustrates the performance differences between various SystemC data types.trace: Illustrates how to get timing traces for viewing with waveform viewers ()
There are some important helper scripts and utilities that are not direct SystemC code, but used to build and run simulations:
cmakesimplifiesCMakeLists.txtexterncontains third-party libraries built with scripts (e.g.,build-crc)includecontains useful SystemC utilities (e.g., netlist and reporting add-ons)setup.profilesets up the environment (e.g., $WORKPATH_DIR)tools/*scripts that simplify building
Note: The top-level
CMakeLists.txtwill build and include all the mini-projects, but you are encouraged to enter each mini-project and build there. The top-level one is mostly used as a regression test.
All of the samples are built inside their respective directories using cmake, and several of them use some third party libraries (mostly downloaded from GitHub). So you will need the following:
- Set up the environment
source setup.profile # Assumes you are inside the top-level project directory. Only needs to be done once per shell.- Build the SystemC library itself if needed
build-systemc- Build the
fmtandcrclibraries using the build script as follows:
# both of the following will be installed under ../extern
build-crc
build-fmt ;#< this may take a few minutesIMPORTANT: See note about locale's.
- Enter the mini-project
cd MINI_PROJECT_NAME #< directory containing `CMakeLists.txt` and code of interest- Examine and build each project using following instructions.
The build script, located in ../extern/bin was designed to simplify using cmake; although, cmake is very simple to use once you learn it. When build runs it will display the steps you would need to use with cmake as output beginning with a % character.
By default, build will only configure and compile the code; however, you can have it run the code by adding the -test option:
build -testYou can make this the default by creating a file named .buildrc located in your home directory. This file simply contains command-line options for use with build.
echo "-test" >"${HOME}/.buildrc"For more information using the --help option:
build --helpTry not to get bogged down in the advanced features. I normally restrict myself to:
build -clean
build -testUbunutu recently changed the way locales are handled. Instead of installing support for all locales, you may need to generate those you need. Here's how:
- Examine /etc/locale.gen and choose an appropriate locale
- Run:
sudo locale-gen LOCALE - Run:
sudo update-locale - Examine the ouput of
locale - Add:
export LANG=LOCALE
You will know if you get a complaint about LOCALE.
Have fun learning!