Skip to content
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

Add new extensions Zcb, Zfh, Zbkb, partial Zfa #921

Open
wants to merge 77 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
b09bb67
Delete .riscv_instr_base_test.py.swp
fanghuaqi Jul 25, 2022
5e72708
This commit adds support for the following extension:
JJ-Gaisler Jan 30, 2023
527db57
Fixed two issues:
JJ-Gaisler Oct 2, 2023
6fb1a3f
ZIP and UNZIP was erroneously generated on 32-bit arch
JJ-Gaisler Oct 2, 2023
5aad8f7
Fixed format issues for zbkb
JJ-Gaisler Oct 2, 2023
55f497e
Fixed incorrect binning of subnormal
JJ-Gaisler Oct 2, 2023
be5fa29
atohex was used to parse 64-bit values, replaced with sscanf
JJ-Gaisler Oct 2, 2023
7bf0e19
Missed to add FSH as an allowed instruction
JJ-Gaisler Oct 2, 2023
24b63d8
Fixed illegal SV code which didn't work with riviera
JJ-Gaisler Oct 12, 2023
5c43db1
NOEL-V adaptations to riscv-dv
JJ-Gaisler Oct 12, 2023
2150047
restore page-table generation to original strategy
JJ-Gaisler Oct 12, 2023
f613b79
Add noelv configurations for OVPsim
JJ-Gaisler Oct 12, 2023
e69995e
riviera needed explicit cast
JJ-Gaisler Oct 12, 2023
bc47dfb
Zbb exception for rori missed the case for roriw
JJ-Gaisler Oct 12, 2023
d881629
rv32zbkc and rv64zkbc added to isa
Jan 31, 2024
ae2bb54
src riscv_instr generator modified to add RV32ZBKC and RV64ZBKC exten…
Jan 31, 2024
663b5eb
line for coverage not needed yet, commented to make it compile
Jan 31, 2024
b66fb99
ecall and ebreak were repeated which produces an errro, warning solved
Feb 1, 2024
9c8133b
changes to solve compilation issues
Feb 1, 2024
46eddda
RV32ZBKC extension added to supported ones by noel-V
Feb 1, 2024
87ea537
UVM FATAL bug sovled when csr instruction where generated (using rivi…
Feb 6, 2024
a4aa7f9
Merge branch 'feature/csr_rnd_bug' into feature/Zbkb_Zbkc_Zbkx
Feb 6, 2024
a25f368
extension zbkx added
Feb 6, 2024
7b24fb9
Merge branch 'feature/Zbkb_Zbkc_Zbkx'
Feb 6, 2024
9fb530b
Fork updated from chipsalliance/riscv-dv
Feb 6, 2024
6675914
Update run-tests.yml
acb-gaisler Feb 7, 2024
d39ef68
Update run-tests.yml
acb-gaisler Feb 7, 2024
fd842f1
Update run-tests.yml
acb-gaisler Feb 7, 2024
2faf903
leave github workflow file as it was before testing
Feb 7, 2024
5970b38
zfa extension added
Feb 13, 2024
b534184
set_rand_mode and convert2asm methods added to riscv_zfa_instr
Feb 13, 2024
c10a3cf
small bugs solved to make it compile
Feb 13, 2024
bbc50b6
legalization for zfa instructions properly done now (taking in accoun…
Feb 14, 2024
57c46a9
Merge branch 'feature/Zfa'
Feb 14, 2024
49b96f7
fli inmediates are now generated
Feb 15, 2024
37cc356
Merge branch 'feature/Zfa'
Feb 15, 2024
86ca7d4
riviera simulator removed from available ones since randomization of …
Feb 15, 2024
8873d2a
sys time as file name for test, now unix timestamp is used which prod…
Feb 20, 2024
0b8f7ed
tmp file commited by error removed
Feb 20, 2024
898314c
docs update to include newly added extensions zfa, zfh, zcb, zbkb, zb…
Feb 20, 2024
4f22a8e
riviera simulator included back to list since the issues are a rivier…
Feb 20, 2024
39ddf9b
riscv_asm_program_gen.sv now allows for custom instructions in interr…
Feb 20, 2024
e4cf309
linker script left as it was for spike support
Feb 20, 2024
08bac92
run.py now includes zicsr and zifencei in all the supported targets
Feb 20, 2024
b57fc16
zfa rm now generates the 111 value when the instruction rm is not bei…
Feb 21, 2024
b09c880
Merge branch 'feature/zfa_bit_rm'
Feb 21, 2024
9ccd20f
zfa coverage group added
Feb 21, 2024
2c95a0c
special case for Zfa instr that are I_format but doesnt have 3 operan…
Feb 21, 2024
e0f6b04
zfa extension added to coverage group
Feb 21, 2024
327cc0b
typo in fvmp intructinos which made them not being covered solved
Feb 21, 2024
c758adf
forgoten zfa intruction added to the is_supported funcion because whe…
Feb 21, 2024
687b99e
gorci instructions are not in the ratified zbb standard, orc.b was be…
Feb 22, 2024
9f97735
zext.b and zext.h renaming in lib.py removed since those instructions…
Feb 22, 2024
2022f11
c.zext.b instructions was not being covered since the opcode was inco…
Feb 22, 2024
d7dd673
cov solved for orc.b and fli intructions which needed special treatment
Feb 23, 2024
1391248
cover point for round mode in FP instruction added
Feb 27, 2024
32767da
display statment removed in floating_point_instr for rm print in log
Feb 28, 2024
b5e7540
renaming in rev8 instr removed since is no longer pseudoinstr
Feb 28, 2024
96ae314
coverage groups now depend on the ext that are being used
Feb 28, 2024
ce4bf3f
new regex for implicit csr writes (like float instr)
Feb 28, 2024
d3a77bf
ignore zero register for store instr rs2 since is not generated by de…
Feb 29, 2024
4e20c90
LUI and AUIPC instr have unsigned imm so coverage for rd_sign removed
Feb 29, 2024
f316bd7
sign calculation for some forgotten zfh instr
Feb 29, 2024
5b194b1
rm coverpoint added for float instr that use it
Feb 29, 2024
159be0c
fp operand sign added for all new floating point intructions
Feb 29, 2024
8cc1e7f
rounding mode covergroup added for all floating point intructions
Feb 29, 2024
5df645f
directed_intr for int numeric values takes in account now new float ext
Mar 4, 2024
c5438ca
align cover point since non aligned ld/st are not supported by noel-v
Mar 4, 2024
7491666
sign check updated for all float intr not in F or D exts
Mar 5, 2024
705ef53
direct test for zfa instr
Mar 5, 2024
cc69b46
cross cover for signs in float ops updated to a achivable one by remo…
Mar 5, 2024
214c3aa
rv64_noelv test updated to make generate all types of intructions
Mar 5, 2024
787ad7d
floating point special values for cov updated to be able to be covered
Mar 5, 2024
79c7710
add.uw intr added to the get_opcode function
Mar 6, 2024
0b93b9c
fcvt special values for fd reg added
Mar 6, 2024
cfc2718
revert cp_align removal since is only for noel-v (wich does not allow…
Mar 6, 2024
43f056f
Merge branch 'feature/cov'
Mar 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added dataset.asdb
Binary file not shown.
2 changes: 2 additions & 0 deletions library.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
$INCLUDE = "$VSIMSALIBRARYCFG"
work = "./out_2024-02-14/work/work.lib" 1707905482696
24 changes: 18 additions & 6 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def do_simulate(sim_cmd, simulator, test_list, cwd, sim_opts, seed_gen,
debug_cmd=debug_cmd)
if sim_seed:
with open(('{}/seed.yaml'.format(os.path.abspath(output_dir))),
'w') as outfile:
'a') as outfile:
yaml.dump(sim_seed, outfile, default_flow_style=False)
if lsf_cmd:
run_parallel_cmd(cmd_list, timeout_s,
Expand Down Expand Up @@ -421,6 +421,9 @@ def gcc_compile(test_list, output_dir, isa, mabi, opts, debug_cmd):
debug_cmd : Produce the debug cmd log without running
"""
cwd = os.path.dirname(os.path.realpath(__file__))
addr_bits = 32
data_bytes = 16
successful_test = []
for test in test_list:
for i in range(0, test['iterations']):
if 'no_gcc' in test and test['no_gcc'] == 1:
Expand All @@ -429,10 +432,14 @@ def gcc_compile(test_list, output_dir, isa, mabi, opts, debug_cmd):
asm = prefix + ".S"
elf = prefix + ".o"
binary = prefix + ".bin"
srec = prefix + ".srec"
OBJCOPY_OPTS = "--srec-len=16 --srec-forceS3 --gap-fill=0 --remove-section=.comment --remove-section=.riscv.attributes" #jonathanjonsson
test_isa = isa
if not os.path.isfile(asm) and not debug_cmd:
logging.error("Cannot find assembly test: {}\n".format(asm))
#continue
sys.exit(RET_FAIL)

# gcc compilation
cmd = ("{} -static -mcmodel=medany \
-fvisibility=hidden -nostdlib \
Expand All @@ -446,7 +453,7 @@ def gcc_compile(test_list, output_dir, isa, mabi, opts, debug_cmd):
if 'gen_opts' in test:
# Disable compressed instruction
if re.search('disable_compressed_instr', test['gen_opts']):
test_isa = re.sub("c", "", test_isa)
test_isa = re.sub("c", "", test_isa, 1)
# If march/mabi is not defined in the test gcc_opts, use the default
# setting from the command line.
if not re.search('march', cmd):
Expand All @@ -456,10 +463,15 @@ def gcc_compile(test_list, output_dir, isa, mabi, opts, debug_cmd):
logging.info("Compiling {}".format(asm))
run_cmd_output(cmd.split(), debug_cmd=debug_cmd)
# Convert the ELF to plain binary, used in RTL sim
logging.info("Converting to {}".format(binary))
cmd = ("{} -O binary {} {}".format(
get_env_var("RISCV_OBJCOPY", debug_cmd=debug_cmd), elf, binary))
run_cmd_output(cmd.split(), debug_cmd=debug_cmd)
#logging.info("Converting to {}".format(binary))
#cmd = ("{} -O binary {} {}".format(
# get_env_var("RISCV_OBJCOPY", debug_cmd=debug_cmd), elf, binary))
#run_cmd_output(cmd.split(), debug_cmd=debug_cmd)
logging.info("Converting to {}".format(srec))
#cmd_srec = ("{} -O srec {} {} {}".format(
# get_env_var("RISCV_OBJCOPY", debug_cmd=debug_cmd), elf, srec, OBJCOPY_OPTS))
cmd_srec = (f"bincopy convert -i elf -o srec,{data_bytes},{addr_bits} {elf} {srec}")
run_cmd_output(cmd_srec.split(), debug_cmd=debug_cmd) #jonathanjonsson


def run_assembly(asm_test, iss_yaml, isa, mabi, gcc_opts, iss_opts, output_dir,
Expand Down
7 changes: 7 additions & 0 deletions scripts/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import signal

from datetime import date
from datetime import datetime

RET_SUCCESS = 0
RET_FAIL = 1
Expand Down Expand Up @@ -237,8 +238,11 @@ def process_regression_list(testlist, test, iterations, matched_list,
if iterations > 0 and entry['iterations'] > 0:
entry['iterations'] = iterations
if entry['iterations'] > 0:
now = datetime.now()
current_time = now.strftime("%Y-%m-%d_%H:%M:%S")
logging.info("Found matched tests: {}, iterations:{}".format(
entry['test'], entry['iterations']))
entry['test'] = entry['test']+'_'+str(current_time)
matched_list.append(entry)


Expand Down Expand Up @@ -486,6 +490,9 @@ def convert_pseudo_instr(instr_name, operands, binary):
elif instr_name == "rev":
instr_name = "grevi"
operands += ",31"
elif instr_name == "gorci" and ",7" in operands:
instr_name = "orc.b"
operands = operands.replace(",7","") # new addition
elif instr_name == "orc.p":
instr_name = "gorci"
operands += ",1"
Expand Down
3 changes: 2 additions & 1 deletion scripts/link.ld
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ ENTRY(_start)

SECTIONS
{
. = 0x80000000;
/*. = 0x40000000;*/
. = 0x00000000;
.text : { *(.text) }
. = ALIGN(0x1000);
.tohost : { *(.tohost) }
Expand Down
36 changes: 26 additions & 10 deletions scripts/ovpsim_log_to_trace_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@

INSTR_RE = re.compile(r"riscvOVPsim.*, 0x(?P<addr>.*?)(?P<section>\(.*\): ?)" \
"(?P<mode>[A-Za-z]*?)\s+(?P<bin>[a-f0-9]*?)\s+(?P<instr_str>.*?)$")
RD_RE = re.compile(r" (?P<r>[a-z]*[0-9]{0,2}?) (?P<pre>[a-f0-9]+?)" \
EXCEPT_RE = re.compile("riscvOVPsim.*, 0x(?P<addr>[0-9a-f]+).*: (?P<mode>[A-Za-z]*?)\s+[*]+\s+(?P<exception>[A-Z ]+)\s+")
RD_RE = re.compile(r" (?P<r>[a-z_]*[0-9]{0,2}?) (?P<pre>[a-f0-9]+?)" \
" -> (?P<val>[a-f0-9]+?)$")
BASE_RE = re.compile(
r"(?P<rd>[a-z0-9]+?),(?P<imm>[\-0-9]*?)\((?P<rs1>[a-z0-9]+?)\)")
Expand All @@ -51,9 +52,9 @@ def is_csr(r):
""" see if r is a csr """
if len(r) > 4:
return True
elif r[0] in ["m", "u", "d"]:
elif r[0] in ["m", "u", "d", "h"]:
return True
elif r in ["frm", "fcsr", "vl", "satp"]:
elif r in ["frm", "fcsr", "vl", "satp", "time", "sie", "sepc", "sip", "vsie", "vsip"]:
return True
else:
return False
Expand All @@ -69,7 +70,6 @@ def process_ovpsim_sim_log(ovpsim_log, csv,
log and save to a list.
"""
logging.info("Processing ovpsim log : {}".format(ovpsim_log))

# Remove the header part of ovpsim log
cmd = ("sed -i '/Info 1:/,$!d' {}".format(ovpsim_log))
os.system(cmd)
Expand All @@ -89,16 +89,24 @@ def process_ovpsim_sim_log(ovpsim_log, csv,
for line in f:
# Extract instruction infromation
m = INSTR_RE.search(line)
if m:
e = EXCEPT_RE.search(line)
#print(f"{line} is m? {m}, is e {e}")
if m or e:
if prev_trace: # write out the previous one when find next one
trace_csv.write_trace_entry(prev_trace)
instr_cnt += 1
prev_trace = 0
prev_trace = RiscvInstructionTraceEntry()
prev_trace.instr_str = m.group("instr_str")
prev_trace.pc = m.group("addr")
prev_trace.mode = convert_mode(m.group("mode"), line)
prev_trace.binary = m.group("bin")
if m:
prev_trace.instr_str = m.group("instr_str")
prev_trace.pc = m.group("addr")
prev_trace.mode = convert_mode(m.group("mode"), line)
prev_trace.binary = m.group("bin")
elif e:
prev_trace.instr_str = e.group("exception")
prev_trace.pc = e.group("addr")
prev_trace.mode = convert_mode(e.group("mode"), line)
prev_trace.binary = "00000000" #insert non-valid instruction
if full_trace:
prev_trace.instr = prev_trace.instr_str.split(" ")[0]
prev_trace.operand = prev_trace.instr_str[
Expand All @@ -110,13 +118,15 @@ def process_ovpsim_sim_log(ovpsim_log, csv,
c = RD_RE.search(line)
if c:
if is_csr(c.group("r")):
#print("CSR: "+c.group("r") + ":" + c.group("val"))
prev_trace.csr.append(c.group("r") + ":" + c.group("val"))
else:
#print("GPR: "+c.group("r") + ":" + c.group("val"))
prev_trace.gpr.append(c.group("r") + ":" + c.group("val"))
logging.info("Processed instruction count : {} ".format(instr_cnt))
if instr_cnt == 0:
logging.error("No Instructions in logfile: {}".format(ovpsim_log))
sys.exit(RET_FATAL)
#sys.exit(RET_FATAL)
logging.info("CSV saved to : {}".format(csv))


Expand All @@ -126,6 +136,12 @@ def process_trace(trace):
process_imm(trace)
if trace.instr == "jalr":
process_jalr(trace)

# the coverage mechanism doesn't handle more than 4 operands
rounding_modes = ["rne", "rtz", "rdn", "rup", "rmm", "dyn"]
if any(rmm in trace.operand for rmm in rounding_modes):
trace.operand = ','.join(trace.operand.split(",")[:-1])

trace.instr, trace.operand = convert_pseudo_instr(
trace.instr, trace.operand, trace.binary)
# process any instruction of the form:
Expand Down
18 changes: 10 additions & 8 deletions src/isa/riscv_b_instr.sv
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,16 @@ class riscv_b_instr extends riscv_instr;
GORCI, SLOI, SROI, GREVI, CMIX, CMOV, FSL: get_opcode = 7'b0010011;
FSR, FSRI, BMATFLIP, CRC32_B, CRC32_H, CRC32_W, CRC32C_B, CRC32C_H: get_opcode = 7'b0010011;
CRC32C_W, CRC32_D, CRC32C_D: get_opcode = 7'b0010011;
SHFL, UNSHFL, BCOMPRESS, BDECOMPRESS, PACK, PACKU, BMATOR, BMATXOR, PACKH, BFP: get_opcode
// PACK, PACKH (now in zbkb)
SHFL, UNSHFL, BCOMPRESS, BDECOMPRESS, PACKU, BMATOR, BMATXOR, BFP: get_opcode
= 7'b0110011;
SHFLI, UNSHFLI: get_opcode = 7'b0010011;
SLOW, SROW, GORCW, GREVW: get_opcode = 7'b0111011;
SLOIW, SROIW, GORCIW, GREVIW: get_opcode = 7'b0011011;
FSLW, FSRW: get_opcode = 7'b0111011;
FSRIW: get_opcode = 7'b0011011;
SHFLW, UNSHFLW, BCOMPRESSW, BDECOMPRESSW, PACKW, PACKUW, BFPW: get_opcode = 7'b0111011;
// PACKW,
SHFLW, UNSHFLW, BCOMPRESSW, BDECOMPRESSW, PACKUW, BFPW: get_opcode = 7'b0111011;
default: get_opcode = super.get_opcode();
endcase
endfunction
Expand Down Expand Up @@ -152,11 +154,11 @@ class riscv_b_instr extends riscv_instr;
UNSHFL: get_func3 = 3'b101;
BCOMPRESS: get_func3 = 3'b110;
BDECOMPRESS: get_func3 = 3'b110;
PACK: get_func3 = 3'b100;
//PACK: get_func3 = 3'b100;
PACKU: get_func3 = 3'b100;
BMATOR: get_func3 = 3'b011;
BMATXOR: get_func3 = 3'b011;
PACKH: get_func3 = 3'b111;
//PACKH: get_func3 = 3'b111;
BFP: get_func3 = 3'b111;
SHFLI: get_func3 = 3'b001;
UNSHFLI: get_func3 = 3'b101;
Expand All @@ -177,7 +179,7 @@ class riscv_b_instr extends riscv_instr;
UNSHFLW: get_func3 = 3'b101;
BCOMPRESSW: get_func3 = 3'b110;
BDECOMPRESSW: get_func3 = 3'b110;
PACKW: get_func3 = 3'b100;
//PACKW: get_func3 = 3'b100;
PACKUW: get_func3 = 3'b100;
BFPW: get_func3 = 3'b111;
XPERM_N: get_func3 = 3'b010;
Expand Down Expand Up @@ -213,11 +215,11 @@ class riscv_b_instr extends riscv_instr;
UNSHFL: get_func7 = 7'b0000100;
BCOMPRESS: get_func7 = 7'b0000100;
BDECOMPRESS: get_func7 = 7'b0100100;
PACK: get_func7 = 7'b0000100;
//PACK: get_func7 = 7'b0000100;
PACKU: get_func7 = 7'b0100100;
BMATOR: get_func7 = 7'b0000100;
BMATXOR: get_func7 = 7'b0100100;
PACKH: get_func7 = 7'b0000100;
//PACKH: get_func7 = 7'b0000100;
BFP: get_func7 = 7'b0100100;
SLOW: get_func7 = 7'b0010000;
SROW: get_func7 = 7'b0010000;
Expand All @@ -231,7 +233,7 @@ class riscv_b_instr extends riscv_instr;
UNSHFLW: get_func7 = 7'b0000100;
BCOMPRESSW: get_func7 = 7'b0000100;
BDECOMPRESSW: get_func7 = 7'b0100100;
PACKW: get_func7 = 7'b0000100;
//PACKW: get_func7 = 7'b0000100;
PACKUW: get_func7 = 7'b0100100;
BFPW: get_func7 = 7'b0100100;
XPERM_N: get_func7 = 7'b0010100;
Expand Down
53 changes: 42 additions & 11 deletions src/isa/riscv_floating_point_instr.sv
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright 2020 Google LLC
* Copyright 2023 Frontgrade Gaisler
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -53,11 +54,14 @@ class riscv_floating_point_instr extends riscv_instr;
asm_str = $sformatf("%0s%0s, %0s(%0s)", asm_str, fd.name(), get_imm(), rs1.name());
end else if (instr_name inside {FMV_X_W, FMV_X_D, FCVT_W_S, FCVT_WU_S,
FCVT_L_S, FCVT_LU_S, FCVT_L_D, FCVT_LU_D,
FCVT_W_D, FCVT_WU_D}) begin
FCVT_W_D, FCVT_WU_D, FMV_X_H, FCVT_W_H,
FCVT_WU_H, FCVT_L_H, FCVT_LU_H}) begin

asm_str = $sformatf("%0s%0s, %0s", asm_str, rd.name(), fs1.name());
end else if (instr_name inside {FMV_W_X, FMV_D_X, FCVT_S_W, FCVT_S_WU,
FCVT_S_L, FCVT_D_L, FCVT_S_LU, FCVT_D_W,
FCVT_D_LU, FCVT_D_WU}) begin
FCVT_D_LU, FCVT_D_WU, FCVT_H_WU, FCVT_H_W,
FMV_H_X, FCVT_H_L, FCVT_H_LU}) begin
asm_str = $sformatf("%0s%0s, %0s", asm_str, fd.name(), rs1.name());
end else begin
asm_str = $sformatf("%0s%0s, %0s", asm_str, fd.name(), fs1.name());
Expand All @@ -67,7 +71,7 @@ class riscv_floating_point_instr extends riscv_instr;
R_FORMAT:
if (category == COMPARE) begin
asm_str = $sformatf("%0s%0s, %0s, %0s", asm_str, rd.name(), fs1.name(), fs2.name());
end else if (instr_name inside {FCLASS_S, FCLASS_D}) begin
end else if (instr_name inside {FCLASS_H, FCLASS_S, FCLASS_D}) begin
asm_str = $sformatf("%0s%0s, %0s", asm_str, rd.name(), fs1.name());
end else begin
asm_str = $sformatf("%0s%0s, %0s, %0s", asm_str, fd.name(), fs1.name(), fs2.name());
Expand All @@ -88,9 +92,11 @@ class riscv_floating_point_instr extends riscv_instr;
endcase
if ((category == ARITHMETIC) && use_rounding_mode_from_instr &&
!(instr_name inside {FMIN_S, FMAX_S, FMIN_D, FMAX_D, FMV_W_X, FMV_X_W,
FMV_D_X, FMV_X_D, FCLASS_S, FCLASS_D,
FCVT_D_S, FCVT_D_W, FCVT_D_WU,
FSGNJ_S, FSGNJN_S, FSGNJX_S, FSGNJ_D, FSGNJN_D, FSGNJX_D})) begin
FMV_D_X, FMV_X_D, FCLASS_H, FCLASS_S, FCLASS_D,
FCVT_D_S, FCVT_D_W, FCVT_D_WU, FSGNJ_S, FSGNJN_S,
FCVT_S_H, FCVT_D_H, FCVT_Q_H, FMV_X_H, FSGNJX_S,
FSGNJ_D, FSGNJN_D, FSGNJX_D, FSGNJ_H, FSGNJN_H,
FSGNJX_H, FMIN_H, FMAX_H, FCLASS_H, FMV_H_X })) begin
asm_str = {asm_str, ", ", rm.name()};
end
if(comment != "")
Expand Down Expand Up @@ -131,12 +137,14 @@ class riscv_floating_point_instr extends riscv_instr;
has_imm = 1'b1;
end else if (instr_name inside {FMV_X_W, FMV_X_D, FCVT_W_S, FCVT_WU_S,
FCVT_L_S, FCVT_LU_S, FCVT_L_D, FCVT_LU_D, FCVT_LU_S,
FCVT_W_D, FCVT_WU_D}) begin
FCVT_W_D, FCVT_WU_D, FCVT_W_H, FCVT_WU_H, FMV_X_H,
FCVT_L_H, FCVT_LU_H }) begin
has_fd = 1'b0;
has_rd = 1'b1;
end else if (instr_name inside {FMV_W_X, FMV_D_X, FCVT_S_W, FCVT_S_WU,
FCVT_S_L, FCVT_D_L, FCVT_S_LU, FCVT_D_W,
FCVT_D_LU, FCVT_D_WU}) begin
FCVT_D_LU, FCVT_D_WU, FCVT_H_W,
FCVT_H_WU, FMV_H_X, FCVT_H_L, FCVT_H_LU}) begin
has_rs1 = 1'b1;
has_fs1 = 1'b0;
end
Expand All @@ -151,7 +159,7 @@ class riscv_floating_point_instr extends riscv_instr;
if (category == COMPARE) begin
has_rd = 1'b1;
has_fd = 1'b0;
end else if (instr_name inside {FCLASS_S, FCLASS_D}) begin
end else if (instr_name inside {FCLASS_H, FCLASS_S, FCLASS_D}) begin
has_rd = 1'b1;
has_fd = 1'b0;
has_fs2 = 1'b0;
Expand Down Expand Up @@ -222,8 +230,9 @@ class riscv_floating_point_instr extends riscv_instr;
R_FORMAT: begin
// convert Pseudoinstructions for ovpsim
// fmv.s rd, rs -> fsgnj.s rd, rs, rs
if (operands.size() == 2 && instr_name inside {FSGNJ_S, FSGNJX_S, FSGNJN_S, FSGNJ_D,
FSGNJX_D, FSGNJN_D}) begin
if (operands.size() == 2 && instr_name inside {FSGNJ_H, FSGNJX_H, FSGNJN_H,
FSGNJ_S, FSGNJX_S, FSGNJN_S,
FSGNJ_D, FSGNJX_D, FSGNJN_D}) begin
operands.push_back(operands[$]);
end

