Skip to content

Commit fa1bc46

Browse files
authored
Merge pull request #770 from davidharrishmc/main
Started trickbox
2 parents 0bfa31a + 1fae06b commit fa1bc46

37 files changed

+2480
-354
lines changed

docs/ctp/src/a.adoc

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
2+
=== A Atomic Extension
3+
4+
The A extension is subdivided into Zaamo and Zalrsc.
5+
<<t-A-normative-statements>> lists the normative statements in the RV{32/64}A specification applicable to all instructions, and the unprivileged coverpoints that exercise them.
6+
7+
[[t-A-normative-statements]]
8+
.A Normative Statements
9+
[cols="1, 4, 2" options=header]
10+
|===
11+
|Unpriv Section|Normative Statement|Coverpoints
12+
|===
13+
14+
<<t-A-priv-normative-statements>> summarizes normative statements relating to atomic instructions affecting privileged behavior.
15+
16+
==== Zaamo Atomic Memory Operations Extension
17+
18+
<<t-Zaamo-coverpoints>> summarizes the coverpoints for the Zaamo extension.
19+
20+
[[t-Zaamo-coverpoints]]
21+
.Zaamo Instruction Coverpoints
22+
[options=header]
23+
[%AUTOWIDTH]
24+
,===
25+
include::{testplansdir}/Zaamo.csv[]
26+
,===
27+
28+
[[t-Zaamo-normative-statements]]
29+
.Zaamo Normative Statements
30+
[cols="1, 4, 2" options=header]
31+
|===
32+
33+
|===
34+
35+
==== Zalrsc Load-Reserved / Store-Conditional Extension
36+
37+
<<t-Zalrsc-coverpoints>> summarizes the coverpoints for the Zalrsc extension.
38+
39+
[[t-Zalrsc-coverpoints]]
40+
.Zalrsc Instruction Coverpoints
41+
[options=header]
42+
[%AUTOWIDTH]
43+
,===
44+
include::{testplansdir}/Zalrsc.csv[]
45+
,===
46+
47+
[[t-Zalrsc-normative-statements]]
48+
.Zalrsc Normative Statements
49+
[cols="1, 4, 2" options=header]
50+
|===
51+
|===

docs/ctp/src/aia.adoc

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
2+
=== AIA Advanced Interrupt Architecture
3+
4+
This section describes AIA extension test plans.
5+
6+
==== Smaia Machine-Mode Advanced Interrupt Architecture
7+
8+
[[t-Smaia-coverpoints]]
9+
.Smaia Coverpoints
10+
[options=header]
11+
[%AUTOWIDTH]
12+
,===
13+
//include::{testplansdir}/Smaia.csv[]
14+
,===
15+
16+
==== Ssaia Supervisor-Mode Advanced Interrupt Architecture
17+
18+
[[t-Ssaia-coverpoints]]
19+
.Ssaia Coverpoints
20+
[options=header]
21+
[%AUTOWIDTH]
22+
,===
23+
//include::{testplansdir}/Ssaia.csv[]
24+
,===
25+
26+
==== IMSIC Incoming MSI Controller
27+
28+
[[t-imsic-coverpoints]]
29+
.IMSIC Coverpoints
30+
[options=header]
31+
[%AUTOWIDTH]
32+
,===
33+
//include::{testplansdir}/imsic.csv[]
34+
,===
35+
36+
==== APLIC Advanced Platform-Level Interrupt Controller
37+
38+
[[t-aplic-coverpoints]]
39+
.APLIC Coverpoints
40+
[options=header]
41+
[%AUTOWIDTH]
42+
,===
43+
//include::{testplansdir}/aplic.csv[]
44+
,===
45+
46+
==== IOMMU I/O Memory Management Unit
47+
48+
[[t-iommu-coverpoints]]
49+
.IOMMU Coverpoints
50+
[options=header]
51+
[%AUTOWIDTH]
52+
,===
53+
//include::{testplansdir}/iommu.csv[]
54+
,===

docs/ctp/src/c.adoc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
=== C Compressed Extension
33

4-
The C extension is subdivided into Zca, Zcf, and Zcd. All configurations supporting C contain Zca. RV32CF configurations also contain Zcf, and RV{32/64}CD configurations also contain Zcd. A configuration supporting C should test all of the applicable Zc* extensions. <<t-C-normative-statements>> lists the normative statements in the RV{32/64}C specification applicable to all instructions, and the unprivileged coverpoints that exercise them. Normative statements related to privileged behavior of C instructions are given in <<
4+
The C extension is subdivided into Zca, Zcf, and Zcd. All configurations supporting C contain Zca. RV32CF configurations also contain Zcf, and RV{32/64}CD configurations also contain Zcd. A configuration supporting C should test all of the applicable Zc* extensions. <<t-C-normative-statements>> lists the normative statements in the RV{32/64}C specification applicable to all instructions, and the unprivileged coverpoints that exercise them.
55

66
[[t-C-normative-statements]]
77
.C Normative Statements
@@ -46,8 +46,6 @@ implementations that ignore them.|Hints are not tested
4646
include::{testplansdir}/Zca.csv[]
4747
,===
4848
49-
*** update all coverpoint refs
50-
5149
[[t-Zca-normative-statements]]
5250
.Zca Normative Statements
5351
[cols="1, 4, 2" options=header]

