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
89 changes: 0 additions & 89 deletions parse_input.py

This file was deleted.

73 changes: 34 additions & 39 deletions run.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,12 @@
#!/usr/bin/env python3

import os
import sys
import json
import argparse
from pathlib import Path

from utils.run_utils import RunUtils
from utils.class_process import Process
from utils.class_memory import Memory

from utils.create_lib import create_lib
from utils.create_lef import create_lef
from utils.create_verilog import create_verilog

################################################################################
# RUN GENERATOR
#
# This is the main part of the script. It will read in the JSON configuration
# file, create a Cacti configuration file, run Cacti, extract the data from
# Cacti, and then generate the timing, physical and logical views for each SRAM
# found in the JSON configuration file.
################################################################################
from utils.memory_factory import MemoryFactory
from utils.timing_data import TimingData


def get_args() -> argparse.Namespace:
Expand All @@ -29,9 +15,8 @@ def get_args() -> argparse.Namespace:
"""
parser = argparse.ArgumentParser(
description="""
BSG Black-box SRAM Generator --
This project is designed to generate black-boxed SRAMs for use in CAD
flows where either an SRAM generator is not avaible or doesn't
flows where either an SRAM generator is not available or doesn't
exist. """
)
parser.add_argument("config", help="JSON configuration file")
Expand All @@ -40,39 +25,49 @@ def get_args() -> argparse.Namespace:
action="store",
help="Output directory ",
required=False,
default=None,
default="results",
)
return parser.parse_args()


def ensure_results_dir(output_dir, memory_name):
if output_dir: # Output dir was set by command line option
p = str(Path(output_dir).expanduser().resolve(strict=False))
results_dir = os.sep.join([p, memory_name])
else:
results_dir = os.sep.join([os.getcwd(), "results", memory_name])
if not os.path.exists(results_dir):
os.makedirs(results_dir)
return results_dir
def get_memory_type(json_data):
if "memory_type" in json_data:
return json_data["memory_type"]
return "RAM"


def main(args: argparse.Namespace):
def get_port_config(json_data):
if "port_configuration" in json_data:
return json_data["port_configuration"]
return "SP"
Comment on lines +39 to +42

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can just be

def get_port_config(json_data):
    return json_data.get("port_configuration", "SP")

same elsewhere


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

def main(args: argparse.Namespace):
json_data = RunUtils.get_config(args.config)
# Create a process object (shared by all srams)
process = Process(json_data)
timing_data = TimingData(json_data)

memory_type = get_memory_type(json_data)
port_config = get_port_config(json_data)

# Go through each sram and generate the lib, lef and v files
for sram_data in json_data["srams"]:
memory = Memory(process, sram_data)
results_dir = ensure_results_dir(args.output_dir, memory.name)
create_lib(memory, results_dir)
create_lef(memory, results_dir)
create_verilog(memory, results_dir)
name = str(sram_data["name"])
width_in_bits = int(sram_data["width"])
depth = int(sram_data["depth"])
num_banks = int(sram_data["banks"])
memory = MemoryFactory.create(
name,
width_in_bits,
depth,
num_banks,
memory_type,
port_config,
process,
timing_data,
)
RunUtils.write_memory(memory, args.output_dir)


### Entry point
Expand Down
3 changes: 2 additions & 1 deletion test/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
#*#
.#*
__pycache__
results
results
*_results
Loading
Loading