Skip to content

Commit

Permalink
Add YoWASP support for Verilog generation, importing from Python, and…
Browse files Browse the repository at this point in the history
… demos.
  • Loading branch information
cr1901 committed Nov 25, 2024
1 parent 9b8df5d commit 1241826
Show file tree
Hide file tree
Showing 5 changed files with 208 additions and 16 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,43 @@ name: CI
# gzip -c cover.vcd | base64 | base64 -d | gunzip > cover-out.vcd

jobs:
ci-quickstart:
name: Minimal Dependencies Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- uses: pdm-project/setup-pdm@v4
with:
python-version: 3.11
cache: false
- uses: dtolnay/rust-toolchain@stable
with:
targets: riscv32i-unknown-none-elf
# Simulate installing Amaranth with builtin-yosys outside of PDM.
- name: Install Minimal Deps
run: |
pdm run python -m ensurepip
pdm run python -m pip install amaranth[builtin-yosys]
pdm install --prod
# Test code gen both within and outside a PDM script.
- name: Test Generate Verilog with Minimal Deps
run: |
pdm run python -m sentinel.gen -o sentinel-direct.v
pdm gen -o sentinel-pdm.v
- name: Test Import
run: pdm run python -c 'from sentinel.top import Top'
- name: Install PDM Demo Groups and Prepare YoWASP
run: |
pdm install -G examples -G yowasp
pdm use-yowasp
- name: Check Demo Bitstream Generation with Minimal Deps
run: |
pdm demo -i csr -p ice40_hx8k_b_evn
pdm demo-rust -i csr -p ice40_hx8k_b_evn
ci-basic:
name: Basic CI Check
strategy:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ __pycache__/
# RVFormal disassembled counterexamples
*.s

# YoWASP setup
.env.toolchain

# Added by cargo

Expand Down
27 changes: 26 additions & 1 deletion dodo.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Task driver for Sentinel.
DoIt tasks are typically called from PDM. The DoIt tasks and may call PDM
DoIt tasks are typically called from PDM. The DoIt tasks may call PDM
scripts recursively to implement a super-powered PDM "composite" type.
"""

Expand All @@ -17,6 +17,7 @@
from doit import task_params
# https://groups.google.com/g/python-doit/c/GFtEuBp82xc/m/j7jFkvAGH1QJ
from doit.action import CmdAction
from doit.task import clean_targets
from doit.tools import run_once, create_folder, result_dep, title_with_actions
from doit.reporter import ConsoleReporter

Expand Down Expand Up @@ -173,6 +174,30 @@ def task_ucode():
}


# YoWASP
def write_yowasp_env_toolchain(fn): # noqa: D103
envs = {
"AMARANTH_USE_YOSYS": "builtin",
"YOSYS": "yowasp-yosys",
"NEXTPNR_ICE40": "yowasp-nextpnr-ice40",
"ICEPACK": "yowasp-icepack"
}

with open(fn, "w") as fp:
for k, v in envs.items():
fp.write(f"{k}={v}\n")


def task_prepare_yowasp():
"""prepare Sentinel source for YoWASP tools"""
return {
"actions": [(write_yowasp_env_toolchain, (".env.toolchain",))],
"uptodate": [run_once],
"clean": [clean_targets],
"targets": [".env.toolchain"],
}


# RISCOF
def opam_vars(): # noqa: D103
out = subprocess.run("opam env", shell=True, stdout=subprocess.PIPE).stdout
Expand Down
145 changes: 130 additions & 15 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1241826

Please sign in to comment.