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
Create a new source folder src in your project
and inside it a new file main.cpp
8. Configure systemc library Path for the project
At this point, your project isn’t configured with the library path:
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.
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
Now expand GCC C++ Linker and under Libraries, at the top Libraries(-l) entry, click on the + icon and add the library name “systemc”
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
9. Build and run
Click on the build symbol, the hummer, and if everything is ok in terminal: saying finished building target,
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:
Related
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”
标签:SystemC,Eclipse,up,https,wp,2014,data,karibe,systemc 来源: https://www.cnblogs.com/ztguang/p/15835548.html
probably you should have indicated …that one needs the “build-essentials to proceed with installation of systemC” at the top
Yes and build-essential is a bundle that includes g++, that’s what you need here so you can just install that :-).
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?
Make sure you have a symbolic link to the /usr/lib/ folder of your systemc library file, check that step in the post.
Very detailed guide, very helpful! Great work! Thank you!
You are welcome, glad I could help
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
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
Just for the record, I’m running Fedora 20, the latest version of Eclipse (Luna) and the latest version of SystemC (2.3.1).
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
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!
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.
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
And just for the record, libsystemc2.3.1.so does exist in the /usr/lib/ directory
I found a solution here: https://bbs.archlinux.org/viewtopic.php?pid=1443580
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
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.
Awesome, you’re the best Karibe!
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
This seems like a problem with a systemc test after the build. at what point are you getting this?
Sir….I have had to re-install the eclipse and it has worked…Thanx alot
[…] 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 […]
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”
email me your code, will have a look.
[…] 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 […]