PySysC/README.md

69 lines
2.3 KiB
Markdown
Raw Permalink Normal View History

2018-12-31 15:23:37 +01:00
# PySysC
2020-12-23 09:17:31 +01:00
A Python 3 package to use SystemC from Python
2018-12-31 15:23:37 +01:00
## How to setup the environment
2021-02-09 12:27:30 +01:00
The installation for PySysC is as follows (using bash shell). The process has
been tested under CentOS7 and Ubuntu 20.04. Make sure a newer version of gcc
is in your path (tested with gcc-6.3.0). Also the SystemC installation has to
be reference with the environment variable SYSTEMC_HOME.
If you get an error complaining about
missing Python.h, you need to install Python development headers. See the
articel under https://blog.ducthinh.net/gcc-no-such-file-python-h.
2018-12-31 15:23:37 +01:00
```
2020-12-23 09:17:31 +01:00
# create virtual environment
python3 -m venv pysysc-env
2021-03-14 12:13:52 +01:00
# and avtivate it
2020-12-23 09:17:31 +01:00
. pysysc-env/bin/activate
2021-03-14 12:16:08 +01:00
# update pip to mekae sure we have the newest version
2021-03-14 12:13:52 +01:00
python3 -m pip install --upgrade pip
# install wheel package
2020-12-23 09:17:31 +01:00
python3 -m pip install wheel
2021-03-14 12:16:08 +01:00
# install cppyy, C++ std version needs to match the version used when building the SystemC library
2020-12-23 09:17:31 +01:00
STDCXX=11 python3 -m pip install cppyy
# clone of PySysC
git clone https://git.minres.com/SystemC/PySysC.git
# install PySysC, for development PySysC use 'python3 -m pip install -e`
2021-03-14 12:13:52 +01:00
SYSTEMC_HOME=<path to SystemC> python3 -m pip install -e PySysC
2018-12-31 15:23:37 +01:00
```
2021-03-14 12:13:52 +01:00
## Running the example
2020-12-23 09:19:56 +01:00
2021-03-14 12:13:52 +01:00
To run the example you also need to clone and build the PySysC-SC repo. It contains the the code and libraries being used in the example. This project uses Conan.io as package manager so it should be installed (see down below).
To deactivate conan and use a SystemC installation just comment out the line `setup_conan()` in CMakeLists.txt and set the environment variable SYSTEMC_HOME.
### Run the router_eample.py
```
# get the PySysC-SC repo
git clone --recursive https://git.minres.com/SystemC/PySysC-SC.git
# build the project libraries as shared libs
cd PySysC-SC
mkdir -p build/Debug
cd build/Debug
cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=ON ../..
make -j components
cd ../..
# now we are ready to run the example
python3 router_eample.py
```
### Installing conan
```
# install conan into our virtual environment pysysc-env
python3 -m pip install conan
# create the default profile
conan profile new default --detect
# add the repo for SystemC packages used in the project
conan remote add minres https://api.bintray.com/conan/minres/conan-repo
```
2020-12-23 09:19:56 +01:00
2019-01-03 21:15:57 +01:00
## TODO
2020-12-23 09:17:31 +01:00
* pythonize `sc_module` with iteration protocol (`__next__` and `StopIteration` exception)