Skip to content

Commit

Permalink
WIP: Himbächel Gowin support.
Browse files Browse the repository at this point in the history
  • Loading branch information
whitequark committed Jan 21, 2025
1 parent f5dcbc5 commit fd5f7bd
Show file tree
Hide file tree
Showing 19 changed files with 192 additions and 3 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ jobs:
./package-pypi-machxo2.sh
./package-pypi-nexus.sh
./package-pypi-gowin.sh
./package-pypi-himbaechel-gowin.sh
- name: Upload Python artifact
uses: actions/upload-artifact@v4
with:
Expand All @@ -57,6 +58,7 @@ jobs:
./package-npmjs-ecp5.sh
./package-npmjs-machxo2.sh
./package-npmjs-nexus.sh
./package-npmjs-himbaechel-gowin.sh
- name: Upload JavaScript artifact
uses: actions/upload-artifact@v4
with:
Expand Down Expand Up @@ -119,6 +121,11 @@ jobs:
pip install pypi-gowin/dist/*.whl
yowasp-nextpnr-gowin --help
yowasp-nextpnr-gowin --device GW1N-LV1QN48C6/I5 --test
- name: Test Himbächel Gowin Python artifact
run: |
pip install pypi-himbaechel-gowin/dist/*.whl
yowasp-nextpnr-himbaechel-gowin --help
yowasp-nextpnr-himbaechel-gowin --device GW1NR-LV9QN88PC6/I5 --vopt family=GW1N-9C --test
check: # group all `test (*)` workflows into one for the required status check
needs: [test-python]
if: ${{ always() && !contains(needs.*.result, 'cancelled') }}
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Notes

For technical reasons, the `ecppack`, `ecpunpack`, `ecpbram`, `ecppll`, and `ecpmulti` tools from the MachXO2 toolchain shipped in the `yowasp-nextpnr-machxo2` PyPI package are installed under the names `yowasp-xo2pack`, `yowasp-xo2unpack`, `yowasp-xo2bram`, `yowasp-xo2pll`, and `yowasp-xo2multi` respectively. These commands run bit-for-bit identical code as their `yowasp-ecp*` prefixed brethren from the `yowasp-nextpnr-ecp5` PyPI package of the same version.

For technical reasons, the `nextpnr-himbaechel` tool is installed under the name `nextpnr-himbaechel-gowin`. Newly added Himbächel microarchitectures will be installed under a correspondingly suffixed name.


Versioning
----------
Expand Down
7 changes: 5 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,12 @@ cmake -B nextpnr-build -S nextpnr-src \
-DBUILD_PYTHON=OFF \
-DEXTERNAL_CHIPDB=ON \
-DEXTERNAL_CHIPDB_ROOT=/share \
-DARCH="ice40;ecp5;machxo2;nexus;gowin" \
-DARCH="ice40;ecp5;machxo2;nexus;gowin;himbaechel" \
-DHIMBAECHEL_SPLIT=ON \
-DHIMBAECHEL_UARCH="gowin" \
-DICESTORM_INSTALL_PREFIX=$(pwd)/icestorm-prefix \
-DTRELLIS_INSTALL_PREFIX=$(pwd)/libtrellis-prefix \
-DOXIDE_INSTALL_PREFIX=$(pwd)/prjoxide-prefix \
-DGOWIN_BBA_EXECUTABLE=$(pwd)/apycula-prefix/bin/gowin_bba
-DGOWIN_BBA_EXECUTABLE=$(pwd)/apycula-prefix/bin/gowin_bba \
-DAPYCULA_INSTALL_PREFIX=$(pwd)/apycula-prefix
cmake --build nextpnr-build
2 changes: 1 addition & 1 deletion nextpnr-src
Submodule nextpnr-src updated 82 files
+2 −2 .github/ci/build_himbaechel.sh
+3 −3 .github/workflows/arch_ci.yml
+0 −1 .gitignore
+1 −1 3rdparty/googletest/googletest/src/gtest-death-test.cc
+5 −0 3rdparty/json11/CMakeLists.txt
+9 −0 3rdparty/oourafft/CMakeLists.txt
+200 −210 CMakeLists.txt
+9 −10 README.md
+1 −1 bba/CMakeLists.txt
+8 −8 bba/main.cc
+171 −0 cmake/BBAsm.cmake
+30 −0 cmake/CheckCXXCompilerHashEmbed.cmake
+0 −0 cmake/CodeCoverage.cmake
+19 −0 cmake/FindApycula.cmake
+14 −0 cmake/FindIceStorm.cmake
+13 −0 cmake/FindOxide.cmake
+63 −0 cmake/FindTrellis.cmake
+20 −0 common/CMakeLists.txt
+86 −0 common/kernel/CMakeLists.txt
+2 −2 common/kernel/command.cc
+1 −5 common/kernel/pybindings.cc
+23 −0 common/place/CMakeLists.txt
+10 −0 common/route/CMakeLists.txt
+60 −113 ecp5/CMakeLists.txt
+0 −53 ecp5/family.cmake
+0 −4 ecp5/main.cc
+9 −0 frontend/CMakeLists.txt
+37 −0 generic/CMakeLists.txt
+1 −0 generic/chipdb.cc
+0 −7 generic/family.cmake
+0 −4 generic/main.cc
+45 −45 gowin/CMakeLists.txt
+0 −53 gowin/family.cmake
+0 −3 gowin/main.cc
+82 −38 gui/CMakeLists.txt
+0 −0 gui/ecp5/family.cmake
+0 −0 gui/fpga_interchange/family.cmake
+0 −0 gui/generic/family.cmake
+0 −0 gui/gowin/family.cmake
+0 −0 gui/himbaechel/family.cmake
+0 −0 gui/himbaechel/mainwindow.cc
+0 −0 gui/ice40/family.cmake
+0 −0 gui/machxo2/family.cmake
+0 −1 gui/mistral/family.cmake
+0 −0 gui/nexus/family.cmake
+1 −1 gui/quadtree.h
+89 −0 himbaechel/CMakeLists.txt
+0 −14 himbaechel/family.cmake
+0 −4 himbaechel/main.cc
+33 −26 himbaechel/uarch/example/CMakeLists.txt
+3 −3 himbaechel/uarch/example/example.cc
+42 −42 himbaechel/uarch/gowin/CMakeLists.txt
+5 −4 himbaechel/uarch/gowin/gowin.cc
+1 −2 himbaechel/uarch/gowin/gowin_arch_gen.py
+6 −6 himbaechel/uarch/gowin/pack.cc
+56 −32 himbaechel/uarch/ng-ultra/CMakeLists.txt
+1 −1 himbaechel/uarch/ng-ultra/ng_ultra.cc
+47 −30 himbaechel/uarch/xilinx/CMakeLists.txt
+1 −1 himbaechel/uarch/xilinx/xilinx.cc
+77 −81 ice40/CMakeLists.txt
+0 −53 ice40/family.cmake
+0 −4 ice40/main.cc
+106 −0 ice40/tests/hx1k.cc
+106 −0 ice40/tests/hx8k.cc
+106 −0 ice40/tests/lp1k.cc
+106 −0 ice40/tests/lp384.cc
+106 −0 ice40/tests/lp8k.cc
+27 −0 ice40/tests/main.cc
+106 −0 ice40/tests/up5k.cc
+8 −0 json/CMakeLists.txt
+59 −106 machxo2/CMakeLists.txt
+0 −56 machxo2/family.cmake
+0 −4 machxo2/main.cc
+44 −0 mistral/CMakeLists.txt
+0 −13 mistral/family.cmake
+0 −4 mistral/main.cc
+48 −55 nexus/CMakeLists.txt
+0 −53 nexus/family.cmake
+0 −4 nexus/main.cc
+8 −0 rust/CMakeLists.txt
+1 −1 rust/rust.h
+1 −1 tests
9 changes: 9 additions & 0 deletions npmjs-himbaechel-gowin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/package-lock.json
/package.json
/node_modules
/dist

/*.wasm
/gen
/share
/index.*
36 changes: 36 additions & 0 deletions npmjs-himbaechel-gowin/lib/api.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
export type Tree = {
[name: string]: Tree | string | Uint8Array
};

export type InputStream =
(byteLength: number) => Uint8Array | null;

export type OutputStream =
(bytes: Uint8Array | null) => void;

export type RunOptions = {
stdin?: InputStream | null;
stdout?: OutputStream | null;
stderr?: OutputStream | null;
decodeASCII?: boolean;
synchronously?: boolean;
};

export type Command =
(args?: string[], files?: Tree, options?: RunOptions) => Promise<Tree> | Tree | undefined;

export class Exit extends Error {
code: number;
files: Tree;
}

//--------8<--------8<--------8<--------8<--------8<--------8<--------8<--------8<--------8<--------

export const runNextpnrHimbaechelGowin: Command;

export const commands: {
'gowin_pll': Command,
'gowin_pack': Command,
'gowin_unpack': Command,
'nextpnr-himbaechel-gowin': Command,
};
27 changes: 27 additions & 0 deletions npmjs-himbaechel-gowin/lib/api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Application } from '@yowasp/runtime';
import { instantiate as instantiateNextpnrHimbaechelGowin } from '../gen/nextpnr-himbaechel-gowin.js';

export { Exit } from '@yowasp/runtime';

const resources = () => import('./resources-nextpnr-himbaechel-gowin.js');

const runGowinPll = () => { throw new Error("unimplemented") }; // TODO
const runGowinPack = () => { throw new Error("unimplemented") }; // TODO
const runGowinUnpack = () => { throw new Error("unimplemented") }; // TODO

const nextpnrHimbaechelGowin = new Application(resources, instantiateNextpnrHimbaechelGowin, 'yowasp-nextpnr-himbaechel-gowin');
const runNextpnrHimbaechelGowin = nextpnrHimbaechelGowin.run.bind(nextpnrHimbaechelGowin);

export {
runGowinPll,
runGowinPack,
runGowinUnpack,
runNextpnrHimbaechelGowin,
};

export const commands = {
'gowin_pll': runGowinPll,
'gowin_pack': runGowinPack,
'gowin_unpack': runGowinUnpack,
'nextpnr-himbaechel-gowin': runNextpnrHimbaechelGowin,
};
1 change: 1 addition & 0 deletions npmjs-himbaechel-gowin/package-in.json
7 changes: 7 additions & 0 deletions npmjs-himbaechel-gowin/package-local.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"scripts": {
"transpile": [
"../nextpnr-build/nextpnr-himbaechel-gowin.wasm"
]
}
}
1 change: 1 addition & 0 deletions npmjs-himbaechel-gowin/prepare.py
17 changes: 17 additions & 0 deletions package-npmjs-himbaechel-gowin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh -ex

cd $(dirname $0)

PYTHON=${PYTHON:-python}

mkdir -p npmjs-himbaechel-gowin/share/himbaechel/gowin
cp nextpnr-build/share/himbaechel/gowin/*.bin \
npmjs-himbaechel-gowin/share/himbaechel/gowin

cd npmjs-himbaechel-gowin
${PYTHON} prepare.py himbaechel-gowin
npm install
npm run all

mkdir -p dist
npm pack --pack-destination dist
16 changes: 16 additions & 0 deletions package-pypi-himbaechel-gowin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh -ex

PYTHON=${PYTHON:-python}

cd $(dirname $0)

mkdir -p pypi-himbaechel-gowin/yowasp_nextpnr_himbaechel_gowin/bin/
cp nextpnr-build/nextpnr-himbaechel-gowin.wasm \
pypi-himbaechel-gowin/yowasp_nextpnr_himbaechel_gowin/
mkdir -p pypi-himbaechel-gowin/yowasp_nextpnr_himbaechel_gowin/share/himbaechel/gowin
cp nextpnr-build/share/himbaechel/gowin/*.bin \
pypi-himbaechel-gowin/yowasp_nextpnr_himbaechel_gowin/share/himbaechel/gowin

cd pypi-himbaechel-gowin
rm -rf build && ${PYTHON} -m build -w
sha256sum dist/*.whl
7 changes: 7 additions & 0 deletions pypi-himbaechel-gowin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
__pycache__/
/*.egg-info
/.eggs
/build
/dist

/yowasp_*/share
1 change: 1 addition & 0 deletions pypi-himbaechel-gowin/README.md
1 change: 1 addition & 0 deletions pypi-himbaechel-gowin/dependencies-apycula.txt
1 change: 1 addition & 0 deletions pypi-himbaechel-gowin/dependencies.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yowasp-runtime~=1.1
32 changes: 32 additions & 0 deletions pypi-himbaechel-gowin/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[build-system]
requires = ["setuptools~=67.0", "setuptools_scm~=6.2"]
build-backend = "setuptools.build_meta"

