Skip to content
This repository was archived by the owner on Nov 4, 2021. It is now read-only.

Commit 412668c

Browse files
committed
update yosys_ghdl.diff
1 parent becd6aa commit 412668c

File tree

2 files changed

+23
-52
lines changed

2 files changed

+23
-52
lines changed

scripts/compile_yosys.sh

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,48 +21,42 @@ fi
2121

2222
cd $BUILD_DIR/$dir_name
2323

24-
MAKEFILE_CONF_GHDL=
25-
GHDL_LDLIBS=
26-
if [ $COMPILE_GHDL == "1" ]
27-
then
28-
patch < $WORK_DIR/scripts/yosys_ghdl.diff
29-
30-
mkdir -p frontends/ghdl
31-
cp -R ../$dir_name_gyp/src/* frontends/ghdl
32-
MAKEFILE_CONF_GHDL=$'ENABLE_GHDL := 1\n'
33-
MAKEFILE_CONF_GHDL+="GHDL_DIR := $PACKAGE_DIR/$NAME"
34-
35-
if [ $ARCH == "darwin" ]; then
36-
GHDL_LDLIBS="$PACKAGE_DIR/$NAME/lib/libghdl.a $(tr -s '\n' ' ' < $PACKAGE_DIR/$NAME/lib/libghdl.link)"
37-
elif [ ${ARCH:0:7} == "windows" ]; then
38-
GHDL_LDLIBS="$(cygpath -m -a $PACKAGE_DIR/$NAME/lib/libghdl.a) $(cat $PACKAGE_DIR/$NAME/lib/libghdl.link | tr -s '\n' ' ' | tr -s '\\' '/' )"
39-
else
40-
GHDL_LDLIBS="$PACKAGE_DIR/$NAME/lib/libghdl.a $(tr -s '\n' ' ' < $PACKAGE_DIR/$NAME/lib/libghdl.link)"
24+
patch < $WORK_DIR/scripts/yosys.diff
25+
26+
setup_ghdl-yosys-plugin() {
27+
if [ $COMPILE_GHDL == "1" ]
28+
then
29+
mkdir -p frontends/ghdl
30+
cp -R ../$dir_name_gyp/src/* frontends/ghdl
31+
32+
echo 'ENABLE_GHDL := 1' >> Makefile.conf
33+
echo "GHDL_DIR := $PACKAGE_DIR/$NAME" >> Makefile.conf
34+
echo "GHDL_PREFIX := $PACKAGE_DIR/$NAME" >> Makefile.conf
4135
fi
42-
fi
36+
}
4337

4438
# -- Compile it
4539
if [ $ARCH == "darwin" ]; then
4640
OLDPATH=$PATH
4741
export PATH="/usr/local/opt/bison/bin:/usr/local/opt/flex/bin:$PATH"
4842
$MAKE config-clang
49-
echo "$MAKEFILE_CONF_GHDL" >> Makefile.conf
43+
setup_ghdl-yosys-plugin
5044
gsed -r -i 's/^(YOSYS_VER := [0-9]+\.[0-9]+\+[0-9]+).*$/\1 \(open-tool-forge build\)/;' Makefile
5145
sed -i "" "s/-Wall -Wextra -ggdb/-w/;" Makefile
5246
CXXFLAGS="-std=c++11 $CXXFLAGS" make \
5347
-j$J GIT_REV="${GIT_REV}" PRETTY=0 \
54-
LDLIBS="-lm $GHDL_LDLIBS" \
48+
LDLIBS="-lm" \
5549
ENABLE_TCL=0 ENABLE_PLUGINS=0 ENABLE_READLINE=0 ENABLE_COVER=0 ENABLE_ZLIB=0 ENABLE_ABC=1 \
5650
ABCMKARGS="CC=\"$CC\" CXX=\"$CXX\" OPTFLAGS=\"-O\" \
5751
ARCHFLAGS=\"$ABC_ARCHFLAGS\" ABC_USE_NO_READLINE=1"
5852

5953
export PATH=$OLDPATH
6054
elif [ ${ARCH:0:7} == "windows" ]; then
6155
$MAKE config-msys2-64
62-
echo "$MAKEFILE_CONF_GHDL" >> Makefile.conf
56+
setup_ghdl-yosys-plugin
6357
sed -r -i 's/^(YOSYS_VER := [0-9]+\.[0-9]+\+[0-9]+).*$/\1 \(open-tool-forge build\)/;' Makefile
6458
$MAKE -j$J GIT_REV="${GIT_REV}" PRETTY=0 \
65-
LDLIBS="-static -lstdc++ -lm $GHDL_LDLIBS" \
59+
LDLIBS="-static -lstdc++ -lm" \
6660
ABCMKARGS="CC=\"$CC\" CXX=\"$CXX\" LIBS=\"-static -lm\" OPTFLAGS=\"-O\" \
6761
ARCHFLAGS=\"$ABC_ARCHFLAGS\" \
6862
ABC_USE_NO_READLINE=1 \
@@ -74,14 +68,14 @@ elif [ ${ARCH:0:7} == "windows" ]; then
7468
test_bin yosys-smtbmc$EXE
7569
else
7670
$MAKE config-gcc
77-
echo "$MAKEFILE_CONF_GHDL" >> Makefile.conf
71+
setup_ghdl-yosys-plugin
7872
sed -i "s/-Wall -Wextra -ggdb/-w/;" Makefile
7973
sed -r -i 's/^(YOSYS_VER := [0-9]+\.[0-9]+\+[0-9]+).*$/\1 \(open-tool-forge build\)/;' Makefile
8074
# sed -i "s/LD = gcc$/LD = $CC/;" Makefile
8175
# sed -i "s/CXX = gcc$/CXX = $CC/;" Makefile
8276
# sed -i "s/LDFLAGS += -rdynamic/LDFLAGS +=/;" Makefile
8377
$MAKE -j$J GIT_REV="${GIT_REV}" PRETTY=0 \
84-
LDLIBS="-static -lstdc++ -lm $GHDL_LDLIBS -ldl" \
78+
LDLIBS="-static -lstdc++ -lm -ldl" \
8579
ENABLE_TCL=0 ENABLE_PLUGINS=0 ENABLE_READLINE=0 ENABLE_COVER=0 ENABLE_ZLIB=0 ENABLE_ABC=1 \
8680
ABCMKARGS="CC=\"$CC\" CXX=\"$CXX\" LIBS=\"-static -lm -ldl -pthread\" \
8781
OPTFLAGS=\"-O\" \

scripts/yosys_ghdl.diff renamed to scripts/yosys.diff

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,53 +2,30 @@ diff --git a/Makefile b/Makefile
22
index 45213c6f..f8393ea4 100644
33
--- a/Makefile
44
+++ b/Makefile
5-
@@ -21,6 +21,7 @@ ENABLE_COVER := 1
6-
ENABLE_LIBYOSYS := 0
7-
ENABLE_PROTOBUF := 0
8-
ENABLE_ZLIB := 1
9-
+ENABLE_GHDL := 0
10-
11-
# python wrappers
12-
ENABLE_PYOSYS := 0
135
@@ -82,7 +83,7 @@ all: top-all
146
YOSYS_SRC := $(dir $(firstword $(MAKEFILE_LIST)))
157
VPATH := $(YOSYS_SRC)
16-
8+
179
-CXXFLAGS := $(CXXFLAGS) -Wall -Wextra -ggdb -I. -I"$(YOSYS_SRC)" -MD -MP -D_YOSYS_ -fPIC -I$(PREFIX)/include
1810
+CXXFLAGS := $(CXXFLAGS) -w -I. -I"$(YOSYS_SRC)" -MD -MP -D_YOSYS_ -I$(PREFIX)/include
1911
LDLIBS := $(LDLIBS) -lstdc++ -lm
2012
PLUGIN_LDFLAGS :=
21-
13+
2214
@@ -119,7 +120,7 @@ export PATH := $(PORT_PREFIX)/bin:$(PATH)
2315
endif
24-
16+
2517
else
2618
-LDFLAGS += -rdynamic
2719
+LDFLAGS +=
2820
LDLIBS += -lrt
2921
endif
30-
22+
3123
@@ -184,7 +185,7 @@ endif
3224
ifeq ($(CONFIG),clang)
3325
CXX = clang
3426
LD = clang++
3527
-CXXFLAGS += -std=c++11 -Os
3628
+CXXFLAGS += -std=c++11
3729
ABCMKARGS += ARCHFLAGS="-DABC_USE_STDINT_H"
38-
30+
3931
ifneq ($(SANITIZER),)
40-
@@ -510,6 +511,14 @@ endif
41-
endif
42-
endif
43-
44-
+ifeq ($(ENABLE_GHDL),1)
45-
+GHDL_DIR ?= /usr/local/ghdl
46-
+GHDL_INCLUDE_DIR ?= $(GHDL_DIR)/include
47-
+GHDL_LIB_DIR ?= $(GHDL_DIR)/lib
48-
+CXXFLAGS += -I$(GHDL_INCLUDE_DIR) -DYOSYS_ENABLE_GHDL
49-
+LDLIBS += $(GHDL_LIB_DIR)/libghdl.a $(shell cat $(GHDL_LIB_DIR)/ghdl.link)
50-
+endif
51-
+
52-
ifeq ($(ENABLE_VERIFIC),1)
53-
VERIFIC_DIR ?= /usr/local/src/verific_lib
54-
VERIFIC_COMPONENTS ?= verilog vhdl database util containers hier_tree

0 commit comments

Comments
 (0)