2022-07-12 15:36:50 -04:00
|
|
|
#!/usr/bin/python3
|
|
|
|
import json
|
|
|
|
|
|
|
|
reg_names = {
|
2022-07-27 09:32:49 -04:00
|
|
|
"adc" : ("from_slave", "finished", "arm", "conv"),
|
|
|
|
"dac" : ("from_slave", "to_slave", "finished", "arm", "ss")
|
2022-07-12 15:36:50 -04:00
|
|
|
}
|
|
|
|
max_num = 8
|
2022-07-14 15:46:38 -04:00
|
|
|
# TODO: make dependent on adc, dac
|
2022-07-12 15:36:50 -04:00
|
|
|
|
|
|
|
def get_reg(j, name, num, pos):
|
|
|
|
return j["csr_registers"][f"{name}{num}_{pos}"]["addr"]
|
|
|
|
|
|
|
|
j = json.load(open("csr.json"))
|
|
|
|
|
2022-07-13 15:35:42 -04:00
|
|
|
print('''
|
|
|
|
#pragma once
|
|
|
|
typedef volatile uint32_t *csr_t;
|
|
|
|
#define ADC_MAX 8
|
|
|
|
#define DAC_MAX 8
|
2022-07-14 15:46:38 -04:00
|
|
|
#ifdef CSR_LOCATIONS
|
2022-07-13 15:35:42 -04:00
|
|
|
''')
|
2022-07-12 15:36:50 -04:00
|
|
|
|
|
|
|
for conv in iter(reg_names):
|
|
|
|
for reg in reg_names[conv]:
|
2022-07-14 15:46:38 -04:00
|
|
|
print(f"static const csr_t {conv}_{reg}[{max_num}] =", "{")
|
2022-07-12 15:36:50 -04:00
|
|
|
for i in range(0,max_num):
|
2022-07-13 12:11:47 -04:00
|
|
|
print("\t (csr_t)", get_reg(j, conv, i, reg), end='')
|
2022-07-12 15:36:50 -04:00
|
|
|
if i != max_num - 1:
|
|
|
|
print(",")
|
|
|
|
print("\n};")
|
2022-07-14 15:46:38 -04:00
|
|
|
print("#endif // CSR_LOCATION")
|