Skip to content

Commit 80590e0

Browse files
committed
[hw,pwm,dv] Templify DV for module_instance_name
Signed-off-by: Robert Schilling <[email protected]>
1 parent ab150bb commit 80590e0

25 files changed

+198
-198
lines changed

hw/ip_templates/pwm/dv/README.md.tpl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ that are common across the project:
4040

4141
${"###"} Global types & methods
4242
All common types and methods defined at the package level can be found in
43-
`pwm_env_pkg`. Some of them in use are:
43+
`${module_instance_name}_env_pkg`. Some of them in use are:
4444
```systemverilog
4545
parameter uint NUM_PWM_CHANNELS = 6;
4646

@@ -96,8 +96,8 @@ It can be created manually by invoking [`regtool`](../../../../../util/reggen/do
9696
${"###"} Stimulus strategy
9797
${"####"} Test sequences
9898
All test sequences reside in `hw/ip/pwm/dv/env/seq_lib`.
99-
The `pwm_base_vseq` virtual sequence is extended from `cip_base_vseq` and serves as a starting point.
100-
All test sequences are extended from `pwm_base_vseq`.
99+
The `${module_instance_name}_base_vseq` virtual sequence is extended from `cip_base_vseq` and serves as a starting point.
100+
All test sequences are extended from `${module_instance_name}_base_vseq`.
101101
It provides commonly-used handles, variables, functions and tasks that the test sequences can simple use / call.
102102

103103
Some of the most commonly-used tasks / functions are as follows:
@@ -115,7 +115,7 @@ The functional coverage plan can be found here: [coverageplan](#testplan)
115115

116116
${"###"} Self-checking strategy
117117
${"####"} Scoreboard
118-
The `pwm_scoreboard` is primarily used for transaction-by-transaction checking.
118+
The `${module_instance_name}_scoreboard` is primarily used for transaction-by-transaction checking.
119119
It creates the following analysis ports to retrieve the data monitored by corresponding interface agents:
120120
* item_fifo[NUM_PWM_CHANNELS]: the FIFO w.r.t channels receives the dut items sent by the pwm_monitor
121121
* exp_item : It is used to store the expected item constructed from tl address and data channels.
@@ -131,7 +131,7 @@ For blink and heart beat mode after an item is compared successfully the scorebo
131131
If an error is found the scoreboard will throw an error.
132132

133133
${"####"} Assertions
134-
* TLUL assertions: The `tb/pwm_bind.sv` binds the `tlul_assert` [assertions](../../../../ip/tlul/doc/TlulProtocolChecker.md) to the IP to ensure TileLink interface protocol compliance.
134+
* TLUL assertions: The `tb/${module_instance_name}_bind.sv` binds the `tlul_assert` [assertions](../../../../ip/tlul/doc/TlulProtocolChecker.md) to the IP to ensure TileLink interface protocol compliance.
135135
* Unknown checks on DUT outputs: The RTL has assertions to ensure all outputs are initialized to known values after coming out of reset.
136136

137137

hw/ip_templates/pwm/dv/env/pwm_env.core.tpl

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,30 @@ filesets:
1212
- ${instance_vlnv(f"lowrisc:ip:{module_instance_name}:0.1")}
1313
- lowrisc:dv:pwm_monitor
1414
files:
15-
- pwm_env_pkg.sv
16-
- pwm_env_cfg.sv: {is_include_file: true}
17-
- pwm_env_cov.sv: {is_include_file: true}
18-
- pwm_virtual_sequencer.sv: {is_include_file: true}
19-
- pwm_scoreboard.sv: {is_include_file: true}
20-
- pwm_env.sv: {is_include_file: true}
21-
- seq_lib/pwm_vseq_list.sv: {is_include_file: true}
22-
- seq_lib/pwm_base_vseq.sv: {is_include_file: true}
23-
- seq_lib/pwm_common_vseq.sv: {is_include_file: true}
24-
- seq_lib/pwm_phase_vseq.sv: {is_include_file: true}
25-
- seq_lib/pwm_smoke_vseq.sv: {is_include_file: true}
26-
- seq_lib/pwm_rand_output_vseq.sv: {is_include_file: true}
27-
- seq_lib/pwm_heartbeat_wrap_vseq.sv: {is_include_file: true}
28-
- seq_lib/pwm_perf_vseq.sv: {is_include_file: true}
29-
- seq_lib/pwm_regwen_vseq.sv: {is_include_file: true}
30-
- seq_lib/pwm_stress_all_vseq.sv: {is_include_file: true}
15+
- ${module_instance_name}_env_pkg.sv
16+
- ${module_instance_name}_env_cfg.sv: {is_include_file: true}
17+
- ${module_instance_name}_env_cov.sv: {is_include_file: true}
18+
- ${module_instance_name}_virtual_sequencer.sv: {is_include_file: true}
19+
- ${module_instance_name}_scoreboard.sv: {is_include_file: true}
20+
- ${module_instance_name}_env.sv: {is_include_file: true}
21+
- seq_lib/${module_instance_name}_vseq_list.sv: {is_include_file: true}
22+
- seq_lib/${module_instance_name}_base_vseq.sv: {is_include_file: true}
23+
- seq_lib/${module_instance_name}_common_vseq.sv: {is_include_file: true}
24+
- seq_lib/${module_instance_name}_phase_vseq.sv: {is_include_file: true}
25+
- seq_lib/${module_instance_name}_smoke_vseq.sv: {is_include_file: true}
26+
- seq_lib/${module_instance_name}_rand_output_vseq.sv: {is_include_file: true}
27+
- seq_lib/${module_instance_name}_heartbeat_wrap_vseq.sv: {is_include_file: true}
28+
- seq_lib/${module_instance_name}_perf_vseq.sv: {is_include_file: true}
29+
- seq_lib/${module_instance_name}_regwen_vseq.sv: {is_include_file: true}
30+
- seq_lib/${module_instance_name}_stress_all_vseq.sv: {is_include_file: true}
3131
file_type: systemVerilogSource
3232

3333
generate:
3434
ral:
3535
generator: ralgen
3636
parameters:
37-
name: pwm
38-
ip_hjson: ../../data/pwm.hjson
37+
name: ${module_instance_name}
38+
ip_hjson: ../../data/${module_instance_name}.hjson
3939
position: prepend
4040

4141
targets:

hw/ip_templates/pwm/dv/env/pwm_env.sv renamed to hw/ip_templates/pwm/dv/env/pwm_env.sv.tpl

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

5-
class pwm_env extends cip_base_env #(
6-
.CFG_T (pwm_env_cfg),
7-
.COV_T (pwm_env_cov),
8-
.VIRTUAL_SEQUENCER_T(pwm_virtual_sequencer),
9-
.SCOREBOARD_T (pwm_scoreboard)
5+
class ${module_instance_name}_env extends cip_base_env #(
6+
.CFG_T (${module_instance_name}_env_cfg),
7+
.COV_T (${module_instance_name}_env_cov),
8+
.VIRTUAL_SEQUENCER_T(${module_instance_name}_virtual_sequencer),
9+
.SCOREBOARD_T (${module_instance_name}_scoreboard)
1010
);
11-
`uvm_component_utils(pwm_env)
11+
`uvm_component_utils(${module_instance_name}_env)
1212
`uvm_component_new
1313

