Setting up SystemC and Eclipse for C++ hardware simulation

https://karibe.co.ke/2014/02/setting-up-systemc-and-eclipse-for-c-hardware-simulation/

 

Browse: Home / 2014 / February / Setting up SystemC and Eclipse for C++ hardware simulation

Setting up SystemC and Eclipse for C++ hardware simulation

This post was updated on 26th April,2018 for the latest systemc release: version 2.3.2.
This is a step by step guide to setting up systemc library based on an edit of instructions that come with the source and configuring and running an eclipse-IDE C++ Project. As of now (April 2018), systemc-2.3.2 is the most recent systemc version. It provides several improvements over systemc-2.3.1, including bug fixes and several new features that are disabled by default. On this post, we will be installing systemc2.3.2 “as is” without enabling any new experimental features, for learning purposes.

1. May the source be with you

There are two ways to get the source:
First and easiest is cloning the github repository
Get into the source/dev’t directory

cd ~/src/git

clone the repo

git clone https://github.com/Muriukidavid/systemc-2.3.2.git

Get into the systemC source directory, ready to build.

cd systemc-2.3.2

Second method is getting the latest from the developer community:
To get the source code from accellera systems, you need to head to the download page and download the latest version of the library.
Place and Extract the source in your home folder and cd there

cd systemc-2.3.2

2. pre-requisites

Most Linux installations have the required tools by default, just make sure you have make installed. If not, install it:

sudo apt-get install build-essential automake libtool

To check that you have these already, use the which command:

which g++

Then you have to set some environmental variables:

export CXX=g++

If you have a custom compiled gcc, you have the /usr/local/bin/gcc and its g++ as default compiler, probably an older version for building something, then you need to be more specific with the system installed gcc path like so:

export CXX=/usr/bin/g++
export CC=/usr/bin/gcc

Then create a working directory, where you will build the library before installing it

mkdir objdir

get into that directory

cd objdir 

3. configuring

Run autoreconf command in the base directory to prepare for configuration, check for dependancies according to the system you have.

../autoreconf -f -i

Create a folder where the installation will be made under /usr/local

sudo mkdir /usr/local/systemc-2.3.2

While at ‘objdir’ folder, run the command

../configure --prefix=/usr/local/systemc-2.3.2

This configures the installation folder and generates the makefiles, among other things…. Last few lines output:

configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: creating src/systemc.pc
config.status: creating src/tlm.pc
config.status: creating src/sysc/Makefile
config.status: creating src/sysc/packages/boost/Makefile
config.status: creating src/sysc/packages/qt/Makefile
config.status: creating src/tlm_core/Makefile
config.status: creating src/tlm_utils/Makefile
config.status: creating examples/Makefile
config.status: creating examples/sysc/Makefile
config.status: creating examples/tlm/Makefile
config.status: creating examples/tlm/common/Makefile
config.status: creating docs/Makefile
config.status: creating docs/sysc/doxygen/Doxyfile
config.status: creating docs/tlm/doxygen/Doxyfile
config.status: executing depfiles commands
config.status: executing libtool commands
---------------------------------------------------------------------
Configuration summary of SystemC 2.3.2 for x86_64-unknown-linux-gnu
---------------------------------------------------------------------

 Directory setup (based on classic layout):
   Installation prefix (aka SYSTEMC_HOME):
      /usr/local/systemc-2.3.2
   Header files  : /include
   Libraries     : /lib-linux64
   Documentation : /docs
   Examples      : /examples

 Architecture    : linux64
 Compiler        : /usr/bin/g++ (C/C++)
 
 Build settings:
   Enable compiler optimizations  : yes
   Include debugging symbols      : no
   Coroutine package for processes: QuickThreads
   Enable VCD scopes by default   : yes
   Disable async_request_update   : no
   Phase callbacks (experimental) : no
 
---------------------------------------------------------------------

4. make the library

Assuming configuration went on finishing smoothly, build the library

make

If you want it to run faster, make use of multiple threads with the -j option, I used

make -j4    

5. Install the library in your system

sudo make install

After this command, you can check that the library was properly installed:

