From 34095deff570336bec35e54d9e576cb0c751dc6d Mon Sep 17 00:00:00 2001 From: malsheimer Date: Fri, 10 Nov 2023 00:34:56 +0100 Subject: [PATCH] Fixed error when defining a reserved field at LSB position in Markdown template --- corsair/templates/regmap_md.j2 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/corsair/templates/regmap_md.j2 b/corsair/templates/regmap_md.j2 index 9bf0fb8..1124190 100755 --- a/corsair/templates/regmap_md.j2 +++ b/corsair/templates/regmap_md.j2 @@ -15,7 +15,7 @@ {#- value in hex format #} {% macro literal(reset, width) %} -{{ "0x%0{w}x".format(w=width // 4) % reset }} +{{ "0x%0{w}x".format(w=(width + 3) // 4) % reset }} {%- endmacro %} {#- TEMPLATE NAMESPACE #} @@ -77,6 +77,10 @@ Reset value: {{ literal(reg.reset, config['data_width']) }} {{ "| %-16s | %-6s | %-15s | %-10s | %s |" % (bf.name, range(bf.msb, bf.lsb), mode(bf), literal(bf.reset, bf.width), bf.description) }} {% set tmp.reserved_msb = bf.lsb - 1 %} {% endfor %} + {#- Check that the LSB is less than zero. If not, add a "reserved" field #} + {% if tmp.reserved_msb >= 0 %} +{{ "| %-16s | %-6s | %-15s | %-10s | %s |" % ('-', range(tmp.reserved_msb, 0), '-', literal(0, tmp.reserved_msb + 1), 'Reserved') }} + {% endif %} {% for bf in reg %} {% if bf.enums %}