Repository navigation
riscv32i: declare dmem's procedurally assigned signals as regs #4556
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
Merged
maliberty
merged 2 commits into
The-OpenROAD-Project:master
from
oharboe:riscv32i-dmem-procedural-regs
Sep 26, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| #!/usr/bin/env python3 | ||
| """riscv32i's sources read under slang, which is stricter than yosys's own | ||
| Verilog frontend: a signal assigned in an always block must be declared a | ||
| variable (reg), not a net (IEEE 1364-2005 6.1.2, IEEE 1800-2023 6.5). | ||
|
|
||
| The SRAM macro comes from its liberty file in the flow; here a black-box | ||
| module with the same ports stands in for it. Skipped when no yosys with | ||
| read_slang is available: YOSYS_EXE or yosys on PATH, with the plugin from | ||
| SLANG_PLUGIN_PATH when read_slang is not built in. | ||
| """ | ||
|
|
||
| import glob | ||
| import os | ||
| import shutil | ||
| import subprocess | ||
| import tempfile | ||
| import unittest | ||
|
|
||
| SRC_DIR = os.path.join( | ||
| os.path.dirname(os.path.abspath(__file__)), "..", "designs", "src", "riscv32i" | ||
| ) | ||
|
|
||
| FAKERAM_STUB = """\ | ||
| (* blackbox *) | ||
| module fakeram7_256x32 ( | ||
| input clk, | ||
| input [31:0] wd_in, | ||
| input ce_in, | ||
| input we_in, | ||
| output [31:0] rd_out, | ||
| input [7:0] addr_in | ||
| ); | ||
| endmodule | ||
| """ | ||
|
|
||
|
|
||
| def yosys_command(): | ||
| yosys = os.environ.get("YOSYS_EXE") or shutil.which("yosys") | ||
| if not yosys: | ||
| return None | ||
| cmd = [yosys, "-q"] | ||
| plugin = os.environ.get("SLANG_PLUGIN_PATH") | ||
| if plugin: | ||
| cmd += ["-m", plugin] | ||
| probe = subprocess.run(cmd + ["-p", "help read_slang"], capture_output=True) | ||
| return cmd if probe.returncode == 0 else None | ||
|
|
||
|
|
||
| class TestRiscv32iSlang(unittest.TestCase): | ||
| def test_sources_read_under_slang(self): | ||
| cmd = yosys_command() | ||
| if cmd is None: | ||
| self.skipTest("no yosys with read_slang") | ||
| with tempfile.TemporaryDirectory() as tmp: | ||
| stub = os.path.join(tmp, "fakeram7_256x32.v") | ||
| with open(stub, "w") as f: | ||
| f.write(FAKERAM_STUB) | ||
| sources = sorted(glob.glob(os.path.join(SRC_DIR, "*.v"))) + [stub] | ||
| result = subprocess.run( | ||
| cmd + ["-p", f"read_slang {' '.join(sources)} --top riscv_top"], | ||
| capture_output=True, | ||
| text=True, | ||
| ) | ||
| output = result.stdout + result.stderr | ||
| self.assertNotIn("cannot assign to a net", output) | ||
| self.assertEqual(result.returncode, 0, output) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.