diff --git a/litex/soc/integration/export.py b/litex/soc/integration/export.py index 3a00b88f7..79e70eae1 100644 --- a/litex/soc/integration/export.py +++ b/litex/soc/integration/export.py @@ -466,6 +466,28 @@ def get_csr_svd(soc, vendor="litex", name="soc", description=None): svd.append(' {}'.format(field.offset)) svd.append(' '.format( reflow(field.description))) + + if field.values is not None: + svd_v = [] + for value in field.values: + if len(value) == 3: + name, description, value = value[1], value[2], value[0] + else: + name, description, value = value[1].split()[0], value[1], value[0] + name = re.search("[_A-Za-z0-9]+", name).group(0) + matches = re.findall("[+]?(0[xX][0-9a-fA-F]+|(#|0b)[01xX]+|[0-9]+)", value) + if len(matches) != 1 or len(name) == 0: + continue + value = matches[0][0] + svd_v.append(' ') + svd_v.append(' {}'.format(name)) + svd_v.append(' {}'.format(description)) + svd_v.append(' {}'.format(value)) + svd_v.append(' ') + if len(svd_v) != 0: + svd.append(' ') + svd += svd_v + svd.append(' ') svd.append(' ') else: field_size = csr.size