-
Notifications
You must be signed in to change notification settings - Fork 250
Coverpoints for EndianH, SvinvalH, ZicntrH, Zihpm #715
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: act4
Are you sure you want to change the base?
Conversation
coreyqh
left a comment
There was a problem hiding this 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 |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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}; |
There was a problem hiding this comment.
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]); |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
coverpoints/priv/Zihpm_coverage.svh
Outdated
| `endif | ||
| } | ||
|
|
||
| cp_hmp_write: cross cp_hpmh_count, priv_mode_m; |
There was a problem hiding this comment.
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
|
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]>
coreyqh
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work
jordancarlin
left a comment
There was a problem hiding this 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.
| /////////////////////////////////////////// | ||
| // | ||
| // RISC-V Architectural Functional Coverage Covergroups Initialization File | ||
| // | ||
| /////////////////////////////////////////// |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| `define COVER_ENDIANS | |
| `define COVER_ENDIANH |
| cp_sd: coverpoint ins.current.insn { | ||
| wildcard bins sd = {32'b????????????_?????_011_?????_0100011}; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation issue
| hstatus_vsbe: coverpoint ins.current.csr[12'h600][5] { // vsbe is hstatus[5] in RV64 | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation
| wildcard bins hinval.vvma = {32'b0010001_?????_?????_000_00000_1110011}; | ||
| wildcard bins hinval.gvma = {32'b0110001_?????_?????_000_00000_1110011}; |
There was a problem hiding this comment.
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.
| bins vtvm_0 = {0}; | ||
| bins vtvm_1 = {1}; |
There was a problem hiding this comment.
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.
coverpoints/priv/Zihpm_coverage.svh
Outdated
| 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] } { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation
coverpoints/priv/Zihpm_coverage.svh
Outdated
| bins cycle_enabled = {44'b110000000000_00000000000000000000000000000001}; | ||
| bins time_enabled = {44'b110000000001_00000000000000000000000000000010}; | ||
| bins instret_enabled = {44'b110000000010_00000000000000000000000000000100}; |
There was a problem hiding this comment.
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}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation
davidharrishmc
left a comment
There was a problem hiding this 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}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
funct3 = 011
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
| // 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}; | ||
| } |
There was a problem hiding this comment.
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}; |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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]} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Garble?
Description
Related Issues
Ratified/Unratified Extensions
List Extensions
Reference Model Used
Mandatory Checklist:
Optional Checklist: