Add support for field paritycheck. #35
This commit is contained in:
@@ -274,6 +274,19 @@ class FieldLogic:
|
||||
# Not sw modifiable
|
||||
return "1'b0"
|
||||
|
||||
def get_parity_identifier(self, field: 'FieldNode') -> str:
|
||||
"""
|
||||
Returns the identifier for the stored 'golden' parity value of the field
|
||||
"""
|
||||
path = get_indexed_path(self.top_node, field)
|
||||
return f"field_storage.{path}.parity"
|
||||
|
||||
def get_parity_error_identifier(self, field: 'FieldNode') -> str:
|
||||
"""
|
||||
Returns the identifier for whether the field currently has a parity error
|
||||
"""
|
||||
path = get_indexed_path(self.top_node, field)
|
||||
return f"field_combo.{path}.parity_error"
|
||||
|
||||
def has_next_q(self, field: 'FieldNode') -> bool:
|
||||
"""
|
||||
|
||||
@@ -53,6 +53,8 @@ class CombinationalStructGenerator(RDLStructGenerator):
|
||||
self.add_up_counter_members(node)
|
||||
if node.is_down_counter:
|
||||
self.add_down_counter_members(node)
|
||||
if node.get_property('paritycheck'):
|
||||
self.add_member("parity_error")
|
||||
self.pop_struct()
|
||||
|
||||
def add_up_counter_members(self, node: 'FieldNode') -> None:
|
||||
@@ -88,6 +90,8 @@ class FieldStorageStructGenerator(RDLStructGenerator):
|
||||
|
||||
if node.implements_storage:
|
||||
self.add_member("value", node.width)
|
||||
if node.get_property('paritycheck'):
|
||||
self.add_member("parity")
|
||||
|
||||
if self.field_logic.has_next_q(node):
|
||||
self.add_member("next_q", node.width)
|
||||
@@ -233,6 +237,7 @@ class FieldLogicGenerator(RDLForLoopGenerator):
|
||||
'get_value': self.exp.dereferencer.get_value,
|
||||
'get_resetsignal': self.exp.dereferencer.get_resetsignal,
|
||||
'get_input_identifier': self.exp.hwif.get_input_identifier,
|
||||
'ds': self.ds,
|
||||
}
|
||||
self.add_content(self.field_storage_template.render(context))
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
always_comb begin
|
||||
automatic logic [{{node.width-1}}:0] next_c = {{field_logic.get_storage_identifier(node)}};
|
||||
automatic logic load_next_c = '0;
|
||||
|
||||
{%- for signal in extra_combo_signals %}
|
||||
{{field_logic.get_field_combo_identifier(node, signal.name)}} = {{signal.default_assignment}};
|
||||
{%- endfor %}
|
||||
@@ -13,22 +14,35 @@ always_comb begin
|
||||
{%- endfor %}
|
||||
end
|
||||
{%- endfor %}
|
||||
|
||||
{%- if node.is_up_counter %}
|
||||
{{counter_macros.up_counter(node)}}
|
||||
{%- endif %}
|
||||
|
||||
{%- if node.is_down_counter %}
|
||||
{{counter_macros.down_counter(node)}}
|
||||
{%- endif %}
|
||||
{{field_logic.get_field_combo_identifier(node, "next")}} = next_c;
|
||||
{{field_logic.get_field_combo_identifier(node, "load_next")}} = load_next_c;
|
||||
|
||||
{%- if node.get_property('paritycheck') %}
|
||||
{{field_logic.get_parity_error_identifier(node)}} = ({{field_logic.get_parity_identifier(node)}} != ^{{field_logic.get_storage_identifier(node)}});
|
||||
{%- endif %}
|
||||
end
|
||||
always_ff {{get_always_ff_event(resetsignal)}} begin
|
||||
{% if reset is not none -%}
|
||||
if({{get_resetsignal(resetsignal)}}) begin
|
||||
{{field_logic.get_storage_identifier(node)}} <= {{reset}};
|
||||
{%- if node.get_property('paritycheck') %}
|
||||
{{field_logic.get_parity_identifier(node)}} <= ^{{reset}};
|
||||
{%- endif %}
|
||||
end else {% endif %}if({{field_logic.get_field_combo_identifier(node, "load_next")}}) begin
|
||||
{{field_logic.get_storage_identifier(node)}} <= {{field_logic.get_field_combo_identifier(node, "next")}};
|
||||
{%- if node.get_property('paritycheck') %}
|
||||
{{field_logic.get_parity_identifier(node)}} <= ^{{field_logic.get_field_combo_identifier(node, "next")}};
|
||||
{%- endif %}
|
||||
end
|
||||
|
||||
{%- if field_logic.has_next_q(node) %}
|
||||
{{field_logic.get_next_q_identifier(node)}} <= {{get_input_identifier(node)}};
|
||||
{%- endif %}
|
||||
|
||||
Reference in New Issue
Block a user