Skip to content

Convert generated register blocks to use SystemRDL (PeakRDL) #73

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/authors-cfg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ exclude-paths:
allowed-years:
- 2023
- 2024
- 2025

allowed-authors:
Axel Vanoni: axvanoni@ethz.ch
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/analyze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
-
name: Install Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.9'
cache: 'pip'
Expand All @@ -53,10 +53,10 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
-
name: Install Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.9'
cache: 'pip'
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
-
name: Install Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: 3.9
cache: pip
Expand All @@ -42,7 +42,7 @@ jobs:
run: pip install -r requirements.txt
-
name: Setup Graphviz
uses: ts-graphviz/setup-graphviz@v1
uses: ts-graphviz/setup-graphviz@v2
-
name: Install RISC-V GCC toolchain
uses: pulp-platform/pulp-actions/riscv-gcc-install@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
fetch-depth: 0
-
name: Install Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.9'
cache: 'pip'
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
-
name: Install Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: 3.9
cache: pip
Expand All @@ -34,7 +34,7 @@ jobs:
run: pip install -r requirements.txt
-
name: Setup Graphviz
uses: ts-graphviz/setup-graphviz@v1
uses: ts-graphviz/setup-graphviz@v2
-
name: Install RISC-V GCC toolchain
uses: pulp-platform/pulp-actions/riscv-gcc-install@v2
Expand Down Expand Up @@ -78,4 +78,4 @@ jobs:
-
name: Deploy to Github Pages
id: deployment
uses: actions/deploy-pages@v3
uses: actions/deploy-pages@v4
22 changes: 11 additions & 11 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
-
name: Check license
uses: pulp-platform/pulp-actions/lint-license@v2
Expand All @@ -44,7 +44,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
-
name: Run Verible
uses: chipsalliance/verible-linter-action@main
Expand Down Expand Up @@ -83,10 +83,10 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
-
name: Install Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: 3.9
-
Expand All @@ -101,10 +101,10 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
-
name: Install Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: 3.9
-
Expand All @@ -118,15 +118,15 @@ jobs:
runs-on: ubuntu-latest
steps:
-
uses: actions/checkout@v3
uses: actions/checkout@v4
if: ${{ github.event_name == 'push' }}
-
uses: actions/checkout@v3
uses: actions/checkout@v4
if: ${{ github.event_name == 'pull_request' }}
with:
ref: ${{ github.event.pull_request.head.sha }}
-
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: '3.9'
cache: 'pip'
Expand All @@ -142,10 +142,10 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
-
name: Install Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.9'
cache: 'pip'
Expand Down
20 changes: 10 additions & 10 deletions Bender.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ packages:
dependencies:
- common_cells
axi:
revision: fccffb5953ec8564218ba05e20adbedec845e014
version: 0.39.1
revision: 39f5f2d51c5e524f6fc5cf8b6e901f7dcc5622d7
version: 0.39.6
source:
Git: https://github.com/pulp-platform/axi.git
dependencies:
Expand All @@ -23,30 +23,30 @@ packages:
dependencies:
- common_cells
common_cells:
revision: 13f28aa0021fc22c0d01a12d618fda58d2c93239
version: 1.33.0
revision: 9afda9abb565971649c2aa0985639c096f351171
version: 1.38.0
source:
Git: https://github.com/pulp-platform/common_cells.git
dependencies:
- common_verification
- tech_cells_generic
common_verification:
revision: 9c07fa860593b2caabd9b5681740c25fac04b878
version: 0.2.3
revision: fb1885f48ea46164a10568aeff51884389f67ae3
version: 0.2.5
source:
Git: https://github.com/pulp-platform/common_verification.git
dependencies: []
obi:
revision: 1aa411df145c4ebdd61f8fed4d003c33f7b20636
version: 0.1.2
revision: 8097928cf1b43712f93d5356f336397879b4ad2c
version: 0.1.6
source:
Git: https://github.com/pulp-platform/obi.git
dependencies:
- common_cells
- common_verification
register_interface:
revision: e25b36670ff7aab3402f40efcc2b11ee0f31cf19
version: 0.4.3
revision: 5daa85d164cf6b54ad061ea1e4c6f3624556e467
version: 0.4.5
source:
Git: https://github.com/pulp-platform/register_interface.git
dependencies:
Expand Down
1 change: 1 addition & 0 deletions Bender.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ dependencies:
common_cells: { git: "https://github.com/pulp-platform/common_cells.git", version: 1.33.0 }
common_verification: { git: "https://github.com/pulp-platform/common_verification.git", version: 0.2.3 }
register_interface: { git: "https://github.com/pulp-platform/register_interface.git", version: 0.4.3 }
apb: { git: "https://github.com/pulp-platform/apb.git", version: 0.2.3 }
obi: { git: "https://github.com/pulp-platform/obi.git", version: 0.1.2 }

