ibex/vendor/lowrisc_ip/dvsim/OneShotCfg.py
Rupert Swarbrick f35a407906 Update lowrisc_ip to lowRISC/opentitan@5cae0cf1
Update code from upstream repository
https://github.com/lowRISC/opentitan to revision
5cae0cf1fac783e0d0df8c8597bf65322a696a56

* Allow different assertion "backends" in prim_assert.sv (Rupert
  Swarbrick)
* [prim_prince/doc] Update documentation (Michael Schaffner)
* [prim_prince] Add option to instantiate a registers half-way
  (Michael Schaffner)
* [prim_cipher_pkg] Reuse sbox4_8bit to build wider sbox layers
  (Michael Schaffner)
* [dv/prim] add PRESENT testbench (Udi Jonnalagadda)
* [uvmdvgen] Scoreboard update. (Srikrishna Iyer)
* [flash_ctrl dv] Fix V1 tests (Srikrishna Iyer)
* [prim_cipher_pkg] Replicate common subfunctions for other widths
  (Michael Schaffner)
* [prim/present] fix PRESENT decryption bugs (Udi Jonnalagadda)
* [prim/present] fix some PRESENT encryption bugs (Udi Jonnalagadda)
* [dv] Add get_mem DPI function to Verilator simutil (Stefan
  Wallentowitz)
* [lint/entropy_src] Add the entropy source to the lint regression
  (Michael Schaffner)
* [style-lint] Fix some common style lint warnings (Michael Schaffner)
* first set of security checks added to D2 checklist (Scott Johnson)
* [fpv/tooling] add FPV class extension in dvsim (Cindy Chen)
* [dvsim/lint] Minor fixes for printout issues and result parser
  status (Michael Schaffner)
* [syn] Print detailed messages to .md if publication is disabled
  (Michael Schaffner)
* [prim_util] Do not use $clog2() in Xcelium (Philipp Wagner)
* [prim] Update ResetValue parameter in prim_flop_2sync (Timothy Chen)
* Modified some command-line arguments for DSim (Aimee Sutton)
* [prim_util] Make prim_util a package (Philipp Wagner)
* [dv] Move mem checking to scb (Weicai Yang)
* [lint] Make PINCONNECTEMPTY Verilator waiver common (Philipp Wagner)
* [prim] - Fix generic flash enum reference (Timothy Chen)
* [prim_ram_*adv] Mark cfg port as unused (Philipp Wagner)
* [prim_fifo_sync] Use vbits() for simpler code (Philipp Wagner)
* [prim_flash] Add reset to held_part (Eunchan Kim)
* [lint] Add more lint waivers (Philipp Wagner)
* [dv] Add random backdoor for csr_hw_reset (Weicai Yang)
* [dv] Add set_freq_khz in clk_rst_if (Weicai Yang)
* [prim] Close GAPI file handle in primgen (Philipp Wagner)
* [fpv/prim_packer] fix CI failure due to index out of bound (Cindy
  Chen)
* [prim_arbiter_*] Propagate parameter changes (Michael Schaffner)
* [prim_arbiter_tree] Fix incorrect arbitration behavior (Michael
  Schaffner)
* [prim_arbiter_ppc] Add more FPV fairness checks (Michael Schaffner)
* [prim_ram*] Add an assertion that checks wmask consistency (Michael
  Schaffner)
* [memutil] Increase max memory width to 256bit (Tom Roberts)
* [flash] - Add flash info page support (Timothy Chen)

Signed-off-by: Rupert Swarbrick <rswarbrick@lowrisc.org>
2020-07-01 14:54:13 +01:00

190 lines
6.3 KiB
Python

