Setting up SystemC and Eclipse for C++ hardware simulation

发布时间:2022-06-25 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了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

By Karibe on February 21, 2014

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:

  • Tweet
  •  
  • Email
  • Print

Like this:

Related

Setting up SystemC-AMS and EclipseFebruary 3, 2016In "Embedded systems"

systemc hardware simulation VCD trace output viewing using Impulse eclipse pluginSeptember 19, 2014In "Embedded systems"

Modeling and Simulation in Systemc - top down methodoLOGy introductionJuly 15, 2012In "Embedded systems"

Posted in Embedded systems, Linux | Tagged C++, hardware, Simulation, SystemC | 25 Responses

Articles in this series

  • Setting up SystemC-AMS and Eclipse
  • systemc hardware simulation VCD trace output viewing using Impulse eclipse plugin
  • Setting up SystemC and Eclipse for C++ hardware simulation
  • Modeling and Simulation in Systemc - top down methodology introduction

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

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

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

      1. Setting up SystemC and Eclipse for C++ hardware simulation
        karibe March 23, 2014 at 10:48 pm | Permalink | Reply

        Yes and build-essential is a bundle that includes g++, that’s what you need here so you can just install that :-).

    2. Setting up SystemC and Eclipse for C++ hardware simulation
      katontwo April 5, 2014 at 1:44 am | Permalink | 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?

      1. Setting up SystemC and Eclipse for C++ hardware simulation
        karibe April 5, 2014 at 9:00 pm | Permalink | Reply

        Make sure you have a symbolic link to the /usr/lib/ folder of your systemc library file, check that step in the post.

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

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

      1. Setting up SystemC and Eclipse for C++ hardware simulation
        karibe May 5, 2014 at 4:55 pm | Permalink | Reply

        You are welcome, glad I could help 

    4. Setting up SystemC and Eclipse for C++ hardware simulation
      Frank September 2, 2014 at 5:53 am | Permalink | 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 simulation
      Frank September 3, 2014 at 1:38 am | Permalink | 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 simulation
        Frank September 3, 2014 at 1:39 am | Permalink | 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).

      2. Setting up SystemC and Eclipse for C++ hardware simulation
        karibe September 4, 2014 at 8:28 pm | Permalink | Reply

        Hi Frank, thanks for the heads up, sorry for not replying on time, been very busy. That “m” thing is probably for the new version and very suspicious. will most def check it out

        1. Setting up SystemC and Eclipse for C++ hardware simulation
          Frank September 5, 2014 at 10:10 pm | Permalink | Reply

          Thanks for getting back to me; no worries, I’m just glad it’s working now.

          But after making a few new projects, it appears I no longer need the “m” and I can setup the project exactly as outlined. It’s probably just some weird quirk. I’ve noticed that eclipse is somewhat slow in parsing the systemc library. For instance, when I copied and pasted a “hello world” program into my project, it would yell at me and give me all sorts of errors when I compiled. Then I simply let it sit for 30 seconds or so and all the errors dissapeared; very Fishy.

          Anyway, as I’ve said before, thanks for the awesome tutorial; it really helped a lot!

          1. Setting up SystemC and Eclipse for C++ hardware simulation
            karibe September 5, 2014 at 11:18 pm | Permalink | Reply

            You are welcome Frank, the thing with eclipse is, it can be slow, you need to force rebuild index after making some changes to a project sometimes, or even set refresh on change of resource. I have found rebuilding index helpful.

            1. Setting up SystemC and Eclipse for C++ hardware simulation
              Frank September 15, 2014 at 8:56 pm | Permalink

              That seems to have done it, thanks again. However, I do have one more question for you. I recently bought a new computer and so I’m trying to install SystemC on the new one as well. However, when I try to make soft links, there seems to be an issue that I didn’t have before.

              I created the soft links just as you describe (only difference being that I change the 2.3.0 to 2.3.1 as usual). However, when I try to run a simple hello world program, Eclipse gives me the following error:

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

              Do you have any idea what might trigger this?

              Thanks again, Frank

            2. Setting up SystemC and Eclipse for C++ hardware simulation
              Frank September 15, 2014 at 9:43 pm | Permalink

              And just for the record, libsystemc2.3.1.so does exist in the /usr/lib/ directory

            3. Setting up SystemC and Eclipse for C++ hardware simulation
              Frank September 15, 2014 at 9:55 pm | Permalink

              I found a solution here: https://BBS.archlinux.org/viewtopic.php?pid=1443580

            4. Setting up SystemC and Eclipse for C++ hardware simulation
              karibe September 16, 2014 at 10:28 am | Permalink

              Thanks Frank, I guess we have not had that problem in Ubuntu and may be its on Fedora and Arch, although the last time I installed SystemC was quite a while ago. The solution makes sense, though the system should autoMATE that configuration somehow

            5. Setting up SystemC and Eclipse for C++ hardware simulation
              karibe September 19, 2014 at 12:29 pm | Permalink

              I tested with Ubuntu 14.04 and for sure the problem is there. I have updated the post with the relevant info accordingly. Thanks for the heads up.

            6. Setting up SystemC and Eclipse for C++ hardware simulation
              Frank October 1, 2014 at 6:12 pm | Permalink

              Awesome, you’re the best Karibe!

    6. Setting up SystemC and Eclipse for C++ hardware simulation
      Meshack Mbuvi October 20, 2014 at 2:11 pm | Permalink | 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

      1. Setting up SystemC and Eclipse for C++ hardware simulation
        karibe October 21, 2014 at 1:00 am | Permalink | Reply

        This seems like a problem with a systemc test after the build. at what point are you getting this?

    7. Setting up SystemC and Eclipse for C++ hardware simulation
      Meshack Mbuvi October 21, 2014 at 10:25 am | Permalink | 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 | Permalink

      […] 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 simulation
      alexua August 21, 2016 at 1:22 pm | Permalink | 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”

      1. Setting up SystemC and Eclipse for C++ hardware simulation
        Karibe August 21, 2016 at 1:28 pm | Permalink | Reply

        email me your code, will have a look.

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

      […] 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 […]

脚本宝典总结

以上是脚本宝典为你收集整理的Setting up SystemC and Eclipse for C++ hardware simulation全部内容,希望文章能够帮你解决Setting up SystemC and Eclipse for C++ hardware simulation所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。