export_include_dirs:
Expand Down
2 changes: 1 addition & 1 deletion doc/src/frontends/descriptor_fe.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Frontend for Ariane (CVA6) ready for Linux use.

.. only:: html

- `descriptor-based frontend <../regs/idma_desc64.html>`_
- `descriptor-based frontend <../regs/idma_desc64_reg/index.html>`_

Morty docs:

Expand Down
5 changes: 3 additions & 2 deletions doc/src/frontends/register_fe.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ Currently supported are:

.. only:: html

- `32bit 3D register frontend <../regs/idma_reg32_3d.html>`_
- `64bit 2D register frontend <../regs/idma_reg64_2d.html>`_
- `32bit 3D register frontend <../regs/idma_reg32_3d_reg/index.html>`_
- `64bit 1D register frontend <../regs/idma_reg64_1d_reg/index.html>`_
- `64bit 2D register frontend <../regs/idma_reg64_2d_reg/index.html>`_
79 changes: 49 additions & 30 deletions idma.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ CAT ?= cat
DOT ?= dot
GIT ?= git
MORTY ?= morty
PEAKRDL ?= peakrdl
PRINTF ?= printf
PYTHON ?= python3
SPHINXBUILD ?= sphinx-build
VCS ?= vcs
VERILATOR ?= verilator
VLOGAN ?= vlogan
SED ?= sed

# Shell
SHELL := /bin/bash
Expand Down Expand Up @@ -162,52 +164,65 @@ IDMA_FE_DIR := $(IDMA_ROOT)/src/frontend
IDMA_FE_REGS := desc64
IDMA_FE_REGS += $(IDMA_FE_IDS)

# customize the HJSON
$(IDMA_RTL_DIR)/idma_%.hjson: $(IDMA_GEN) $(IDMA_FE_DIR)/reg/tpl/idma_reg.hjson.tpl
$(call idma_gen,reg_hjson,$(IDMA_FE_DIR)/reg/tpl/idma_reg.hjson.tpl,,,$*,$@)

IDMA_REG_CUST_ALL += $(foreach Y,$(IDMA_FE_IDS),$(IDMA_RTL_DIR)/idma_$Y.hjson)

# ----

$(IDMA_HTML_DIR)/regs/reg_html.css:
mkdir -p $(IDMA_HTML_DIR)/regs
cp $(IDMA_REG_DIR)/vendor/lowrisc_opentitan/util/reggen/reg_html.css $@

$(IDMA_RTL_DIR)/idma_%_reg_pkg.sv $(IDMA_RTL_DIR)/idma_%_reg_top.sv: $(IDMA_REG_CUST_ALL)
if [ -a "$(IDMA_FE_DIR)/$*/idma_$*.hjson" ]; then \
$(PYTHON) $(IDMA_REGTOOL) $(IDMA_FE_DIR)/$*/idma_$*.hjson -t $(IDMA_RTL_DIR) -r; \
else \
$(PYTHON) $(IDMA_REGTOOL) $(IDMA_RTL_DIR)/idma_$*.hjson -t $(IDMA_RTL_DIR) -r; \
fi
regwidth = $(word 1,$(subst _, ,$1))
dimension = $(word 2,$(subst _, ,$1))
log2dimension = $(shell echo $$(( $$( echo "obase=2;$$(($(1)-1))" | bc | wc -c ) - 1 )) )

$(IDMA_RTL_DIR)/idma_reg%d_reg_pkg.sv $(IDMA_RTL_DIR)/idma_reg%d_reg_top.sv $(IDMA_RTL_DIR)/idma_reg%d_addrmap_pkg.sv:
$(PEAKRDL) regblock $(IDMA_FE_DIR)/reg/idma_reg.rdl -o $(IDMA_RTL_DIR) \
--default-reset arst_n --cpuif apb4-flat \
--module-name idma_reg$*d_reg_top \
--package idma_reg$*d_reg_pkg \
-P SysAddrWidth=$(call regwidth,$*) \
-P NumDims=$(call dimension,$*) \
-P Log2NumDims=$(call log2dimension,$(call dimension,$*))
$(PEAKRDL) raw-header $(IDMA_FE_DIR)/reg/idma_reg.rdl \
--format svpkg \
-o $(IDMA_RTL_DIR)/idma_reg$*d_addrmap_pkg.sv \
--base_name idma_reg$*d \
--license_str="Copyright 2025 ETH Zurich and University of Bologna.\nSolderpad Hardware License, Version 0.51, see LICENSE for details.\nSPDX-License-Identifier: SHL-0.51" \
-P SysAddrWidth=$(call regwidth,$*) \
-P NumDims=$(call dimension,$*) \
-P Log2NumDims=$(call log2dimension,$(call dimension,$*))

