From 1e59f804d1598b7a49c0e9e20b496ae56e204fcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Harboe?= Date: Sat, 3 Oct 2026 09:02:39 +0200 Subject: [PATCH] memories: run the in-tree FakeRAM2.0, drop FAKERAM_RUN_PY MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit gen_memories.py found FakeRAM through FAKERAM_RUN_PY, or else by searching bazel's RUNFILES_DIR for a run.py under a directory named like "fakeram". Both date from a632406e8, when FakeRAM2.0 was a separate repository that ORFS's MODULE.bazel fetched. The same day it moved into ORFS (76a445c42), so its location relative to this script is fixed. Nothing in the make flow ever set FAKERAM_RUN_PY, so AUTO_MEMORIES under make stopped with "FAKERAM_RUN_PY not set and FakeRAM run.py not found" unless the user exported it. The RUNFILES_DIR search could not match "FakeRAM2.0" (it is case-sensitive), and ORFS no longer builds with bazel. Run tools/FakeRAM2.0/run.py relative to this script, and drop the variable, the search and the test's bazel branch. A missing run.py now fails in the subprocess, which names the path. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Øyvind Harboe --- flow/scripts/memories/gen_memories.py | 22 ++-------------------- flow/scripts/memories/gen_memories_test.py | 19 ------------------- 2 files changed, 2 insertions(+), 39 deletions(-) diff --git a/flow/scripts/memories/gen_memories.py b/flow/scripts/memories/gen_memories.py index d6d6d12965..8c606d8ec0 100644 --- a/flow/scripts/memories/gen_memories.py +++ b/flow/scripts/memories/gen_memories.py @@ -25,23 +25,12 @@ sys.path.insert(0, str(Path(__file__).resolve().parent)) import subprocess -import os import detect # noqa: E402 import idiomatic # noqa: E402 import schema # noqa: E402 - -def find_fakeram_run() -> str | None: - fakeram_run = os.environ.get("FAKERAM_RUN_PY") - if fakeram_run and os.path.isfile(fakeram_run): - return fakeram_run - runfiles_dir = os.environ.get("RUNFILES_DIR") - if runfiles_dir: - for p in Path(runfiles_dir).rglob("run.py"): - if "fakeram" in p.parts[-2]: - return str(p) - return None +FAKERAM_RUN_PY = Path(__file__).resolve().parents[3] / "tools/FakeRAM2.0/run.py" def run( @@ -76,17 +65,10 @@ def run( for mem in converted: schema.validate_emittable(mem) - fakeram_run = find_fakeram_run() - if not fakeram_run: - sys.stderr.write( - "gen_memories: FAKERAM_RUN_PY not set and FakeRAM run.py not found.\n" - ) - return 1 - subprocess.check_call( [ sys.executable, - fakeram_run, + str(FAKERAM_RUN_PY), "--orfs_asap7_backend", "--output_dir", str(out_dir), diff --git a/flow/scripts/memories/gen_memories_test.py b/flow/scripts/memories/gen_memories_test.py index 96cb1fad2a..8493cd6b94 100644 --- a/flow/scripts/memories/gen_memories_test.py +++ b/flow/scripts/memories/gen_memories_test.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 import json -import os import sys import tempfile import unittest @@ -10,24 +9,6 @@ import gen_memories -# Setup FAKERAM_RUN_PY using runfiles if available, otherwise assume a relative path -if "TEST_WORKSPACE" in os.environ: - # Bazel test execution - runfiles_dir = Path(os.environ.get("RUNFILES_DIR", ".")) - candidates = list(runfiles_dir.glob("**/fakeram*/run.py")) + list( - runfiles_dir.glob("**/run.py") - ) - fakeram_run = candidates[0] if candidates else runfiles_dir / "fakeram" / "run.py" -else: - fakeram_run = ( - Path(__file__).resolve().parent.parent.parent.parent - / "tools" - / "FakeRAM2.0" - / "run.py" - ) - -os.environ["FAKERAM_RUN_PY"] = str(fakeram_run) - SAMPLE_YOSYS_NETLIST = { "modules": { "\\mem_128x32": {