Skip to content

Commit 5c6198f

Browse files
committed
[acrc, dv] Autogen DV Darjeeling AC Range Check IP
- Run the command: util/ipgen.py generate \ -C hw/ip_templates/ac_range_check \ -o hw/top_darjeeling/ip_autogen/ac_range_check \ -c hw/top_darjeeling/ip_autogen/ac_range_check/data/\ top_darjeeling_ac_range_check.ipconfig.hjson -f Signed-off-by: Martin Velay <[email protected]>
1 parent 34efc38 commit 5c6198f

22 files changed

+4824
-0
lines changed

hw/top_darjeeling/ip_autogen/ac_range_check/doc/checklist.md

Lines changed: 275 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# AC_RANGE_CHECK DV document
2+
3+
## Goals
4+
* **DV**
5+
* Verify all AC_RANGE_CHECK IP features by running dynamic simulations with a SV/UVM based testbench
6+
* Develop and run all tests based on the [testplan](#testplan) below towards closing code and functional coverage on the IP and all of its sub-modules
7+
* **FPV**
8+
* Verify TileLink device protocol compliance with an SVA based testbench
9+
10+
## Current status
11+
* [Design & verification stage](../../../../README.md)
12+
* [HW development stages](../../../../../doc/project_governance/development_stages.md)
13+
* [Simulation results](https://reports.opentitan.org/hw/top_darjeeling/ip_autogen/ac_range_check/dv/latest/report.html)
14+
15+
## Design features
16+
For detailed information on `ac_range_check` design features, please see the [`ac_range_check` HWIP technical specification](../README.md).
17+
18+
## Testbench architecture
19+
The `ac_range_check` UVM DV testbench has been constructed based on the [CIP testbench architecture](../../../../dv/sv/cip_lib/README.md).
20+
21+
### Block diagram
22+
![Block diagram](./doc/tb.svg)
23+
24+
### Top level testbench
25+
Top level testbench is located at `hw/top_darjeeling/ip_autogen/ac_range_check/dv/tb/tb.sv`.
26+
It instantiates the `ac_range_check` DUT module `hw/ip/ac_range_check/rtl/ac_range_check.sv`.
27+
In addition, the testbench instantiates the following interfaces, connects them to the DUT and sets their handle into `uvm_config_db`:
28+
* [Clock and reset interface](../../../../dv/sv/common_ifs/README.md)
29+
* [Reset shadowed interface](../../../../dv/sv/common_ifs/README.md) // TODO add something in this doc about this interface.
30+
* [TileLink host interface for the CSRs](../../../../dv/sv/tl_agent/README.md)
31+
* [TileLink host interface for the Unfiltered CTN accesses](../../../../dv/sv/tl_agent/README.md)
32+
* [TileLink device interface for the Filtered CTN accesses](../../../../dv/sv/tl_agent/README.md)
33+
* Interrupts ([`pins_if`](../../../../dv/sv/common_ifs/README.md))
34+
* Alerts ([`alert_esc_if`](../../../../dv/sv/alert_esc_agent/README.md))
35+
36+
37+
### Common DV utility components
38+
The following utilities provide generic helper tasks and functions to perform activities that are common across the project:
39+
* [dv_utils_pkg](../../../../dv/sv/dv_utils/README.md)
40+
* [csr_utils_pkg](../../../../dv/sv/csr_utils/README.md)
41+
42+
### Compile-time configurations
43+
[list compile time configurations, if any and what are they used for]
44+
45+
### Global types & methods
46+
All common types and methods defined at the package level can be found in `ac_range_check_env_pkg`.
47+
Some of them in use are:
48+
```systemverilog
49+
[list a few parameters, types & methods; no need to mention all]
50+
```
51+
52+
### TL_agent
53+
* `ac_range_check` UVM environment instantiates a (already handled in CIP base env) [tl_agent](../../../../dv/sv/tl_agent/README.md) which provides the ability to drive and independently monitor random traffic via TL host interface into `ac_range_check` device, to access to the CSRs (Control/Status Registers).
54+
* Host interface to the Unfiltered CTN accesses.
55+
* Device interface to the Filtered CTN accesses.
56+
57+
The `tl_agent` monitor supplies partial TileLink request packets as well as completed TileLink response packets over the TLM analysis port for further processing within the `ac_range_check` scoreboard.
58+
59+
### Alert_agent
60+
`ac_range_check` testbench instantiates (already handled in CIP base env) [alert_agents](../../../../dv/sv/alert_esc_agent/README.md):
61+
[list alert names].
62+
The alert_agents provide the ability to drive and independently monitor alert handshakes via alert interfaces in AC_RANGE_CHECK device.
63+
64+
### UVM RAL Model
65+
The `ac_range_check` RAL model is created with the [`ralgen`](../../../../dv/tools/ralgen/README.md) FuseSoC generator script automatically when the simulation is at the build stage.
66+
67+
It can be created manually by invoking [`regtool`](../../../../../util/reggen/doc/setup_and_use.md):
68+
69+
#### Sequence cfg
70+
An efficient way to develop test sequences is by providing some random variables that are used to configure the DUT / drive stimulus.
71+
The random variables are constrained using weights and knobs that can be controlled.
72+
These weights and knobs take on a "default" value that will result in the widest exploration of the design state space, when the test sequence is randomized and run as-is.
73+
To steer the randomization towards a particular distribution or to achieve interesting combinations of the random variables, the test sequence can be extended to create a specialized variant.
74+
In this extended sequence, nothing would need to be done, other than setting those weights and knobs appropriately.
75+
This helps increase the likelihood of hitting the design corners that would otherwise be difficult to achieve, while maximizing reuse.
76+
77+
This object aims to provide such run-time controls.
78+
79+
#### Env cfg
80+
The `ac_range_check_env_cfg`, environment configuration object provides access to the following elements:
81+
* Build-time controls to configure the UVM environment composition during the `build_phase`
82+
* Downstream agent configuration objects for ease of lookup from any environment component
83+
* This includes the `tl_agent_cfg` objects for both TL interfaces
84+
* All virtual interfaces that connect to the DUT listed above (retrieved from the `uvm_config_db`)
85+
* Sequence configuration object described above
86+
87+
All environment components contain a handle to an instance of this class (that was created in the test class via the parent `dv_base_test`).
88+
By housing all of the above, all pertinent information is more easily shared with all environment components.
89+
90+
### Stimulus strategy
91+
#### Test sequences
92+
All test sequences reside in `hw/top_darjeeling/ip_autogen/ac_range_check/dv/env/seq_lib`.
93+
The `ac_range_check_base_vseq` virtual sequence is extended from `cip_base_vseq` and serves as a starting point.
94+
All test sequences are extended from `ac_range_check_base_vseq`.
95+
It provides commonly used handles, variables, functions and tasks that the test sequences can simple use / call.
96+
Some of the most commonly used tasks / functions are as follows: From `hw/top_darjeeling/ip_autogen/ac_range_check/dv/env/seq/ac_range_check_base_vseq.sv`,
97+
* task 1:
98+
* task 2:
99+
100+
#### Functional coverage
101+
To ensure high quality constrained random stimulus, it is necessary to develop a functional coverage model.
102+
The following covergroups have been developed to prove that the test intent has been adequately met:
103+
* cg1:
104+
* cg2:
105+
106+
### Self-checking strategy
107+
#### Scoreboard
108+
It creates the following analysis ports to retrieve the data monitored by corresponding interface agents:
109+
* analysis port1:
110+
* analysis port2:
111+
<!-- explain inputs monitored, flow of data and outputs checked -->
112+
113+
#### Assertions
114+
* TLUL assertions: The `hw/top_darjeeling/ip_autogen/ac_range_check/dv/sva/ac_range_check_bind.sv` binds the `tlul_assert` [assertions](../../../../ip/tlul/doc/TlulProtocolChecker.md) to the IP to ensure TileLink interface protocol compliance.
115+
* Unknown checks on DUT outputs: The RTL has assertions to ensure all outputs are initialized to known values after coming out of reset.
116+
* assert prop 1:
117+
* assert prop 2:
118+
119+
## Building and running tests
120+
We are using our in-house developed [regression tool](../../../../../util/dvsim/README.md) for building and running our tests and regressions.
121+
Please take a look at the link for detailed information on the usage, capabilities, features and known issues.
122+
Here's how to run a smoke test:
123+
```console
124+
$ cd $REPO_TOP
125+
$ ./util/dvsim/dvsim.py hw/top_darjeeling/ip_autogen/ac_range_check/dv/ac_range_check_sim_cfg.hjson -i ac_range_check_smoke
126+
```
127+
128+
## Testplan
129+
[Testplan](../data/ac_range_check_testplan.hjson)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
CAPI=2:
2+
# Copyright lowRISC contributors (OpenTitan project).
3+
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
4+
# SPDX-License-Identifier: Apache-2.0
5+
name: lowrisc:opentitan:top_darjeeling_ac_range_check_sim:0.1
6+
description: "AC_RANGE_CHECK DV sim target"
7+
filesets:
8+
files_rtl:
9+
depend:
10+
- lowrisc:ip:tlul
11+
- lowrisc:opentitan:top_darjeeling_ac_range_check:0.1
12+
file_type: systemVerilogSource
13+
14+
files_dv:
15+
depend:
16+
- lowrisc:opentitan:top_darjeeling_ac_range_check_test
17+
- lowrisc:opentitan:top_darjeeling_ac_range_check_sva
18+
- lowrisc:opentitan:top_darjeeling_ac_range_check_cov
19+
files:
20+
- tb/tb.sv
21+
file_type: systemVerilogSource
22+
23+
targets:
24+
sim: &sim_target
25+
toplevel: tb
26+
filesets:
27+
- files_rtl
28+
- files_dv
29+
default_tool: xcelium
30+
31+
lint:
32+
<<: *sim_target
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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+
// Name of the sim cfg - typically same as the name of the DUT.
6+
name: ac_range_check
7+
8+
// Top level dut name (sv module).
9+
dut: ac_range_check
10+
11+
// Top level testbench name (sv module).
12+
tb: tb
13+
14+
// Simulator used to sign off this block
15+
tool: xcelium
16+
17+
// Fusesoc core file used for building the file list.
18+
fusesoc_core: lowrisc:opentitan:top_darjeeling_ac_range_check_sim:0.1
19+
20+
// Testplan hjson file.
21+
testplan: "{self_dir}/../data/ac_range_check_testplan.hjson"
22+
23+
// Import additional common sim cfg files.
24+
import_cfgs: [// Project wide common sim cfg file
25+
"{proj_root}/hw/dv/tools/dvsim/common_sim_cfg.hjson",
26+
// Common CIP test lists
27+
"{proj_root}/hw/dv/tools/dvsim/tests/csr_tests.hjson",
28+
"{proj_root}/hw/dv/tools/dvsim/tests/mem_tests.hjson", // TODO MVy needed?
29+
"{proj_root}/hw/dv/tools/dvsim/tests/intr_test.hjson",
30+
"{proj_root}/hw/dv/tools/dvsim/tests/alert_test.hjson",
31+
"{proj_root}/hw/dv/tools/dvsim/tests/shadow_reg_errors_tests.hjson",
32+
"{proj_root}/hw/dv/tools/dvsim/tests/tl_access_tests.hjson",
33+
"{proj_root}/hw/dv/tools/dvsim/tests/sec_cm_tests.hjson", // TODO MVy needed?
34+
"{proj_root}/hw/dv/tools/dvsim/tests/stress_tests.hjson"]
35+
36+
// Add additional tops for simulation.
37+
sim_tops: ["ac_range_check_bind"]
38+
39+
// Default iterations for all tests - each test entry can override this.
40+
reseed: 50
41+
42+
// Default UVM test and seq class name.
43+
uvm_test: ac_range_check_base_test
44+
uvm_test_seq: ac_range_check_base_vseq
45+
46+
// List of test specifications.
47+
tests: [
48+
{
49+
name: ac_range_check_smoke
50+
uvm_test_seq: ac_range_check_smoke_vseq
51+
}
52+
53+
// TODO: add more tests here
54+
]
55+
56+
// List of regressions.
57+
regressions: [
58+
{
59+
name: smoke
60+
tests: ["ac_range_check_smoke"]
61+
}
62+
]
63+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
CAPI=2:
2+
# Copyright lowRISC contributors (OpenTitan project).
3+
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
4+
# SPDX-License-Identifier: Apache-2.0
5+
name: "lowrisc:dv:ac_range_check_env:0.1"
6+
description: "AC_RANGE_CHECK DV UVM environment"
7+
filesets:
8+
files_dv:
9+
depend:
10+
- lowrisc:dv:ralgen
11+
- lowrisc:dv:cip_lib
12+
- lowrisc:dv:tl_agent
13+
- lowrisc:dv:dv_base_reg
14+
files:
15+
- ac_range_check_env_pkg.sv
16+
- ac_range_check_ral_pkg.sv
17+
- ac_range_check_env_cfg.sv: {is_include_file: true}
18+
- ac_range_check_env_cov.sv: {is_include_file: true}
19+
- ac_range_check_virtual_sequencer.sv: {is_include_file: true}
20+
- ac_range_check_scoreboard.sv: {is_include_file: true}
21+
- ac_range_check_env.sv: {is_include_file: true}
22+
- seq_lib/ac_range_check_vseq_list.sv: {is_include_file: true}
23+
- seq_lib/ac_range_check_base_vseq.sv: {is_include_file: true}
24+
- seq_lib/ac_range_check_common_vseq.sv: {is_include_file: true}
25+
- seq_lib/ac_range_check_smoke_vseq.sv: {is_include_file: true}
26+
file_type: systemVerilogSource
27+
28+
generate:
29+
ral:
30+
generator: ralgen
31+
parameters:
32+
name: ac_range_check
33+
ip_hjson: ../../data/ac_range_check.hjson
34+
35+
targets:
36+
default:
37+
filesets:
38+
- files_dv
39+
generate:
40+
- ral
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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 ac_range_check_env extends cip_base_env #(
6+
.CFG_T (ac_range_check_env_cfg),
7+
.COV_T (ac_range_check_env_cov),
8+
.VIRTUAL_SEQUENCER_T(ac_range_check_virtual_sequencer),
9+
.SCOREBOARD_T (ac_range_check_scoreboard)
10+
);
11+
`uvm_component_utils(ac_range_check_env)
12+
13+
tl_agent tl_csr_agt;
14+
tl_agent tl_unfilt_agt;
15+
tl_agent tl_filt_agt;
16+
17+
// Standard SV/UVM methods
18+
extern function new(string name="", uvm_component parent=null);
19+
extern function void build_phase(uvm_phase phase);
20+
extern function void connect_phase(uvm_phase phase);
21+
endclass : ac_range_check_env
22+
23+
24+
function ac_range_check_env::new(string name="", uvm_component parent=null);
25+
super.new(name, parent);
26+
endfunction : new
27+
28+
function void ac_range_check_env::build_phase(uvm_phase phase);
29+
super.build_phase(phase);
30+
31+
// Create CSR TL agent
32+
tl_csr_agt = tl_agent::type_id::create("tl_csr_agt", this);
33+
uvm_config_db#(tl_agent_cfg)::set(this, "tl_csr_agt*", "cfg", cfg.tl_csr_agt_cfg);
34+
cfg.tl_csr_agt_cfg.en_cov = cfg.en_cov;
35+
36+
// Create Unfiltered TL agent
37+
tl_unfilt_agt = tl_agent::type_id::create("tl_unfilt_agt", this);
38+
uvm_config_db#(tl_agent_cfg)::set(this, "tl_unfilt_agt*", "cfg", cfg.tl_unfilt_agt_cfg);
39+
cfg.tl_unfilt_agt_cfg.en_cov = cfg.en_cov;
40+
41+
// Create Fltered TL agent
42+
tl_filt_agt = tl_agent::type_id::create("tl_filt_agt", this);
43+
uvm_config_db#(tl_agent_cfg)::set(this, "tl_filt_agt*", "cfg", cfg.tl_filt_agt_cfg);
44+
cfg.tl_filt_agt_cfg.en_cov = cfg.en_cov;
45+
endfunction : build_phase
46+
47+
function void ac_range_check_env::connect_phase(uvm_phase phase);
48+
super.connect_phase(phase);
49+
if (cfg.en_scb) begin
50+
tl_csr_agt.monitor.analysis_port.connect(scoreboard.tl_csr_fifo.analysis_export);
51+
tl_unfilt_agt.monitor.analysis_port.connect(scoreboard.tl_unfilt_fifo.analysis_export);
52+
tl_filt_agt.monitor.analysis_port.connect(scoreboard.tl_filt_fifo.analysis_export);
53+
end
54+
if (cfg.is_active && cfg.tl_csr_agt_cfg.is_active) begin
55+
virtual_sequencer.tl_csr_sqr = tl_csr_agt.sequencer;
56+
end
57+
if (cfg.is_active && cfg.tl_unfilt_agt_cfg.is_active) begin
58+
virtual_sequencer.tl_unfilt_sqr = tl_unfilt_agt.sequencer;
59+
end
60+
if (cfg.is_active && cfg.tl_filt_agt_cfg.is_active) begin
61+
virtual_sequencer.tl_filt_sqr = tl_filt_agt.sequencer;
62+
end
63+
endfunction : connect_phase
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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 ac_range_check_env_cfg extends cip_base_env_cfg #(.RAL_T(ac_range_check_reg_block));
6+
7+
// External component config objects
8+
rand tl_agent_cfg tl_csr_agt_cfg;
9+
rand tl_agent_cfg tl_unfilt_agt_cfg;
10+
rand tl_agent_cfg tl_filt_agt_cfg;
11+
12+
`uvm_object_utils_begin(ac_range_check_env_cfg)
13+
`uvm_field_object(tl_csr_agt_cfg, UVM_DEFAULT)
14+
`uvm_field_object(tl_unfilt_agt_cfg, UVM_DEFAULT)
15+
`uvm_field_object(tl_filt_agt_cfg, UVM_DEFAULT)
16+
`uvm_object_utils_end
17+
18+
// Standard SV/UVM methods
19+
extern function new(string name="");
20+
21+
// Class specific methods
22+
extern function void initialize(bit [31:0] csr_base_addr = '1);
23+
endclass : ac_range_check_env_cfg
24+
25+
26+
function ac_range_check_env_cfg::new(string name="");
27+
super.new(name);
28+
endfunction : new
29+
30+
function void ac_range_check_env_cfg::initialize(bit [31:0] csr_base_addr = '1);
31+
list_of_alerts = ac_range_check_env_pkg::LIST_OF_ALERTS;
32+
super.initialize(csr_base_addr);
33+
// Create tl_csr agent config obj
34+
tl_csr_agt_cfg = tl_agent_cfg::type_id::create("tl_csr_agt_cfg");
35+
// Create tl_unfilt agent config obj
36+
tl_unfilt_agt_cfg = tl_agent_cfg::type_id::create("tl_unfilt_agt_cfg");
37+
// Create tl_filt agent config obj
38+
tl_filt_agt_cfg = tl_agent_cfg::type_id::create("tl_filt_agt_cfg");
39+
40+
// Set num_interrupts
41+
begin
42+
uvm_reg rg = ral.get_reg_by_name("intr_state");
43+
if (rg != null) begin
44+
num_interrupts = ral.intr_state.get_n_used_bits();
45+
end
46+
end
47+
endfunction : initialize

0 commit comments

Comments
 (0)