Skip to content

Commit 7ed60fe

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 Add test assets to gitignore add specific version of surelog
1 parent 834794d commit 7ed60fe

File tree

65 files changed

+474
-455
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

+474
-455
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 & 12 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,109 @@ jobs:
4141

4242
steps:
4343

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

48-
- uses: actions/setup-python@v2
48+
- uses: actions/setup-python@v4
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 install bison boost ccache cmake flex graphviz icarus-verilog make nlohmann-json
81+
sudo ln -s /usr/local/bin/gmake /usr/local/bin/make
82+
env:
83+
HOMEBREW_NO_AUTO_UPDATE: "1"
84+
if: ${{ runner.os == 'macOS'}}
5785

5886
- name: Format
5987
run: source .github/workflows/format-check.sh
6088
env:
6189
OS: ${{ runner.os }}
90+
if: ${{ runner.os != 'macOS'}}
6291

6392
- name: ccache
6493
uses: hendrikmuhs/ccache-action@v1
94+
with:
95+
key: ccache-${{ matrix.os }}-${{ matrix.plugin }}
6596

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

73143
- name: Build and test plugins
74144
run: |
75145
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
146+
.github/workflows/build-and-test.sh
78147
env:
79148
OS: ${{ runner.os }}
80149
PLUGIN_NAME: ${{ matrix.plugin }}
@@ -87,7 +156,7 @@ jobs:
87156
contents: write
88157

89158
steps:
90-
- uses: actions/checkout@v2
159+
- uses: actions/checkout@v4
91160
with:
92161
fetch-depth: 0
93162
token: ${{ secrets.GITHUB_TOKEN }}

.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: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,11 @@ jobs:
2525
Checks:
2626
runs-on: ubuntu-latest
2727
steps:
28-
- uses: actions/checkout@v2
28+
- uses: actions/checkout@v4
2929

3030
- uses: SymbiFlow/actions/checks@main
3131
with:
3232
exclude_license: |
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)