Skip to content
Merged
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
51 changes: 51 additions & 0 deletions flow/designs/asap7/tinyRocket/tag_array.memories
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,57 @@
"memories": [
{
"name": "tag_array",
"rows": 4,
"bits": 25,
"addr_w": 2,
"read_ports": 0,
"write_ports": 0,
"rw_ports": 1,
"mask_lanes": 0,
"pins": [
{
"name": "RW0_addr",
"direction": "input",
"width": 2,
"port_id": "RW0",
"function": "addr"
},
{
"name": "RW0_en",
"direction": "input",
"width": 1,
"port_id": "RW0",
"function": "en"
},
{
"name": "RW0_clk",
"direction": "input",
"width": 1,
"port_id": "RW0",
"function": "clk"
},
{
"name": "RW0_wmode",
"direction": "input",
"width": 1,
"port_id": "RW0",
"function": "wmode"
},
{
"name": "RW0_wdata_0",
"direction": "input",
"width": 25,
"port_id": "RW0",
"function": "data_in"
},
{
"name": "RW0_rdata_0",
"direction": "output",
"width": 25,
"port_id": "RW0",
"function": "data_out"
}
],
"idiomatic": true,
"reason": "forced: the RTL provides no behavioral fallback for this wrapper"
}
Expand Down
42 changes: 42 additions & 0 deletions flow/scripts/memories/schema_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
import json
import re
import sys
import tempfile
import unittest
Expand Down Expand Up @@ -116,5 +117,46 @@ def test_validate_emittable(self):
schema.validate_emittable(dataless)


FLOW_DIR = Path(__file__).resolve().parents[2]


def module_ports(verilog: Path, module: str) -> dict[str, tuple[str, int]]:
"""{name: (direction, width)} from an ANSI-style module header."""
ports = {}
in_header = False
for line in verilog.read_text().splitlines():
if line.startswith(f"module {module}("):
in_header = True
continue
if in_header:
if line.startswith(");"):
return ports
Comment thread
oharboe marked this conversation as resolved.
Resolved
m = re.match(r"\s*(input|output)\s+(?:\[(\d+):0\])?\s*(\w+)", line)
if m:
direction, msb, name = m.groups()
ports[name] = (direction, int(msb) + 1 if msb else 1)
raise AssertionError(f"module {module} not found in {verilog}")


class TinyRocketTagArrayTest(unittest.TestCase):
"""tinyRocket's tag_array wrapper has no inferred memory for detection
to find, so its override is taken whole and must be emittable on its
own, with the pins of the module it replaces."""

def setUp(self):
path = FLOW_DIR / "designs/asap7/tinyRocket/tag_array.memories"
(self.mem,) = schema.merge([], schema.load(path))

def test_override_is_emittable(self):
schema.validate_emittable(self.mem)

def test_pins_match_the_rtl(self):
rtl = (
FLOW_DIR / "designs/src/tinyRocket/freechips.rocketchip.system.TinyConfig.v"
)
pins = {p.name: (p.direction, p.width) for p in self.mem.pins}
self.assertEqual(pins, module_ports(rtl, "tag_array"))


if __name__ == "__main__":
unittest.main()
Loading