mirror of
https://github.com/retroSoC/retroSoC.git
synced 2026-11-04 22:32:36 +00:00
- Updated the JPEG table register bank module to use combinational logic for data handling and simplified the write logic for quantization, DC, and AC entries. - Introduced a new function in the run_flow script to handle process termination more gracefully, including signal handling for interrupts. - Enhanced the flow script to log peak RSS memory usage during execution. - Modified multiple testbench files to include new storage access signals and improved the test logic for better validation of KWS and SRAM interactions. - Updated tests to validate the new peak RSS memory logging in the flow script. - Adjusted Yosys synthesis recipes to include timeout settings and ensure proper reporting of pre-memory synthesis outputs.
85 lines
3.8 KiB
Python
85 lines
3.8 KiB
Python
"""Tests for Yosys recipe selection and ABC period derivation."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
from scripts.yosys_period import period_ps
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
DOMAINS = ROOT / "rtl/mini/integration/clock_reset_domains.json"
|
|
PERIOD_HELPER = ROOT / "scripts/yosys_period.py"
|
|
YOSYS_SCRIPTS = ROOT / "physical/smoke/syn/yosys/script"
|
|
|
|
|
|
def run_period(*args: str) -> subprocess.CompletedProcess[str]:
|
|
return subprocess.run(
|
|
[sys.executable, str(PERIOD_HELPER), *args],
|
|
text=True,
|
|
capture_output=True,
|
|
)
|
|
|
|
|
|
def test_yosys_period_rounds_hp_sta_period() -> None:
|
|
assert period_ps({"domains": [{"name": "hp", "sta": {"period_ns": 4.166666667}}]}) == 4167
|
|
|
|
result = run_period("--domains", str(DOMAINS))
|
|
assert result.returncode == 0, result.stderr
|
|
assert result.stdout.strip() == "4167"
|
|
|
|
|
|
def test_yosys_period_rejects_unknown_domain() -> None:
|
|
result = run_period("--domains", str(DOMAINS), "--domain", "missing")
|
|
assert result.returncode != 0
|
|
assert "domain missing is not declared" in result.stderr
|
|
|
|
|
|
def test_yosys_recipe_scripts_and_public_slot_are_stable() -> None:
|
|
makefile = (ROOT / "Makefile").read_text(encoding="utf-8")
|
|
yosys_mk = (ROOT / "physical/smoke/syn/yosys/yosys.mk").read_text(encoding="utf-8")
|
|
synth_tcl = (YOSYS_SCRIPTS / "synth.tcl").read_text(encoding="utf-8")
|
|
opensta = (ROOT / "physical/smoke/sta/opensta/opensta.mk").read_text(encoding="utf-8")
|
|
iverilog = (ROOT / "rtl/mini/mk/iverilog.mk").read_text(encoding="utf-8")
|
|
vcs = (ROOT / "rtl/mini/mk/vcs.mk").read_text(encoding="utf-8")
|
|
|
|
assert "SYNTH_RECIPE ?= balanced" in makefile
|
|
assert "VALID_SYNTH_RECIPE := balanced area speed" in makefile
|
|
assert "syn/yosys-$(SYNTH_RECIPE)" in makefile
|
|
assert "sta/opensta-$(SYNTH_RECIPE)" in makefile
|
|
assert "netl-$(SYNTH_RECIPE)" in makefile
|
|
assert "metrics-$(SYNTH_RECIPE).json" in makefile
|
|
assert "CONFIG_KEY_VARS" in makefile
|
|
assert "SYNTH_RECIPE" not in makefile.split("CONFIG_KEY_VARS", 1)[1].split("VARIANT_ID", 1)[0]
|
|
assert "--env SYNTH_RECIPE=$(SYNTH_RECIPE)" in yosys_mk
|
|
assert "--env YOSYS_TARGET_PERIOD_PS=$(YOSYS_TARGET_PERIOD_PS)" in yosys_mk
|
|
assert "YOSYS_TIMEOUT ?= 10800" in yosys_mk
|
|
assert "timeout --foreground --kill-after=5s $(YOSYS_TIMEOUT)s" in yosys_mk
|
|
assert "yosys -t --perffile $(YOSYS_BUILD)/yosys-perf.json" in yosys_mk
|
|
assert "abc_${synth_recipe}.script" in synth_tcl
|
|
assert '${proj_name}_pre_memory.rpt' in synth_tcl
|
|
assert '${proj_name}_pre_memory.json' in synth_tcl
|
|
assert synth_tcl.index('${proj_name}_pre_memory.json') < synth_tcl.index("yosys memory")
|
|
assert "yosys abc {*}$tech_cells_args -D $period_ps -script $abc_script -constr $abc_constr" in synth_tcl
|
|
assert "S110" not in synth_tcl
|
|
assert "$(SYN_BUILD_ROOT)/out/retrosoc_asic_yosys.v" in opensta
|
|
assert "$(SYN_BUILD_ROOT)/out/retrosoc_asic_yosys.v" in iverilog
|
|
assert "$(SYN_BUILD_ROOT)/out/retrosoc_asic_yosys.v" in vcs
|
|
assert "$(NETLIST_SIM_ROOT)" in iverilog
|
|
assert "$(NETLIST_SIM_ROOT)" in vcs
|
|
assert "$(VARIANT_ROOT)/syn/yosys/out/retrosoc_asic_yosys.v" not in vcs
|
|
assert (YOSYS_SCRIPTS / "abc_balanced.script").read_text(encoding="utf-8").count("&nf {D}") == 1
|
|
assert "&nf {D}" not in (YOSYS_SCRIPTS / "abc_area.script").read_text(encoding="utf-8")
|
|
assert (YOSYS_SCRIPTS / "abc_speed.script").read_text(encoding="utf-8").count("&nf {D}") == 6
|
|
leftover = {
|
|
"abc-opt.script",
|
|
"abc.constr",
|
|
"cell_dont_use.py",
|
|
"filter_output.awk",
|
|
}
|
|
assert leftover.isdisjoint({path.name for path in YOSYS_SCRIPTS.iterdir()})
|
|
assert not (ROOT / "physical/smoke/syn/dc").exists()
|
|
assert not (ROOT / "physical/smoke/syn/Makefile").exists()
|