Skip to content

Commit a03634a

Browse files
committed
Re-factored fakeram to support sp/dp ram/regfile
fixed coverage instrumentation more cleanup and code coverage Signed-off-by: Jeff Ng <jeffng@precisioninno.com>
1 parent 75611b2 commit a03634a

57 files changed

Lines changed: 40891 additions & 1025 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

run.py

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
#!/usr/bin/env python3
22

3-
import os
43
import sys
5-
import json
64
import argparse
7-
from pathlib import Path
85

6+
from utils.run_utils import RunUtils
97
from utils.class_process import Process
10-
from utils.class_memory import Memory
11-
12-
from utils.create_lib import create_lib
13-
from utils.create_lef import create_lef
14-
from utils.create_verilog import create_verilog
8+
from utils.memory_factory import MemoryFactory
9+
from utils.timing_data import TimingData
1510

1611
################################################################################
1712
# RUN GENERATOR
@@ -40,39 +35,49 @@ def get_args() -> argparse.Namespace:
4035
action="store",
4136
help="Output directory ",
4237
required=False,
43-
default=None,
38+
default="results",
4439
)
4540
return parser.parse_args()
4641

4742

48-
def ensure_results_dir(output_dir, memory_name):
49-
if output_dir: # Output dir was set by command line option
50-
p = str(Path(output_dir).expanduser().resolve(strict=False))
51-
results_dir = os.sep.join([p, memory_name])
52-
else:
53-
results_dir = os.sep.join([os.getcwd(), "results", memory_name])
54-
if not os.path.exists(results_dir):
55-
os.makedirs(results_dir)
56-
return results_dir
43+
def get_memory_type(json_data):
44+
if "memory_type" in json_data:
45+
return json_data["memory_type"]
46+
return "RAM"
5747

5848

59-
def main(args: argparse.Namespace):
49+
def get_port_config(json_data):
50+
if "port_configuration" in json_data:
51+
return json_data["port_configuration"]
52+
return "SP"
6053

61-
# Load the JSON configuration file
62-
with open(args.config, "r") as fid:
63-
raw = [line.strip() for line in fid if not line.strip().startswith("#")]
64-
json_data = json.loads("\n".join(raw))
6554

55+
def main(args: argparse.Namespace):
56+
json_data = RunUtils.get_config(args.config)
6657
# Create a process object (shared by all srams)
6758
process = Process(json_data)
59+
timing_data = TimingData(json_data)
60+
61+
memory_type = get_memory_type(json_data)
62+
port_config = get_port_config(json_data)
6863

6964
# Go through each sram and generate the lib, lef and v files
7065
for sram_data in json_data["srams"]:
71-
memory = Memory(process, sram_data)
72-
results_dir = ensure_results_dir(args.output_dir, memory.name)
73-
create_lib(memory, results_dir)
74-
create_lef(memory, results_dir)
75-
create_verilog(memory, results_dir)
66+
name = str(sram_data["name"])
67+
width_in_bits = int(sram_data["width"])
68+
depth = int(sram_data["depth"])
69+
num_banks = int(sram_data["banks"])
70+
memory = MemoryFactory.create(
71+
name,
72+
width_in_bits,
73+
depth,
74+
num_banks,
75+
memory_type,
76+
port_config,
77+
process,
78+
timing_data,
79+
)
80+
RunUtils.write_memory(memory, args.output_dir)
7681

7782

7883
### Entry point

test/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
#*#
33
.#*
44
__pycache__
5-
results
5+
results
6+
*_results

0 commit comments

Comments
 (0)