[project]
dynamic = ["version", "dependencies"]

name = "yowasp-nextpnr-himbaechel-gowin"
description = "nextpnr-himbaechel-gowin FPGA place and route tool"
readme = "README.md"
authors = [{name = "Catherine", email = "[email protected]"}]
license = {text = "ISC"}
classifiers = [
"License :: OSI Approved :: ISC License (ISCL)"
]

[project.scripts]
yowasp-nextpnr-himbaechel-gowin = "yowasp_nextpnr_himbaechel_gowin:_run_nextpnr_himbaechel_gowin_argv"

[project.urls]
"Homepage" = "https://yowasp.org/"
"Source Code" = "https://github.com/YoWASP/nextpnr"
"Bug Tracker" = "https://github.com/YoWASP/nextpnr/issues"

[tool.setuptools.package-data]
yowasp_nextpnr_himbaechel_gowin = [
"*.wasm",
"share/himbaechel/gowin/chipdb-*.bin",
]

[tool.setuptools.dynamic]
dependencies = {file = ["dependencies.txt", "dependencies-apycula.txt"]}
10 changes: 10 additions & 0 deletions pypi-himbaechel-gowin/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import os, sys
sys.path.append(os.path.join(os.path.dirname(__file__), "..", "pypi-common"))

from setuptools import setup
from yowasp_nextpnr_version import version


setup(
version=version(),
)
11 changes: 11 additions & 0 deletions pypi-himbaechel-gowin/yowasp_nextpnr_himbaechel_gowin/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import sys
import yowasp_runtime


def run_nextpnr_himbaechel_gowin(argv):
return yowasp_runtime.run_wasm(__package__, "nextpnr-himbaechel-gowin.wasm", resources=["share"],
argv=["yowasp-nextpnr-himbaechel-gowin", *argv])


def _run_nextpnr_himbaechel_gowin_argv():
sys.exit(run_nextpnr_himbaechel_gowin(sys.argv[1:]))

0 comments on commit fd5f7bd

Please sign in to comment.