From a47ca9dadcf2fec62d20097fad1a80fca7fd927d Mon Sep 17 00:00:00 2001 From: Hoa Nguyen Date: Sun, 15 Oct 2023 19:29:01 -0700 Subject: [PATCH] arch-riscv: Add a function generating the ISA string Currently, we are hardcoding the ISA string in the device tree generator. The ISA string from the device tree affects which ISA extensions will be used by the bootloader/kernel. This function allows generating the ISA string from the gem5's ISA object rather than using hardcoded values. Change-Id: I2f3720fb6da24347f38f26d9a49939484b11d3bb Signed-off-by: Hoa Nguyen --- src/arch/riscv/RiscvISA.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/arch/riscv/RiscvISA.py b/src/arch/riscv/RiscvISA.py index 3f123405e9..62dcffb5d8 100644 --- a/src/arch/riscv/RiscvISA.py +++ b/src/arch/riscv/RiscvISA.py @@ -13,6 +13,7 @@ # # Copyright (c) 2016 RISC-V Foundation # Copyright (c) 2016 The University of Virginia +# Copyright (c) 2023 The Regents of the University of California # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -94,3 +95,18 @@ class RiscvISA(BaseISA): "Length of each vector element in bits. \ ELEN in Ch. 2 of RISC-V vector spec", ) + + def get_isa_string(self): + isa_extensions = [] + # check for the base ISA type + if self.riscv_type.value == "RV32": + isa_extensions.append("rv32") + elif self.riscv_type.value == "RV64": + isa_extensions.append("rv64") + # use imafdc by default + isa_extensions.extend(["i", "m", "a", "f", "d", "c"]) + # check for the vector extension + if self.enable_rvv.value == True: + isa_extensions.append("v") + isa_string = "".join(isa_extensions) + return isa_string