From 409b6969a8f74856df000ea683bfbc5e57728fa4 Mon Sep 17 00:00:00 2001 From: Mateusz Holenko Date: Fri, 12 Jul 2019 17:18:22 +0200 Subject: [PATCH] Generate `cas` (Control And Status) peripheral. --- generate-renode-scripts.py | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/generate-renode-scripts.py b/generate-renode-scripts.py index feef2436e..dfaf58686 100755 --- a/generate-renode-scripts.py +++ b/generate-renode-scripts.py @@ -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: @@ -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. @@ -269,6 +301,9 @@ def generate_repl(): 'buffer': lambda: mem_regions['ethmac'], 'phy': lambda: peripherals['ethphy'] }, + 'cas': { + 'handler': generate_cas, + }, 'ddrphy': { 'handler': generate_silencer },