Skip to content

Commit cc67c77

Browse files
committed
FakeRAM2.0: apply the ORFS asap7 backend to the vendored copy
AUTO_MEMORIES calls tools/FakeRAM2.0/run.py --orfs_asap7_backend (flow/scripts/memories/gen_memories.py). The backend was shipped as patches/fakeram/0001-Add-ORFS-ASAP7-backend.patch, which ORFS's MODULE.bazel applied to the external FakeRAM2.0 repository. FakeRAM is now vendored here and ORFS no longer builds with bazel, so nothing applied the patch and run.py rejected the flag. Apply it to tools/FakeRAM2.0 and remove patches/fakeram. The patch's BUILD.bazel and MODULE.bazel are left out: they only made FakeRAM a bazel module. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
1 parent c712df0 commit cc67c77

5 files changed

Lines changed: 98 additions & 170 deletions

File tree

‎patches/fakeram/0001-Add-ORFS-ASAP7-backend.patch‎

Lines changed: 0 additions & 169 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# ORFS ASAP7 package
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import json
2+
import sys
3+
from pathlib import Path
4+
5+
from utils.class_process import Process
6+
from utils.memory_config import MemoryConfig
7+
from utils.memory_factory import MemoryFactory
8+
from utils.timing_data import TimingData
9+
from utils.ram_liberty_exporter import RAMLibertyExporter
10+
from utils.lef_exporter import LefExporter
11+
12+
ASAP7_PROCESS_CONFIG = {
13+
"tech_nm": 7,
14+
"voltage": 0.7,
15+
"metal_prefix": "M",
16+
"metal_layer": "M4",
17+
"pin_width_nm": 24,
18+
"pin_pitch_nm": 48,
19+
"metal_track_pitch_nm": 48,
20+
"manufacturing_grid_nm": 1,
21+
"contacted_poly_pitch_nm": 54,
22+
"fin_pitch_nm": 27,
23+
"column_mux_factor": 1,
24+
"snap_width_nm": 190,
25+
"snap_height_nm": 1400,
26+
}
27+
28+
ASAP7_TIMING_CONFIG = {
29+
"cycle_time": 1.0,
30+
"access_time": 0.5,
31+
"setup_time": 0.1,
32+
"hold_time": 0.05,
33+
"leakage": 0.001,
34+
}
35+
36+
def run_orfs_asap7(platform: str, out_dir: Path, json_path: Path):
37+
if platform != "asap7":
38+
sys.stderr.write(f"FakeRAM2.0 orfs_asap7: unsupported platform {platform}\n")
39+
return 1
40+
41+
try:
42+
data = json.loads(json_path.read_text())
43+
memories = data.get("memories", [])
44+
except Exception as e:
45+
sys.stderr.write(f"FakeRAM2.0 orfs_asap7: failed to read {json_path}: {e}\n")
46+
return 1
47+
48+
out_dir.mkdir(parents=True, exist_ok=True)
49+
converted = sorted((m for m in memories if m.get("idiomatic")), key=lambda m: m["name"])
50+
51+
process = Process(ASAP7_PROCESS_CONFIG)
52+
timing_data = TimingData(ASAP7_TIMING_CONFIG)
53+
54+
for m in converted:
55+
name = m["name"]
56+
bits = m.get("bits", 32)
57+
rows = m.get("rows", 128)
58+
59+
sram_dict = {
60+
"name": name,
61+
"width": bits,
62+
"depth": rows,
63+
"banks": 1,
64+
}
65+
mem_config = MemoryConfig.from_json(sram_dict)
66+
ram = MemoryFactory.create(mem_config, "RAM", "SP", process, timing_data)
67+
68+
# Export Liberty
69+
lib_path = out_dir / f"{name}.lib"
70+
with open(lib_path, "w") as f:
71+
RAMLibertyExporter(ram).export(f)
72+
73+
pre_lib_path = out_dir / f"{name}_pre_layout.lib"
74+
with open(pre_lib_path, "w") as f:
75+
RAMLibertyExporter(ram).export(f)
76+
77+
# Export LEF
78+
lef_path = out_dir / f"{name}.lef"
79+
with open(lef_path, "w") as f:
80+
LefExporter(ram).export(f)
81+
82+
(out_dir / "blackboxes.txt").write_text("".join(f"{m['name']}\n" for m in converted))
83+
return 0

‎tools/FakeRAM2.0/run.py‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from utils.memory_config import MemoryConfig
99
from utils.memory_factory import MemoryFactory
1010
from utils.timing_data import TimingData
11+
from orfs_asap7.generate import run_orfs_asap7
1112

1213

1314
def get_args() -> argparse.Namespace:
@@ -26,10 +27,19 @@ def get_args() -> argparse.Namespace:
2627
required=False,
2728
default="results",
2829
)
30+
parser.add_argument(
31+
"--orfs_asap7_backend",
32+
action="store_true",
33+
help="Use ORFS ASAP7 backend (expects JSON in memories.json format)",
34+
)
2935
return parser.parse_args()
3036

3137

3238
def main(args: argparse.Namespace):
39+
if args.orfs_asap7_backend:
40+
from pathlib import Path
41+
return run_orfs_asap7(platform="asap7", out_dir=Path(args.output_dir), json_path=Path(args.config))
42+
3343
json_data = RunUtils.get_config(args.config)
3444
# Create a process object (shared by all srams)
3545
process = Process(json_data)
@@ -50,4 +60,4 @@ def main(args: argparse.Namespace):
5060
### Entry point
5161
if __name__ == "__main__":
5262
args = get_args()
53-
main(args)
63+
sys.exit(main(args))

‎tools/FakeRAM2.0/utils/class_process.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ def get_macro_dimensions(self, width_in_bits, depth, num_banks, additional_heigh
119119

120120
total_height += additional_height
121121

122+
min_height = max(3.5, self.snap_height_nm / 1000.0 if self.snap_height_nm else 0)
123+
total_height = max(total_height, min_height)
124+
122125
return (total_width, total_height)
123126

124127
def get_tech_nm(self):

0 commit comments

Comments
 (0)