Skip to content

Commit

Permalink
[aon_timer, dv] Add extern keyword to methods/constraints
Browse files Browse the repository at this point in the history
Moving TB towards declaring functions and constraints as extern to
enhance readability

Signed-off-by: Antonio Martinez Zambrana <[email protected]>
  • Loading branch information
antmarzam authored and andrea-caforio committed Nov 12, 2024
1 parent ae660ea commit 78c2b34
Show file tree
Hide file tree
Showing 11 changed files with 714 additions and 665 deletions.
51 changes: 26 additions & 25 deletions hw/ip/aon_timer/dv/env/aon_timer_env.sv
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,32 @@ class aon_timer_env extends cip_base_env #(
);
`uvm_component_utils(aon_timer_env)

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

function void build_phase(uvm_phase phase);
super.build_phase(phase);
// get the vifs from config db
if (!uvm_config_db#(virtual clk_rst_if)::
get(this, "", "aon_clk_rst_vif", cfg.aon_clk_rst_vif)) begin
`uvm_fatal(`gfn, "failed to get aon_clk_rst_vif from uvm_config_db")
end
if (!uvm_config_db#(virtual pins_if #(1))::
get(this, "", "lc_escalate_en_vif", cfg.lc_escalate_en_vif)) begin
`uvm_fatal(`gfn, "failed to get lc_escalate_en_vif from uvm_config_db")
end
if (!uvm_config_db#(virtual pins_if #(2))::
get(this, "", "aon_intr_vif", cfg.aon_intr_vif)) begin
`uvm_fatal(`gfn, "failed to get aon_intr_vif from uvm_config_db")
end
if (!uvm_config_db#(virtual pins_if #(1))::
get(this, "", "sleep_vif", cfg.sleep_vif)) begin
`uvm_fatal(`gfn, "failed to get sleep_vif from uvm_config_db")
end
endfunction
endclass : aon_timer_env

function void connect_phase(uvm_phase phase);
super.connect_phase(phase);
endfunction
function aon_timer_env::new (string name="", uvm_component parent=null);
super.new(name, parent);
endfunction : new

endclass
function void aon_timer_env::build_phase(uvm_phase phase);
super.build_phase(phase);
// get the vifs from config db
if (!uvm_config_db#(virtual clk_rst_if)::
get(this, "", "aon_clk_rst_vif", cfg.aon_clk_rst_vif)) begin
`uvm_fatal(`gfn, "failed to get aon_clk_rst_vif from uvm_config_db")
end
if (!uvm_config_db#(virtual pins_if #(1))::
get(this, "", "lc_escalate_en_vif", cfg.lc_escalate_en_vif)) begin
`uvm_fatal(`gfn, "failed to get lc_escalate_en_vif from uvm_config_db")
end
if (!uvm_config_db#(virtual pins_if #(2))::
get(this, "", "aon_intr_vif", cfg.aon_intr_vif)) begin
`uvm_fatal(`gfn, "failed to get aon_intr_vif from uvm_config_db")
end
if (!uvm_config_db#(virtual pins_if #(1))::
get(this, "", "sleep_vif", cfg.sleep_vif)) begin
`uvm_fatal(`gfn, "failed to get sleep_vif from uvm_config_db")
end
endfunction : build_phase
25 changes: 14 additions & 11 deletions hw/ip/aon_timer/dv/env/aon_timer_env_cfg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,21 @@ class aon_timer_env_cfg extends cip_base_env_cfg #(.RAL_T(aon_timer_reg_block));
`uvm_object_utils_begin(aon_timer_env_cfg)
`uvm_object_utils_end

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

virtual function void initialize(bit [31:0] csr_base_addr = '1);
list_of_alerts = aon_timer_env_pkg::LIST_OF_ALERTS;
super.initialize(csr_base_addr);
endclass : aon_timer_env_cfg

m_tl_agent_cfg.max_outstanding_req = 1;
function aon_timer_env_cfg::new (string name="");
super.new(name);
endfunction : new

// set num_interrupts & num_alerts
num_interrupts = ral.intr_state.get_n_used_bits();
endfunction
function void aon_timer_env_cfg::initialize(bit [31:0] csr_base_addr = '1);
list_of_alerts = aon_timer_env_pkg::LIST_OF_ALERTS;
super.initialize(csr_base_addr);

endclass
m_tl_agent_cfg.max_outstanding_req = 1;

// set num_interrupts & num_alerts
num_interrupts = ral.intr_state.get_n_used_bits();
endfunction : initialize
23 changes: 12 additions & 11 deletions hw/ip/aon_timer/dv/env/aon_timer_env_cov.sv
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,15 @@ class aon_timer_env_cov extends cip_base_env_cov #(.CFG_T(aon_timer_env_cfg));
wdog_thold_cpXwdog_bark_rst: cross wdog_thold_cp, wdog_bark_int;
endgroup : watchdog_timer_bark_thold_hit_cg


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

endclass
extern function new(string name, uvm_component parent);

endclass : aon_timer_env_cov

function aon_timer_env_cov::new(string name, uvm_component parent);
super.new(name, parent);
// [instantiate covergroups here]
timer_cfg_cg = new(name);
wake_up_timer_thold_hit_cg = new();
watchdog_timer_bite_thold_hit_cg = new();
watchdog_timer_bark_thold_hit_cg = new();
endfunction : new
Loading

0 comments on commit 78c2b34

Please sign in to comment.