upsilon/gateware/csr2mp.py

29 lines
742 B
Python

#!/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
#
# TODO: Devicetree?
import collections
import argparse
import json
import sys
import mmio_descr
with open(sys.argv[1], 'rt') as f:
j = json.load(f)
print("from micropython import const")
for key in j["csr_registers"]:
if key.startswith("picorv32"):
print(f'{key} = const({j["csr_registers"][key]["addr"]})')
print(f'picorv32_ram = const({j["memories"]["picorv32_ram"]["base"]})')