Skip to content

Commit be49d9a

Browse files
Incarnation-p-leecmuellner
authored andcommitted
Fix one bug of spike varch elen
According to the ISA, the zve32/zve64 xdf decides the elen of the RVV. Thus we should pick up extension instead of xlen for spike varch generation. Signed-off-by: Pan Li <[email protected]>
1 parent 99e2d2b commit be49d9a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

scripts/march-to-cpu-opt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ SPIKE_EXT_NOT_ALLOWED = [
4141
CPU_OPTIONS = {
4242
"xlen": "",
4343
"vlen": "",
44+
"elen": "",
4445
"extensions": [],
4546
}
4647

@@ -146,6 +147,14 @@ def get_vlen(ext_dict):
146147
vlen = max(vlen, zvelen)
147148
return vlen
148149

150+
def get_elen(ext_dict):
151+
elen = 32
152+
153+
if "zve64x" in ext_dict or "zve64f" in ext_dict or "zve64d" in ext_dict:
154+
elen = 64
155+
156+
return elen
157+
149158
def print_qemu_cpu():
150159
cpu_options = []
151160
cpu_options.append("rv{0}".format(CPU_OPTIONS['xlen']))
@@ -186,7 +195,7 @@ def print_spike_varch():
186195
if not CPU_OPTIONS['vlen']:
187196
return ""
188197

189-
return "vlen:{0},elen:{1}".format(CPU_OPTIONS['vlen'], CPU_OPTIONS['xlen'])
198+
return "vlen:{0},elen:{1}".format(CPU_OPTIONS['vlen'], CPU_OPTIONS['elen'])
190199

191200
class TestArchStringParse(unittest.TestCase):
192201
def _test(self, arch, expected_arch_list, expected_vlen=0):
@@ -256,6 +265,7 @@ def parse_elf_file(elf_file_path):
256265

257266
CPU_OPTIONS["extensions"] = extensions
258267
CPU_OPTIONS["vlen"] = get_vlen(extension_dict)
268+
CPU_OPTIONS["elen"] = get_elen(extension_dict)
259269
CPU_OPTIONS["xlen"] = get_xlen(elf_file_path)
260270

261271
def main(argv):

0 commit comments

Comments
 (0)