Skip to content

Conversation

@juliacygong
Copy link

Description

Provide a detailed description of the changes performed by the PR.

Related Issues

Please list all the issues related to this PR. Use NA if no issues exist

Ratified/Unratified Extensions

  • Ratified
  • Unratified

List Extensions

List the extensions that your PR affects. In case of unratified extensions, please provide a link to the spec draft that was referred to make this PR.

Reference Model Used

  • SAIL
  • Spike
  • Other - < SPECIFY HERE >

Mandatory Checklist:

  • All tests are compliant with the test-format spec present in this repo ?
  • Ran the new tests on RISCOF with SAIL/Spike as reference model successfully ?
  • Ran the new tests on RISCOF in coverage mode
  • Link to Google-Drive folder containing the new coverage reports (See this for more info): < SPECIFY HERE >

Optional Checklist:

  • Were the tests hand-written/modified ?
  • Have you run these on any hard DUT model ? Please specify name and provide link if possible in the description
  • If you have modified arch_test.h Please provide a detailed description of the changes in the Description section above.

@juliacygong juliacygong changed the title coverpoints draft Draft Coverpoints for EndianH, SvinvalH, ZicntrH, Zihpm Nov 4, 2025
Copy link

@coreyqh coreyqh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall good work, a few minor changes needed across the board and some major changes needed for ZicntrH

hstatus_vsbe: coverpoint ins.current.csr[12'h600][5] { // vsbe is hstatus[5] in RV64
}
`else
hstatus_vsbe: coverpoint ins.current.csr[12'h600][5] { // vsbe is hstatush[5] in RV32
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the hstatus_vsbe helper coverpoint is the same regardless of XLEN. Need to update with the address of hstatush for the RV32 version.

covergroup EndianH_endian_cg with function sample(ins_t ins);
option.per_instance = 0;
`include "coverage/RISCV_coverage_standard_coverpoints.svh"
// "Endianness tests in machine mode"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment should likely be "endianness tests in hypervisor mode" or similar

