Skip to content

Commit

Permalink
Merge branch 'foss-for-synopsys-dwc-arc-processors-SolveEncodings'
Browse files Browse the repository at this point in the history
  • Loading branch information
aswaterman committed Sep 30, 2024
2 parents 6a1be96 + 191123c commit 47862ce
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -945,17 +945,19 @@ def make_c(instr_dict):

arg_str = ''
for name, rng in arg_lut.items():
sanitized_name = name.replace(' ', '_').replace('=', '_eq_')
begin = rng[1]
end = rng[0]
mask = ((1 << (end - begin + 1)) - 1) << begin
arg_str += f"#define INSN_FIELD_{name.upper().replace(' ', '_')} {hex(mask)}\n"
arg_str += f"#define INSN_FIELD_{sanitized_name.upper()} {hex(mask)}\n"

with open(f'{os.path.dirname(__file__)}/encoding.h', 'r') as file:
enc_header = file.read()

commit = os.popen('git log -1 --format="format:%h"').read()
enc_file = open('encoding.out.h','w')
enc_file.write(f'''/* SPDX-License-Identifier: BSD-3-Clause */

# Generate the output as a string
output_str = f'''/* SPDX-License-Identifier: BSD-3-Clause */
/* Copyright (c) 2023 RISC-V International */
Expand All @@ -978,8 +980,11 @@ def make_c(instr_dict):
{declare_csr_str}#endif
#ifdef DECLARE_CAUSE
{declare_cause_str}#endif
''')
enc_file.close()
'''

# Write the modified output to the file
with open('encoding.out.h', 'w') as enc_file:
enc_file.write(output_str)

def make_go(instr_dict):

Expand Down

0 comments on commit 47862ce

Please sign in to comment.