// Copyright lowRISC contributors (OpenTitan project).
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
{
  flow:             sim
  // Where to find DV code
  dv_root:          "{proj_root}/vendor/lowrisc_ip/dv"
  flow_makefile:    "{dv_root}/tools/dvsim/sim.mk"

  import_cfgs:      ["{proj_root}/dv/uvm/common_project_cfg.hjson",
                     "{dv_root}/tools/dvsim/common_modes.hjson",
                     "{dv_root}/tools/dvsim/fusesoc.hjson",
                     "{dv_root}/tools/dvsim/bazel.hjson",
                     "{dv_root}/tools/dvsim/{tool}.hjson"]

  sv_flist_gen_flags: ["--mapping=lowrisc:prim_generic:all:0.1"]

  // Default directory structure for the output
  build_dir:          "{scratch_path}/{build_mode}"
  run_dir_name:       "{index}.{test}"
  run_dir:            "{scratch_path}/{run_dir_name}/latest"
  sw_root_dir:        "{proj_root}/sw"

  // Default file to store build_seed value
  build_seed_file_path: "{build_dir}/build_seed.log"

  run_pass_patterns:   ["^TEST PASSED (UVM_)?CHECKS$"]
  run_fail_patterns:   ["^UVM_ERROR\\s[^:].*$",
                        "^UVM_FATAL\\s[^:].*$",
                        "^UVM_WARNING\\s[^:].*$",
                        "^Assert failed: ",
                        "^\\s*Offending '.*'",
                        "^TEST FAILED (UVM_)?CHECKS$",
                        "^Error:.*$"]  // ISS errors

  // Default TileLink widths
  tl_aw: 32
  tl_dw: 32
  tl_dbw: 4

  // Default UVM verbosity settings
  expand_uvm_verbosity_n: UVM_NONE
  expand_uvm_verbosity_l: UVM_LOW
  expand_uvm_verbosity_m: UVM_MEDIUM
  expand_uvm_verbosity_h: UVM_HIGH
  expand_uvm_verbosity_f: UVM_FULL
  expand_uvm_verbosity_d: UVM_DEBUG

  // Default simulation verbosity (l => UVM_LOW). Can be overridden by
  // the --verbosity command-line argument.
  verbosity: l

  // Path to the dut instance (this is used in a couple of places such as coverage cfg
  // file, xprop cfg file etc. If this is different for your block, then override it with
  // the 'overrides' directive.
  dut_instance: "{tb}.dut"

  timescale: "1ns/1ps"

  // Top level simulation entities.
  sim_tops: ["{tb}"]

  // Default build and run opts
  build_opts: [// Standard UVM defines
               "+define+UVM",
               "+define+UVM_NO_DEPRECATED",
               "+define+UVM_REGEX_NO_DPI",
               "+define+UVM_REG_ADDR_WIDTH={tl_aw}",
               "+define+UVM_REG_DATA_WIDTH={tl_dw}",
               "+define+UVM_REG_BYTENABLE_WIDTH={tl_dbw}",
               "+define+SIMULATION",
               "+define+DUT_HIER={dut_instance}"]

  run_opts: ["+UVM_NO_RELNOTES",
             "+UVM_VERBOSITY={expand_uvm_verbosity_{verbosity}}"]

  // Default list of things to export to shell
  exports: [
    { dv_root: "{dv_root}" },
    { self_dir: "{self_dir}" },
    { SIMULATOR: "{tool}" },
    { GUI: "{gui}"},
    { GUI_DEBUG: "{gui_debug}"},
    { WAVES: "{waves}" },
    { DUT_TOP: "{dut}" },
    { TB_TOP: "{tb}" },
    { dut_instance: "{dut_instance}" }
  ]

  // Build modes are collection of build_opts and run_opts
  //
  // To define a build mode that overrides these flags, add something
  // like the following to the IP block's configuration:
  //
  //   build_modes: [
  //     {
  //       name: foo
  //       build_opts: ["+define+bx",
  //                    "+define+by",
  //                    "+define+bz"]
  //       run_opts: ["+rx=1",
  //                  "+ry=2",
  //                  "+rz=3"]
  //     }
  //   ]
  //
  // To use a build mode for a specific test, set the 'build_mode' key.
  //
  build_modes: []

  // Regressions are tests that can be grouped together and run in one shot
  // By default, two regressions are made available - "all" and "nightly". Both
  // run all available tests for the DUT. "nightly" enables coverage as well.
  // The 'tests' key is set to an empty list, which indicates "run everything".
  // Regressions can enable sim modes, which are a set of build_opts and run_opts
  // that are grouped together. These are appended to the build modes used by the
  // tests.
  regressions: [
    {
      name: smoke
      tests: []
      reseed: 1
      run_opts: [// Knob used to configure an existing test / vseq to have a shorter runtime.
                 "+smoke_test=1"
                ]
    }
    {
      name: all
    }
    {
      name: all_once
      reseed: 1
    }
    {
      name: nightly
      en_sim_modes: ["cov"]
    }
  ]

  // Project defaults for VCS
  vcs_cov_cfg_file: "{{build_mode}_vcs_cov_cfg_file}"
  vcs_unr_cfg_file: "{dv_root}/tools/vcs/unr.cfg"
  vcs_xprop_cfg_file: "{dv_root}/tools/vcs/xprop.cfg"
  vcs_fsm_reset_cov_cfg_file: "{dv_root}/tools/vcs/fsm_reset_cov.cfg"
  vcs_cov_excl_files: []

  // Build-specific coverage cfg files for VCS.
  default_vcs_cov_cfg_file: "-cm_hier {dv_root}/tools/vcs/cover.cfg+{dv_root}/tools/vcs/common_cov_excl.cfg"
  cover_reg_top_vcs_cov_cfg_file: "-cm_hier {dv_root}/tools/vcs/cover_reg_top.cfg+{dv_root}/tools/vcs/common_cov_excl.cfg"

  // Project defaults for Xcelium
  xcelium_cov_cfg_file: "{{build_mode}_xcelium_cov_cfg_file}"
  xcelium_unr_cfg_file:  "{dv_root}/tools/xcelium/unr.cfg"
  xcelium_cov_excl_script: "{dv_root}/tools/xcelium/common_cov_excl.tcl"
  xcelium_cov_refine_files: []

  // Build-specific coverage cfg files for Xcelium.
  default_xcelium_cov_cfg_file: "{dv_root}/tools/xcelium/cover.ccf"
  cover_reg_top_xcelium_cov_cfg_file: "{dv_root}/tools/xcelium/cover_reg_top.ccf"
}