ls /usr/local/systemc-2.3.2/lib-linux64/
libsystemc-2.3.2.so  libsystemc.a  libsystemc.la  libsystemc.so  pkgconfig

Note: for a 32-bit system, the library folder is /usr/local/systemc-2.3.2/lib-linux/. you can type while using tab to auto-complete paths 

To configure the library with the standard Linux library path, which will ease up linking stage of project build:

sudo ln -s /usr/local/systemc-2.3.2/lib-linux64/libsystemc-2.3.2.so /usr/lib/libsystemc-2.3.2.so

You can check the path is correct:

ls -l /usr/lib/libsystemc-2.3.2.so 
lrwxrwxrwx 1 root root 56 Apr 26 12:31 /usr/lib/libsystemc-2.3.2.so -> /usr/local/systemc-2.3.2/lib-linux64/libsystemc-2.3.2.so

This library path problem has of late been persistent and the solution is to add a config file under /etc/ld.so.conf.d/ as follows:

sudo gedit /etc/ld.so.conf.d/systemc.conf

add the path information to that file, i.e “/usr/local/systemc-2.3.2/lib-linux/” or “/usr/local/systemc-2.3.2/lib-linux64/” depending on your system.
then run

sudo ldconfig

6. Get Eclipse

If you already have eclipse, go to step 7. If not, go to Eclipse.org and download the Eclipse IDE for C/C++ developers. Choose 32-bit/64-bit Linux version and the closest mirror… Extract under the home folder and optionally set up a .desktop shortcut

7. Create a new eclipse project

Open Eclipse and create a new C++ project, under New menu

Setting up SystemC and Eclipse for C++ hardware simulation

Eclipse new project

Create a new source folder src in your project

Setting up SystemC and Eclipse for C++ hardware simulation

eclipse create source folder

and inside it a new file main.cpp

Setting up SystemC and Eclipse for C++ hardware simulation

eclipse new source file

8. Configure systemc library Path for the project

At this point, your project isn’t configured with the library path:

Setting up SystemC and Eclipse for C++ hardware simulation

systemc header not found

Right Click on the project root folder in the project explorer view and click on properties, alternatively, go to the Project menu and click properties.

Setting up SystemC and Eclipse for C++ hardware simulation

eclipse project properties

Expand the C/C++ Build entry, and click on settings. Under tool settings tab, expand GCC C++ Compiler and click on includes. On the right under include paths(-l), click the + icon and add a path to /usr/local/systemc-2.3.2/include/ by browsing File System. Note: The path in the image is actually different as it was added in 2014 when the latest version was still 2.3.0

Setting up SystemC and Eclipse for C++ hardware simulation

eclipse systemc include path

Now expand GCC C++ Linker and under Libraries, at the top Libraries(-l) entry, click on the + icon and add the library name “systemc”

Setting up SystemC and Eclipse for C++ hardware simulation

eclipse systemc library name

then at the bottom Library search path, click on the + icon and on the pop-up, add the path to the installation directory /usr/local/systemc-2.3.2/lib-linux64 for 64-bit or /usr/local/systemc-2.3.2/lib-linux for 32-bit systems. Note: The path in the image is for systemc version 2.3.0, but we are using 2.3.2

Setting up SystemC and Eclipse for C++ hardware simulation

ecipse systemc library search path

Setting up SystemC and Eclipse for C++ hardware simulation

eclipse systemc library configured

9. Build and run

Click on the build symbol, the hummer, and if everything is ok in terminal: saying finished building target,

Setting up SystemC and Eclipse for C++ hardware simulation

eclipse systemc build success

click on the Run icon(like play icon) the one to the right of the IDE, not the one on the left side.

At this point its hard to tell what the output of the terminal will be  depends on how much you have learnt systemc and implemented in your main.cpp file.

10. Working Example

You should try a simple working example to begin with:

Share this:

Like this:

Articles in this series

