2018-05-12 01:32:00 +02:00
|
|
|
#!/usr/bin/env python3
|
2019-04-26 21:21:50 +02:00
|
|
|
# See LICENSE for licensing information.
|
|
|
|
|
#
|
2021-01-22 20:23:28 +01:00
|
|
|
# Copyright (c) 2016-2021 Regents of the University of California and The Board
|
2019-06-14 17:43:41 +02:00
|
|
|
# of Regents for the Oklahoma Agricultural and Mechanical College
|
|
|
|
|
# (acting for and on behalf of Oklahoma State University)
|
|
|
|
|
# All rights reserved.
|
2019-04-26 21:21:50 +02:00
|
|
|
#
|
2016-11-08 18:57:35 +01:00
|
|
|
"""
|
|
|
|
|
SRAM Compiler
|
|
|
|
|
|
|
|
|
|
The output files append the given suffixes to the output name:
|
|
|
|
|
a spice (.sp) file for circuit simulation
|
|
|
|
|
a GDS2 (.gds) file containing the layout
|
|
|
|
|
a LEF (.lef) file for preliminary P&R (real one should be from layout)
|
|
|
|
|
a Liberty (.lib) file for timing analysis/optimization
|
|
|
|
|
"""
|
|
|
|
|
|
2019-10-03 01:26:02 +02:00
|
|
|
import sys
|
2022-11-27 22:01:20 +01:00
|
|
|
import os
|
2016-11-08 18:57:35 +01:00
|
|
|
import datetime
|
2022-11-07 06:56:40 +01:00
|
|
|
try:
|
|
|
|
|
import openram
|
|
|
|
|
except:
|
2022-11-18 20:16:28 +01:00
|
|
|
# If openram library isn't found as a python package,
|
|
|
|
|
# import it from the $OPENRAM_HOME path.
|
|
|
|
|
import importlib.util
|
|
|
|
|
OPENRAM_HOME = os.getenv("OPENRAM_HOME")
|
|
|
|
|
# Import using spec since the directory can be named something
|
|
|
|
|
# other than "openram".
|
|
|
|
|
spec = importlib.util.spec_from_file_location("openram", "{}/../__init__.py".format(OPENRAM_HOME))
|
|
|
|
|
module = importlib.util.module_from_spec(spec)
|
|
|
|
|
sys.modules["openram"] = module
|
|
|
|
|
spec.loader.exec_module(module)
|
|
|
|
|
import openram
|
2016-11-08 18:57:35 +01:00
|
|
|
|
2022-11-18 20:16:28 +01:00
|
|
|
(OPTS, args) = openram.parse_args()
|
2018-02-09 18:53:28 +01:00
|
|
|
|
|
|
|
|
# Check that we are left with a single configuration file as argument.
|
|
|
|
|
if len(args) != 1:
|
2022-11-18 20:16:28 +01:00
|
|
|
print(openram.USAGE)
|
2018-02-09 18:53:28 +01:00
|
|
|
sys.exit(2)
|
|
|
|
|
|
2017-11-14 22:24:14 +01:00
|
|
|
|
2016-11-08 18:57:35 +01:00
|
|
|
# These depend on arguments, so don't load them until now.
|
2022-11-27 22:01:20 +01:00
|
|
|
from openram import debug
|
2016-11-08 18:57:35 +01:00
|
|
|
|
2019-11-26 22:54:37 +01:00
|
|
|
# Parse config file and set up all the options
|
2022-11-21 23:52:57 +01:00
|
|
|
openram.init_openram(config_file=args[0])
|
2018-02-09 18:53:28 +01:00
|
|
|
|
2019-11-26 22:54:37 +01:00
|
|
|
# Ensure that the right bitcell exists or use the parameterised one
|
2022-11-18 20:16:28 +01:00
|
|
|
openram.setup_bitcell()
|
2019-11-26 22:54:37 +01:00
|
|
|
|
2018-02-08 21:47:19 +01:00
|
|
|
# Only print banner here so it's not in unit tests
|
2022-11-18 20:16:28 +01:00
|
|
|
openram.print_banner()
|
2016-11-08 18:57:35 +01:00
|
|
|
|
2018-12-08 00:50:18 +01:00
|
|
|
# Keep track of running stats
|
|
|
|
|
start_time = datetime.datetime.now()
|
2022-11-18 20:16:28 +01:00
|
|
|
openram.print_time("Start", start_time)
|
2018-12-08 00:50:18 +01:00
|
|
|
|
2018-02-09 18:53:28 +01:00
|
|
|
# Output info about this run
|
2022-11-18 20:16:28 +01:00
|
|
|
openram.report_status()
|
2016-11-08 18:57:35 +01:00
|
|
|
|
2022-11-27 22:01:20 +01:00
|
|
|
from openram.modules import sram_config
|
2018-12-06 22:11:47 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
# Configure the SRAM organization
|
|
|
|
|
c = sram_config(word_size=OPTS.word_size,
|
2019-06-29 00:43:09 +02:00
|
|
|
num_words=OPTS.num_words,
|
2020-02-20 18:01:52 +01:00
|
|
|
write_size=OPTS.write_size,
|
2020-07-13 21:37:56 +02:00
|
|
|
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)
|
2019-01-13 23:34:46 +01:00
|
|
|
debug.print_raw("Words per row: {}".format(c.words_per_row))
|
2018-12-06 22:11:47 +01:00
|
|
|
|
2020-07-03 15:55:35 +02:00
|
|
|
output_extensions = ["lvs", "sp", "v", "lib", "py", "html", "log"]
|
2019-04-01 18:58:59 +02:00
|
|
|
# Only output lef/gds if back-end
|
2018-08-27 23:33:02 +02:00
|
|
|
if not OPTS.netlist_only:
|
2019-10-03 01:26:02 +02:00
|
|
|
output_extensions.extend(["lef", "gds"])
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2019-10-03 01:26:02 +02:00
|
|
|
output_files = ["{0}{1}.{2}".format(OPTS.output_path,
|
|
|
|
|
OPTS.output_name, x)
|
|
|
|
|
for x in output_extensions]
|
2019-01-13 23:34:46 +01:00
|
|
|
debug.print_raw("Output files are: ")
|
2019-10-03 01:26:02 +02:00
|
|
|
for path in output_files:
|
2019-01-13 23:34:46 +01:00
|
|
|
debug.print_raw(path)
|
2018-02-26 17:54:35 +01:00
|
|
|
|
2018-02-08 21:47:19 +01:00
|
|
|
|
2022-11-27 22:01:20 +01:00
|
|
|
from openram.modules import sram
|
2022-04-19 17:50:11 +02:00
|
|
|
s = sram(name=OPTS.output_name,
|
2022-03-12 03:01:45 +01:00
|
|
|
sram_config=c)
|
2016-11-08 18:57:35 +01:00
|
|
|
|
|
|
|
|
# Output the files for the resulting SRAM
|
2018-07-12 19:35:38 +02:00
|
|
|
s.save()
|
2016-11-08 18:57:35 +01:00
|
|
|
|
2018-02-08 21:47:19 +01:00
|
|
|
# Delete temp files etc.
|
2022-11-18 20:16:28 +01:00
|
|
|
openram.end_openram()
|
|
|
|
|
openram.print_time("End", datetime.datetime.now(), start_time)
|
2016-11-08 18:57:35 +01:00
|
|
|
|