upsilon/gateware/csr2mp.py

29 lines
742 B
Python
Raw Normal View History

2023-06-21 18:47:52 -04:00
#!/usr/bin/python3
# Copyright 2023 (C) Peter McGoron
#
# This file is a part of Upsilon, a free and open source software project.
# For license terms, refer to the files in `doc/copying` in the Upsilon
# source distribution.
#######################################################################
#
# This file generates memory locations
2023-06-21 18:47:52 -04:00
#
# TODO: Devicetree?
2023-06-26 15:49:20 -04:00
import collections
2023-06-23 18:15:53 -04:00
import argparse
2023-06-21 18:47:52 -04:00
import json
import sys
2023-06-28 18:49:26 -04:00
import mmio_descr
2023-06-23 18:15:53 -04:00
with open(sys.argv[1], 'rt') as f:
j = json.load(f)
2023-06-23 18:15:53 -04:00
print("from micropython import const")
2023-06-21 18:47:52 -04:00
for key in j["csr_registers"]:
if key.startswith("picorv32"):
print(f'{key} = const({j["csr_registers"][key]["addr"]})')
2023-06-21 18:47:52 -04:00
print(f'picorv32_ram = const({j["memories"]["picorv32_ram"]["base"]})')