# Copyright lowRISC contributors.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
r"""
Class describing a one-shot build configuration object
"""
import logging as log
import os
import sys
from collections import OrderedDict
from Deploy import CompileOneShot
from FlowCfg import FlowCfg
from Modes import BuildModes, Modes
from utils import find_and_substitute_wildcards
class OneShotCfg(FlowCfg):
"""Simple one-shot build flow for non-simulation targets like
linting, synthesis and FPV.
"""
def __init__(self, flow_cfg_file, proj_root, args):
super().__init__(flow_cfg_file, proj_root, args)
assert args.tool is not None
# Options set from command line
self.tool = args.tool
self.verbose = args.verbose
self.flist_gen_cmd = ""
self.flist_gen_opts = []
self.sv_flist_gen_dir = ""
self.flist_file = ""
self.build_cmd = ""
self.build_opts = []
self.build_log = ""
self.report_cmd = ""
self.report_opts = []
self.build_opts.extend(args.build_opts)
self.build_unique = args.build_unique
self.build_only = args.build_only
# Options built from cfg_file files
self.project = ""
self.flow = ""
self.flow_makefile = ""
self.scratch_path = ""
self.build_dir = ""
self.run_dir = ""
self.sw_build_dir = ""
self.pass_patterns = []
self.fail_patterns = []
self.name = ""
self.dut = ""
self.fusesoc_core = ""
self.ral_spec = ""
self.build_modes = []
self.run_modes = []
self.regressions = []
self.max_msg_count = -1
# Flow results
self.result = OrderedDict()
self.result_summary = OrderedDict()
self.dry_run = args.dry_run
# Not needed for this build
self.verbosity = ""
self.en_build_modes = []
# Generated data structures
self.links = {}
self.build_list = []
self.deploy = []
self.cov = args.cov
# Parse the cfg_file file tree
self.parse_flow_cfg(flow_cfg_file)
self._post_parse_flow_cfg()
# If build_unique is set, then add current timestamp to uniquify it
if self.build_unique:
self.build_dir += "_" + self.timestamp
# Process overrides before substituting the wildcards.
self._process_overrides()
# Make substitutions, while ignoring the following wildcards
# TODO: Find a way to set these in sim cfg instead
ignored_wildcards = ["build_mode", "index", "test"]
self.__dict__ = find_and_substitute_wildcards(self.__dict__,
self.__dict__,
ignored_wildcards)
# Stuff below only pertains to individual cfg (not master cfg).
if not self.is_master_cfg:
# Print info
log.info("[scratch_dir]: [%s]: [%s]", self.name, self.scratch_path)
# Set directories with links for ease of debug / triage.
self.links = {
"D": self.scratch_path + "/" + "dispatched",
"P": self.scratch_path + "/" + "passed",
"F": self.scratch_path + "/" + "failed",
"K": self.scratch_path + "/" + "killed"
}
# Use the default build mode for tests that do not specify it
if not hasattr(self, "build_mode"):
setattr(self, "build_mode", "default")
self._process_exports()
# Create objects from raw dicts - build_modes, sim_modes, run_modes,
# tests and regressions, only if not a master cfg obj
self._create_objects()
# Post init checks
self.__post_init__()
def __post_init__(self):
# Run some post init checks
super().__post_init__()
# Purge the output directories. This operates on self.
def _purge(self):
if self.scratch_path:
try:
log.info("Purging scratch path %s", self.scratch_path)
os.system("/bin/rm -rf " + self.scratch_path)
except IOError:
log.error('Failed to purge scratch directory %s',
self.scratch_path)
def _create_objects(self):
# Create build and run modes objects
build_modes = Modes.create_modes(BuildModes,
getattr(self, "build_modes"))
setattr(self, "build_modes", build_modes)
# All defined build modes are being built, h
# ence extend all with the global opts.
for build_mode in build_modes:
build_mode.build_opts.extend(self.build_opts)
def _print_list(self):
for list_item in self.list_items:
log.info("---- List of %s in %s ----", list_item, self.name)
if hasattr(self, list_item):
items = getattr(self, list_item)
for item in items:
log.info(item)
else:
log.error("Item %s does not exist!", list_item)
def _create_dirs(self):
'''Create initial set of directories
'''
# Invoking system calls has a performance penalty.
# Construct a single command line chained with '&&' to invoke
# the system call only once, rather than multiple times.
create_link_dirs_cmd = ""
for link in self.links.keys():
create_link_dirs_cmd += "/bin/rm -rf " + self.links[link] + " && "
create_link_dirs_cmd += "mkdir -p " + self.links[link] + " && "
create_link_dirs_cmd += " true"
try:
os.system(create_link_dirs_cmd)
except IOError:
log.error("Error running when running the cmd \"%s\"",
create_link_dirs_cmd)
sys.exit(1)
def _create_deploy_objects(self):
'''Create deploy objects from build modes
'''
builds = []
build_map = {}
for build in self.build_modes:
item = CompileOneShot(build, self)
builds.append(item)
build_map[build] = item
self.builds = builds
self.deploy = builds
# Create initial set of directories before kicking off the regression.
self._create_dirs()