Skip to content

Commit e9f6465

Browse files
committed
Add Zicbom and Zicbop extension
1 parent ea99406 commit e9f6465

File tree

9 files changed

+218
-44
lines changed

9 files changed

+218
-44
lines changed

coverage/cmo/cbom.cgf

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# For Licence details look at https://github.com/riscv-software-src/riscv-ctg/-/blob/master/LICENSE.incore
2+
3+
cbo.clean:
4+
config:
5+
- check ISA:=regex(.*I.*Zicbom.*Zicsr.*)
6+
mnemonics:
7+
cbo.clean: 0
8+
rs1:
9+
<<: *all_regs_mx0
10+
val_comb:
11+
<<: [*base_rs1val_unsgn]
12+
abstract_comb:
13+
<<: [*rs1val_walking_unsgn]
14+
15+
cbo.flush:
16+
config:
17+
- check ISA:=regex(.*I.*Zicbom.*Zicsr.*)
18+
mnemonics:
19+
cbo.flush: 0
20+
rs1:
21+
<<: *all_regs_mx0
22+
val_comb:
23+
<<: [*base_rs1val_unsgn]
24+
abstract_comb:
25+
<<: [*rs1val_walking_unsgn]
26+
27+
cbo.inval:
28+
config:
29+
- check ISA:=regex(.*I.*Zicbom.*Zicsr.*)
30+
mnemonics:
31+
cbo.inval: 0
32+
rs1:
33+
<<: *all_regs_mx0
34+
val_comb:
35+
<<: [*base_rs1val_unsgn]
36+
abstract_comb:
37+
<<: [*rs1val_walking_unsgn]

coverage/cmo/cbop.cgf

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# For Licence details look at https://github.com/riscv-software-src/riscv-ctg/-/blob/master/LICENSE.incore
2+
3+
prefetch.i:
4+
config:
5+
- check ISA:=regex(.*I.*Zicbop.*Zicsr.*)
6+
mnemonics:
7+
prefetch.i: 0
8+
rs1:
9+
<<: *all_regs
10+
val_comb:
11+
<<: [*zicbop_ifmt_val_comb_unsgn, *base_rs1val_unsgn, *ifmt_base_immval11_5_sgn]
12+
abstract_comb:
13+
<<: [*rs1val_walking_unsgn, *ifmt_immval_walking_11_5]
14+
15+
prefetch.r:
16+
config:
17+
- check ISA:=regex(.*I.*Zicbop.*Zicsr.*)
18+
mnemonics:
19+
prefetch.r: 0
20+
rs1:
21+
<<: *all_regs
22+
val_comb:
23+
<<: [*zicbop_ifmt_val_comb_unsgn, *base_rs1val_unsgn, *ifmt_base_immval11_5_sgn]
24+
abstract_comb:
25+
<<: [*rs1val_walking_unsgn, *ifmt_immval_walking_11_5]
26+
27+
prefetch.w:
28+
config:
29+
- check ISA:=regex(.*I.*Zicbop.*Zicsr.*)
30+
mnemonics:
31+
prefetch.w: 0
32+
rs1:
33+
<<: *all_regs
34+
val_comb:
35+
<<: [*zicbop_ifmt_val_comb_unsgn, *base_rs1val_unsgn, *ifmt_base_immval11_5_sgn]
36+
abstract_comb:
37+
<<: [*rs1val_walking_unsgn, *ifmt_immval_walking_11_5]

coverage/rv32i_cbo.cgf renamed to coverage/cmo/cboz.cgf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# For Licence details look at https://github.com/riscv-software-src/riscv-ctg/-/blob/master/LICENSE.incore
22

3-
cbozero:
3+
cbo.zero:
44
config:
55
- check ISA:=regex(.*I.*Zicboz.*Zicsr.*)
66
mnemonics:

coverage/cmo/rvi_cmo.cgf

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

coverage/dataset.cgf

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ datasets:
305305
r0fmt_op_comb: &r0fmt_op_comb
306306
'rs1 == 0': 0
307307
'rs1 != 0': 0
308-
308+
309309
base_rs1val_sgn: &base_rs1val_sgn
310310
'rs1_val == (-2**(xlen-1))': 0
311311
'rs1_val == 0': 0
@@ -317,7 +317,7 @@ datasets:
317317
'rs1_val == 0 and rs2_val == 0': 0
318318
'rs1_val == (2**(xlen-1)-1) and rs2_val == 0': 0
319319
'rs1_val == 1 and rs2_val == 0': 0
320-
320+
321321
base_rs2val_sgn: &base_rs2val_sgn
322322
'rs2_val == (-2**(xlen-1))': 0
323323
'rs2_val == 0': 0
@@ -330,12 +330,11 @@ datasets:
330330
'rs3_val == (2**(xlen-1)-1)': 0
331331
'rs3_val == 1': 0
332332

