From d47b5612d515082d683b99c1500dea4f57f2e168 Mon Sep 17 00:00:00 2001 From: samuelkcrow Date: Wed, 2 Mar 2022 12:18:54 -0800 Subject: [PATCH] characterizer and functional simulator working from command line --- compiler/characterize_existing.py | 2 + compiler/characterizer/functional.py | 7 +-- compiler/func_sim_existing.py | 70 ++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+), 3 deletions(-) create mode 100755 compiler/func_sim_existing.py diff --git a/compiler/characterize_existing.py b/compiler/characterize_existing.py index 82e95b1b..f6c83c4b 100755 --- a/compiler/characterize_existing.py +++ b/compiler/characterize_existing.py @@ -34,6 +34,8 @@ import debug # Parse config file and set up all the options init_openram(config_file=args[0], is_unit_test=False) +print_banner() + # Configure the SRAM organization (duplicated from openram.py) from sram_config import sram_config c = sram_config(word_size=OPTS.word_size, diff --git a/compiler/characterizer/functional.py b/compiler/characterizer/functional.py index e7d03f25..3bc94ab7 100644 --- a/compiler/characterizer/functional.py +++ b/compiler/characterizer/functional.py @@ -36,9 +36,6 @@ class functional(simulation): if not corner: corner = (OPTS.process_corners[0], OPTS.supply_voltages[0], OPTS.temperatures[0]) - if period: - self.period = period - if not output_path: self.output_path = OPTS.openram_temp else: @@ -73,6 +70,10 @@ class functional(simulation): self.set_spice_constants() self.set_stimulus_variables() + # Override default period + if period: + self.period = period + # For the debug signal names self.wordline_row = 0 self.bitline_column = 0 diff --git a/compiler/func_sim_existing.py b/compiler/func_sim_existing.py new file mode 100755 index 00000000..ec89c3d7 --- /dev/null +++ b/compiler/func_sim_existing.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python3 +# See LICENSE for licensing information. +# +# Copyright (c) 2016-2021 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. +# +""" +This script will characterize an SRAM previously generated by OpenRAM given a +configuration file. Configuration option "use_pex" determines whether extracted +or generated spice is used and option "analytical_delay" determines whether +an analytical model or spice simulation is used for characterization. +""" + +import sys +import datetime +from globals import * +from importlib import reload + +(OPTS, args) = parse_args() + +# Override the usage +USAGE = "Usage: {} [options] \nUse -h for help.\n".format(__file__) + +# Check that we are left with a single configuration file as argument. +if len(args) != 3: + print(USAGE) + sys.exit(2) + +# Parse argument +config_file = args[0] +cycles = int(args[1]) +period = float(args[2]) + +# These depend on arguments, so don't load them until now. +import debug + +# Parse config file and set up all the options +init_openram(config_file=config_file, is_unit_test=False) + +print_banner() + +# Configure the SRAM organization (duplicated from openram.py) +from sram_config import sram_config +c = sram_config(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) + +# Initialize and create the sram object +from sram import sram +s = sram(name=OPTS.output_name, sram_config=c) +s.create() + +# Generate stimulus and run functional simulation on the design +start_time = datetime.datetime.now() +from characterizer import functional +debug.print_raw("Functional simulation... ") +f = functional(s.s, cycles=cycles, spfile=s.get_sp_name(), period=period, output_path=OPTS.openram_temp) +(fail, error) = f.run() +print_time("Functional simulation", datetime.datetime.now(), start_time) +print(error) + +# Delete temp files, remove the dir, etc. after success +if fail: + end_openram()