Skip to content

Commit

Permalink
working on mac compatibility changes
Browse files Browse the repository at this point in the history
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
  • Loading branch information
timkpaine committed Sep 4, 2023
1 parent 834794d commit d849f50
Show file tree
Hide file tree
Showing 65 changed files with 443 additions and 423 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/build-and-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,32 @@ fi
start_section Building

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

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

end_section

##########################################################################

start_section Installing
make install_${PLUGIN_NAME} -j`nproc`
sudo make install_${PLUGIN_NAME} -j$NPROC
end_section

##########################################################################

start_section Testing
make test_${PLUGIN_NAME} -j`nproc`
make test_${PLUGIN_NAME} -j$NPROC
end_section

##########################################################################

start_section Cleanup
make clean_${PLUGIN_NAME} -j`nproc`
make clean_${PLUGIN_NAME} -j$NPROC
end_section

##########################################################################
92 changes: 81 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ on: [push, pull_request]
jobs:

Run-tests:
runs-on: ubuntu-20.04

runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, macos-11]
plugin:
- fasm
- xdc
Expand All @@ -41,40 +41,110 @@ jobs:

steps:

- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: recursive

- uses: actions/setup-python@v2
- uses: actions/setup-python@v3
with:
python-version: '3.9'

- name: Install
- name: Install Ubuntu Dependencies
run: |
sudo apt-get update
sudo apt-get install git g++-9 build-essential bison flex \
libreadline-dev gawk tcl-dev libffi-dev git graphviz xdot \
pkg-config libboost-system-dev libboost-python-dev \
libboost-filesystem-dev zlib1g-dev clang-format-8 cmake
libboost-filesystem-dev zlib1g-dev clang-format-8 cmake \
nlohmann-json3-dev iverilog
if: ${{ runner.os != 'macOS'}}

- name: Setup homebrew cache
uses: actions/cache@v3
with:
path: |
~/Library/Caches/Homebrew/boost--*
~/Library/Caches/Homebrew/downloads/*--boost-*
key: brew-${{ hashFiles('cpp/perspective/CMakeLists.txt') }}
restore-keys: brew-
if: ${{ runner.os == 'macOS' }}

- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
if: ${{ matrix.plugin == 'systemverilog'}}

- name: Install Mac Dependencies
run: |
brew update
brew install bison boost cmake flex graphviz icarus-verilog make nlohmann-json
sudo ln -s /usr/local/bin/gmake /usr/local/bin/make
env:
HOMEBREW_NO_AUTO_UPDATE: "1"
if: ${{ runner.os == 'macOS'}}

- name: Format
run: source .github/workflows/format-check.sh
env:
OS: ${{ runner.os }}
if: ${{ runner.os != 'macOS'}}

- name: ccache
uses: hendrikmuhs/ccache-action@v1
with:
key: ccache-${{ matrix.os }}

- name: Install Yosys
- name: Install yosys
run: |
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
source .github/workflows/setup.sh
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
set -ex
git clone https://github.com/YosysHQ/yosys.git --branch yosys-0.17
pushd yosys
make CONFIG=gcc -j`nproc` && sudo make CONFIG=gcc install
if: ${{ runner.os != 'macOS' }}

- name: Install yosys
run: |
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
set -ex
git clone https://github.com/YosysHQ/yosys.git --branch yosys-0.17
pushd yosys
make -j`nproc` && sudo make install
if: ${{ runner.os == 'macOS' }}

- name: Install Googletest
run: |
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
set -ex
git clone --branch release-1.8.1 https://github.com/google/googletest.git
pushd googletest
cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=17 . && cmake --build build && sudo cmake --install build
popd
- name: Install Surelog
run: |
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
set -ex
python -m pip install -vvv orderedmultidict
git clone https://github.com/chipsalliance/Surelog.git -b v1.70
pushd Surelog
git submodule update --init --recursive
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
popd
env:
OS: ${{ runner.os }}
if: ${{ matrix.plugin == 'systemverilog'}}

- name: Build and test plugins
run: |
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
source env/conda/bin/activate yosys-plugins
source .github/workflows/build-and-test.sh
.github/workflows/build-and-test.sh
env:
OS: ${{ runner.os }}
PLUGIN_NAME: ${{ matrix.plugin }}
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ fi
# Parallel builds!
MAKEFLAGS="-j 2"

export UNAME=`uname`
if [ "$UNAME" == "Darwin" ]; then
export NPROC=`sysctl -n hw.physicalcpu`
else
export NPROC=`nproc`
fi

function action_fold() {
if [ "$1" = "start" ]; then
echo "::group::$2"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/format-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ source .github/workflows/common.sh
##########################################################################

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

Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/licensing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,3 @@ jobs:
./design_introspection-plugin/tests/selection_to_tcl_list/selection_to_tcl_list.v
./third_party/minilitex_ddr_arty/minilitex_ddr_arty.v
./third_party/VexRiscv_Lite/VexRiscv_Lite.v
third_party: |
./third_party/googletest/
69 changes: 0 additions & 69 deletions .github/workflows/setup.sh

This file was deleted.

11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,14 @@
*.swp
*.log
/*/build
pmgen.py


