Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

updates for crypto scalar instructions #34

Open
wants to merge 8 commits into
base: dev
Choose a base branch
from
8 changes: 4 additions & 4 deletions riscv_isac/coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,15 @@
'aes32esmi', 'aes32esi', 'aes32dsmi', 'aes32dsi','bclr','bext','binv',\
'bset','zext.h','sext.h','sext.b','minu','maxu','orc.b','add.uw','sh1add.uw',\
'sh2add.uw','sh3add.uw','slli.uw','clz','clzw','ctz','ctzw','cpop','cpopw','rev8',\
'bclri','bexti','binvi','bseti']
'bclri','bexti','binvi','bseti','xperm4','xperm8','zip','unzip','gorci']
unsgn_rs2 = ['bgeu', 'bltu', 'sltiu', 'sltu', 'sll', 'srl', 'sra','mulhu',\
'mulhsu','divu','remu','divuw','remuw','aes64ds','aes64dsm','aes64es',\
'aes64esm','aes64ks2','sm4ed','sm4ks','ror','rol','rorw','rolw','clmul',\
'clmulh','clmulr','andn','orn','xnor','pack','packh','packu','packuw','packw',\
'xperm.n','xperm.b', 'aes32esmi', 'aes32esi', 'aes32dsmi', 'aes32dsi',\
'sha512sum1r','sha512sum0r','sha512sig1l','sha512sig1h','sha512sig0l','sha512sig0h','fsw',\
'bclr','bext','binv','bset','minu','maxu','add.uw','sh1add.uw','sh2add.uw','sh3add.uw']
'bclr','bext','binv','bset','minu','maxu','add.uw','sh1add.uw','sh2add.uw','sh3add.uw',\
'xperm4','xperm8','zip','unzip']

class cross():

Expand Down Expand Up @@ -719,7 +720,6 @@ def compute_per_line(queue, event, cgf_queue, stats_queue, cgf, xlen, addr_pairs
local_dict[i] = int(csr_regfile[i],16)

local_dict['xlen'] = xlen

if enable :
for cov_labels,value in cgf.items():
if cov_labels != 'datasets':
Expand Down Expand Up @@ -1059,7 +1059,7 @@ def compute(trace_file, test_name, cgf, parser_name, decoder_name, detailed, xle
decoderclass = getattr(instructionObjectfile, "disassembler")
decoder_pm.register(decoderclass())
decoder = decoder_pm.hook
decoder.setup(arch="rv"+str(xlen))
decoder.setup(arch="rv"+str(xlen),isa=cgf[cov_labels]['config'])

iterator = iter(parser.__iter__()[0])

Expand Down
4 changes: 4 additions & 0 deletions riscv_isac/data/rvopcodesdecoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,10 @@ def decode(self, instrObj_temp):
temp_instrobj.rm = int(get_arg_val(arg)(mcode), 2)
if arg == 'csr':
temp_instrobj.imm = int(get_arg_val(arg)(mcode), 2)
if arg == 'bs':
temp_instrobj.imm = int(get_arg_val(arg)(mcode), 2)
if arg == 'rnum':
temp_instrobj.imm = int(get_arg_val(arg)(mcode), 2)
if arg.find('imm') != -1:
if arg in ['imm12', 'imm20', 'zimm', 'imm2', 'imm3', 'imm4', 'imm5']:
imm = get_arg_val(arg)(mcode)
Expand Down
47 changes: 23 additions & 24 deletions riscv_isac/plugins/internaldecoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,9 @@ def init_rvp_dictionary(self):
self.rvp_dict_11[0x00003077] = 'bpick'

@plugins.decoderHookImpl
def setup(self, arch):
def setup(self, arch,isa):
self.arch = arch
self.isa = isa

FIRST2_MASK = 0x00000003
OPCODE_MASK = 0x0000007f
Expand Down Expand Up @@ -598,10 +599,10 @@ def arithi_ops(self, instrObj):

if funct3 == 0b001:
if funct7 == 0b0000100:
if instrObj.arch == 'rv32':
instrObj.instr_name = 'zip'
instrObj.rs1= rs1
instrObj.rd = rd
if self.arch == 'rv32':
instrObj.instr_name = 'zip'
instrObj.rs1= rs1
instrObj.rd = rd
elif sbi == 0b0100100 or sbi == 0b010010:
instrObj.rs1 = rs1
instrObj.rd = rd
Expand Down Expand Up @@ -720,7 +721,7 @@ def arithi_ops(self, instrObj):

if funct3 == 0b101:
if funct7 == 0b0000100:
if instrObj.arch == 'rv32':
if self.arch == 'rv32':
instrObj.instr_name = 'unzip'
instrObj.rs1= rs1
instrObj.rd = rd
Expand Down Expand Up @@ -1210,15 +1211,14 @@ def arith_ops(self, instrObj):
instrObj.rs2 = rs2
instrObj.rd = rd
elif funct7 == 0b0000100:
if rs2[0] == 0b0:
instrObj.instr_name = 'zext.h'
instrObj.rs1 = rs1
instrObj.rd = rd
else:
instrObj.instr_name = 'pack'
instrObj.rs1 = rs1
instrObj.rs2 = rs2
instrObj.rd = rd
# pack and zext.h have same opcode, func3, funct7 only diffrence is in rs2 value
# for zext.h rs2 is always 0, if pack instruction is used with x0 as rs2
# then cannot distinguish from each other, hence using isa to differentiate.
# zext.h is part of Zbb, pack is part of Zbkb
instrObj.instr_name = 'pack'
instrObj.rs1 = rs1
instrObj.rs2 = rs2
instrObj.rd = rd
elif funct7 == 0b0000101:
instrObj.instr_name = 'min'
instrObj.rs1 = rs1
Expand Down Expand Up @@ -1499,15 +1499,14 @@ def rv64i_arith_ops(self, instrObj):

if funct3 == 0b100:
if funct7 == 0b0000100:
if rs2[0] == 0b0:
instrObj.instr_name = 'zext.h'
instrObj.rs1 = rs1
instrObj.rd = rd
else:
instrObj.instr_name = 'packw'
instrObj.rs1 = rs1
instrObj.rs2 = rs2
instrObj.rd = rd
# packw and zext.h have same opcode, func3, funct7 only diffrence is in rs2 value
# for zext.h rs2 is always 0, if packw instruction is used with x0 as rs2
# then cannot distinguish from each other, hence using isa to differentiate.
# zext.h is part of Zbb, packw is part of Zbkb
instrObj.instr_name = 'packw'
instrObj.rs1 = rs1
instrObj.rs2 = rs2
instrObj.rd = rd
elif funct7 == 0b0010000:
instrObj.instr_name = 'sh2add.uw'
instrObj.rs1 = rs1
Expand Down
4 changes: 2 additions & 2 deletions riscv_isac/plugins/specification.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class DecoderSpec(object):
@decoderHookSpec
def setup(self,arch):
def setup(self,arch,isa):
Copy link
Collaborator

Choose a reason for hiding this comment

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

The setup function of the plugins does not need the isa anymore and all of the changes related need to be reverted back.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed isa from the plugin setup function

pass

@decoderHookSpec
Expand All @@ -19,4 +19,4 @@ def setup(self,trace,arch):

@parserHookSpec
def __iter__(self):
pass
pass