Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions hw/ip/racl_ctrl/dv/env/racl_ctrl_common.core
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
CAPI=2:
# Copyright lowRISC contributors (OpenTitan project).
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
name: "lowrisc:dv:racl_ctrl_common:0.1"
description: "Common files for RACL_CTRL DV UVM environment"
filesets:
files_dv:
depend:
- lowrisc:dv:cip_lib
- lowrisc:dv:racl_error_log_agent
files:
- racl_ctrl_policies_if.sv
- racl_ctrl_reg_window.sv: {is_include_file: true}
- racl_ctrl_env_wrapper_cfg.sv: {is_include_file: true}
file_type: systemVerilogSource

targets:
default:
filesets:
- files_dv
51 changes: 0 additions & 51 deletions hw/ip/racl_ctrl/dv/racl_ctrl_tests.hjson

This file was deleted.

42 changes: 42 additions & 0 deletions hw/ip_templates/racl_ctrl/dv/env/racl_ctrl_env.core.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
CAPI=2:
# Copyright lowRISC contributors (OpenTitan project).
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
name: ${instance_vlnv(f"lowrisc:dv:{module_instance_name}_env:0.1")}
description: "RACL_CTRL DV UVM environment"
filesets:
files_dv:
depend:
- lowrisc:dv:ralgen
- lowrisc:dv:cip_lib
- lowrisc:dv:racl_ctrl_common
- ${instance_vlnv(f"lowrisc:ip:{module_instance_name}:0.1")}
files:
- ${module_instance_name}_env_pkg.sv
- ${module_instance_name}_env_cfg.sv: {is_include_file: true}
- ${module_instance_name}_env_cov.sv: {is_include_file: true}
- ${module_instance_name}_virtual_sequencer.sv: {is_include_file: true}
- ${module_instance_name}_error_arb_predictor.sv: {is_include_file: true}
- ${module_instance_name}_scoreboard.sv: {is_include_file: true}
- ${module_instance_name}_env.sv: {is_include_file: true}
- seq_lib/${module_instance_name}_vseq_list.sv: {is_include_file: true}
- seq_lib/${module_instance_name}_base_vseq.sv: {is_include_file: true}
- seq_lib/${module_instance_name}_common_vseq.sv: {is_include_file: true}
- seq_lib/${module_instance_name}_smoke_vseq.sv: {is_include_file: true}
- seq_lib/${module_instance_name}_stress_all_vseq.sv: {is_include_file: true}
file_type: systemVerilogSource

generate:
ral:
generator: ralgen
parameters:
name: ${module_instance_name}
ip_hjson: ../../data/${module_instance_name}.hjson
position: prepend

targets:
default:
filesets:
- files_dv
generate:
- ral
56 changes: 56 additions & 0 deletions hw/ip_templates/racl_ctrl/dv/env/racl_ctrl_env.sv.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright lowRISC contributors (OpenTitan project).
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0

class ${module_instance_name}_env extends cip_base_env #(.CFG_T (${module_instance_name}_env_cfg),
.COV_T (${module_instance_name}_env_cov),
.VIRTUAL_SEQUENCER_T(${module_instance_name}_virtual_sequencer),
.SCOREBOARD_T (${module_instance_name}_scoreboard));
`uvm_component_utils(${module_instance_name}_env)

// Agents to drive the racl_error_i and racl_error_external_i input ports
racl_error_log_agent internal_error_agent;
racl_error_log_agent external_error_agent;

extern function new (string name="", uvm_component parent=null);
extern function void build_phase(uvm_phase phase);
extern function void connect_phase(uvm_phase phase);
endclass

function ${module_instance_name}_env::new (string name="", uvm_component parent=null);
super.new(name, parent);
endfunction

function void ${module_instance_name}_env::build_phase(uvm_phase phase);
racl_ctrl_env_wrapper_cfg wrapper;

super.build_phase(phase);

// Consume the configuration for the environment from uvm_config_db
if (!uvm_config_db#(racl_ctrl_env_wrapper_cfg)::get(null, "*.env", "wrapper", wrapper)) begin
`uvm_fatal(`gfn, "Cannot find wrapper object in config db")
end
cfg.internal_error_agent_cfg.num_subscribing_ips = wrapper.num_subscribing_ips;
cfg.external_error_agent_cfg.num_subscribing_ips = wrapper.num_external_subscribing_ips;

cfg.policies_vif = wrapper.policies_vif;
cfg.internal_error_agent_cfg.vif = wrapper.internal_error_vif;
cfg.external_error_agent_cfg.vif = wrapper.external_error_vif;

// Connect up configuration for each of the agents in uvm_config_db
uvm_config_db#(racl_error_log_agent_cfg)::set(this, "internal_error_agent*", "cfg",
cfg.internal_error_agent_cfg);
uvm_config_db#(racl_error_log_agent_cfg)::set(this, "external_error_agent*", "cfg",
cfg.external_error_agent_cfg);

// Create tha agents
internal_error_agent = racl_error_log_agent::type_id::create("internal_error_agent", this);
external_error_agent = racl_error_log_agent::type_id::create("external_error_agent", this);
endfunction

function void ${module_instance_name}_env::connect_phase(uvm_phase phase);
super.connect_phase(phase);

internal_error_agent.errors_seen.connect(scoreboard.internal_errors_export);
external_error_agent.errors_seen.connect(scoreboard.external_errors_export);
endfunction
46 changes: 46 additions & 0 deletions hw/ip_templates/racl_ctrl/dv/env/racl_ctrl_env_cfg.sv.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright lowRISC contributors (OpenTitan project).
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0

// An environment config for interfacing with ${module_instance_name}.

class ${module_instance_name}_env_cfg extends cip_base_env_cfg #(.RAL_T(${module_instance_name}_reg_block));
`uvm_object_utils(${module_instance_name}_env_cfg)

racl_ctrl_reg_window regs;

// An interface that will be bound to the racl_policies_o output of the dut.
virtual racl_ctrl_policies_if policies_vif;

// Configuration for the two error log agents
rand racl_error_log_agent_cfg internal_error_agent_cfg;
rand racl_error_log_agent_cfg external_error_agent_cfg;

extern function new (string name="");
extern virtual function void initialize(bit [31:0] csr_base_addr = '1);
endclass

function ${module_instance_name}_env_cfg::new (string name="");
super.new(name);

if (!$cast(regs, racl_ctrl_reg_window::type_id::create("regs")))
`uvm_fatal(`gfn, "Could not create reg window of correct type")
endfunction

function void ${module_instance_name}_env_cfg::initialize(bit [31:0] csr_base_addr = '1);
list_of_alerts = ${module_instance_name}_env_pkg::LIST_OF_ALERTS;

// Tell the CIP base code how many interrupts we have (defaults to zero)
num_interrupts = 1;

super.initialize(csr_base_addr);

// Tell regs about ral, which contains the actual register model.
regs.set_reg_block(ral);

// Used to allow reset operations without waiting for CSR accesses to complete
can_reset_with_csr_accesses = 1;

internal_error_agent_cfg = racl_error_log_agent_cfg::type_id::create("internal_error_agent_cfg");
external_error_agent_cfg = racl_error_log_agent_cfg::type_id::create("external_error_agent_cfg");
endfunction
32 changes: 32 additions & 0 deletions hw/ip_templates/racl_ctrl/dv/env/racl_ctrl_env_cov.sv.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright lowRISC contributors (OpenTitan project).
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0

/**
* Covergroups that are dependent on run-time parameters that may be available
* only in build_phase can be defined here
* Covergroups may also be wrapped inside helper classes if needed.
*/

class ${module_instance_name}_env_cov extends cip_base_env_cov #(.CFG_T(${module_instance_name}_env_cfg));
`uvm_component_utils(${module_instance_name}_env_cov)

// the base class provides the following handles for use:
// ${module_instance_name}_env_cfg: cfg

// covergroups
// [add covergroups here]

function new(string name, uvm_component parent);
super.new(name, parent);
// [instantiate covergroups here]
endfunction : new

virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
// [or instantiate covergroups here]
// Please instantiate sticky_intr_cov array of objects for all interrupts that are sticky
// See cip_base_env_cov for details
endfunction

endclass
48 changes: 48 additions & 0 deletions hw/ip_templates/racl_ctrl/dv/env/racl_ctrl_env_pkg.sv.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright lowRISC contributors (OpenTitan project).
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0

package ${module_instance_name}_env_pkg;
// dep packages
import uvm_pkg::*;
import top_pkg::*;
import dv_utils_pkg::*;
import dv_lib_pkg::*;
import tl_agent_pkg::*;
import cip_base_pkg::*;
import dv_base_reg_pkg::*;
import csr_utils_pkg::*;
import ${module_instance_name}_ral_pkg::*;

import racl_error_log_agent_pkg::racl_error_log_agent;
import racl_error_log_agent_pkg::racl_error_log_agent_cfg;
import racl_error_log_agent_pkg::racl_error_log_sequencer;
import racl_error_log_agent_pkg::racl_error_log_item;
import racl_error_log_agent_pkg::racl_error_log_vec_item;
import racl_error_log_agent_pkg::racl_error_log_sporadic_seq;

// macro includes
`include "uvm_macros.svh"
`include "dv_macros.svh"

// The LIST_OF_ALERTS string gives a list of alert names, used by the environment config (through
// cip_base_env_cfg) to instantiate agents for handling alerts.
//
// The connection to the dut is done through interfaces that are put in the config_db in the
// (templated) tb.sv. For this to work, every alert in this list must also be listed in tb.sv.
string LIST_OF_ALERTS[2] = {"fatal_fault", "recov_ctrl_update_err"};

localparam int unsigned PolicyBits = $bits(top_racl_pkg::racl_policy_vec_t);

// package sources
`include "racl_ctrl_reg_window.sv"
`include "racl_ctrl_env_wrapper_cfg.sv"
`include "${module_instance_name}_env_cfg.sv"
`include "${module_instance_name}_env_cov.sv"
`include "${module_instance_name}_virtual_sequencer.sv"
`include "${module_instance_name}_error_arb_predictor.sv"
`include "${module_instance_name}_scoreboard.sv"
`include "${module_instance_name}_env.sv"
`include "${module_instance_name}_vseq_list.sv"

endpackage
Loading
Loading