2016-11-08 18:57:35 +01:00
|
|
|
import sys
|
2018-07-10 23:17:09 +02:00
|
|
|
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
|
2016-11-08 18:57:35 +01:00
|
|
|
|
2017-11-14 22:24:14 +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
|
|
|
"""
|
|
|
|
|
def __init__(self, word_size, num_words, num_banks, name):
|
2017-08-24 00:02:15 +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
|
2018-07-10 23:17:09 +02:00
|
|
|
from design import design
|
|
|
|
|
design.name_map=[]
|
2016-11-08 18:57:35 +01:00
|
|
|
|
2018-07-12 19:30:45 +02:00
|
|
|
debug.info(2, "create sram of size {0} with {1} num of words".format(word_size,
|
|
|
|
|
num_words))
|
2018-02-08 22:11:18 +01:00
|
|
|
start_time = datetime.datetime.now()
|
2016-11-08 18:57:35 +01:00
|
|
|
|
2018-07-12 19:30:45 +02:00
|
|
|
if num_banks == 1:
|
|
|
|
|
from sram_1bank import sram_1bank
|
2018-07-13 18:30:14 +02:00
|
|
|
self.s=sram_1bank(word_size, num_words, name)
|
2018-07-12 19:30:45 +02:00
|
|
|
elif num_banks == 2:
|
|
|
|
|
from sram_2bank import sram_2bank
|
2018-07-13 18:30:14 +02:00
|
|
|
self.s=sram_2bank(word_size, num_words, name)
|
2018-07-12 19:30:45 +02:00
|
|
|
elif num_banks == 4:
|
|
|
|
|
from sram_4bank import sram_4bank
|
2018-07-13 18:30:14 +02:00
|
|
|
self.s=sram_4bank(word_size, num_words, name)
|
2018-07-10 23:17:09 +02:00
|
|
|
else:
|
|
|
|
|
debug.error("Invalid number of banks.",-1)
|
2017-09-14 00:46:41 +02:00
|
|
|
|
2018-07-13 18:30:14 +02:00
|
|
|
self.s.compute_sizes()
|
|
|
|
|
self.s.create_modules()
|
|
|
|
|
self.s.add_pins()
|
|
|
|
|
self.s.create_layout()
|
2017-09-30 01:22:13 +02:00
|
|
|
|
|
|
|
|
# Can remove the following, but it helps for debug!
|
2018-07-13 18:30:14 +02:00
|
|
|
self.s.add_lvs_correspondence_points()
|
2017-09-30 01:22:13 +02:00
|
|
|
|
2018-07-13 18:30:14 +02:00
|
|
|
self.s.offset_all_coordinates()
|
|
|
|
|
highest_coord = self.s.find_highest_coords()
|
|
|
|
|
self.s.width = highest_coord[0]
|
|
|
|
|
self.s.height = highest_coord[1]
|
2017-12-19 18:01:24 +01:00
|
|
|
|
2018-07-13 18:30:14 +02:00
|
|
|
self.s.DRC_LVS(final_verification=True)
|
2016-11-08 18:57:35 +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)
|
2018-02-08 22:11:18 +01:00
|
|
|
|
2018-07-13 18:38:43 +02:00
|
|
|
def get_name(self):
|
|
|
|
|
return self.s.name
|
|
|
|
|
|
|
|
|
|
def sp_write(self,name):
|
|
|
|
|
self.s.sp_write(name)
|
|
|
|
|
|
|
|
|
|
def gds_write(self,name):
|
|
|
|
|
self.s.gds_write(name)
|
2016-11-08 18:57:35 +01:00
|
|
|
|
2018-07-13 18:38:43 +02: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
|
|
|
|
|
|
|
|
# Save the spice file
|
|
|
|
|
start_time = datetime.datetime.now()
|
2018-07-13 18:30:14 +02:00
|
|
|
spname = OPTS.output_path + self.s.name + ".sp"
|
2018-02-08 21:47:19 +01:00
|
|
|
print("SP: Writing to {0}".format(spname))
|
2018-07-13 18:30:14 +02:00
|
|
|
self.s.sp_write(spname)
|
2018-02-08 22:11:18 +01:00
|
|
|
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:
|
2018-02-08 22:11:18 +01:00
|
|
|
start_time = datetime.datetime.now()
|
|
|
|
|
# Output the extracted design if requested
|
|
|
|
|
sp_file = OPTS.output_path + "temp_pex.sp"
|
2018-07-13 18:30:14 +02:00
|
|
|
verify.run_pex(self.s.name, gdsname, spname, output=sp_file)
|
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
|
|
|
|
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
|
2018-02-10 00:33:03 +01:00
|
|
|
print("LIB: Characterizing... ")
|
2018-02-08 21:47:19 +01:00
|
|
|
if OPTS.analytical_delay:
|
|
|
|
|
print("Using analytical delay models (no characterization)")
|
|
|
|
|
else:
|
|
|
|
|
if OPTS.spice_name!="":
|
|
|
|
|
print("Performing simulation-based characterization with {}".format(OPTS.spice_name))
|
|
|
|
|
if OPTS.trim_netlist:
|
|
|
|
|
print("Trimming netlist to speed up characterization.")
|
2018-07-13 18:30:14 +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-02-08 21:47:19 +01:00
|
|
|
|
|
|
|
|
# Write the layout
|
2018-02-08 22:11:18 +01:00
|
|
|
start_time = datetime.datetime.now()
|
2018-07-13 18:30:14 +02:00
|
|
|
gdsname = OPTS.output_path + self.s.name + ".gds"
|
2018-02-08 21:47:19 +01:00
|
|
|
print("GDS: Writing to {0}".format(gdsname))
|
2018-07-13 18:30:14 +02:00
|
|
|
self.s.gds_write(gdsname)
|
2018-02-08 22:11:18 +01:00
|
|
|
print_time("GDS", datetime.datetime.now(), start_time)
|
2018-02-08 21:47:19 +01:00
|
|
|
|
|
|
|
|
# Create a LEF physical model
|
2018-02-08 22:11:18 +01:00
|
|
|
start_time = datetime.datetime.now()
|
2018-07-13 18:30:14 +02:00
|
|
|
lefname = OPTS.output_path + self.s.name + ".lef"
|
2018-02-08 21:47:19 +01:00
|
|
|
print("LEF: Writing to {0}".format(lefname))
|
2018-07-13 18:30:14 +02:00
|
|
|
self.s.lef_write(lefname)
|
2018-02-08 22:11:18 +01:00
|
|
|
print_time("LEF", 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()
|
2018-07-13 18:30:14 +02:00
|
|
|
vname = OPTS.output_path + self.s.name + ".v"
|
2018-02-08 21:47:19 +01:00
|
|
|
print("Verilog: Writing to {0}".format(vname))
|
2018-07-13 18:30:14 +02:00
|
|
|
self.s.verilog_write(vname)
|
2018-02-08 22:11:18 +01:00
|
|
|
print_time("Verilog", datetime.datetime.now(), start_time)
|