333-
334333
base_rs1val_unsgn: &base_rs1val_unsgn
335334
'rs1_val == 0': 0
336335
'rs1_val == (2**(xlen)-1)': 0
337336
'rs1_val == 1': 0
338-
337+
339338
base_rs2val_unsgn: &base_rs2val_unsgn
340339
'rs2_val == 0': 0
341340
'rs2_val == (2**(xlen)-1)': 0
@@ -356,7 +355,7 @@ datasets:
356355

357356
div_corner_case: &div_corner_case
358357
'rs1_val == -(2**(xlen-1)) and rs2_val == -0x01': 0
359-
358+
360359
rfmt_val_comb_unsgn: &rfmt_val_comb_unsgn
361360
'rs1_val > 0 and rs2_val > 0': 0
362361
'rs1_val == rs2_val and rs1_val > 0 and rs2_val > 0': 0
@@ -374,12 +373,23 @@ datasets:
374373
'rs1_val == imm_val and rs1_val > 0 and imm_val > 0': 0
375374
'rs1_val != imm_val and rs1_val > 0 and imm_val > 0': 0
376375

376+
zicbop_ifmt_val_comb_unsgn: &zicbop_ifmt_val_comb_unsgn
377+
'rs1_val == imm_val and rs1_val == 0': 0
378+
'rs1_val < imm_val and rs1_val != 0': 0
379+
'rs1_val > imm_val and imm_val == 0': 0
380+
377381
ifmt_base_immval_sgn: &ifmt_base_immval_sgn
378382
'imm_val == (-2**(12-1))': 0
379383
'imm_val == 0': 0
380384
'imm_val == (2**(12-1)-1)': 0
381385
'imm_val == 1': 0
382386

387+
ifmt_base_immval11_5_sgn: &ifmt_base_immval11_5_sgn
388+
'imm_val == (-2**(7-1)) << 5': 0
389+
'imm_val == 0': 0
390+
'imm_val == (2**(7-1)-1) << 5': 0
391+
'imm_val == 1<<5': 0
392+
383393
ifmt_base_immval_sgn_len: &ifmt_base_immval_sgn_len
384394
'imm_val == (-2**(ceil(log(xlen,2))-1))': 0
385395
'imm_val == 0': 0
@@ -445,7 +455,7 @@ datasets:
445455
'rs1_val > rs2_val and imm_val < 0 and imm_val & 0x03 == 0': 0
446456
'rs1_val < rs2_val and imm_val > 0 and imm_val & 0x03 == 0': 0
447457
'rs1_val < rs2_val and imm_val < 0 and imm_val & 0x03 == 0': 0
448-
458+
449459
bfmt_base_branch_val_align_unsgn: &bfmt_base_branch_val_align_unsgn
450460
'rs1_val > 0 and rs2_val > 0': 0
451461
'rs1_val > 0 and rs2_val > 0 and rs1_val == rs2_val and imm_val > 0': 0
@@ -490,12 +500,17 @@ datasets:
490500
'walking_ones("imm_val", 5, False)': 0
491501
'walking_zeros("imm_val", 5, False)': 0
492502
'alternate("imm_val", 5, False)': 0
493-
503+
504+
ifmt_immval_walking_11_5: &ifmt_immval_walking_11_5
505+
'walking_ones("imm_val", 7, signed = True, scale_func = lambda x: x << 5)': 0
506+
'walking_zeros("imm_val", 7, signed = True, scale_func = lambda x: x << 5)': 0
507+
'alternate("imm_val", 7, signed = True, scale_func = lambda x: x << 5)': 0
508+
494509
rs1val_walking_unsgn: &rs1val_walking_unsgn
495510
'walking_ones("rs1_val", xlen,False)': 0
496511
'walking_zeros("rs1_val", xlen,False)': 0
497512
'alternate("rs1_val",xlen,False)': 0
498-
513+
499514
rs2val_walking_unsgn: &rs2val_walking_unsgn
500515
'walking_ones("rs2_val", xlen,False)': 0
501516
'walking_zeros("rs2_val", xlen,False)': 0
@@ -509,7 +524,7 @@ datasets:
509524
'walking_ones("imm_val", 6)': 0
510525
'walking_zeros("imm_val", 6)': 0
511526
'alternate("imm_val",6)': 0
512-
527+
513528
ifmt_immval_walking_unsgn: &ifmt_immval_walking_unsgn
514529
'walking_ones("imm_val", 12,False)': 0
515530
'walking_zeros("imm_val", 12,False)': 0