Expand Down Expand Up @@ -267,6 +276,9 @@ class riscv_floating_point_instr extends riscv_instr;

virtual function riscv_fpr_t get_fpr(input string str);
str = str.toupper();
if (str == "ZERO") begin
str = "FT0";
end
if (!uvm_enum_wrapper#(riscv_fpr_t)::from_name(str, get_fpr)) begin
`uvm_fatal(`gfn, $sformatf("Cannot convert %0s to FPR", str))
end
Expand All @@ -282,6 +294,25 @@ class riscv_floating_point_instr extends riscv_instr;
fs2_sign = get_fp_operand_sign(fs2_value, 31);
fs3_sign = get_fp_operand_sign(fs3_value, 31);
fd_sign = get_fp_operand_sign(fd_value, 31);
// zfh introduces many new convert functions
end else if (instr_name == FCVT_S_H) begin
fs1_sign = get_fp_operand_sign(fs1_value, 15);
fd_sign = get_fp_operand_sign(fd_value, 31);
end else if (instr_name == FCVT_H_S) begin
fs1_sign = get_fp_operand_sign(fs1_value, 31);
fd_sign = get_fp_operand_sign(fd_value, 15);
end else if (instr_name == FCVT_D_H) begin
fs1_sign = get_fp_operand_sign(fs1_value, 15);
fd_sign = get_fp_operand_sign(fd_value, 63);
end else if (instr_name == FCVT_H_D) begin
fs1_sign = get_fp_operand_sign(fs1_value, 63);
fd_sign = get_fp_operand_sign(fd_value, 15);
end else if (instr_name == FCVT_Q_H) begin
fs1_sign = get_fp_operand_sign(fs1_value, 15);
fd_sign = get_fp_operand_sign(fd_value, 127);
end else if (instr_name == FCVT_H_Q) begin
fs1_sign = get_fp_operand_sign(fs1_value, 127);
fd_sign = get_fp_operand_sign(fd_value, 15);
end else if (instr_name == FCVT_S_D) begin
fs1_sign = get_fp_operand_sign(fs1_value, 63);
fd_sign = get_fp_operand_sign(fd_value, 31);
Expand Down
Loading