1414
// One monitor for each channel; the monitors operate independently.
@@ -28,7 +28,7 @@ class pwm_env extends cip_base_env #(
2828
// generate core clock (must slower than bus clock)
2929
if (!uvm_config_db#(virtual clk_rst_if)
3030
::get(this, "", "clk_rst_core_vif", cfg.clk_rst_core_vif)) begin
31-
`uvm_fatal(`gfn, "\n pwm_env: failed to get clk_rst_core_vif from uvm_config_db")
31+
`uvm_fatal(`gfn, "\n ${module_instance_name}_env: failed to get clk_rst_core_vif from uvm_config_db")
3232
end
3333

3434
cfg.clk_rst_core_vif.set_freq_mhz(cfg.get_clk_core_freq());
@@ -46,4 +46,4 @@ class pwm_env extends cip_base_env #(
4646
end
4747
endfunction : connect_phase
4848

49-
endclass : pwm_env
49+
endclass : ${module_instance_name}_env

hw/ip_templates/pwm/dv/env/pwm_env_cfg.sv renamed to hw/ip_templates/pwm/dv/env/pwm_env_cfg.sv.tpl

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

5-
class pwm_env_cfg extends cip_base_env_cfg #(.RAL_T(pwm_reg_block));
6-
`uvm_object_utils_begin(pwm_env_cfg)
5+
class ${module_instance_name}_env_cfg extends cip_base_env_cfg #(.RAL_T(${module_instance_name}_reg_block));
6+
`uvm_object_utils_begin(${module_instance_name}_env_cfg)
77
`uvm_object_utils_end
88

99
`uvm_object_new
@@ -26,10 +26,10 @@ class pwm_env_cfg extends cip_base_env_cfg #(.RAL_T(pwm_reg_block));
2626

