Shang
Shang copied to clipboard
Installation procedure described in README does not work
The installation procedure described in README.md does not work. Below is the process I used to install the tool (Ubuntu 18.04).
Installation
Prerequisites
Build Tools
- Install
build-essential
,git
,automake
, andcmake
:
sudo apt-get install git automake cmake
Libraries
- Install
liblpsolve55-dev
,libgmp3-dev
,libtool
, andlibboost-dev
:
sudo apt-get install liblpsolve55-dev libgmp3-dev libtool libboost-dev
Lua and LuaBind
- Download Lua 5.1.5:
wget https://www.lua.org/ftp/lua-5.1.5.tar.gz
tar xvf lua-5.1.5.tar.gz
cd lua-5.1.5
- Add the
-fPIC
compilation flag (and, optionally,-g
) tosrc/Makefile
:
CFLAGS= -g -O2 -Wall -fPIC $(MYCFLAGS)
- Build the library:
make linux
make local
cd ..
- Download LuaBind 0.9.1:
wget https://sourceforge.net/projects/luabind/files/luabind/0.9.1/luabind-0.9.1.tar.gz/download -O luabind-0.9.1.tar.gz
tar xvf luabind-0.9.1.tar.gz
cd luabind-0.9.1
- Build the library (
$TOOLS
points to the directory with the manually installed tools and libraries):
LUA_PATH=$(TOOLS)/lua-5.1.5
bjam --prefix=$(TOOLS)/luabind-0.9.1 install
- Install LuaBitOp:
sudo apt-get install luarocks
sudo luarocks install luabitop
SystemC
- Download SystemC 2.3.3:
wget https://www.accellera.org/images/downloads/standards/systemc/systemc-2.3.3.tar.gz
tar xvf systemc-2.3.3.tar.gz
-
Follow the instructions specified in
INSTALL
. -
Set the environment variables (
$TOOLS
points to the directory with the manually installed tools and libraries):
export SYSTEMC_INCLUDE=$(TOOLS)/systemc-2.3.3/include/
export SYSTEMC_LIBDIR=$(TOOLS)/systemc-2.3.3/lib-linux64/
Verilator
git clone https://github.com/verilator/verilator
cd verilator
autoconf
./configure
make
sudo make install
- Set the environment variable (
$TOOLS
points to the directory with the manually installed tools and libraries):
export VERILATOR_ROOT=$(TOOLS)/verilator/
Clang
- Download Clang+LLVM 3.1 to be used as Shang's front-end:
wget https://releases.llvm.org/3.1/clang+llvm-3.1-x86_64-linux-ubuntu_12.04.tar.gz
tar xvf clang+llvm-3.1-x86_64-linux-ubuntu_12.04.tar.gz
ABC
- Install ABC:
git clone https://github.com/ispras/abc.git abc
cd abc
make ABC_USE_PIC=1 libabc.a
Build Shang
- Clone the LLVM sources:
git clone http://llvm.org/git/llvm.git
- Reset to the revision
16436dffb50fac4677c7162639f8da0b73eb4e99
:
cd llvm
git reset --hard 16436dffb50fac4677c7162639f8da0b73eb4e99
- Clone the Shang sources:
cd lib/Target/
git clone https://forge.ispras.ru/git/shang.git VerilogBackend
- Apply the patch:
cd ../../
git apply lib/Target/VerilogBackend/util/llvm-16436dffb50fac4677c7162639f8da0b73eb4e99.patch
- Create the
build
folder:
cd ..
mkdir build
cd build
- Run
cmake
with the following flags ($TOOLS
points to the directory with the manually installed tools and libraries):
/usr/bin/cmake ../llvm/
-DCMAKE_BUILD_TYPE=Debug \
-DENABLE_LOGIC_SYNTHESIS=OFF \
-DLUA_INCLUDE_DIR=$TOOLS/lua-5.1.5/include \
-DLUA_LIBRARY=$TOOLS/lua-5.1.5/lib/liblua.a \
-DLUA_LUAC=$TOOLS/lua-5.1.5/bin/luac \
-DLUABIND_INCLUDE_DIR=/usr/include \
-DLUABIND_LIBRARY=$TOOLS/luabind-0.9.1/lib/libluabindd.so \
-DLPSOLVE_INCLUDE_DIR=/usr/include/lpsolve \
-DLPSOLVE_LIBRARY=/usr/lib/lp_solve/liblpsolve55.so \
-DABC_INCLUDE_DIR=$TOOLS/abc \
-DABC_LIBRARY=$TOOLS/abc/libabc.a \
-DSYSTEMC_ROOT_DIR=$TOOLS/systemc-2.3.3/ \
-DVERILATOR_ROOT_DIR=$TOOLS/verilator/