Skip to content

Commit 91395f9

Browse files
committed
[dv,pwm] Tidying and commenting
Reformatting and tidying of source, including dropping an unused file. No functional changes. Signed-off-by: Adrian Lees <[email protected]>
1 parent 3e7eb56 commit 91395f9

File tree

10 files changed

+125
-158
lines changed

10 files changed

+125
-158
lines changed

hw/dv/sv/pwm_monitor/pwm_monitor_cfg.sv

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
33
// SPDX-License-Identifier: Apache-2.0
44

5-
class pwm_monitor_cfg extends dv_base_agent_cfg;
5+
class pwm_monitor_cfg extends dv_base_agent_cfg;
66

77
int monitor_id = 0;
8-
bit invert = 1'b0; // 0: active high, 1: active low
8+
bit invert = 1'b0; // 0: active high, 1: active low
99
bit active = 1'b0; // 1: valid configuration, collect items 0: ignore
1010
int resolution = 0;
1111
int clk_div = 0;

hw/ip/pwm/dv/env/pwm_env.core

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ filesets:
1313
- lowrisc:dv:pwm_monitor
1414
files:
1515
- pwm_env_pkg.sv
16-
- pwm_seq_cfg.sv: {is_include_file: true}
1716
- pwm_env_cfg.sv: {is_include_file: true}
1817
- pwm_env_cov.sv: {is_include_file: true}
1918
- pwm_virtual_sequencer.sv: {is_include_file: true}

hw/ip/pwm/dv/env/pwm_env.sv

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,17 @@ class pwm_env extends cip_base_env #(
1111
`uvm_component_utils(pwm_env)
1212
`uvm_component_new
1313

14-
pwm_monitor m_pwm_monitor[PWM_NUM_CHANNELS];
14+
// One monitor for each channel; the monitors operate independently.
15+
pwm_monitor m_pwm_monitor[PWM_NUM_CHANNELS];
1516

1617
function void build_phase(uvm_phase phase);
1718
super.build_phase(phase);
1819

19-
// instantiate pwm_monitor
20-
foreach(m_pwm_monitor[i]) begin
20+
// Instantiate PWM monitors.
21+
foreach (m_pwm_monitor[i]) begin
2122
m_pwm_monitor[i] = pwm_monitor::type_id::create($sformatf("m_pwm_monitor%0d", i), this);
2223
uvm_config_db#(pwm_monitor_cfg)::set(this, $sformatf("m_pwm_monitor%0d", i), "cfg",
23-
cfg.m_pwm_monitor_cfg[i]);
24+
cfg.m_pwm_monitor_cfg[i]);
2425
cfg.m_pwm_monitor_cfg[i].ok_to_end_delay_ns = 2000;
2526
end
2627

@@ -31,8 +32,9 @@ class pwm_env extends cip_base_env #(
3132
end
3233

3334
cfg.clk_rst_core_vif.set_freq_mhz(cfg.get_clk_core_freq());
34-
`uvm_info(`gfn, $sformatf("\n env_cfg: bus_clk %0d Mhz, core_clk %0d Mhz",
35-
cfg.clk_rst_vif.clk_freq_mhz, cfg.clk_rst_core_vif.clk_freq_mhz), UVM_DEBUG)
35+
`uvm_info(`gfn, $sformatf("\n env_cfg: bus_clk %0d MHz, core_clk %0d MHz",
36+
cfg.clk_rst_vif.clk_freq_mhz, cfg.clk_rst_core_vif.clk_freq_mhz),
37+
UVM_DEBUG)
3638
endfunction : build_phase
3739

3840
function void connect_phase(uvm_phase phase);

hw/ip/pwm/dv/env/pwm_env_cfg.sv

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ class pwm_env_cfg extends cip_base_env_cfg #(.RAL_T(pwm_reg_block));
88

99
`uvm_object_new
1010

11-
// configs
12-
pwm_monitor_cfg m_pwm_monitor_cfg[PWM_NUM_CHANNELS];
11+
// Configuration for each monitor in turn.
12+
pwm_monitor_cfg m_pwm_monitor_cfg[PWM_NUM_CHANNELS];
1313

14-
// virtual ifs
15-
virtual clk_rst_if clk_rst_core_vif;
14+
// Interface to the core clock on which the DUT logic itself runs. This logic remains active
15+
// even when the bus interface is in a low power state (TL-UL clock stopped).
16+
virtual clk_rst_if clk_rst_core_vif;
1617

1718
// A scaling used to convert from the clock frequency in clk_rst_vif (the bus clock) to the core
1819
// clock. This is a ratio, but scaled so 1.0 is represented by 1024. The scaling is constrained to
@@ -23,26 +24,28 @@ class pwm_env_cfg extends cip_base_env_cfg #(.RAL_T(pwm_reg_block));
2324
// Method from dv_base_env_cfg. Construct RAL models and fill in monitor configs.
2425
extern virtual function void initialize(bit [31:0] csr_base_addr = '1);
2526

26-
// Return the scaled frequency in MHz for the core
27+
// Return the scaled core clock frequency in MHz.
2728
extern virtual function int get_clk_core_freq();
2829
endclass : pwm_env_cfg
2930

3031
function void pwm_env_cfg::initialize(bit [31:0] csr_base_addr = '1);
3132
list_of_alerts = pwm_env_pkg::LIST_OF_ALERTS;
3233
super.initialize(csr_base_addr);
3334

34-
// create pwm_agent_cfg
35+
// Set up the configuration for each of the monitors.
3536
foreach (m_pwm_monitor_cfg[i]) begin
3637
m_pwm_monitor_cfg[i] = pwm_monitor_cfg::type_id::create($sformatf("m_pwm_monitor%0d_cfg", i));
3738
m_pwm_monitor_cfg[i].if_mode = Device;
3839
m_pwm_monitor_cfg[i].is_active = 0;
40+
// Monitors identify themselves and their sequence items, for diagnostic/debugging purposes.
3941
m_pwm_monitor_cfg[i].monitor_id = i;
4042
end
4143

42-
// only support 1 outstanding TL items in tlul_adapter
44+
// Support only a single outstanding TL item in tlul_adapter
4345
m_tl_agent_cfg.max_outstanding_req = 1;
4446
endfunction
4547

48+
// Return the scaled core clock frequency in MHz.
4649
function int pwm_env_cfg::get_clk_core_freq();
4750
real scaled = clk_rst_vif.clk_freq_mhz * clk_scale / 1024;
4851
`DV_CHECK_FATAL(clk_rst_vif.clk_freq_mhz > 0)

hw/ip/pwm/dv/env/pwm_env_pkg.sv

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// SPDX-License-Identifier: Apache-2.0
44

55
package pwm_env_pkg;
6-
// dep packages
76
import uvm_pkg::*;
87
import top_pkg::*;
98
import dv_utils_pkg::*;
@@ -18,32 +17,33 @@ package pwm_env_pkg;
1817

1918
parameter uint PWM_NUM_CHANNELS = pwm_reg_pkg::NOutputs;
2019

21-
// macro includes
2220
`include "uvm_macros.svh"
2321
`include "dv_macros.svh"
2422

25-
// parameters
26-
// alerts
23+
// The DUT has a single alert signal.
2724
parameter uint NUM_ALERTS = 1;
2825
parameter string LIST_OF_ALERTS[] = {"fatal_fault"};
26+
27+
// Constants.
2928
parameter bit [31:0] MAX_32 = 32'hFFFF_FFFF;
3029
parameter bit [15:0] MAX_16 = 16'hFFFF;
3130
parameter bit [26:0] MAX_27 = 27'h7FF_FFFF;
31+
32+
// Duration of test in core clock cycles.
3233
parameter uint NUM_CYCLES = 'd1_049_000;
33-
parameter bit [26:0] MAX_CLK_DIV = 15;
3434

35-
// datatype
36-
typedef enum bit {
37-
Enable = 1'b1,
38-
Disable = 1'b0
39-
} pwm_status_e;
35+
// The DUT has a very flexible interface, clearly intended to support a wide range of bus and
36+
// core clock frequencies; however, large values of `CLK_DIV` are impractical in simulation.
37+
parameter bit [26:0] MAX_CLK_DIV = 15;
4038

39+
// Phase counter configuration (CFG).
4140
typedef struct packed {
4241
bit [26:0] ClkDiv;
4342
bit [3:0] DcResn;
4443
bit CntrEn;
4544
} cfg_reg_t;
4645

46+
// Channel parameters (PWM_PARAM_i register).
4747
typedef struct packed {
4848
bit BlinkEn;
4949
bit HtbtEn;
@@ -62,14 +62,14 @@ package pwm_env_pkg;
6262
bit [15:0] X;
6363
} blink_param_t;
6464

65-
// the index of multi-reg is at the last char of the name
65+
// The index of a multi-reg is given by the last character of the name, since there are fewer
66+
// than ten channels.
6667
function automatic int get_multireg_idx(string name);
6768
string s = name.getc(name.len - 1);
6869
return s.atoi();
6970
endfunction
7071

71-
// package sources
72-
`include "pwm_seq_cfg.sv"
72+
// Package sources
7373
`include "pwm_env_cfg.sv"
7474
`include "pwm_env_cov.sv"
7575
`include "pwm_virtual_sequencer.sv"

0 commit comments

Comments
 (0)