wildcard bins lwu = {32'b????????????_?????_110_?????_0000011};
}
cp_doubleoffset: coverpoint ins.current.imm[2:0] iff (ins.current.rs1_val[2:0] == 3'b000) {
bins zero = {3'b000};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally, I think it would be more readable to define these up with the lw, sw, etc instructions in a separate `ifdef block.

// ---------------------
function void svinvalH_sample(int hart, int issue, ins_t ins);

//$display("Svinval coverage: ins_str %s ins,prev.mode %b tvm %b", ins.ins_str, ins.prev.mode, ins.prev.csr[12'h300][20]);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider removing this debugging print statement

//
///////////////////////////////////////////

define COVER_ZICNTRH
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be `define (missing the "tick")

covergroup ZicntrH_scounters_cg with function sample(ins_t ins);
option.per_instance = 0;
`include "coverage/RISCV_coverage_standard_coverpoints.svh"
// counter access in supervisor mode
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hypervisor mode

`endif

// M mode coverpoints
cp_mhscounteren_access_m: cross csrr, counters_mcounteren, counters_hcounteren, counters_scounteren, priv_mode_m;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

counters_*counteren coverpoints all include parts of the 32-bit machine code instruction.

This means that cross products of these will have mutually exclusive bins since the value of that part of the instruction cannot have multiple values simultaneously. You will need to separate this into different cross products.

`endif
}

cp_hmp_write: cross cp_hpmh_count, priv_mode_m;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be hpm not hpmh

@coreyqh
Copy link

coreyqh commented Nov 8, 2025

Looks amazing @juliacygong

Just a few picky things: there is still a display statement in there, and access is misspelled as acces in a few places.

After those are fixed, this has my endorsement.

Signed-off-by: juliacygong <[email protected]>
Copy link

@coreyqh coreyqh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work

Copy link
Collaborator

@jordancarlin jordancarlin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More comments to come later, but here is a first round of feedback.

Comment on lines 1 to 5
///////////////////////////////////////////
//
// RISC-V Architectural Functional Coverage Covergroups Initialization File
//
///////////////////////////////////////////
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review headers in all files. Currently missing license and this is not an initialization file. See other coverpoint files for an example.

// "Endianness tests in hypervisor mode"

// building blocks for the main coverpoints
// ENDIANNESS COVERPOINTS: check writes and reads with various endianness
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strange indentation

//
///////////////////////////////////////////

`define COVER_ENDIANS
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`define COVER_ENDIANS
`define COVER_ENDIANH

Comment on lines 41 to 43
cp_sd: coverpoint ins.current.insn {
wildcard bins sd = {32'b????????????_?????_011_?????_0100011};
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation issue

Comment on lines 69 to 70
hstatus_vsbe: coverpoint ins.current.csr[12'h600][5] { // vsbe is hstatus[5] in RV64
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation

Comment on lines 14 to 15
wildcard bins hinval.vvma = {32'b0010001_?????_?????_000_00000_1110011};
wildcard bins hinval.gvma = {32'b0110001_?????_?????_000_00000_1110011};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use underscores in place of . in instruction names.

Comment on lines 28 to 29
bins vtvm_0 = {0};
bins vtvm_1 = {1};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to explicitly define the bins since we want all of the values and the default names of 0/1 will be clear enough.

option.per_instance = 0;
`include "coverage/RISCV_coverage_standard_coverpoints.svh"

cp_hpm_count: coverpoint {ins.current.insn[31:20], ins.current.csr[12'hB03][31:0] } {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation

Comment on lines 13 to 15
bins cycle_enabled = {44'b110000000000_00000000000000000000000000000001};
bins time_enabled = {44'b110000000001_00000000000000000000000000000010};
bins instret_enabled = {44'b110000000010_00000000000000000000000000000100};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cycle, time, and instret are part of Zicntr, not Zihpm.

}

counters_scounteren: coverpoint {ins.current.insn[31:20], ins.current.csr[12'h106][31:0]} {
bins cycle_enabled = {44'b110000000000_00000000000000000000000000000001};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation

@juliacygong juliacygong marked this pull request as ready for review November 14, 2025 19:01
@juliacygong juliacygong changed the title Draft Coverpoints for EndianH, SvinvalH, ZicntrH, Zihpm Coverpoints for EndianH, SvinvalH, ZicntrH, Zihpm Nov 14, 2025
Copy link
Collaborator

@davidharrishmc davidharrishmc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finally reviewed. Looking good; most fixes should be easy.

wildcard bins sd = {32'b????????????_?????_011_?????_0100011};
}
cp_ld: coverpoint ins.current.insn {
wildcard bins ld = {32'b????????????_?????_001_?????_0000011};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

funct3 = 011

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed funct3 for ld. I also noticed that funct3 for ld is also incorrect in EndianM, EndianS, and EndianU and fixed them.

cp_hstatus_vbe_endianness_lb: cross priv_mode_vs, hstatus_vsbe, cp_lb, cp_byteoffset;
cp_hstatus_vbe_endianness_lhu: cross priv_mode_vs, hstatus_vsbe, cp_lhu, cp_halfoffset;
cp_hstatus_vbe_endianness_lbu: cross priv_mode_vs, hstatus_vsbe, cp_lbu, cp_byteoffset;
cp_mstatus_mprv_vsbe_endianness_sw: cross priv_mode_m, hstatus_vsbe, cp_sw, cp_wordoffset, mstatus_mprv, mstatus_mbe;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testplan calls for mpp={01/11}, mpv = {0/1}, mbe={0/1} that don't seem to be in these crosses.

Comment on lines 87 to 94
// VS and VU modes
priv_mode_vs: coverpoint {ins.current.VirtMode, ins.current.mode} {
bins VS_mode = {3'b101};
}

priv_mode_vu: coverpoint {ins.current.VirtMode, ins.current.mode} {
bins VU_mode = {3'b100};
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This applies to the other covergroups as well.

wildcard bins sfence_w_inval = {32'b0001100_00000_00000_000_00000_1110011};
wildcard bins sinval_vma = {32'b0001011_?????_?????_000_00000_1110011};
wildcard bins hinval_vvma = {32'b0010001_?????_?????_000_00000_1110011};
wildcard bins hinval_gvma = {32'b0110001_?????_?????_000_00000_1110011};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like funct7 should be 0010011 for hinval_vvma and 0110011 for hinval_gvma per Figure 125 of the priv spec.


cp_htimedelta: coverpoint {ins.current.csr[12'h605][63:0]} {
bins htimedelta_zero = {64'd0};
bins htimedelta_2p30 = {64'd1073741824}; // 2^30
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Write this in hex with a 1 in bit 30.


`ifdef XLEN32

cp_htimedeltah: coverpoint {ins.current.csr[12'h615][31:0]}1 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something is garbled. For RV32, I think you want a htimedelta coverpoint as in RV64, but that it involve {htimedeltah, htimedelta} to give a 64-bit value. I believe there should be an `if/else to define htimedelta differently for RV64 vs 32.


cp_htimedeltah: coverpoint {ins.current.csr[12'h615][31:0]}1 {
bins htimedeltah_zero = {{32'd0, 32'd0}};
bins htimedeltah_2p30 = {{32'd1073741824, 32'd0}}; // 2^30
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be more readable to put the upper bits in the upper half. Use hex rather than decimal. The encoding for 2p60 and n2p60 looks incorrect.

cp_mhscounteren_access_hcnt_m: cross csrr, counters_hcounteren, priv_mode_m;
cp_mhscounteren_access_scnt_m: cross csrr, counters_scounteren, priv_mode_m;
cp_delta_m: cross csrr, cp_htimedelta, priv_mode_m;
`ifdef XLEN32
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If htimedelta coverpoint is defined to depend on XLEN, then this coverpoint is not needed because the 64-bit value is subsumed in htimedelta.

cp_mhscounteren_access_scnt_m: cross csrr, counters_scounteren, priv_mode_m;
cp_delta_m: cross csrr, cp_htimedelta, priv_mode_m;
`ifdef XLEN32
cp_deltah_m: cross csrr, cp_htimedeltah, priv_mode_m;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be more specific about reading time, rather than just a csrr?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comments about htimedelta and csrr time apply to all delta coverpoints.

bins VU_mode = {3'b100};
}

counters_hcounteren: coverpoint {ins.current.insn[31:20], ins.current.csr[12'h606][31:0]}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Garble?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants