Skip to content

Commit

Permalink
[adc_ctrl,dv] Tidy up access to intr_state in env_cfg files
Browse files Browse the repository at this point in the history
This code was duplicated in lots of places: I think probably from a
template file in the first place. In each case, if the code compiles,
then ${MY_BLOCK}_reg_block must have a field called intr_state. In
that situation get_reg_by_name() will always return something that is
not null, so the test in the if statement will always be true.

Use the shorter, more direct, form each time.

Signed-off-by: Rupert Swarbrick <[email protected]>
  • Loading branch information
rswarbrick committed Nov 29, 2023
1 parent 17d386c commit 975a6eb
Show file tree
Hide file tree
Showing 15 changed files with 18 additions and 92 deletions.
7 changes: 1 addition & 6 deletions hw/ip/adc_ctrl/dv/env/adc_ctrl_env_cfg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,7 @@ class adc_ctrl_env_cfg extends cip_base_env_cfg #(
end

// set num_interrupts & num_alerts
begin
uvm_reg rg = ral.get_reg_by_name("intr_state");
if (rg != null) begin
num_interrupts = ral.intr_state.get_n_used_bits();
end
end
num_interrupts = ral.intr_state.get_n_used_bits();

// only support 1 outstanding TL item
m_tl_agent_cfg.max_outstanding_req = 1;
Expand Down
7 changes: 1 addition & 6 deletions hw/ip/aon_timer/dv/env/aon_timer_env_cfg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,7 @@ class aon_timer_env_cfg extends cip_base_env_cfg #(.RAL_T(aon_timer_reg_block));
m_tl_agent_cfg.max_outstanding_req = 1;

// set num_interrupts & num_alerts
begin
uvm_reg rg = ral.get_reg_by_name("intr_state");
if (rg != null) begin
num_interrupts = ral.intr_state.get_n_used_bits();
end
end
num_interrupts = ral.intr_state.get_n_used_bits();
endfunction

endclass
7 changes: 1 addition & 6 deletions hw/ip/csrng/dv/env/csrng_env_cfg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,7 @@ class csrng_env_cfg extends cip_base_env_cfg #(.RAL_T(csrng_reg_block));
end

// set num_interrupts & num_alerts
begin
uvm_reg rg = ral.get_reg_by_name("intr_state");
if (rg != null) begin
num_interrupts = ral.intr_state.get_n_used_bits();
end
end
num_interrupts = ral.intr_state.get_n_used_bits();

// get csrng assert interface handle
if (!uvm_config_db#(virtual csrng_assert_if)::
Expand Down
7 changes: 1 addition & 6 deletions hw/ip/edn/dv/env/edn_env_cfg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,7 @@ class edn_env_cfg extends cip_base_env_cfg #(.RAL_T(edn_reg_block));
end

// set num_interrupts & num_alerts
begin
uvm_reg rg = ral.get_reg_by_name("intr_state");
if (rg != null) begin
num_interrupts = ral.intr_state.get_n_used_bits();
end
end
num_interrupts = ral.intr_state.get_n_used_bits();

// get edn assert interface handle
if (!uvm_config_db#(virtual edn_assert_if)::
Expand Down
7 changes: 1 addition & 6 deletions hw/ip/entropy_src/dv/env/entropy_src_env_cfg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,7 @@ class entropy_src_env_cfg extends cip_base_env_cfg #(.RAL_T(entropy_src_reg_bloc
m_xht_agent_cfg = entropy_src_xht_agent_cfg::type_id::create("m_xht_agent_cfg");

// set num_interrupts & num_alerts
begin
uvm_reg rg = ral.get_reg_by_name("intr_state");
if (rg != null) begin
num_interrupts = ral.intr_state.get_n_used_bits();
end
end
num_interrupts = ral.intr_state.get_n_used_bits();

// get entropy_src assert interface handle
if (!uvm_config_db#(virtual entropy_src_assert_if)::
Expand Down
8 changes: 2 additions & 6 deletions hw/ip/flash_ctrl/dv/env/flash_ctrl_env_cfg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -307,12 +307,8 @@ class flash_ctrl_env_cfg extends cip_base_env_cfg #(
m_fpp_agent_cfg.en_cov = 0;

// set num_interrupts & num_alerts
begin
uvm_reg rg = ral.get_reg_by_name("intr_state");
if (rg != null) begin
num_interrupts = ral.intr_state.get_n_used_bits();
end
end
num_interrupts = ral.intr_state.get_n_used_bits();

m_tl_agent_cfg.max_outstanding_req = 1;
m_tl_agent_cfgs[flash_ral_name].max_outstanding_req = 2;
m_tl_agent_cfgs[prim_ral_name].max_outstanding_req = 1;
Expand Down
7 changes: 1 addition & 6 deletions hw/ip/keymgr/dv/env/keymgr_env_cfg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,7 @@ class keymgr_env_cfg extends cip_base_env_cfg #(.RAL_T(keymgr_reg_block));
m_edn_pull_agent_cfgs[0].ok_to_end_delay_ns = 0;

// set num_interrupts & num_alerts
begin
uvm_reg rg = ral.get_reg_by_name("intr_state");
if (rg != null) begin
num_interrupts = ral.intr_state.get_n_used_bits();
end
end
num_interrupts = ral.intr_state.get_n_used_bits();

// only support 1 outstanding TL item
m_tl_agent_cfg.max_outstanding_req = 1;
Expand Down
7 changes: 1 addition & 6 deletions hw/ip/kmac/dv/env/kmac_env_cfg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,7 @@ class kmac_env_cfg extends cip_base_env_cfg #(.RAL_T(kmac_reg_block));
void'($value$plusargs("test_vectors_shake_variant=%0d", shake_variant));

// set num_interrupts & num_alerts
begin
uvm_reg rg = ral.get_reg_by_name("intr_state");
if (rg != null) begin
num_interrupts = ral.intr_state.get_n_used_bits();
end
end
num_interrupts = ral.intr_state.get_n_used_bits();

// only support 1 outstanding TL items in tlul_adapter
m_tl_agent_cfg.max_outstanding_req = 1;
Expand Down
7 changes: 1 addition & 6 deletions hw/ip/otp_ctrl/dv/env/otp_ctrl_env_cfg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,7 @@ class otp_ctrl_env_cfg extends cip_base_env_cfg #(.RAL_T(otp_ctrl_core_reg_block
m_lc_prog_pull_agent_cfg.agent_type = PullAgent;

// set num_interrupts & num_alerts
begin
uvm_reg rg = ral.get_reg_by_name("intr_state");
if (rg != null) begin
num_interrupts = ral.intr_state.get_n_used_bits();
end
end
num_interrupts = ral.intr_state.get_n_used_bits();

// only support 1 outstanding TL items in tlul_adapter
m_tl_agent_cfg.max_outstanding_req = 1;
Expand Down
11 changes: 3 additions & 8 deletions hw/ip/pattgen/dv/env/pattgen_env_cfg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ class pattgen_env_cfg extends cip_base_env_cfg #(.RAL_T(pattgen_reg_block));

// pattgen_agent_cfg
rand pattgen_agent_cfg m_pattgen_agent_cfg;

// seq cfg
pattgen_seq_cfg seq_cfg;

`uvm_object_utils_begin(pattgen_env_cfg)
`uvm_field_object(m_pattgen_agent_cfg, UVM_DEFAULT)
`uvm_object_utils_end

`uvm_object_new

virtual function void initialize(bit [TL_AW-1:0] csr_base_addr = '1);
Expand All @@ -30,11 +30,6 @@ class pattgen_env_cfg extends cip_base_env_cfg #(.RAL_T(pattgen_reg_block));
seq_cfg = pattgen_seq_cfg::type_id::create("seq_cfg");

// set num_interrupts & num_alerts
begin
uvm_reg rg = ral.get_reg_by_name("intr_state");
if (rg != null) begin
num_interrupts = ral.intr_state.get_n_used_bits();
end
end
num_interrupts = ral.intr_state.get_n_used_bits();
endfunction
endclass : pattgen_env_cfg
7 changes: 1 addition & 6 deletions hw/ip/spi_host/dv/env/spi_host_env_cfg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,7 @@ class spi_host_env_cfg extends cip_base_env_cfg #(.RAL_T(spi_host_reg_block));
seq_cfg = spi_host_seq_cfg::type_id::create("seq_cfg");

// set num_interrupts & num_alerts
begin
uvm_reg rg = ral.get_reg_by_name("intr_state");
if (rg != null) begin
num_interrupts = ral.intr_state.get_n_used_bits();
end
end
num_interrupts = ral.intr_state.get_n_used_bits();
endfunction

// clk_core_freq_mhz is set by
Expand Down
7 changes: 1 addition & 6 deletions hw/ip/sysrst_ctrl/dv/env/sysrst_ctrl_env_cfg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,7 @@ class sysrst_ctrl_env_cfg extends cip_base_env_cfg #(.RAL_T(sysrst_ctrl_reg_bloc
super.initialize(csr_base_addr);

// set num_interrupts
begin
uvm_reg rg = ral.get_reg_by_name("intr_state");
if (rg != null) begin
num_interrupts = ral.intr_state.get_n_used_bits();
end
end
num_interrupts = ral.intr_state.get_n_used_bits();

// only support 1 outstanding TL item
m_tl_agent_cfg.max_outstanding_req = 1;
Expand Down
7 changes: 1 addition & 6 deletions hw/ip/usbdev/dv/env/usbdev_env_cfg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,7 @@ class usbdev_env_cfg extends cip_base_env_cfg #(.RAL_T(usbdev_reg_block));
m_usb20_agent_cfg = usb20_agent_cfg::type_id::create("m_usb20_agent_cfg");

// set num_interrupts & num_alerts
begin
uvm_reg rg = ral.get_reg_by_name("intr_state");
if (rg != null) begin
num_interrupts = ral.intr_state.get_n_used_bits();
end
end
num_interrupts = ral.intr_state.get_n_used_bits();
endfunction

// ral flow is limited in terms of setting correct field access policies and reset values
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,7 @@ class alert_handler_env_cfg extends cip_base_env_cfg #(.RAL_T(alert_handler_reg_
shadow_storage_err_status_fields[ral.loc_alert_cause[LocalShadowRegStorageErr].la] = 1;

// set num_interrupts & num_alerts
begin
uvm_reg rg = ral.get_reg_by_name("intr_state");
if (rg != null) begin
num_interrupts = ral.intr_state.get_n_used_bits();
end
end
num_interrupts = ral.intr_state.get_n_used_bits();

alert_host_cfg = new[NUM_ALERTS];
esc_device_cfg = new[NUM_ESCS];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,7 @@ class alert_handler_env_cfg extends cip_base_env_cfg #(.RAL_T(alert_handler_reg_
shadow_storage_err_status_fields[ral.loc_alert_cause[LocalShadowRegStorageErr].la] = 1;

// set num_interrupts & num_alerts
begin
uvm_reg rg = ral.get_reg_by_name("intr_state");
if (rg != null) begin
num_interrupts = ral.intr_state.get_n_used_bits();
end
end
num_interrupts = ral.intr_state.get_n_used_bits();

alert_host_cfg = new[NUM_ALERTS];
esc_device_cfg = new[NUM_ESCS];
Expand Down

0 comments on commit 975a6eb

Please sign in to comment.