OpenRAM/sram_compiler.py

81 lines
2.2 KiB
Python
Raw Normal View History

#!/usr/bin/env python3
# See LICENSE for licensing information.
#
2024-01-03 23:32:44 +01:00
# Copyright (c) 2016-2024 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.
#
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
2023-02-24 00:05:26 +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
2016-11-08 18:57:35 +01:00
(OPTS, args) = openram.parse_args()
# Check that we are left with a single configuration file as argument.
if len(args) != 1:
print(openram.USAGE)
sys.exit(2)
2022-08-19 05:35:02 +02:00
# Set top process to openram
OPTS.top_process = 'openram'
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
# Parse config file and set up all the options
openram.init_openram(config_file=args[0])
# Ensure that the right bitcell exists or use the parameterised one
openram.setup_bitcell()
2018-02-08 21:47:19 +01:00
# Only print banner here so it's not in unit tests
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()
openram.print_time("Start", start_time)
2018-12-08 00:50:18 +01:00
# Output info about this run
openram.report_status()
2022-11-29 19:33:32 +01:00
debug.print_raw("Words per row: {}".format(OPTS.words_per_row))
output_extensions = ["lvs", "sp", "v", "lib", "py", "html", "log"]
# Only output lef/gds if back-end
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)
2022-11-29 19:33:32 +01:00
# Create an SRAM (we can also pass sram_config, see documentation/tutorials for details)
from openram import sram
2022-11-29 19:33:32 +01:00
s = sram()
2016-11-08 18:57:35 +01:00
# Output the files for the resulting SRAM
s.save()
2016-11-08 18:57:35 +01:00
2018-02-08 21:47:19 +01:00
# Delete temp files etc.
openram.end_openram()
openram.print_time("End", datetime.datetime.now(), start_time)