$(IDMA_RTL_DIR)/idma_desc64_reg_pkg.sv $(IDMA_RTL_DIR)/idma_desc_reg_top.sv $(IDMA_RTL_DIR)/idma_desc64_addrmap_pkg.sv:
$(PEAKRDL) regblock $(IDMA_FE_DIR)/desc64/idma_desc64_reg.rdl -o $(IDMA_RTL_DIR) \
--default-reset arst_n --cpuif apb4-flat \
--module-name idma_desc64_reg_top \
--package idma_desc64_reg_pkg
$(PEAKRDL) raw-header $(IDMA_FE_DIR)/desc64/idma_desc64_reg.rdl \
--format svpkg \
-o $(IDMA_RTL_DIR)/idma_desc64_addrmap_pkg.sv \
--base_name idma_desc64 \
--license_str="Copyright 2025 ETH Zurich and University of Bologna.\nSolderpad Hardware License, Version 0.51, see LICENSE for details.\nSPDX-License-Identifier: SHL-0.51"

$(IDMA_RTL_DIR)/idma_%_top.sv: $(IDMA_GEN) $(IDMA_FE_DIR)/reg/tpl/idma_reg.sv.tpl
$(call idma_gen,reg_top,$(IDMA_FE_DIR)/reg/tpl/idma_reg.sv.tpl,,,$*,$@)

$(IDMA_HTML_DIR)/regs/idma_%.html: $(IDMA_HTML_DIR)/regs/reg_html.css $(IDMA_REG_CUST_ALL)
if [ -a "$(IDMA_FE_DIR)/$*/idma_$*.hjson" ]; then \
$(PRINTF) "<!DOCTYPE html>\n<html>\n<head>\n<link rel="stylesheet" href="reg_html.css">\n</head>\n" > $@; \
$(PYTHON) $(IDMA_REGTOOL) $(IDMA_FE_DIR)/$*/idma_$*.hjson -d >> $@; \
$(PRINTF) "</html>\n" >> $@; \
else \
$(PRINTF) "<!DOCTYPE html>\n<html>\n<head>\n<link rel="stylesheet" href="reg_html.css">\n</head>\n" > $@; \
$(PYTHON) $(IDMA_REGTOOL) $(IDMA_RTL_DIR)/idma_$*.hjson -d >> $@; \
$(PRINTF) "</html>\n" >> $@; \
fi
$(IDMA_HTML_DIR)/regs/idma_reg%d_reg/index.html:
$(PEAKRDL) html $(IDMA_FE_DIR)/reg/idma_reg.rdl -o $(IDMA_HTML_DIR)/regs/idma_reg$*d_reg \
-P SysAddrWidth=$(call regwidth,$*) \
-P NumDims=$(call dimension,$*) \
-P Log2NumDims=$(call log2dimension,$(call dimension,$*))

$(IDMA_HTML_DIR)/regs/idma_desc64_reg/index.html:
$(PEAKRDL) html $(IDMA_FE_DIR)/desc64/idma_desc64_reg.rdl -o $(IDMA_HTML_DIR)/regs/idma_desc64_reg

