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
|
|
|
#
|
2018-07-10 23:17:09 +02:00
|
|
|
import datetime
|
2020-11-09 20:12:31 +01:00
|
|
|
import os
|
2016-11-08 18:57:35 +01:00
|
|
|
import debug
|
2020-11-09 21:00:25 +01:00
|
|
|
from characterizer import functional
|
2018-02-08 21:47:19 +01:00
|
|
|
from globals import OPTS, print_time
|
2021-06-23 01:13:33 +02:00
|
|
|
import shutil
|
2020-03-06 01:20:21 +01:00
|
|
|
|
|
|
|
|
|
2018-07-12 19:30:45 +02:00
|
|
|
class sram():
|
2016-11-08 18:57:35 +01:00
|
|
|
"""
|
2018-07-12 19:30:45 +02: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
|
|
|
"""
|
2018-09-04 19:47:24 +02:00
|
|
|
def __init__(self, sram_config, name):
|
2017-08-24 00:02:15 +02:00
|
|
|
|
2018-08-31 21:03:28 +02:00
|
|
|
sram_config.set_local_config(self)
|
2021-06-23 01:13:33 +02:00
|
|
|
|
2017-06-02 20:11:57 +02:00
|
|
|
# reset the static duplicate name checker for unit tests
|
|
|
|
|
# in case we create more than one SRAM
|
2022-07-13 19:57:56 +02:00
|
|
|
from base import design
|
2018-07-10 23:17:09 +02:00
|
|
|
design.name_map=[]
|
2016-11-08 18:57:35 +01:00
|
|
|
|
2020-03-06 01:20:21 +01:00
|
|
|
debug.info(2, "create sram of size {0} with {1} num of words {2} banks".format(self.word_size,
|
2018-08-31 21:03:28 +02:00
|
|
|
self.num_words,
|
|
|
|
|
self.num_banks))
|
2018-02-08 22:11:18 +01:00
|
|
|
start_time = datetime.datetime.now()
|
2016-11-08 18:57:35 +01:00
|
|
|
|
2018-07-13 23:45:46 +02:00
|
|
|
self.name = name
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2022-06-10 06:40:19 +02:00
|
|
|
from sram_1bank import sram_1bank as sram
|
2018-09-04 19:47:24 +02:00
|
|
|
|
2020-03-06 01:20:21 +01:00
|
|
|
self.s = sram(name, sram_config)
|
2022-06-10 06:40:19 +02:00
|
|
|
|
2018-08-27 23:18:32 +02:00
|
|
|
self.s.create_netlist()
|
2018-08-28 01:42:48 +02:00
|
|
|
if not OPTS.netlist_only:
|
|
|
|
|
self.s.create_layout()
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2018-02-08 23:58:55 +01:00
|
|
|
if not OPTS.is_unit_test:
|
|
|
|
|
print_time("SRAM creation", datetime.datetime.now(), start_time)
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2021-04-07 02:01:52 +02:00
|
|
|
def sp_write(self, name, lvs=False, trim=False):
|
|
|
|
|
self.s.sp_write(name, lvs, trim)
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2020-03-06 01:20:21 +01:00
|
|
|
def lef_write(self, name):
|
2019-01-11 23:15:16 +01:00
|
|
|
self.s.lef_write(name)
|
|
|
|
|
|
2020-03-06 01:20:21 +01:00
|
|
|
def gds_write(self, name):
|
2018-07-13 18:38:43 +02:00
|
|
|
self.s.gds_write(name)
|
2016-11-08 18:57:35 +01:00
|
|
|
|
2020-03-06 01:20:21 +01:00
|
|
|
def verilog_write(self, name):
|
2022-06-15 02:57:04 +02:00
|
|
|
self.s.verilog_write(name + '_1bank.v')
|
|
|
|
|
if self.num_banks != 1:
|
|
|
|
|
from sram_multibank import sram_multibank
|
|
|
|
|
mb = sram_multibank(self.s)
|
|
|
|
|
mb.verilog_write(name + '.v')
|
2018-07-19 19:05:30 +02:00
|
|
|
|
2020-09-09 03:40:39 +02:00
|
|
|
def extended_config_write(self, name):
|
2020-11-03 15:29:17 +01:00
|
|
|
"""Dump config file with all options.
|
2020-09-09 03:40:39 +02:00
|
|
|
Include defaults and anything changed by input config."""
|
|
|
|
|
f = open(name, "w")
|
2020-10-01 20:10:18 +02:00
|
|
|
var_dict = dict((name, getattr(OPTS, name)) for name in dir(OPTS) if not name.startswith('__') and not callable(getattr(OPTS, name)))
|
2020-09-09 03:40:39 +02:00
|
|
|
for var_name, var_value in var_dict.items():
|
|
|
|
|
if isinstance(var_value, str):
|
|
|
|
|
f.write(str(var_name) + " = " + "\"" + str(var_value) + "\"\n")
|
|
|
|
|
else:
|
|
|
|
|
f.write(str(var_name) + " = " + str(var_value)+ "\n")
|
|
|
|
|
f.close()
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2018-07-12 19:30:45 +02:00
|
|
|
def save(self):
|
2018-02-08 21:47:19 +01:00
|
|
|
""" Save all the output files while reporting time to do it as well. """
|
2018-02-08 22:11:18 +01:00
|
|
|
|
2022-07-13 19:57:56 +02:00
|
|
|
# Import this at the last minute so that the proper tech file
|
|
|
|
|
# is loaded and the right tools are selected
|
|
|
|
|
import verify
|
|
|
|
|
|
2020-12-21 22:51:50 +01:00
|
|
|
# Save the spice file
|
|
|
|
|
start_time = datetime.datetime.now()
|
|
|
|
|
spname = OPTS.output_path + self.s.name + ".sp"
|
|
|
|
|
debug.print_raw("SP: Writing to {0}".format(spname))
|
|
|
|
|
self.sp_write(spname)
|
|
|
|
|
functional(self.s,
|
2021-06-23 01:13:33 +02:00
|
|
|
os.path.basename(spname),
|
|
|
|
|
cycles=200,
|
|
|
|
|
output_path=OPTS.output_path)
|
2020-12-21 22:51:50 +01:00
|
|
|
print_time("Spice writing", datetime.datetime.now(), start_time)
|
|
|
|
|
|
2018-10-08 17:42:32 +02:00
|
|
|
if not OPTS.netlist_only:
|
2019-09-03 20:23:35 +02:00
|
|
|
# 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)
|
2020-12-23 16:16:43 +01:00
|
|
|
if OPTS.check_lvsdrc:
|
|
|
|
|
verify.write_drc_script(cell_name=self.s.name,
|
|
|
|
|
gds_name=os.path.basename(gdsname),
|
|
|
|
|
extract=True,
|
|
|
|
|
final_verification=True,
|
|
|
|
|
output_path=OPTS.output_path)
|
2019-09-03 20:23:35 +02:00
|
|
|
print_time("GDS", datetime.datetime.now(), start_time)
|
2019-04-01 18:58:59 +02:00
|
|
|
|
2020-10-07 01:27:02 +02:00
|
|
|
# Create a LEF physical model
|
|
|
|
|
start_time = datetime.datetime.now()
|
|
|
|
|
lefname = OPTS.output_path + self.s.name + ".lef"
|
|
|
|
|
debug.print_raw("LEF: Writing to {0}".format(lefname))
|
|
|
|
|
self.lef_write(lefname)
|
|
|
|
|
print_time("LEF", datetime.datetime.now(), start_time)
|
|
|
|
|
|
2020-07-03 15:55:35 +02:00
|
|
|
# Save the LVS file
|
|
|
|
|
start_time = datetime.datetime.now()
|
2020-08-12 19:41:21 +02:00
|
|
|
lvsname = OPTS.output_path + self.s.name + ".lvs.sp"
|
|
|
|
|
debug.print_raw("LVS: Writing to {0}".format(lvsname))
|
2021-04-07 04:01:33 +02:00
|
|
|
self.sp_write(lvsname, lvs=True)
|
2020-12-23 16:16:43 +01:00
|
|
|
if not OPTS.netlist_only and OPTS.check_lvsdrc:
|
2020-11-09 21:00:25 +01:00
|
|
|
verify.write_lvs_script(cell_name=self.s.name,
|
|
|
|
|
gds_name=os.path.basename(gdsname),
|
|
|
|
|
sp_name=os.path.basename(lvsname),
|
|
|
|
|
final_verification=True,
|
|
|
|
|
output_path=OPTS.output_path)
|
2020-07-03 15:55:35 +02:00
|
|
|
print_time("LVS writing", datetime.datetime.now(), start_time)
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2018-02-08 22:11:18 +01:00
|
|
|
# Save the extracted spice file
|
2018-02-08 21:47:19 +01:00
|
|
|
if OPTS.use_pex:
|
2018-02-08 22:11:18 +01:00
|
|
|
start_time = datetime.datetime.now()
|
|
|
|
|
# Output the extracted design if requested
|
2020-07-30 20:35:13 +02:00
|
|
|
pexname = OPTS.output_path + self.s.name + ".pex.sp"
|
2020-07-15 11:50:21 +02:00
|
|
|
spname = OPTS.output_path + self.s.name + ".sp"
|
2020-07-30 20:35:13 +02:00
|
|
|
verify.run_pex(self.s.name, gdsname, spname, output=pexname)
|
2020-08-03 10:16:12 +02:00
|
|
|
sp_file = pexname
|
2018-02-08 22:11:18 +01:00
|
|
|
print_time("Extraction", datetime.datetime.now(), start_time)
|
|
|
|
|
else:
|
|
|
|
|
# Use generated spice file for characterization
|
|
|
|
|
sp_file = spname
|
2018-07-13 18:38:43 +02:00
|
|
|
|
2020-11-09 20:12:31 +01:00
|
|
|
# Save a functional simulation file
|
|
|
|
|
|
2018-02-08 21:47:19 +01:00
|
|
|
# Characterize the design
|
2018-05-12 01:32:00 +02:00
|
|
|
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... ")
|
2021-06-16 21:36:00 +02:00
|
|
|
lib(out_dir=OPTS.output_path, sram=self.s, sp_file=sp_file)
|
2018-02-08 22:11:18 +01:00
|
|
|
print_time("Characterization", datetime.datetime.now(), start_time)
|
2018-10-31 20:29:13 +01:00
|
|
|
|
|
|
|
|
# Write the config file
|
|
|
|
|
start_time = datetime.datetime.now()
|
|
|
|
|
from shutil import copyfile
|
2019-11-16 23:22:30 +01:00
|
|
|
copyfile(OPTS.config_file, 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'))
|
2018-10-31 20:29:13 +01:00
|
|
|
print_time("Config", datetime.datetime.now(), start_time)
|
|
|
|
|
|
2018-10-12 22:22:12 +02:00
|
|
|
# Write the datasheet
|
|
|
|
|
start_time = datetime.datetime.now()
|
2022-07-13 19:57:56 +02:00
|
|
|
from datasheet import datasheet_gen
|
2018-10-12 22:22:12 +02:00
|
|
|
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))
|
2021-06-16 21:36:00 +02:00
|
|
|
datasheet_gen.datasheet_write(dname)
|
2018-10-12 22:22:12 +02:00
|
|
|
print_time("Datasheet", datetime.datetime.now(), start_time)
|
2018-02-08 21:47:19 +01:00
|
|
|
|
|
|
|
|
# Write a verilog model
|
2018-02-08 22:11:18 +01:00
|
|
|
start_time = datetime.datetime.now()
|
2022-06-15 02:57:04 +02:00
|
|
|
vname = OPTS.output_path + self.s.name
|
2019-01-13 23:34:46 +01:00
|
|
|
debug.print_raw("Verilog: Writing to {0}".format(vname))
|
2019-01-11 23:15:16 +01:00
|
|
|
self.verilog_write(vname)
|
2019-09-03 20:23:35 +02:00
|
|
|
print_time("Verilog", datetime.datetime.now(), start_time)
|
2020-09-09 03:40:39 +02:00
|
|
|
|
|
|
|
|
# Write out options if specified
|
|
|
|
|
if OPTS.output_extended_config:
|
|
|
|
|
start_time = datetime.datetime.now()
|
|
|
|
|
oname = OPTS.output_path + OPTS.output_name + "_extended.py"
|
|
|
|
|
debug.print_raw("Extended Config: Writing to {0}".format(oname))
|
|
|
|
|
self.extended_config_write(oname)
|
2020-10-01 20:10:18 +02:00
|
|
|
print_time("Extended Config", datetime.datetime.now(), start_time)
|