Skip to content

Commit

Permalink
Generate cas (Control And Status) peripheral.
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusz-holenko committed Jul 15, 2019
1 parent ae3bee6 commit 409b696
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion generate-renode-scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def generate_peripheral(peripheral, shadow_base, **kwargs):
for constant, val in peripheral['constants'].items():
if constant == 'interrupt':
result += ' -> cpu@{}\n'.format(val)
else:
elif 'ignored_constants' not in kwargs or constant not in kwargs['ignored_constants']:
result += ' {}: {}\n'.format(constant, val)

if 'properties' in kwargs:
Expand Down Expand Up @@ -241,6 +241,38 @@ def generate_spiflash(peripheral, shadow_base, **kwargs):
return result


def generate_cas(peripheral, shadow_base, **kwargs):
result = generate_peripheral(peripheral, shadow_base, model='GPIOPort.LiteX_ControlAndStatus', ignored_constants=['leds_count', 'switches_count', 'buttons_count'])

leds_count = int(peripheral['constants']['leds_count'])
switches_count = int(peripheral['constants']['switches_count'])
buttons_count = int(peripheral['constants']['buttons_count'])

for i in range(leds_count):
result += """
{} -> led{}@0
""".format(i, i)

for i in range(leds_count):
result += """
led{}: Miscellaneous.LED @ cas {}
""".format(i, i)

for i in range(switches_count):
result += """
switch{}: Miscellaneous.Button @ cas {}
-> cas@{}
""".format(i, i + 32, i + 32)

for i in range(buttons_count):
result += """
button{}: Miscellaneous.Button @ cas {}
-> cas@{}
""".format(i, i + 64, i + 64)

return result


def generate_repl():
""" Generates platform definition.
Expand Down Expand Up @@ -269,6 +301,9 @@ def generate_repl():
'buffer': lambda: mem_regions['ethmac'],
'phy': lambda: peripherals['ethphy']
},
'cas': {
'handler': generate_cas,
},
'ddrphy': {
'handler': generate_silencer
},
Expand Down

0 comments on commit 409b696

Please sign in to comment.