docs/ctp/src/cbo.adoc

Lines changed: 0 additions & 8 deletions
This file was deleted.

docs/ctp/src/cert.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ Certifying a RISC-V Device-Under-Test (DUT) involves the following steps:
99
* Running the tests and reporting pass/fail
1010

1111
Test developers also need to
12-
* Generate a coverage report confirming that the tests hit all the coverpoints footnote:[Open question whether to generate coverage from a Sail log or the DUT. DUT requires a suitable testbench with RVVI interface, but is more robust to check that the tests fully run.]
12+
13+
* Generate a coverage report confirming that the tests hit all the coverpoints based on a Sail trace

docs/ctp/src/coverage.adoc

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
2+
== Architectural Functional Coverage
3+
4+
In principle, a test plan could simply list a set of features to test, and a set of tests that exercise these features. Experienced verification engineers have learned that tests often have bugs and don't exercise the feature that the author intended. Many of these bugs can be caught if a different engineer independently writes functional coverpoints that measure whether the tests exercised the features.
5+
6+
This Certification Test Plan focuses on whether a DUT implements all of the architectural features of a profile. Architectural features are those that are directly visible to the programmer, especially those defined in the unprivileged and privileged ISA specifications.
7+
8+
[NOTE]
9+
====
10+
Later phases of certification tests may add ratified architectural features outside the ISA spec, such as IOMMU, debug, or AIA.
11+
====
12+
13+
_Certification_ differs from _design verification_ in that it does not systematically test microarchitectural features. Design verification must be aware of DUT-specific features such as the pipeline design. For example, DV should test design-specific interactions of interrupt arrival time, pipeline hazards, multicycle instructions, MMU, and memory system. Design verification also should test tricky implementation issues, such as hard floating-point rounding cases.
14+
15+
This plan uses the term _Architectural Functional Coverage_ to describe the functional coverpoints required for certification. In contrast, full design verification also has _Microarchitectural Functional Coverage_.
16+
17+
_Functional coverage_ also differs from _code coverage_, which measures whether the test suite exercises all of the lines of code in the RTL. Each of these detects different types of bugs. Code coverage is part of DV but not certification.
18+
19+
Architectural functional coverage requires a way to measure the architectural state of the machine after each instruction. The https://github.com/riscv-verification/RVVI[RISC-V Verification Interface] (RVVI) provides a standard way to observe this state in the DUT. This document defines Extended RVVI with additional signals to facilitate testing virtual memory.
20+
21+
*** links to unpriv and priv specs
22+
23+
24+
=== Extended RVVI
25+
26+
As compared to the base RVVI, Extended RVVI adds the following signals:
27+
28+
[[t-extendedrvvi]]
29+
.Extended RVVI Signals
30+
[options=header]
31+
[cols="1, 1, 4" options=header]
32+
[%AUTOWIDTH]
33+
|===
34+
|Signal|Width|Description
35+
|virt_adr_i|XLEN|Virtual address of instruction
36+
|virt_adr_d|XLEN|Virtual address of data accessed by instruction
37+
|phys_adr_i|PA_BITS|Physical address of instruction
38+
|phys_adr_d|PA_BITS|Physical address of data accessed by instruction
39+
|pte_i|XLEN|Instruction page table entry
40+
|pte_d|XLEN|Data page table entry
41+
|ppn_i|PPN_BITS|Instruction physical page number
42+
|ppn_d|PPN_BITS|Data physical page number
43+
|page_type_i|2|Instruction page type ***explain
44+
|page_type_d|2|Data page type
45+
|read_access|1|Instruction reads data (loads, AMOs, ***CMO)
46+
|write_access|1|Instruction writes data (stores, AMO, ***cbo.zero)
47+
|execute_access|1|***define - is this jumps? when asserted, and does it only affect data accesses?
48+
|===
49+
50+
*** PA_BITS
51+
PPN_BITS = PA_BITS - 12
52+
*** why do we need ppn when we have phys_addr? Why not derive locally?
53+
54+
*** do we need to add guest physical address? Such as
55+
56+
* gpa_adr_i
57+
* gpa_adr_d
58+
59+
maybe guest page table entries?
60+
61+
=== riscvISACOV Signals
62+
63+
Coverpoints are described using the open https://github.com/riscv-verification/riscvISACOV[riscvISACOV] framework.
64+
65+
The framework collects data coming across the RVVI interface and presents it with `ins.current` and `ins.prev` data structures to allow easy access to the architectural state at the end of the current and previous instructions. For example, `ins.current.rs1` is the source register for the current instruction, and `ins.current.rd_val` is the value written to the destination register by the current instruction.
66+
67+
[NOTE]
68+
====
69+
Most coverpoints use `ins.current`, to measure architectural state at the end of the instruction. However, some privileged coverpoints need to know the privilege mode or values of CSRs at the start of the instruction and thus use `ins.prev`.
70+
====
71+
72+
The available fields are given in fcov/coverage/RISCV_coverage_rvvi.svh. Most commonly used fields are summarized in <<t-riscvISACOV>>. Other fields include floating-point and vector register IDs and values, MMU extended RVVI signals, vector type information, and pending interrupts.
73+
74+
[[t-riscvISACOV]]
75+
.riscvISACOV Signals for Coverpoints
76+
[options=header]
77+
[cols="1, 1, 4, 2" options=header]
78+
[%AUTOWIDTH]
79+
|===
80+
|Signal|Width|Description|Example
81+
|insn|ILEN|Instruction bit pattern|*** add x10, x11, x12
82+
|inst_name|string|Instruction name|add
83+
|disass|string|Disassembled instruction|`add x10, x11, x12`
84+
|trap|1|Instruction trapped rather than retiring|0
85+
|mode|2|Privilege mode 11 = machine, 01 = supervisor, 00 = user|11
86+
|pc_rdata|XLEN|PC of current instruction|0x80000000
87+
|pc_wdata|XLEN|PC of next instruction|0x80000004
88+
|rs1|5|Source register 1 ID|11
89+
|rs2|5|Source register 2 ID|12
90+
|rd|5|Destination register ID|10
91+
|rs1_val|XLEN|Source register 1 value|42
92+
|rs2_val|XLEN|Source register 2 value|69
93+
|rd_val|XLEN|Value written to destination register|111
94+
|imm|XLEN|Value of immediate|100
95+
|csr|XLEN x 4096|Value of CSRs|
96+
|===
97+
98+
*** exact meaning of trap, importance in writing test
99+
*** do we need pending interrupts, or can this be part of mip?
100+
101+
[NOTE]
102+
====
103+
RVVI and riscvISACOV support the notion of multiple harts that retire multiple instructions per cycle. The number of instructions retired per cycle is a microarchitectural issue irrelevant to architectural functional verification, so it is set to 1, consistent with simulators that report each instruction retiring individually. Phase 0-2 testing only involves a single hart. Later phases may need to generalize to multiple harts to exercise fences and atomic operations that relate to memory consistency.
104+
====
105+
106+
[NOTE]
107+
====
108+
Our riscvISACOV implementation uses a SystemVerilog disassmbler in fcov/disassemble.svh, replacing a proprietery disassembler from Imperas. When adding new extensions, update the disassembler accordingly.
109+
====
110+
111+
112+
=== Writing Coverpoints with riscvISACOV
113+
114+
*** example of coverpoint
115+
*** organization of files
116+
117+
118+
119+
=== Sail Trace Coverage Flow
120+
121+
Coverage is measured by running tests on Sail and generating a trace file, then passing this trace file to an RVVI agent in a SystemVerilog testbench that checks coverage.
122+
123+
[NOTE]
124+
====
125+
The number of coverpoints and the number of tests both grow with the number of extensions, so the runtime to measure coverage can grow quadratically with the number of extensions, and becomes problematic. To avoid this, it is recommended to only enable coverpoints for one extension (or small group of extensions) at a time and to only run tests for that extension, and generate a Unified Coverage Database (UDCB) file and report for that extension. A script will kick off such tests in parallel for all extensions, and merge the coverage reports.
126+
====
127+
128+
Sail produces the trace file in a standard RVVI-Trace format (see Section <<RVVI-Trace Format>>). Any other simulator that implements the same trace format can also be used to cross-check coverage.
129+
130+
*** Jordan add instructions on how to run this
131+
132+
=== RVVI-Trace Format
133+
134+
*** Jordan write
135+
*** how to handle instructions that change multiple CSRs, such as a write to mstatus.SIE also affecting sstatus.SIE

