Skip to content

Commit e9cc253

Browse files
committed
fix: remove '_RV32' suffix for CSRs and conditionally generate multi versions for multi arch encoded instructions
1 parent 5b85240 commit e9cc253

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

backends/generators/generator.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -276,15 +276,17 @@ def load_instructions(
276276

277277
# Process RV64 encoding
278278
rv64_match = rv64_encoding.get("match")
279+
rv32_match = rv32_encoding.get("match")
280+
279281
if rv64_match:
280282
instr_dict[name] = {
281283
"match": rv64_match
282284
} # RV64 gets the default name
283285

284-
# Process RV32 encoding with a _rv32 suffix
285-
rv32_match = rv32_encoding.get("match")
286-
if rv32_match:
287-
instr_dict[f"{name}_rv32"] = {"match": rv32_match}
286+
if rv32_match and rv32_match != rv64_match:
287+
# Process RV32 encoding with a _rv32 suffix
288+
if rv32_match:
289+
instr_dict[f"{name}_rv32"] = {"match": rv32_match}
288290

289291
continue # Skip the rest of the loop as we've already added the encodings
290292
elif "RV64" in encoding:
@@ -442,10 +444,11 @@ def load_csrs(csr_root, enabled_extensions, include_all=False, target_arch="RV64
442444
addr_int = int(addr_to_use, 0)
443445

444446
# For BOTH architecture, add suffix to RV32-specific CSRs
445-
if target_arch == "BOTH" and base == 32:
446-
csrs[addr_int] = f"{name.upper()}.RV32"
447-
else:
448-
csrs[addr_int] = name.upper()
447+
# if target_arch == "BOTH" and base == 32:
448+
# csrs[addr_int] = f"{name.upper()}.RV32"
449+
# else:
450+
# csrs[addr_int] = name.upper()
451+
csrs[addr_int] = name.upper()
449452
except Exception as e:
450453
logging.error(f"Error parsing address {addr_to_use} in {path}: {e}")
451454
address_errors += 1

backends/generators/sverilog/sverilog_generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def parse_args():
125125
)
126126
parser.add_argument(
127127
"--arch",
128-
default="RV64",
128+
default="BOTH",
129129
choices=["RV32", "RV64", "BOTH"],
130130
help="Target architecture (RV32, RV64, or BOTH). Default is RV64.",
131131
)

0 commit comments

Comments
 (0)