how to use and install SystemC in terminal mac OS

2019-01-25 00:42发布

how to use and install SystemC in terminal mac OS X?
I tried the Logic poet application, But i use os x 10.10 so it doesn't work.
so i want to know how can i compile and execute SystemC in terminal.
I could't find the detail of SystemC in terminal.

Thank you

3条回答
【Aperson】
2楼-- · 2019-01-25 01:11

The other answer is correct and perfectly fine, however, I thought I'd also answer and provide a little more detail.

Install Apple's "Command Line Tools"

You have two options: install Xcode (a big download), or just the command line tools (a much smaller download). If your goal is simply building SystemC applications at the command line, then I recommend the latter.

Install Apple's "Command Line Tools" by launching Terminal, entering

$ xcode-select --install

then clicking Install. After that, you'll have make, clang and more available at the command line.

Build and install Accellera's SystemC implementation

Download the latest release from the Accellera Downloads page (annoyingly, you'll have to provide a few personal details) and extract the contents of the .zip file.

I like to keep a copy of the SystemC source code available, because it can be useful for debugging or understanding how something works. Therefore, I move the extracted folder (systemc-2.3.1) into ~/Work/Other. That's where I keep source code for third party libraries. However, you can put it wherever you like.

Open Terminal, change into the extracted folder (systemc-2.3.1), and execute:

$ mkdir build
$ cd build
$ export CXX=clang++
$ ../configure --with-arch-suffix=
$ make install

The --with-arch-suffix= option prevents a -macosx64 suffix being add to the lib folder name, allowing your build scripts to be simpler.

After that process, the salient include and lib folders should be available within the systemc-2.3.1 folder.

Configure your build environment

There are many ways you can do this; I have a simple approach that I believe is close to what the SystemC maintainers envisioned. I define two environment variables in my .bash_profile (which is executed for every new Terminal session on OS X):

export CXX="clang++ -fcolor-diagnostics"
export SYSTEMC_HOME=~/Work/Other/systemc-2.3.1

Build a SystemC application

You could use Make, the quintessential build tool, which you get with Apple's "Command Line Tools", or any one of the plethora of other options. I use SCons with SConstruct files that look something like this:

import os
env = Environment(CXX=os.environ["CXX"],
                  SYSTEMC_HOME=os.environ["SYSTEMC_HOME"],
                  CPPPATH="$SYSTEMC_HOME/include",
                  LIBPATH="$SYSTEMC_HOME/lib")
env.Program("main.cpp", LIBS="systemc")

View trace (VCD) files

Scansion is a nice tool for this. GTKWave is another option, but it's a bit clunky.

查看更多
走好不送
3楼-- · 2019-01-25 01:16

Install

Go here click the first link and fill in your information to get the source code

http://www.accellera.org/downloads/standards/systemc

Then cd to the folder

Then run the following commands

./configure --with-unix-layout
gmake
sudo gmake install
gmake clean

After you do that it should all be saved in your use/local/(lib&include) directories

To Use

In code do this #include "systemc.h"

I use a single makefile normally. But you could write the following to link the library. Given your cpp file is called main.

g++ -o main main.cpp -I/usr/local/include -L/usr/local/lib -lsystemc
查看更多
兄弟一词,经得起流年.
4楼-- · 2019-01-25 01:24

Ensure you have xcode command line tools installed.

Follow instructions provided in the official repository.


From personal experience.

Compiling SystemC library with clang results in segmentation fault: 11 error every time I include systemc library into my code. To avoid this use gcc instead.

Note that I use gcc-8, installed with homebrew.

$ cd path/to/systemc-2.3.3
$ mkdir objdir
$ cd objdir
$ export CXX=g++-8
$ ../configure
$ make
$ make install

Use $ make check to launch examples compilation and unit tests.

To compile and run hello world example:

$ export SYSTEMC_HOME=path/to/systemc-2.3.3
$ g++-8 hello.cpp -o hello.o -L $SYSTEMC_HOME/lib-macosx64 -I $SYSTEMC_HOME/include/ -l systemc
$ ./hello.o

Tested on macOS 10.13.6; gcc version 8.2.0; systemc-2.3.3

查看更多
登录 后发表回答