2727
// Return the scaled core clock frequency in MHz.
2828
extern virtual function int get_clk_core_freq();
29-
endclass : pwm_env_cfg
29+
endclass : ${module_instance_name}_env_cfg
3030

31-
function void pwm_env_cfg::initialize(bit [31:0] csr_base_addr = '1);
32-
list_of_alerts = pwm_env_pkg::LIST_OF_ALERTS;
31+
function void ${module_instance_name}_env_cfg::initialize(bit [31:0] csr_base_addr = '1);
32+
list_of_alerts = ${module_instance_name}_env_pkg::LIST_OF_ALERTS;
3333
super.initialize(csr_base_addr);
3434

3535
// Set up the configuration for each of the monitors.
@@ -46,7 +46,7 @@ function void pwm_env_cfg::initialize(bit [31:0] csr_base_addr = '1);
4646
endfunction
4747

4848
// Return the scaled core clock frequency in MHz.
49-
function int pwm_env_cfg::get_clk_core_freq();
49+
function int ${module_instance_name}_env_cfg::get_clk_core_freq();
5050
real scaled = clk_rst_vif.clk_freq_mhz * clk_scale / 1024;
5151
`DV_CHECK_FATAL(clk_rst_vif.clk_freq_mhz > 0)
5252
`DV_CHECK_FATAL(scaled > 0)

hw/ip_templates/pwm/dv/env/pwm_env_cov.sv renamed to hw/ip_templates/pwm/dv/env/pwm_env_cov.sv.tpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
* Covergroups may also be wrapped inside helper classes if needed.
99
*/
1010

11-
class pwm_env_cov extends cip_base_env_cov #(.CFG_T(pwm_env_cfg));
12-
`uvm_component_utils(pwm_env_cov)
11+
class ${module_instance_name}_env_cov extends cip_base_env_cov #(.CFG_T(${module_instance_name}_env_cfg));
12+
`uvm_component_utils(${module_instance_name}_env_cov)
1313

1414
// the base class provides the following handles for use:
15-
// pwm_env_cfg: cfg
15+
// ${module_instance_name}_env_cfg: cfg
1616

1717
// covergroups
1818

hw/ip_templates/pwm/dv/env/pwm_env_pkg.sv renamed to hw/ip_templates/pwm/dv/env/pwm_env_pkg.sv.tpl

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

5-
package pwm_env_pkg;
5+
package ${module_instance_name}_env_pkg;
66
import uvm_pkg::*;
77
import top_pkg::*;
88
import dv_utils_pkg::*;
@@ -12,10 +12,10 @@ package pwm_env_pkg;
1212
import dv_base_reg_pkg::*;
1313
import csr_utils_pkg::*;
1414
import pwm_monitor_pkg::*;
15-
import pwm_reg_pkg::*;
16-
import pwm_ral_pkg::*;
15+
import ${module_instance_name}_reg_pkg::*;
16+
import ${module_instance_name}_ral_pkg::*;
1717

18-
parameter uint PWM_NUM_CHANNELS = pwm_reg_pkg::NOutputs;
18+
parameter uint PWM_NUM_CHANNELS = ${module_instance_name}_reg_pkg::NOutputs;
1919

2020
`include "uvm_macros.svh"
2121
`include "dv_macros.svh"
@@ -73,11 +73,11 @@ package pwm_env_pkg;
7373
endfunction
7474

7575
// Package sources
76-
`include "pwm_env_cfg.sv"
77-
`include "pwm_env_cov.sv"
78-
`include "pwm_virtual_sequencer.sv"
79-
`include "pwm_scoreboard.sv"
80-
`include "pwm_env.sv"
81-
`include "pwm_vseq_list.sv"
76+
`include "${module_instance_name}_env_cfg.sv"
77+
`include "${module_instance_name}_env_cov.sv"
78+
`include "${module_instance_name}_virtual_sequencer.sv"
79+
`include "${module_instance_name}_scoreboard.sv"
80+
`include "${module_instance_name}_env.sv"
81+
`include "${module_instance_name}_vseq_list.sv"
8282

83-
endpackage : pwm_env_pkg
83+
endpackage : ${module_instance_name}_env_pkg

hw/ip_templates/pwm/dv/env/pwm_scoreboard.sv renamed to hw/ip_templates/pwm/dv/env/pwm_scoreboard.sv.tpl

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

5-
class pwm_scoreboard extends cip_base_scoreboard #(
6-
.CFG_T(pwm_env_cfg),
7-
.RAL_T(pwm_reg_block),
8-
.COV_T(pwm_env_cov)
5+
class ${module_instance_name}_scoreboard extends cip_base_scoreboard #(
6+
.CFG_T(${module_instance_name}_env_cfg),
7+
.RAL_T(${module_instance_name}_reg_block),
8+
.COV_T(${module_instance_name}_env_cov)
99
);
10-
`uvm_component_utils(pwm_scoreboard)
10+
`uvm_component_utils(${module_instance_name}_scoreboard)
1111
`uvm_component_new
1212

1313
// TLM agent FIFOs.
@@ -85,16 +85,16 @@ class pwm_scoreboard extends cip_base_scoreboard #(
8585
// configuration registers.
8686
extern function void generate_exp_item(ref pwm_item item, input int unsigned channel);
8787

88-
endclass : pwm_scoreboard
88+
endclass : ${module_instance_name}_scoreboard
8989

90-
function void pwm_scoreboard::build_phase(uvm_phase phase);
90+
function void ${module_instance_name}_scoreboard::build_phase(uvm_phase phase);
9191
super.build_phase(phase);
9292
for (int i = 0; i < PWM_NUM_CHANNELS; i++) begin
9393
item_fifo[i] = new($sformatf("item_fifo[%0d]", i), this);
9494
end
9595
endfunction
9696

97-
task pwm_scoreboard::run_phase(uvm_phase phase);
97+
task ${module_instance_name}_scoreboard::run_phase(uvm_phase phase);
9898
super.run_phase(phase);
9999
if (cfg.en_scb) begin
100100
// For each PWM output create one checker process and one clock/output monitor process.
@@ -112,14 +112,14 @@ task pwm_scoreboard::run_phase(uvm_phase phase);
112112
end
113113
endtask
114114

115-
function void pwm_scoreboard::check_phase(uvm_phase phase);
115+
function void ${module_instance_name}_scoreboard::check_phase(uvm_phase phase);
116116
super.check_phase(phase);
117117
for (int i = 0; i < PWM_NUM_CHANNELS; i++) begin
118118
`DV_EOT_PRINT_TLM_FIFO_CONTENTS(pwm_item, item_fifo[i])
119119
end
120120
endfunction
121121

122-
task pwm_scoreboard::process_tl_access(tl_seq_item item,
122+
task ${module_instance_name}_scoreboard::process_tl_access(tl_seq_item item,
123123
tl_channels_e channel,
124124
string ral_name);
125125
string txt;
@@ -271,7 +271,7 @@ task pwm_scoreboard::process_tl_access(tl_seq_item item,
271271
end
272272
endtask
273273

274-
function void pwm_scoreboard::reset(string kind = "HARD");
274+
function void ${module_instance_name}_scoreboard::reset(string kind = "HARD");
275275
super.reset(kind);
276276
`uvm_info(`gfn, "Reset flushing all channels", UVM_MEDIUM)
277277
for (int unsigned channel = 0; channel < PWM_NUM_CHANNELS; channel++) begin
@@ -281,7 +281,7 @@ function void pwm_scoreboard::reset(string kind = "HARD");
281281
endfunction
282282

283283
// Monitor whether the TL-UL clock is running and whether the PWM output is changing.
284-
task pwm_scoreboard::monitor_clock(int channel);
284+
task ${module_instance_name}_scoreboard::monitor_clock(int channel);
285285
forever begin
286286
// The core clock is always running so we may use this to monitor whether the TL-UL bus clock
287287
// is gated.
@@ -299,14 +299,14 @@ endtask
299299
// We allow a little difference in the timing of the blink state transitions until we've
300300
// synchronized to this PWM output. Until that point a mismatch may legitimately occur between
301301
// the observed and predicted cycles.
302-
function bit pwm_scoreboard::blink_state_untrusted(int unsigned channel);
302+
function bit ${module_instance_name}_scoreboard::blink_state_untrusted(int unsigned channel);
303303
// Until we've synchronized, drift is permitted in either direction.
304304
return !synchronized[channel] &&
305305
(blink_cnt[channel] < SettleTime || ignore_state_change[channel] > 0);
306306
endfunction
307307

308308
// Adjust channel state to synchronize with the monitor/DUT output.
309-
function void pwm_scoreboard::synchronize_blink_state(int unsigned channel);
309+
function void ${module_instance_name}_scoreboard::synchronize_blink_state(int unsigned channel);
310310
`uvm_info(`gfn, $sformatf("Synchronizing on channel %0d (ignore %0d blink_cnt %0d)", channel,
311311
ignore_state_change[channel], blink_cnt[channel]), UVM_MEDIUM)
312312
if (ignore_state_change[channel] > 0) begin
@@ -331,7 +331,7 @@ function void pwm_scoreboard::synchronize_blink_state(int unsigned channel);
331331
ignore_state_change[channel] = 0;
332332
endfunction
333333

334-
task pwm_scoreboard::compare_trans(int unsigned channel);
334+
task ${module_instance_name}_scoreboard::compare_trans(int unsigned channel);
335335
pwm_item compare_item = new($sformatf("expected_item_%0d", channel));
336336
pwm_item input_item = new($sformatf("input_item_%0d", channel));
337337
// Count of predictions made.
@@ -436,7 +436,7 @@ task pwm_scoreboard::compare_trans(int unsigned channel);
436436
endtask : compare_trans
437437

438438
// Advance the blink state at the end of the 'BLINK_PARAM.X+1' or 'BLINK_PARAM.Y+1' pulse cycles.
439-
function void pwm_scoreboard::advance_blink_state(int unsigned channel);
439+
function void ${module_instance_name}_scoreboard::advance_blink_state(int unsigned channel);
440440
`uvm_info(`gfn, $sformatf("Advancing blink state for channel %0d", channel), UVM_HIGH)
441441
if (channel_param[channel].HtbtEn) begin
442442
dc_mod_e dc_mod = (duty_cycle[channel].A > duty_cycle[channel].B) ? LargeA : LargeB;
@@ -500,7 +500,7 @@ function void pwm_scoreboard::advance_blink_state(int unsigned channel);
500500
end
501501
endfunction
502502

503-
function void pwm_scoreboard::generate_exp_item(ref pwm_item item, input int unsigned channel);
503+
function void ${module_instance_name}_scoreboard::generate_exp_item(ref pwm_item item, input int unsigned channel);
504504
uint beats_cycle = 0;
505505
uint period = 0;
506506
uint active_cycles = 0;

hw/ip_templates/pwm/dv/env/pwm_virtual_sequencer.sv

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright lowRISC contributors (OpenTitan project).
2+
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
3+
// SPDX-License-Identifier: Apache-2.0
4+
5+
class ${module_instance_name}_virtual_sequencer extends cip_base_virtual_sequencer #(
6+
.CFG_T(${module_instance_name}_env_cfg),
7+
.COV_T(${module_instance_name}_env_cov)
8+
);
9+
10+
`uvm_component_utils(${module_instance_name}_virtual_sequencer)
11+
`uvm_component_new
12+
13+
endclass : ${module_instance_name}_virtual_sequencer

0 commit comments

Comments
 (0)