Fix CSR map copy issue
@@ -31,6 +31,7 @@ import sys
import yaml
import argparse
import random
+import copy
try:
from bitstring import BitArray as bitarray
@@ -249,14 +250,14 @@ def gen_csr_test_pass(test_file, end_addr):
test_file.write(f"\tj csr_pass\n")
-def gen_csr_instr(csr_map, csr_instructions, xlen,
+def gen_csr_instr(original_csr_map, csr_instructions, xlen,
iterations, out, end_signature_addr):
"""
Uses the information in the map produced by get_csr_map() to generate
test CSR instructions operating on the generated random values.
Args:
- csr_map: The dictionary containing CSR mappings generated by get_csr_map()
+ original_csr_map: The dictionary containing CSR mappings generated by get_csr_map()
csr_instructions: A list of all supported CSR instructions in string form.
xlen: The RISC-V ISA bit length.
iterations: Indicates how many randomized test files will be generated.
@@ -270,6 +271,7 @@ def gen_csr_instr(csr_map, csr_instructions, xlen,
for i in range(iterations):
# pick two GPRs at random to act as source and destination registers
# for CSR operations
+ csr_map = copy.deepcopy(original_csr_map)
source_reg, dest_reg = [f"x{i}" for i in random.sample(range(1, 16), 2)]
csr_list = list(csr_map.keys())
with open(f"{out}/riscv_csr_test.{i}.S", "w") as csr_test_file:
