Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ Constructor for the HTML exporter class
* Additional context variables to load into the template namespace.
* `show_signals`
* Show signal components. Default is False
* `reverse-fields`
* Show fields in reverse order (LSB to MSB). Default is False
* `extra_doc_properties`
* List of properties to explicitly document.

Expand Down
11 changes: 11 additions & 0 deletions src/peakrdl_html/__peakrdl__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class Exporter(ExporterSubcommandPlugin):
"user_static_dir": schema.DirectoryPath(),
"extra_doc_properties": [schema.String()],
"generate_source_links": schema.Boolean(),
"reverse_fields": schema.Boolean(),
}


Expand Down Expand Up @@ -46,14 +47,24 @@ def add_exporter_arguments(self, arg_group: 'argparse.ArgumentParser') -> None:
help="Show signal components in generated doc pages"
)

arg_group.add_argument(
"--reverse-fields",
dest="reverse_fields",
default=False,
action="store_true",
help="Show fields in reverse order (LSB to MSB)"
)

def do_export(self, top_node: 'AddrmapNode', options: 'argparse.Namespace') -> None:
generate_source_links = self.cfg['generate_source_links']
if generate_source_links is None:
generate_source_links = True

reverse_fields = options.reverse_fields or self.cfg['reverse_fields']

html = HTMLExporter(
show_signals=options.show_signals,
reverse_fields=reverse_fields,
user_template_dir=self.cfg['user_template_dir'],
user_static_dir=self.cfg['user_static_dir'],
extra_doc_properties=self.cfg['extra_doc_properties'],
Expand Down
16 changes: 14 additions & 2 deletions src/peakrdl_html/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ def __init__(self, **kwargs: 'Any') -> None:
Additional context variables to load into the template namespace.
show_signals: bool
Show signal components. Default is False
reverse_fields: bool
(optional) Control whether register fields are displayed in reverse
bit order (LSB to MSB). Default is False
extra_doc_properties: List[str]
List of properties to explicitly document.
Nodes that have a property explicitly set will show its value in a
Expand All @@ -60,10 +63,12 @@ def __init__(self, **kwargs: 'Any') -> None:
self.title = "" # type: str
self.home_url = None # type: Optional[str]
self.skip_not_present = True
self.reverse_fields = False
self.current_top_node = None # type: AddrmapNode

self.user_static_dir = kwargs.pop("user_static_dir", None) # type: Optional[str]
self.show_signals = kwargs.pop("show_signals", False)
self.reverse_fields = kwargs.pop("reverse_fields", False)
self.user_context = kwargs.pop("user_context", {})
markdown_inst = kwargs.pop("markdown_inst", None) # type: Optional[markdown.Markdown]
self.extra_properties = kwargs.pop("extra_doc_properties", []) # type: List[str]
Expand Down Expand Up @@ -299,6 +304,12 @@ def write_ral_data(self) -> None:

def write_page(self, this_id: int, node: Node, children: 'Dict[int, Node]') -> None:

def field_order(x):
if not self.reverse_fields:
return reversed(x)
else:
return x

view_source_url, view_source_filename= self.get_view_source_info(node)
context = {
'this_id': this_id,
Expand All @@ -318,13 +329,14 @@ def write_page(self, this_id: int, node: Node, children: 'Dict[int, Node]') -> N
'FieldNode': FieldNode,
'AddressableNode': AddressableNode,
'PropertyReference': rdltypes.PropertyReference,
'reversed': reversed,
'reversed': field_order,
'isinstance': isinstance,
'list': list,
'view_source_url': view_source_url,
'view_source_filename': view_source_filename,
'reg_fields_are_low_to_high': reg_fields_are_low_to_high,
'skip_not_present': self.skip_not_present
'skip_not_present': self.skip_not_present,
'highest_fields_first': not self.reverse_fields
}
context.update(self.user_context)

Expand Down
24 changes: 20 additions & 4 deletions src/peakrdl_html/templates/reg_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,16 @@
<th></th>
</tr>
{%- for field in reversed(list(node.fields(skip_not_present=skip_not_present))) %}
{%- if loop.first and field.high < (node.get_property('regwidth') - 1) %}
{{reserved_field(node.get_property('regwidth') - 1, field.high + 1, reg_fields_are_low_to_high(node))}}
{%- if loop.first %}
{%- if highest_fields_first %}
{%- if field.high < (node.get_property('regwidth') - 1) %}
{{ reserved_field(node.get_property('regwidth') - 1, field.high + 1, reg_fields_are_low_to_high(node))}}
{%- endif %}
{%- else %}
{%- if field.low > 0 %}
{{ reserved_field(0, field.low - 1, reg_fields_are_low_to_high(node))}}
{%- endif %}
{%- endif %}
{%- elif (not loop.first) and field.high < loop.previtem.low - 1 %}
{{reserved_field(loop.previtem.low - 1, field.high + 1, reg_fields_are_low_to_high(node))}}
{%- endif %}
Expand Down Expand Up @@ -89,8 +97,16 @@
<a class="headerlink" href="#{{field.inst_name}}" title="Permalink to this row"></a>
</td>
</tr>
{%- if loop.last and field.low != 0 %}
{{reserved_field(field.low - 1, 0, reg_fields_are_low_to_high(node))}}
{%- if loop.last %}
{%- if highest_fields_first %}
{%- if field.low != 0 %}
{{ reserved_field(field.low - 1, 0, reg_fields_are_low_to_high(node))}}
{%- endif %}
{%- else %}
{%- if field.high != node.get_property('regwidth') - 1 %}
{{ reserved_field(node.get_property('regwidth') - 1, field.high + 1, reg_fields_are_low_to_high(node))}}
{%- endif %}
{%- endif %}
{%- endif %}
{%- endfor %}
</table>
Expand Down