Requirements:

Build Setup

First you need choose where you will keep the source and installed files. I like to keep all installed files of all project’s softwares in the same prefix, and for organization, keep the prefix in the same directory tree of the project sources.

export SOURCE_PREFIX="/A/B/ac_project"
export PREFIX="${SOURCE_PREFIX}/usr"

You can use you home to store this files. But keep in mind that a network mounted home (as NFS) have advantages and disadvantages.

export SOURCE_PREFIX="/${HOME}/A/B/ac_project"
export PREFIX="${SOURCE_PREFIX}/usr"

Both paths must exists:

mkdir -p "${SOURCE_PREFIX}"
mkdir -p "${PREFIX}"

Now, that you know where you will put the installed files, you can setup your paths to this project:

$ export PATH="${PREFIX}/bin/:${PATH}"
$ export LD_LIBRARY_PATH="${PREFIX}/lib/:${LD_LIBRARY_PATH}"
$ export PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig:${PKG_CONFIG_PATH}"

SystemC

SystemC uses the autotools build system. This is a very used build system, maybe you should ever considerate that the software are using this build system or similar one.

Fetch the SystemC, we suggest that you use (our git version)[https://github.com/ArchC/SystemC]. But you can use the (Accellera vanilla code)[http://www.accellera.org/downloads/standards/systemc].

$ git clone https://github.com/ArchC/SystemC.git "${SOURCE_PREFIX}/SystemC"

PS: We are using the commit (a7605fd)[https://github.com/ArchC/SystemC/tree/a7605fd4cd7ada969789d9250f784fc925503d9a].

The SystemC adopts a strange installation layout that you must avoid. In the version 2.3.1 they offer a flag to force use unix layout.

$ cd "${SOURCE_PREFIX}/SystemC"
$ autoreconf -vif
$ ./configure --with-unix-layout --prefix="${PREFIX}"
$ make # Build the source
$ make check # Build and execute the tests
$ make install # Install SystemC in defined $PREFIX

ArchC

Similar to SystemC, the ArchC uses the autotools build system.

Fetch ArchC project:

$ git clone https://github.com/ArchC/ArchC.git "${SOURCE_PREFIX}/ArchC"

PS: We are using the commit (594942b)[https://github.com/ArchC/ArchC/tree/594942bb290f7964b3fff2a05335bcd94bbe480d].

The ArchC will search the SystemC using the pkg-config, remember to use the correct path to help it find your SystemC installation.

$ cd "${SOURCE_PREFIX}/ArchC"
$ autoreconf -vif
$ ./configure --prefix="${PREFIX}"
$ make # Build the source
$ make check # Build and execute the tests
$ make install # Install ArchC in defined $PREFIX

Processors

The ArchC project maintains 4 processor models: * MIPS * ARM * SPARC * POWERPC

You can fetch and build them:

mkdir -p "${SOURCE_PREFIX}/ACModels"
for model in mips arm sparc powerpc; do
  git clone "https://github.com/ArchC/${model}.git" "${SOURCE_PREFIX}/ACModels/${model}";
  cd "${SOURCE_PREFIX}/ACModels/${model}";
  acsim ${model}.ac;
  make;
do

Guest Toolchain

You can get the compiled toolchain for each of the maintained models.

Run Guest Binaries

$ cd "${SOURCE_PREFIX}/ACModels/<model name>"
$ ./<model name>.x --load=<full path to binary>

Example:

$ cd "${SOURCE_PREFIX}/ACModels/mips"
$ ./mips.x --load=/tmp/

Debug processor models

Execution flow

You can compare two execution of same binary using the output and the trace. To generate the trace, you must print the list of PC used. Uncomment the debug line at <model>_isa.cpp :

//#define DEBUG_MODEL

Execute your binary:

$ make clean
$ make
$ ./<model name>.x --load=<full path to binary> 2>/tmp/ac_stderr

Get the trace of PC addresses:

$ LINES = 1000
$ grep '^DBG:.* PC=0x[0-9a-f]\+ .*$' /tmp/ac_stderr | head -n ${LINES} | sed 's/^DBG:.* PC=\(0x[0-9a-f]\+\) .*$/\1/g' >/tmp/ac_trace

If your binary was compiled with debug symbols, you can translate the address to source file and line:

$ cat /tmp/ac_trace | xargs <model>-newlib-elf-addr2line -a -f -p -e <full path to binary> >/tmp/ac_hltrace