Skip to content
Open
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
1 change: 1 addition & 0 deletions src/peakrdl_halcpp/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def export(self,
for halnode in concatenated_iterable:
# Create the context for the template generation
context = {
'parameters': halnode.parameters.items(),
'halnode': halnode,
'halutils': halutils,
'skip_buses': skip_buses,
Expand Down
15 changes: 15 additions & 0 deletions src/peakrdl_halcpp/templates/addrmap.h.j2
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define __{{ halnode.orig_type_name_hal|upper }}_H_

#include <stdint.h>
#include <string_view>
#include "include/halcpp_base.h"

#if defined(__clang__)
Expand All @@ -21,6 +22,20 @@
{% if not halnode.is_bus %}
namespace {{ halnode.orig_type_name }}_nm
{
{# =========== 0. Generate constants =========== -#}
{% for name, value in parameters %}
{% if value is boolean %}
constexpr bool {{name}} = {{value}};
{% elif value is number %}
{# According to SystemRDL spec 6.2.1 all numbers are integral and unsigned.
and only supports `bits` and `longint unsigned`.
However register size is 32bit, for that they will interpreted as uin32_t #}
constexpr uint32_t {{name}} = {{value}};
{% elif value is string %}
constexpr std::string_view {{name}} = "{{value}}";
{% endif %}
{% endfor %}

{#- Enum with same name are not duplicated -#}
{%- set seen_enum_names = [] -%}

Expand Down