2022-03-02 21:18:54 +01:00
|
|
|
#!/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
|
2022-03-02 21:18:54 +01:00
|
|
|
# of Regents for the Oklahoma Agricultural and Mechanical College
|
|
|
|
|
# (acting for and on behalf of Oklahoma State University)
|
|
|
|
|
# All rights reserved.
|
|
|
|
|
#
|
|
|
|
|
"""
|
2023-02-21 22:51:13 +01:00
|
|
|
This script will functionally simulate an SRAM previously generated by OpenRAM
|
|
|
|
|
given a configuration file. Configuration option "use_pex" determines whether
|
2022-04-14 19:04:07 +02:00
|
|
|
extracted or generated spice is used. Command line arguments dictate the
|
|
|
|
|
number of cycles and period to be simulated.
|
2022-03-02 21:18:54 +01:00
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
import sys
|
|
|
|
|
import datetime
|
|
|
|
|
|
2023-02-24 00:14:39 +01:00
|
|
|
# You don't need the next two lines if you're sure that openram package is installed
|
|
|
|
|
from common import *
|
2023-05-17 00:08:21 +02:00
|
|
|
make_openram_package()
|
2023-02-24 00:14:39 +01:00
|
|
|
import openram
|
2023-01-19 21:18:38 +01:00
|
|
|
|
|
|
|
|
(OPTS, args) = openram.parse_args()
|
2022-03-02 21:18:54 +01:00
|
|
|
|
|
|
|
|
# Override the usage
|
2023-05-17 00:08:21 +02:00
|
|
|
USAGE = "Usage: {} [options] <config file> <sp_file> <cycles> <period>\nUse -h for help.\n".format(__file__)
|
2022-03-02 21:18:54 +01:00
|
|
|
|
|
|
|
|
# Check that we are left with a single configuration file as argument.
|
2023-05-17 00:08:21 +02:00
|
|
|
if len(args) != 4:
|
2022-03-02 21:18:54 +01:00
|
|
|
print(USAGE)
|
|
|
|
|
sys.exit(2)
|
|
|
|
|
|
2022-08-19 05:35:02 +02:00
|
|
|
OPTS.top_process = 'memfunc'
|
|
|
|
|
|
2022-03-02 21:18:54 +01:00
|
|
|
# Parse argument
|
|
|
|
|
config_file = args[0]
|
2023-05-17 00:08:21 +02:00
|
|
|
sp_file = args[1]
|
|
|
|
|
cycles = int(args[2])
|
|
|
|
|
period = float(args[3])
|
2022-03-02 21:18:54 +01:00
|
|
|
|
|
|
|
|
# These depend on arguments, so don't load them until now.
|
2023-01-19 21:18:38 +01:00
|
|
|
from openram import debug
|
2022-03-02 21:18:54 +01:00
|
|
|
|
|
|
|
|
# Parse config file and set up all the options
|
2023-01-19 21:18:38 +01:00
|
|
|
openram.init_openram(config_file=config_file, is_unit_test=False)
|
2022-03-02 21:18:54 +01:00
|
|
|
|
2023-01-19 21:18:38 +01:00
|
|
|
openram.print_banner()
|
2022-03-02 21:18:54 +01:00
|
|
|
|
2023-09-04 03:35:07 +02:00
|
|
|
# Configure the SRAM organization (duplicated from sram_compiler.py)
|
2023-07-05 23:29:51 +02:00
|
|
|
from openram.characterizer.fake_sram import fake_sram
|
2022-12-13 16:53:58 +01:00
|
|
|
s = fake_sram(name=OPTS.output_name,
|
|
|
|
|
word_size=OPTS.word_size,
|
|
|
|
|
num_words=OPTS.num_words,
|
|
|
|
|
write_size=OPTS.write_size,
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
|
|
s.generate_pins()
|
|
|
|
|
s.setup_multiport_constants()
|
2022-03-02 21:18:54 +01:00
|
|
|
|
2022-04-14 19:04:07 +02:00
|
|
|
OPTS.netlist_only = True
|
2022-04-14 19:13:48 +02:00
|
|
|
OPTS.check_lvsdrc = False
|
2022-04-14 19:04:07 +02:00
|
|
|
|
2022-03-02 21:18:54 +01:00
|
|
|
# Generate stimulus and run functional simulation on the design
|
|
|
|
|
start_time = datetime.datetime.now()
|
2023-01-19 21:18:38 +01:00
|
|
|
from openram.characterizer import functional
|
2022-03-02 21:18:54 +01:00
|
|
|
debug.print_raw("Functional simulation... ")
|
2023-01-19 21:18:38 +01:00
|
|
|
f = functional(s, cycles=cycles, spfile=sp_file, period=period, output_path=OPTS.openram_temp)
|
2022-03-02 21:18:54 +01:00
|
|
|
(fail, error) = f.run()
|
2022-03-09 18:43:00 +01:00
|
|
|
debug.print_raw(error)
|
2023-01-19 21:18:38 +01:00
|
|
|
openram.print_time("Functional simulation", datetime.datetime.now(), start_time)
|
2022-03-02 21:18:54 +01:00
|
|
|
|
|
|
|
|
# Delete temp files, remove the dir, etc. after success
|
|
|
|
|
if fail:
|
2023-01-19 21:18:38 +01:00
|
|
|
openram.end_openram()
|