25 responses to “Setting up SystemC and Eclipse for C++ hardware simulation”

    1. Setting up SystemC and Eclipse for C++ hardware simulationkevin March 22, 2014 at 7:45 pm | | Reply

      probably you should have indicated …that one needs the “build-essentials to proceed with installation of systemC” at the top

    2. Setting up SystemC and Eclipse for C++ hardware simulationkatontwo April 5, 2014 at 1:44 am | | Reply

      i have tried several times to set the library path, but after running an err message .
      01:25:31 **** Incremental Build of configuration Debug for project systemc_test ****
      make all
      Building target: systemc_test
      Invoking: GCC C++ Linker
      g++ -L/home/katontwo/systemc-2.3.0/lib-linux -o “systemc_test” ./src/main.o ./main.o -lsystemc
      /usr/bin/ld: cannot find -lsystemc
      collect2: error: ld returned 1 exit status
      make: *** [systemc_test] Error 1

      01:25:32 Build Finished (took 74ms)
      HOW CAN I SOLVE THIS?

    3. Setting up SystemC and Eclipse for C++ hardware simulationMyzel May 5, 2014 at 1:52 pm | | Reply

      Very detailed guide, very helpful! Great work! Thank you!

    4. Setting up SystemC and Eclipse for C++ hardware simulationFrank September 2, 2014 at 5:53 am | | Reply

      Hello Karibe,

      Thank you very much for the tutorial; I would probably be struggling much more had it not been for your detailed, step by step instructions.

      With that said, I am still having one issue. I followed your instructions to a T, except that I’m using Fedora 20 rather than Ubuntu and I’m using the newer version of SystemC, 2.3.1 (and so I modified your steps to reflect that). I can build my projects fine, but when I try to run them, I encounter the following error:

      “error while loading shared libraries: libsystemc-2.3.1.so: cannot open shared object file: No such file or directory”

      I did create the soft link as instructed and verified that it was correct, so I’m not entirely sure what I could be doing wrong. I’d appreciate any advice you can give here. Thanks

    5. Setting up SystemC and Eclipse for C++ hardware simulationFrank September 3, 2014 at 1:38 am | | Reply

      Hey David,

      I think I solved my problem. For whatever reason I needed to add “m” to the libraries list in addition to “systemc” as was done on this tutorial: http://geekwentfreak-raviteja.rhcloud.com/blog/2011/01/21/eclipse-as-development-environmentide-for-systemc-in-ubuntu/

      I’m not sure what the reasons was, but I figured I’d post here for other people who have the same problem. If you get a chance to look into it, I’d love to get your feedback on this issue.

      Frank

      1. Setting up SystemC and Eclipse for C++ hardware simulationFrank September 3, 2014 at 1:39 am | | Reply

        Just for the record, I’m running Fedora 20, the latest version of Eclipse (Luna) and the latest version of SystemC (2.3.1).

    6. Setting up SystemC and Eclipse for C++ hardware simulationMeshack Mbuvi October 20, 2014 at 2:11 pm | | Reply

      Mr karibe i have followed all the steps but on build, am given this error
      Description Resource Path Location Type
      make: *** [systemc-test] Error 1 systemc-test C/C++ Problem

    7. Setting up SystemC and Eclipse for C++ hardware simulationMeshack Mbuvi October 21, 2014 at 10:25 am | | Reply

      Sir….I have had to re-install the eclipse and it has worked…Thanx alot

    8. Setting up SystemC and Eclipse for C++ hardware simulation Setting up SystemC-AMS and Eclipse >> Karibe February 3, 2016 at 2:54 pm |

      […] procedure is really simple! You just need to follow the same steps as those in the previous post on Setting up SystemC and Eclipse for C++ hardware simulation. BUT in addition to configuring the SystemC library and includes, add those of SystemC-ams as well […]

    9. Setting up SystemC and Eclipse for C++ hardware simulationalexua August 21, 2016 at 1:22 pm | | Reply

      I have tried it but it is not working well I am having “Type sc_signal_resolved could not be resolved” error, and at times an undefined reference to “sc_main”

    10. Setting up SystemC and Eclipse for C++ hardware simulation Setting up SystemC-AMS and Eclipse >> Karibe May 2, 2018 at 10:57 pm |

      […] procedure is really simple! You just need to follow the same steps as those in the previous post on Setting up SystemC and Eclipse for C++ hardware simulation. BUT in addition to configuring the SystemC library and includes, add those of SystemC-ams as […]

上一篇:用NSubstitute来mock


下一篇:每天学点linux命令