coverage/rv64i_cbo.cgf

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

riscv-ctg/riscv_ctg/data/template.yaml

Lines changed: 108 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10424,15 +10424,120 @@ cbo.zero:
1042410424
sz: 'RVMODEL_CBZ_BLOCKSIZE'
1042510425
xlen: [32,64]
1042610426
isa:
10427-
- IZicbozZicsr
10427+
- IZicboz_Zicsr
1042810428
formattype: 'zformat'
1042910429
rs1_op_data: *all_regs_mx0
10430-
rs1_val_data: 'gen_usign_dataset(12)'
10430+
rs1_val_data: 'gen_usign_dataset(12) + gen_sp_dataset(xlen,False)'
1043110431
template: |-
1043210432
1043310433
// $comment
1043410434
// opcode: $inst ; op1:$rs1; op1val:$rs1_val
10435-
TEST_CBO_ZERO($swreg,$rs1,$inst,$rs1_val)
10435+
TEST_CBO($swreg,$rs1,$inst,$rs1_val)
10436+
10437+
cbo.clean:
10438+
std_op:
10439+
sig:
10440+
stride: 1
10441+
sz: 'XLEN/8'
10442+
xlen: [32,64]
10443+
isa:
10444+
- IZicbom_Zicsr
10445+
formattype: 'zformat'
10446+
rs1_op_data: *all_regs
10447+
rs1_val_data: 'gen_usign_dataset(xlen) + gen_sp_dataset(xlen,False)'
10448+
template: |-
10449+
10450+
// $comment
10451+
// opcode: $inst ; op1:$rs1; op1val:$rs1_val
10452+
TEST_CBO($swreg,$rs1,$inst,$rs1_val)
10453+
10454+
cbo.flush:
10455+
std_op:
10456+
sig:
10457+
stride: 1
10458+
sz: 'XLEN/8'
10459+
xlen: [32,64]
10460+
isa:
10461+
- IZicbom_Zicsr
10462+
formattype: 'zformat'
10463+
rs1_op_data: *all_regs
10464+
rs1_val_data: 'gen_usign_dataset(xlen) + gen_sp_dataset(xlen,False)'
10465+
template: |-
10466+
10467+
// $comment
10468+
// opcode: $inst ; op1:$rs1; op1val:$rs1_val
10469+
TEST_CBO($swreg,$rs1,$inst,$rs1_val)
10470+
10471+
cbo.inval:
10472+
std_op:
10473+
sig:
10474+
stride: 1
10475+
sz: 'XLEN/8'
10476+
xlen: [32,64]
10477+
isa:
10478+
- IZicbom_Zicsr
10479+
formattype: 'zformat'
10480+
rs1_op_data: *all_regs
10481+
rs1_val_data: 'gen_usign_dataset(xlen) + gen_sp_dataset(xlen,False)'
10482+
template: |-
10483+
10484+
// $comment
10485+
// opcode: $inst ; op1:$rs1; op1val:$rs1_val
10486+
TEST_CBO($swreg,$rs1,$inst,$rs1_val)
10487+
10488+
prefetch.i:
10489+
sig:
10490+
stride: 1
10491+
sz: 'XLEN/8'
10492+
xlen: [32,64]
10493+
std_op:
10494+
isa:
10495+
- IZicbop_Zicsr
10496+
formattype: 'iformat'
10497+
rs1_op_data: *all_regs
10498+
rs1_val_data: 'gen_usign_dataset(xlen) + gen_sp_dataset(xlen,False)'
10499+
imm_val_data: '[v << 5 for v in gen_sign_dataset(7)]'
10500+
template: |-
10501+
10502+
// $comment
10503+
// opcode: $inst ; op1:$rs1; dest:$rd; op1val:$rs1_val; op2val:$imm_val
10504+
TEST_PREFETCH($swreg,$rs1,$inst,$rs1_val,$imm_val)
10505+
10506+
prefetch.r:
10507+
sig:
10508+
stride: 1
10509+
sz: 'XLEN/8'
10510+
xlen: [32,64]
10511+
std_op:
10512+
isa:
10513+
- IZicbop_Zicsr
10514+
formattype: 'iformat'
10515+
rs1_op_data: *all_regs
10516+
rs1_val_data: 'gen_usign_dataset(xlen) + gen_sp_dataset(xlen,True)'
10517+
imm_val_data: '[v << 5 for v in gen_sign_dataset(7)]'
10518+
template: |-
10519+
10520+
// $comment
10521+
// opcode: $inst ; op1:$rs1; dest:$rd; op1val:$rs1_val; op2val:$imm_val
10522+
TEST_PREFETCH($swreg,$rs1,$inst,$rs1_val,$imm_val)
10523+
10524+
prefetch.w:
10525+
sig:
10526+
stride: 1
10527+
sz: 'XLEN/8'
10528+
xlen: [32,64]
10529+
std_op:
10530+
isa:
10531+
- IZicbop_Zicsr
10532+
formattype: 'iformat'
10533+
rs1_op_data: *all_regs
10534+
rs1_val_data: 'gen_usign_dataset(xlen) + gen_sp_dataset(xlen,True)'
10535+
imm_val_data: '[v << 5 for v in gen_sign_dataset(7)]'
10536+
template: |-
10537+
10538+
// $comment
10539+
// opcode: $inst ; op1:$rs1; dest:$rd; op1val:$rs1_val; op2val:$imm_val
10540+
TEST_PREFETCH($swreg,$rs1,$inst,$rs1_val,$imm_val)
1043610541
1043710542
amoadd.w:
1043810543
sig:

