OpenRAM/sram_char.py

80 lines
2.6 KiB
Python
Raw Normal View History

2022-03-02 00:12:03 +01:00
#!/usr/bin/env python3
# See LICENSE for licensing information.
#
2023-02-21 22:51:13 +01:00
# Copyright (c) 2016-2023 Regents of the University of California and The Board
2022-03-02 00:12:03 +01:00
# of Regents for the Oklahoma Agricultural and Mechanical College
# (acting for and on behalf of Oklahoma State University)
# All rights reserved.
#
"""
This script will characterize an SRAM previously generated by OpenRAM given a
configuration file. Configuration option "use_pex" determines whether extracted
or generated spice is used and option "analytical_delay" determines whether
an analytical model or spice simulation is used for characterization.
"""
import sys
import datetime
2023-02-24 00:14:39 +01:00
# You don't need the next two lines if you're sure that openram package is installed
from common import *
make_openram_package()
import openram
2022-03-02 00:12:03 +01:00
2023-01-19 21:18:38 +01:00
(OPTS, args) = openram.parse_args()
2022-03-02 00:12:03 +01:00
# Override the usage
USAGE = "Usage: {} [options] <config file> <spice netlist>\nUse -h for help.\n".format(__file__)
2022-03-02 00:12:03 +01:00
# Check that we are left with a single configuration file as argument.
if len(args) != 2:
2022-03-02 00:12:03 +01:00
print(USAGE)
sys.exit(2)
2022-08-19 05:35:02 +02:00
OPTS.top_process = 'memchar'
2022-03-02 00:12:03 +01:00
# These depend on arguments, so don't load them until now.
2023-01-19 21:18:38 +01:00
from openram import debug
2022-03-02 00:12:03 +01:00
# Parse config file and set up all the options
2023-01-19 21:18:38 +01:00
openram.init_openram(config_file=args[0], is_unit_test=False)
2022-03-02 00:12:03 +01:00
2023-01-19 21:18:38 +01:00
openram.print_banner()
2023-09-04 03:35:07 +02:00
# Configure the SRAM organization (duplicated from sram_compiler.py)
2023-01-19 21:18:38 +01:00
from openram.characterizer import fake_sram
2022-11-29 23:53:02 +01:00
s = fake_sram(name=OPTS.output_name,
word_size=OPTS.word_size,
num_words=OPTS.num_words,
write_size=OPTS.write_size,
num_banks=OPTS.num_banks,
words_per_row=OPTS.words_per_row,
num_spare_rows=OPTS.num_spare_rows,
num_spare_cols=OPTS.num_spare_cols)
2022-03-02 00:12:03 +01:00
debug.check(os.path.exists(args[1]), "Spice netlist file {} not found.".format(args[1]))
2023-01-19 21:18:38 +01:00
sp_file = args[1]
2022-08-19 06:09:48 +02:00
s.generate_pins()
2022-11-29 23:53:02 +01:00
s.setup_multiport_constants()
2022-08-13 08:29:33 +02:00
OPTS.netlist_only = True
OPTS.check_lvsdrc = False
2023-02-14 21:01:14 +01:00
OPTS.nomimal_corner_only = True
# TODO: remove this after adding trimmed netlist gen to sram run
OPTS.trim_netlist = False
2022-03-02 00:12:03 +01:00
# Characterize the design
start_time = datetime.datetime.now()
2023-01-19 21:18:38 +01:00
from openram.characterizer import lib
2022-03-02 00:12:03 +01:00
debug.print_raw("LIB: Characterizing... ")
2023-01-19 21:18:38 +01:00
lib(out_dir=OPTS.output_path, sram=s, sp_file=sp_file, use_model=False)
2022-03-02 00:12:03 +01:00
print_time("Characterization", datetime.datetime.now(), start_time)
# Output info about this run
2022-03-02 21:47:05 +01:00
print("Output files are:\n{0}*.lib".format(OPTS.output_path))
2022-03-02 00:12:03 +01:00
#report_status() #could modify this function to provide relevant info
# Delete temp files, remove the dir, etc.
2023-01-19 21:18:38 +01:00
openram.end_openram()