Skip to content

Commit

Permalink
Rework obtaining system clock frequency.
Browse files Browse the repository at this point in the history
Different versions of LiteX report this value
as different properties. This commit adds a wrapper
function that iterates over them and returns the
proper one.
  • Loading branch information
mateusz-holenko committed Jul 22, 2019
1 parent bd77b6c commit aebbe7f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions generate-renode-scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,16 @@ def generate_cas(peripheral, shadow_base, **kwargs):
return result


def get_clock_frequency():
"""
Returns:
int: system clock frequency
"""
# in different LiteX versions this property
# has different names
return constants['config_clock_frequency' if 'config_clock_frequency' in constants else 'system_clock_frequency']['value']


def generate_repl():
""" Generates platform definition.
Expand All @@ -316,7 +326,7 @@ def generate_repl():
'model': 'Timers.LiteX_Timer',
'properties': {
'frequency':
lambda: constants['system_clock_frequency']['value']
lambda: get_clock_frequency()
}
},
'ethmac': {
Expand All @@ -333,7 +343,7 @@ def generate_repl():
'model': 'Timers.LiteX_CPUTimer',
'properties': {
'frequency':
lambda: constants['system_clock_frequency']['value']
lambda: get_clock_frequency()
},
'interrupts': {
# IRQ #100 in Renode's VexRiscv model is mapped to Machine Timer Interrupt
Expand Down

0 comments on commit aebbe7f

Please sign in to comment.