docs/ctp/src/ctp.adoc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ include::profiles.adoc[]
6464
include::strategy.adoc[]
6565
include::unpriv.adoc[]
6666
include::priv.adoc[]
67-
include::nondeterministic.adoc[]
67+
include::nonisa.adoc[]
68+
include::trickbox.adoc[]
69+
include::coverage.adoc[]
70+
include::ref.adoc[]
6871
include::todo.adoc[]
6972
include::examples.adoc[]

docs/ctp/src/debug.adoc

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
=== Debug
3+
4+
This section describes debug-related extensions not required in RVA23.
5+
6+
==== DM Debug Module
7+
8+
[[t-DM-coverpoints]]
9+
.DM Coverpoints
10+
[options=header]
11+
[%AUTOWIDTH]
12+
,===
13+
//include::{testplansdir}/DM.csv[]
14+
,===
15+
16+
==== DTM Debug Transport Module
17+
18+
[[t-DTM-coverpoints]]
19+
.DTM Coverpoints
20+
[options=header]
21+
[%AUTOWIDTH]
22+
,===
23+
//include::{testplansdir}/DTM.csv[]
24+
,===
25+
26+
==== Sdext Debug Extension
27+
28+
[[t-Sdext-coverpoints]]
29+
.Sdext Coverpoints
30+
[options=header]
31+
[%AUTOWIDTH]
32+
,===
33+
//include::{testplansdir}/Sdext.csv[]
34+
,===

0 commit comments

Comments
 (0)