Skip to content

Commit d849f50

Browse files
committed
working on mac compatibility changes
rename synth_quicklogic to synth_quicklogic_f4pga to not conflict with yosys internal update gha to just use vendored surelog deps build and install flatbuffers . install orderedmultidict for surelog . . . . . . fix surelog build on mac squashme Add test assets to gitignore add specific version of surelog undo
1 parent 834794d commit d849f50

File tree

65 files changed

+443
-423
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+443
-423
lines changed

.github/workflows/build-and-test.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,32 +29,32 @@ fi
2929
start_section Building
3030

3131
if [ "$PLUGIN_NAME" == "xdc" ] || [ "$PLUGIN_NAME" == "sdc" ]; then
32-
make design_introspection.so -j`nproc`
33-
make install_design_introspection -j`nproc`
32+
make design_introspection.so -j$NPROC
33+
sudo make install_design_introspection -j$NPROC
3434
fi
3535

3636
export CXXFLAGS=-Werror
37-
make UHDM_INSTALL_DIR=`pwd`/env/conda/envs/yosys-plugins/ ${PLUGIN_NAME}.so -j`nproc`
37+
make ${PLUGIN_NAME}.so -j$NPROC
3838
unset CXXFLAGS
3939

4040
end_section
4141

4242
##########################################################################
4343

4444
start_section Installing
45-
make install_${PLUGIN_NAME} -j`nproc`
45+
sudo make install_${PLUGIN_NAME} -j$NPROC
4646
end_section
4747

4848
##########################################################################
4949

5050
start_section Testing
51-
make test_${PLUGIN_NAME} -j`nproc`
51+
make test_${PLUGIN_NAME} -j$NPROC
5252
end_section
5353

5454
##########################################################################
5555

5656
start_section Cleanup
57-
make clean_${PLUGIN_NAME} -j`nproc`
57+
make clean_${PLUGIN_NAME} -j$NPROC
5858
end_section
5959

6060
##########################################################################

.github/workflows/ci.yml

Lines changed: 81 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ on: [push, pull_request]
2121
jobs:
2222

2323
Run-tests:
24-
runs-on: ubuntu-20.04
25-
24+
runs-on: ${{ matrix.os }}
2625
strategy:
2726
fail-fast: false
2827
matrix:
28+
os: [ubuntu-20.04, macos-11]
2929
plugin:
3030
- fasm
3131
- xdc
@@ -41,40 +41,110 @@ jobs:
4141

4242
steps:
4343

44-
- uses: actions/checkout@v2
44+
- uses: actions/checkout@v3
4545
with:
4646
submodules: recursive
4747

48-
- uses: actions/setup-python@v2
48+
- uses: actions/setup-python@v3
49+
with:
50+
python-version: '3.9'
4951

