From 32f102263bf28cd66a725d1f31379664809dbe9e Mon Sep 17 00:00:00 2001 From: Alex Mykyta Date: Mon, 7 Nov 2022 22:45:51 -0800 Subject: [PATCH] Fix misinterpretation of swacc behavior. Is asserted on both sw read and write. #21 --- docs/props/field.rst | 6 +++--- docs/props/rhs_props.rst | 4 ++-- src/peakrdl_regblock/field_logic/__init__.py | 18 ++++++++++++++---- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/docs/props/field.rst b/docs/props/field.rst index 7010f3d..93281d1 100644 --- a/docs/props/field.rst +++ b/docs/props/field.rst @@ -42,9 +42,9 @@ swacc ^^^^^ |OK| -If true, infers an output signal ``hwif_out..swacc`` that is asserted on the -same clock cycle that the field is being sampled during a software read -operation. +If true, infers an output signal ``hwif_out..swacc`` that is asserted when +accessed by software. Specifically, on the same clock cycle that the field is +being sampled during a software read operation, or as it is being written. .. wavedrom:: diff --git a/docs/props/rhs_props.rst b/docs/props/rhs_props.rst index 7e3dbc5..f9931f1 100644 --- a/docs/props/rhs_props.rst +++ b/docs/props/rhs_props.rst @@ -22,8 +22,8 @@ field -> swacc ^^^^^^^^^^^^^^ |EX| -Single-cycle strobe that indicates the field is being sampled during a software -read operation. +Single-cycle strobe that indicates the field is being accessed by software +(read or write). field -> swmod diff --git a/src/peakrdl_regblock/field_logic/__init__.py b/src/peakrdl_regblock/field_logic/__init__.py index 346b74d..d1fb5ae 100644 --- a/src/peakrdl_regblock/field_logic/__init__.py +++ b/src/peakrdl_regblock/field_logic/__init__.py @@ -173,15 +173,25 @@ class FieldLogic: def get_swacc_identifier(self, field: 'FieldNode') -> str: """ - Asserted when field is software accessed (read) + Asserted when field is software accessed (read or write) """ buffer_reads = field.parent.get_property('buffer_reads') - if buffer_reads: + buffer_writes = field.parent.get_property('buffer_writes') + if buffer_reads and buffer_writes: rstrb = self.exp.read_buffering.get_trigger(field.parent) - return rstrb + wstrb = self.exp.write_buffering.get_write_strobe(field) + return f"{rstrb} || {wstrb}" + elif buffer_reads and not buffer_writes: + strb = self.exp.dereferencer.get_access_strobe(field) + rstrb = self.exp.read_buffering.get_trigger(field.parent) + return f"{rstrb} || ({strb} && decoded_req_is_wr)" + elif not buffer_reads and buffer_writes: + strb = self.exp.dereferencer.get_access_strobe(field) + wstrb = self.exp.write_buffering.get_write_strobe(field) + return f"{wstrb} || ({strb} && !decoded_req_is_wr)" else: strb = self.exp.dereferencer.get_access_strobe(field) - return f"{strb} && !decoded_req_is_wr" + return strb def get_swmod_identifier(self, field: 'FieldNode') -> str: """