# Test assets
*/tests/*/ok
*/tests/*/*.eblif
*/tests/*/*.json
*/tests/*/*.sdc
*/tests/*/*.test
*/tests/*/tmp
*/tests/*/*.txt
6 changes: 0 additions & 6 deletions .gitmodules

This file was deleted.

14 changes: 9 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,14 @@ PLUGINS_TEST := $(foreach plugin,$(PLUGIN_LIST),test_$(plugin))
all: plugins

TOP_DIR := $(realpath $(dir $(lastword $(MAKEFILE_LIST))))
REQUIREMENTS_FILE ?= requirements.txt
ENVIRONMENT_FILE ?= environment.yml

-include third_party/make-env/conda.mk
UNAME := $(shell uname)
ifeq ($(UNAME), Linux)
NPROC = $(shell nproc)
endif
ifeq ($(UNAME), Darwin)
NPROC = $(shell sysctl -n hw.physicalcpu)
endif

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

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

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

VERIBLE_FORMAT ?= verible-verilog-format
.PHONY: format-verilog
Expand Down
11 changes: 9 additions & 2 deletions Makefile_plugin.common
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ TOP_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))

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

UNAME := $(shell uname)

# Either find yosys in system and use its path or use the given path
YOSYS_PATH ?= $(realpath $(dir $(shell command -v yosys))/..)

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

ifeq ($(shell uname), Linux)
EXTRA_FLAGS := $(EXTRA_FLAGS) -MMD
endif

YOSYS_DATA_DIR = $(DESTDIR)$(shell $(YOSYS_CONFIG) --datdir)
YOSYS_PLUGINS_DIR = $(YOSYS_DATA_DIR)/plugins

Expand Down Expand Up @@ -93,7 +99,7 @@ endef
$(foreach source,$(SOURCES),$(eval $(value _process-single-source-file)))

$(_ALL_OBJECTS): $(_MAKEFILES)
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(EXTRA_FLAGS) -MMD -c -o $@ $(TARGET_SOURCES)
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(EXTRA_FLAGS) -c -o $@ $(TARGET_SOURCES)

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

$(YOSYS_PLUGINS_DIR)/$(NAME).so: $(SO_LIB) | $(YOSYS_PLUGINS_DIR)
install -D $(SO_LIB) $@
mkdir -p $(YOSYS_PLUGINS_DIR)
install $(SO_LIB) $@

.PHONY: install_plugin
install_plugin: $(YOSYS_PLUGINS_DIR)/$(NAME).so
Expand Down
Loading

0 comments on commit d849f50

Please sign in to comment.