json2renode: cpu: Extract minor common logic

This commit is contained in:
Mateusz Karlic 2022-10-21 14:36:59 +02:00 committed by Mateusz Karlic
parent 97772eb4bd
commit eccb26874e

View file

@ -241,10 +241,6 @@ CPU.VexRiscv @ sysbus
cpu_string += """ cpu_string += """
cpuType: "rv32im" cpuType: "rv32im"
""" """
if time_provider:
cpu_string += """
timeProvider: {}
""".format(time_provider)
elif kind == 'picorv32': elif kind == 'picorv32':
cpu_string = """ cpu_string = """
@ -271,10 +267,6 @@ CPU.CV32E40P @ sysbus
cpu_string += """ cpu_string += """
cpuType: "rv32imc" cpuType: "rv32imc"
""" """
if time_provider:
cpu_string += """
timeProvider: {}
""".format(time_provider)
else: else:
raise Exception('Unsupported cpu type: {}'.format(kind)) raise Exception('Unsupported cpu type: {}'.format(kind))
@ -285,6 +277,8 @@ CPU.CV32E40P @ sysbus
cpu{cpu_id}: {cpu_string.strip()} cpu{cpu_id}: {cpu_string.strip()}
hartId: {cpu_id} hartId: {cpu_id}
""" """
if time_provider:
result += f' timeProvider: {time_provider}\n'
return result return result