riscv-ctg/riscv_ctg/generator.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def get_rm(opcode):
172172
'prrformat': '["rs1_val", "rs2_val"]',
173173
'prrrformat': "['rs1_val', 'rs2_val' , 'rs3_val']",
174174
'dcasrformat': '["rs1_val", "rs2_val"]',
175-
'zformat': ['rs1']
175+
'zformat': "['rs1_val']"
176176
}
177177
''' Dictionary mapping instruction formats to operand value variables used by those formats '''
178178

@@ -1134,6 +1134,7 @@ def swreg(self, instr_dict):
11341134
else:
11351135
FLEN = 0
11361136
XLEN = max(self.opnode['xlen'])
1137+
RVMODEL_CBZ_BLOCKSIZE = XLEN
11371138
SIGALIGN = max(XLEN,FLEN)/8
11381139
stride_sz = eval(suffix)
11391140
for instr in instr_dict:

riscv-test-suite/env/test_macros.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -769,14 +769,21 @@ nop ;\
769769
csrr flagreg, fcsr ;\
770770
RVTEST_SIGUPD_F(swreg,destreg,flagreg)
771771

772-
#define TEST_CBO_ZERO(swreg,rs1,inst,imm_val) ;\
773-
LI(rs1,imm_val&(RVMODEL_CBZ_BLOCKSIZE-1)) ;\
772+
#define TEST_CBO(swreg,rs1,inst,rs1_val) ;\
773+
LI(rs1,rs1_val&(RVMODEL_CBZ_BLOCKSIZE-1)) ;\
774774
add rs1,rs1,swreg ;\
775775
inst (rs1) ;\
776776
nop ;\
777777
nop ;\
778778
ADDI(swreg, swreg, RVMODEL_CBZ_BLOCKSIZE)
779779

780+
#define TEST_PREFETCH(swreg,rs1,inst,rs1_val,imm_val) ;\
781+
LI(rs1,rs1_val) ;\
782+
inst imm_val(rs1) ;\
783+
nop ;\
784+
nop ;\
785+
ADDI(swreg, swreg, RVMODEL_CBZ_BLOCKSIZE)
786+
780787
#define TEST_CSR_FIELD(ADDRESS,TEMP_REG,MASK_REG,NEG_MASK_REG,VAL,DEST_REG,OFFSET,BASE_REG) ;\
781788
LI(TEMP_REG,VAL) ;\
782789
and TEMP_REG,TEMP_REG,MASK_REG ;\

0 commit comments

Comments
 (0)