Skip to content

Commit d2b74aa

Browse files
authored
Merge pull request #4603 from oharboe/fakeram-fold-asap7-backend
FakeRAM2.0: apply the ORFS asap7 backend to the vendored copy
2 parents 55687ec + b54a844 commit d2b74aa

5 files changed

Lines changed: 108 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: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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+
37+
def run_orfs_asap7(platform: str, out_dir: Path, json_path: Path):
38+
if platform != "asap7":
39+
sys.stderr.write(f"FakeRAM2.0 orfs_asap7: unsupported platform {platform}\n")
40+
return 1
41+
42+
try:
43+
data = json.loads(json_path.read_text())
44+
memories = data.get("memories", [])
45+
except Exception as e:
46+
sys.stderr.write(f"FakeRAM2.0 orfs_asap7: failed to read {json_path}: {e}\n")
47+
return 1
48+
49+
out_dir.mkdir(parents=True, exist_ok=True)
50+
converted = sorted(
51+
(m for m in memories if m.get("idiomatic")), key=lambda m: m["name"]
52+
)
53+
54+
process = Process(ASAP7_PROCESS_CONFIG)
55+
timing_data = TimingData(ASAP7_TIMING_CONFIG)
56+
57+
for m in converted:
58+
name = m["name"]
59+
bits = m.get("bits", 32)
60+
rows = m.get("rows", 128)
61+
62+
sram_dict = {
63+
"name": name,
64+
"width": bits,
65+
"depth": rows,
66+
"banks": 1,
67+
}
68+
mem_config = MemoryConfig.from_json(sram_dict)
69+
ram = MemoryFactory.create(mem_config, "RAM", "SP", process, timing_data)
70+
71+
# Export Liberty
72+
lib_path = out_dir / f"{name}.lib"
73+
with open(lib_path, "w") as f:
74+
RAMLibertyExporter(ram).export(f)
75+
76+
pre_lib_path = out_dir / f"{name}_pre_layout.lib"
77+
with open(pre_lib_path, "w") as f:
78+
RAMLibertyExporter(ram).export(f)
79+
80+
# Export LEF
81+
lef_path = out_dir / f"{name}.lef"
82+
with open(lef_path, "w") as f:
83+
LefExporter(ram).export(f)
84+
85+
(out_dir / "blackboxes.txt").write_text(
86+
"".join(f"{m['name']}\n" for m in converted)
87+
)
88+
return 0

‎tools/FakeRAM2.0/run.py‎

Lines changed: 14 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,22 @@ 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+
42+
return run_orfs_asap7(
43+
platform="asap7", out_dir=Path(args.output_dir), json_path=Path(args.config)
44+
)
45+
3346
json_data = RunUtils.get_config(args.config)
3447
# Create a process object (shared by all srams)
3548
process = Process(json_data)
@@ -50,4 +63,4 @@ def main(args: argparse.Namespace):
5063
### Entry point
5164
if __name__ == "__main__":
5265
args = get_args()
53-
main(args)
66+
sys.exit(main(args))

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

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

120120
total_height += additional_height
121121

122+
min_height = max(
123+
3.5, self.snap_height_nm / 1000.0 if self.snap_height_nm else 0
124+
)
125+
total_height = max(total_height, min_height)
126+
122127
return (total_width, total_height)
123128

124129
def get_tech_nm(self):

0 commit comments

Comments
 (0)