50-
- name: Install
52+
- name: Install Ubuntu Dependencies
5153
run: |
5254
sudo apt-get update
5355
sudo apt-get install git g++-9 build-essential bison flex \
5456
libreadline-dev gawk tcl-dev libffi-dev git graphviz xdot \
5557
pkg-config libboost-system-dev libboost-python-dev \
56-
libboost-filesystem-dev zlib1g-dev clang-format-8 cmake
58+
libboost-filesystem-dev zlib1g-dev clang-format-8 cmake \
59+
nlohmann-json3-dev iverilog
60+
if: ${{ runner.os != 'macOS'}}
61+
62+
- name: Setup homebrew cache
63+
uses: actions/cache@v3
64+
with:
65+
path: |
66+
~/Library/Caches/Homebrew/boost--*
67+
~/Library/Caches/Homebrew/downloads/*--boost-*
68+
key: brew-${{ hashFiles('cpp/perspective/CMakeLists.txt') }}
69+
restore-keys: brew-
70+
if: ${{ runner.os == 'macOS' }}
71+
72+
- uses: actions/setup-java@v3
73+
with:
74+
distribution: 'temurin'
75+
java-version: '11'
76+
if: ${{ matrix.plugin == 'systemverilog'}}
77+
78+
- name: Install Mac Dependencies
79+
run: |
80+
brew update
81+
brew install bison boost cmake flex graphviz icarus-verilog make nlohmann-json
82+
sudo ln -s /usr/local/bin/gmake /usr/local/bin/make
83+
env:
84+
HOMEBREW_NO_AUTO_UPDATE: "1"
85+
if: ${{ runner.os == 'macOS'}}
5786

5887
- name: Format
5988
run: source .github/workflows/format-check.sh
6089
env:
6190
OS: ${{ runner.os }}
91+
if: ${{ runner.os != 'macOS'}}
6292

6393
- name: ccache
6494
uses: hendrikmuhs/ccache-action@v1
95+
with:
96+
key: ccache-${{ matrix.os }}
6597

66-
- name: Install Yosys
98+
- name: Install yosys
6799
run: |
68-
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
69-
source .github/workflows/setup.sh
100+
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
101+
set -ex
102+
103+
git clone https://github.com/YosysHQ/yosys.git --branch yosys-0.17
104+
pushd yosys
105+
make CONFIG=gcc -j`nproc` && sudo make CONFIG=gcc install
106+
if: ${{ runner.os != 'macOS' }}
107+
108+
- name: Install yosys
109+
run: |
110+
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
111+
set -ex
112+
113+
git clone https://github.com/YosysHQ/yosys.git --branch yosys-0.17
114+
pushd yosys
115+
make -j`nproc` && sudo make install
116+
if: ${{ runner.os == 'macOS' }}
117+
118+
- name: Install Googletest
119+
run: |
120+
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
121+
set -ex
122+
123+
git clone --branch release-1.8.1 https://github.com/google/googletest.git
124+
pushd googletest
125+
cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=17 . && cmake --build build && sudo cmake --install build
126+
popd
127+
128+
- name: Install Surelog
129+
run: |
130+
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
131+
set -ex
132+
133+
python -m pip install -vvv orderedmultidict
134+
135+
git clone https://github.com/chipsalliance/Surelog.git -b v1.70
136+
pushd Surelog
137+
git submodule update --init --recursive
138+
cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=17 -DSURELOG_USE_HOST_GTEST=ON -DPYTHON_EXECUTABLE=`which python` -DPython3_EXECUTABLE=`which python` -S . && cmake --build build && sudo cmake --install build
139+
popd
70140
env:
71141
OS: ${{ runner.os }}
142+
if: ${{ matrix.plugin == 'systemverilog'}}
72143

73144
- name: Build and test plugins
74145
run: |
75146
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
76-
source env/conda/bin/activate yosys-plugins
77-
source .github/workflows/build-and-test.sh
147+
.github/workflows/build-and-test.sh
78148
env:
79149
OS: ${{ runner.os }}
80150
PLUGIN_NAME: ${{ matrix.plugin }}

.github/workflows/common.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ fi
2626
# Parallel builds!
2727
MAKEFLAGS="-j 2"
2828

29+
export UNAME=`uname`
30+
if [ "$UNAME" == "Darwin" ]; then
31+
export NPROC=`sysctl -n hw.physicalcpu`
32+
else
33+
export NPROC=`nproc`
34+
fi
35+
2936
function action_fold() {
3037
if [ "$1" = "start" ]; then
3138
echo "::group::$2"

.github/workflows/format-check.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ source .github/workflows/common.sh
2222
##########################################################################
2323

2424
start_section Formatting
25-
make format -j`nproc`
25+
make format -j$NPROC
2626
test $(git status --porcelain | wc -l) -eq 0 || { git diff; false; }
2727
end_section
2828

.github/workflows/licensing.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,3 @@ jobs:
3333
./design_introspection-plugin/tests/selection_to_tcl_list/selection_to_tcl_list.v
3434
./third_party/minilitex_ddr_arty/minilitex_ddr_arty.v
3535
./third_party/VexRiscv_Lite/VexRiscv_Lite.v
36-
third_party: |
37-
./third_party/googletest/

.github/workflows/setup.sh

Lines changed: 0 additions & 69 deletions
This file was deleted.

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,14 @@
44
*.swp
55
*.log
66
/*/build
7+
pmgen.py
8+
9+
10+
# Test assets
11+
*/tests/*/ok
12+
*/tests/*/*.eblif
13+
*/tests/*/*.json
14+
*/tests/*/*.sdc
15+
*/tests/*/*.test
16+
*/tests/*/tmp
17+
*/tests/*/*.txt

.gitmodules

Lines changed: 0 additions & 6 deletions
This file was deleted.

Makefile

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,14 @@ PLUGINS_TEST := $(foreach plugin,$(PLUGIN_LIST),test_$(plugin))
3434
all: plugins
3535

3636
TOP_DIR := $(realpath $(dir $(lastword $(MAKEFILE_LIST))))
37-
REQUIREMENTS_FILE ?= requirements.txt
38-
ENVIRONMENT_FILE ?= environment.yml
3937

40-
-include third_party/make-env/conda.mk
38+
UNAME := $(shell uname)
39+
ifeq ($(UNAME), Linux)
40+
NPROC = $(shell nproc)
41+
endif
42+
ifeq ($(UNAME), Darwin)
43+
NPROC = $(shell sysctl -n hw.physicalcpu)
44+
endif
4145

4246
define install_plugin =
4347
.PHONY: $(1).so
@@ -60,7 +64,7 @@ endef
6064
$(foreach plugin,$(PLUGIN_LIST),$(eval $(call install_plugin,$(plugin))))
6165

6266
pmgen.py:
63-
wget -nc -O $@ https://raw.githubusercontent.com/YosysHQ/yosys/master/passes/pmgen/pmgen.py
67+
wget -nc -O $@ https://raw.githubusercontent.com/YosysHQ/yosys/yosys-0.17/passes/pmgen/pmgen.py
6468

6569
.PHONY: plugins
6670
plugins: $(PLUGINS)
@@ -81,7 +85,7 @@ clean:: plugins_clean
8185
CLANG_FORMAT ?= clang-format-8
8286
.PHONY: format
8387
format:
84-
find . \( -name "*.h" -o -name "*.cc" \) -and -not -path '*/third_party/*' -print0 | xargs -0 -P $$(nproc) ${CLANG_FORMAT} -style=file -i
88+
find . \( -name "*.h" -o -name "*.cc" \) -and -not -path '*/third_party/*' -print0 | xargs -0 -P ${NPROC} ${CLANG_FORMAT} -style=file -i
8589

8690
VERIBLE_FORMAT ?= verible-verilog-format
8791
.PHONY: format-verilog

Makefile_plugin.common

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ TOP_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
4646

4747
_MAKEFILES := $(abspath $(filter-out %.d,$(MAKEFILE_LIST)))
4848

49+
UNAME := $(shell uname)
50+
4951
# Either find yosys in system and use its path or use the given path
5052
YOSYS_PATH ?= $(realpath $(dir $(shell command -v yosys))/..)
5153

@@ -61,6 +63,10 @@ LDFLAGS := $(shell $(YOSYS_CONFIG) --ldflags) $(LDFLAGS)
6163
LDLIBS := $(shell $(YOSYS_CONFIG) --ldlibs) $(LDLIBS)
6264
EXTRA_FLAGS ?=
6365

66+
ifeq ($(shell uname), Linux)
67+
EXTRA_FLAGS := $(EXTRA_FLAGS) -MMD
68+
endif
69+
6470
YOSYS_DATA_DIR = $(DESTDIR)$(shell $(YOSYS_CONFIG) --datdir)
6571
YOSYS_PLUGINS_DIR = $(YOSYS_DATA_DIR)/plugins
6672

@@ -93,7 +99,7 @@ endef
9399
$(foreach source,$(SOURCES),$(eval $(value _process-single-source-file)))
94100

95101
$(_ALL_OBJECTS): $(_MAKEFILES)
96-
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(EXTRA_FLAGS) -MMD -c -o $@ $(TARGET_SOURCES)
102+
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(EXTRA_FLAGS) -c -o $@ $(TARGET_SOURCES)
97103

98104
# Objects list for the purpose of adding extra dependencies after inclusion.
99105
# Example use: `$(OBJECTS): $(BUILD_DIR)/some-file.h`
@@ -126,7 +132,8 @@ endif
126132
# Installation
127133

128134
$(YOSYS_PLUGINS_DIR)/$(NAME).so: $(SO_LIB) | $(YOSYS_PLUGINS_DIR)
129-
install -D $(SO_LIB) $@
135+
mkdir -p $(YOSYS_PLUGINS_DIR)
136+
install $(SO_LIB) $@
130137

131138
.PHONY: install_plugin
132139
install_plugin: $(YOSYS_PLUGINS_DIR)/$(NAME).so

0 commit comments

Comments
 (0)