idma_reg_clean:
rm -rf $(IDMA_HTML_DIR)/regs
rm -f $(IDMA_RTL_DIR)/*_reg_top.sv
rm -f $(IDMA_RTL_DIR)/*_reg_pkg.sv
rm -f $(IDMA_RTL_DIR)/Bender.yml
rm -f $(IDMA_RTL_DIR)/*.hjson
rm -f $(IDMA_REG_CUST_ALL)

# assemble the required files
IDMA_RTL_ALL += $(foreach Y,$(IDMA_FE_REGS),$(IDMA_RTL_DIR)/idma_$Y_reg_pkg.sv)
IDMA_RTL_ALL += $(foreach Y,$(IDMA_FE_REGS),$(IDMA_RTL_DIR)/idma_$Y_reg_top.sv)
IDMA_RTL_ALL += $(foreach Y,$(IDMA_FE_REGS),$(IDMA_RTL_DIR)/idma_$Y_addrmap_pkg.sv)
IDMA_RTL_ALL += $(foreach Y,$(IDMA_FE_REGS),$(IDMA_RTL_DIR)/idma_$Y_top.sv)
IDMA_RTL_DOC_ALL += $(foreach Y,$(IDMA_FE_REGS),$(IDMA_HTML_DIR)/regs/idma_$Y.html)
IDMA_RTL_DOC_ALL += $(foreach Y,$(IDMA_FE_REGS),$(IDMA_HTML_DIR)/regs/idma_$Y_reg/index.html)
IDMA_HJSON_ALL += $(foreach Y,$(IDMA_FE_REGS),$(IDMA_RTL_DIR)/idma_$Y.hjson)


Expand Down Expand Up @@ -243,6 +258,8 @@ $(IDMA_PICKLE_DIR)/%.sv: $(IDMA_PICKLE_DIR)/sources.json
else \
$(CAT) $(IDMA_CF_PKG) $@.pre > $@; \
fi
# Hack apb_pkg::prot_t to logic [2:0]
$(SED) -i 's/apb_pkg::prot_t/logic [2:0]/g' $@
rm -f $@.pre

$(IDMA_HTML_DIR)/%/index.html: $(IDMA_PICKLE_DIR)/%.sv
Expand Down Expand Up @@ -389,13 +406,15 @@ IDMA_VLT_PARAMS ?=
$(IDMA_VLT_DIR)/%_elab.log: $(IDMA_PICKLE_DIR)/sources.json
mkdir -p $(IDMA_VLT_DIR)
# We need a dedicated pickle here to set the defines
$(MORTY) -f $< -i --top $(IDMA_VLT_TOP) -DVERILATOR --propagate_defines -o $(IDMA_VLT_DIR)/$(IDMA_VLT_TOP).sv.pre
$(MORTY) -f $< -i --top $(IDMA_VLT_TOP) -DVERILATOR -D ASSERTS_OFF --propagate_defines -o $(IDMA_VLT_DIR)/$(IDMA_VLT_TOP).sv.pre
# Hack cf_math_pkg in
if grep -q "package cf_math_pkg;" "$(IDMA_VLT_DIR)/$(IDMA_VLT_TOP).sv.pre"; then \
$(CAT) $(IDMA_VLT_DIR)/$(IDMA_VLT_TOP).sv.pre > $(IDMA_VLT_DIR)/$(IDMA_VLT_TOP).sv; \
else \
$(CAT) $(IDMA_CF_PKG) $(IDMA_VLT_DIR)/$(IDMA_VLT_TOP).sv.pre > $(IDMA_VLT_DIR)/$(IDMA_VLT_TOP).sv; \
fi
# Hack apb_pkg::prot_t to logic [2:0]
$(SED) -i 's/apb_pkg::prot_t/logic [2:0]/g' $(IDMA_VLT_DIR)/$(IDMA_VLT_TOP).sv
rm -f $(IDMA_VLT_DIR)/$(IDMA_VLT_TOP).sv.pre
cd $(IDMA_VLT_DIR); $(VERILATOR) $(IDMA_VLT_ARGS) $(IDMA_VLT_PARAMS) -Mdir obj_$* $(IDMA_VLT_TOP).sv --top-module $(IDMA_VLT_TOP) 2> $*_elab.log

Expand Down Expand Up @@ -480,7 +499,7 @@ idma_doc_all: idma_spinx_doc

idma_pickle_all: $(IDMA_PICKLE_ALL)

idma_hw_all: $(IDMA_FULL_RTL) $(IDMA_INCLUDE_ALL) $(IDMA_FULL_TB) $(IDMA_HJSON_ALL) $(IDMA_WAVE_ALL)
idma_hw_all: $(IDMA_FULL_RTL) $(IDMA_INCLUDE_ALL) $(IDMA_FULL_TB) $(IDMA_WAVE_ALL)

idma_sim_all: $(IDMA_VCS_DIR)/compile.sh $(IDMA_VSIM_DIR)/compile.tcl

Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ recommonmark
sphinxcontrib-svg2pdfconverter
pylint
flatdict
peakrdl
peakrdl-rawheader @ git+https://github.com/micprog/PeakRDL-rawheader.git
Loading