Skip to content

Commit f0c274c

Browse files
authored
Update model (#3304)
Since the GCC update, new instructions are used in CoreMark (mostly clmul). It decreases the accuracy of the model compared to the CVA6. This PR updates the performance model to correctly decode and process these instructions. It also fixes a bug for jump dispatch to functional units. Note: the current version of the model is still based on the superscalar without ALU forwarding.
1 parent eb6ff33 commit f0c274c

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

perf-model/isa.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,8 @@ def __init__(self, instr):
385385
| (((i >> 3) & 3) << 1) \
386386
| (((i >> 2) & 1) << 5)
387387
, 8)
388-
if base in CBtype.regimm:
389-
if base == 'C.ANDI':
388+
else:
389+
if (instr.bin >> 10) & 3 == 2:
390390
self.shamt = sign_ext(CItype.imm(i), 5)
391391
else:
392392
self.shamt = CItype.imm(i)
@@ -470,7 +470,7 @@ class Instr:
470470
'C.ADDIW': CItype,
471471
'C.ADDI4SPN': CIWtype,
472472
'C.SLLI': CItype,
473-
'MISC-ALU': CAtype,
473+
'MISC-ALU': lambda instr: CAtype(instr) if (instr.bin >> 10) & 3 == 3 else CBtype(instr),
474474
}
475475
iloads = ['C.LW', 'C.LWSP', 'LOAD']
476476
floads = ['C.FLD', 'C.FLW', 'C.FLDSP', 'C.FLWSP', 'LOAD-FP']
@@ -534,7 +534,10 @@ def is_jump(self):
534534

535535
def is_muldiv(self):
536536
"""Is it a muldiv instruction?"""
537-
return self.base() in ['OP', 'OP-32'] and self.fields().funct7 == 1
537+
if self.base() not in ['OP', 'OP-32']:
538+
return False
539+
f = self.fields()
540+
return f.funct7 == 1 or (f.funct7 == 5 and f.funct3 in [1, 3])
538541

539542
def offset(self):
540543
"""Get offset from instr (sometimes it is just 'imm' in RISCV spec)"""

perf-model/model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ def _index(self, addr):
260260
# This way we do not have more write-back ports than currently with F
261261

262262
def to_fu(instr):
263-
if instr.is_branch() or instr.is_regjump():
263+
if instr.is_branch() or instr.is_jump() or instr.is_regjump():
264264
return Fu.BRANCH
265265
if instr.is_muldiv():
266266
return Fu.MUL

0 commit comments

Comments
 (0)