OpenRAM/compiler/sram.py

137 lines
5.0 KiB
Python
Raw Normal View History

# See LICENSE for licensing information.
#
#Copyright (c) 2019 Regents of the University of California and The Board
#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
import sys
import datetime
import getpass
2016-11-08 18:57:35 +01:00
import debug
2018-02-08 21:47:19 +01:00
from globals import OPTS, print_time
from sram_config import sram_config
class sram():
2016-11-08 18:57:35 +01:00
"""
This is not a design module, but contains an SRAM design instance.
It could later try options of number of banks and oganization to compare
results.
We can later add visualizer and other high-level functions as needed.
2016-11-08 18:57:35 +01:00
"""
def __init__(self, sram_config, name):
sram_config.set_local_config(self)
# reset the static duplicate name checker for unit tests
# in case we create more than one SRAM
from design import design
design.name_map=[]
2016-11-08 18:57:35 +01:00
debug.info(2, "create sram of size {0} with {1} num of words {2} banks".format(self.word_size,
self.num_words,
self.num_banks))
start_time = datetime.datetime.now()
2016-11-08 18:57:35 +01:00
self.name = name
if self.num_banks == 1:
from sram_1bank import sram_1bank as sram
elif self.num_banks == 2:
from sram_2bank import sram_2bank as sram
else:
debug.error("Invalid number of banks.",-1)
self.s = sram(name, sram_config)
self.s.create_netlist()
if not OPTS.netlist_only:
self.s.create_layout()
if not OPTS.is_unit_test:
print_time("SRAM creation", datetime.datetime.now(), start_time)
def sp_write(self,name):
self.s.sp_write(name)
def lef_write(self,name):
self.s.lef_write(name)
def gds_write(self,name):
self.s.gds_write(name)
2016-11-08 18:57:35 +01:00
def verilog_write(self,name):
self.s.verilog_write(name)
def save(self):
2018-02-08 21:47:19 +01:00
""" Save all the output files while reporting time to do it as well. """
if not OPTS.netlist_only:
# Create a LEF physical model
start_time = datetime.datetime.now()
lefname = OPTS.output_path + self.s.name + ".lef"
2019-01-13 23:34:46 +01:00
debug.print_raw("LEF: Writing to {0}".format(lefname))
self.lef_write(lefname)
print_time("LEF", datetime.datetime.now(), start_time)
if OPTS.route_supplies:
# Write the layout
start_time = datetime.datetime.now()
gdsname = OPTS.output_path + self.s.name + ".gds"
debug.print_raw("GDS: Writing to {0}".format(gdsname))
self.gds_write(gdsname)
print_time("GDS", datetime.datetime.now(), start_time)
# Save the spice file
start_time = datetime.datetime.now()
spname = OPTS.output_path + self.s.name + ".sp"
2019-01-13 23:34:46 +01:00
debug.print_raw("SP: Writing to {0}".format(spname))
self.sp_write(spname)
print_time("Spice writing", datetime.datetime.now(), start_time)
# Save the extracted spice file
2018-02-08 21:47:19 +01:00
if OPTS.use_pex:
import verify
start_time = datetime.datetime.now()
# Output the extracted design if requested
sp_file = OPTS.output_path + "temp_pex.sp"
verify.run_pex(self.s.name, gdsname, spname, output=sp_file)
print_time("Extraction", datetime.datetime.now(), start_time)
else:
# Use generated spice file for characterization
sp_file = spname
2018-02-08 21:47:19 +01:00
# Characterize the design
start_time = datetime.datetime.now()
2018-02-08 21:47:19 +01:00
from characterizer import lib
2019-01-13 23:34:46 +01:00
debug.print_raw("LIB: Characterizing... ")
lib(out_dir=OPTS.output_path, sram=self.s, sp_file=sp_file)
print_time("Characterization", datetime.datetime.now(), start_time)
# Write the config file
start_time = datetime.datetime.now()
from shutil import copyfile
copyfile(OPTS.config_file + '.py', OPTS.output_path + OPTS.output_name + '.py')
2019-01-13 23:34:46 +01:00
debug.print_raw("Config: Writing to {0}".format(OPTS.output_path + OPTS.output_name + '.py'))
print_time("Config", datetime.datetime.now(), start_time)
# Write the datasheet
start_time = datetime.datetime.now()
from datasheet_gen import datasheet_gen
dname = OPTS.output_path + self.s.name + ".html"
2019-01-13 23:34:46 +01:00
debug.print_raw("Datasheet: Writing to {0}".format(dname))
datasheet_gen.datasheet_write(dname)
print_time("Datasheet", datetime.datetime.now(), start_time)
2018-02-08 21:47:19 +01:00
# Write a verilog model
start_time = datetime.datetime.now()
vname = OPTS.output_path + self.s.name + ".v"
2019-01-13 23:34:46 +01:00
debug.print_raw("Verilog: Writing to {0}".format(vname))
self.verilog_write(vname)
print_time("Verilog", datetime.datetime.now(), start_time)