Bug 636 - exceptions, predication and zeroing masks need to be added to Function Unit context
Summary: exceptions, predication and zeroing masks need to be added to Function Unit c...
Status: CONFIRMED
Alias: None
Product: Libre-SOC's first SoC
Classification: Unclassified
Component: Source Code (show other bugs)
Version: unspecified
Hardware: Other Linux
: --- enhancement
Assignee: Luke Kenneth Casson Leighton
URL:
Depends on:
Blocks: 491
  Show dependency treegraph
 
Reported: 2021-05-04 01:42 BST by Luke Kenneth Casson Leighton
Modified: 2021-05-06 18:55 BST (History)
3 users (show)

See Also:
NLnet milestone: ---
total budget (EUR) for completion of task and all subtasks: 0
budget (EUR) for this task, excluding subtasks' budget: 0
parent task for budget allocation:
child tasks for budget allocation:
The table of payments (in EUR) for this task; TOML format:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Comment 1 Luke Kenneth Casson Leighton 2021-05-04 01:45:43 BST
http://lists.libre-soc.org/pipermail/libre-soc-dev/2021-May/002518.html

this is quite a complex chain.  links to source code to be added to first comment.
Comment 2 Luke Kenneth Casson Leighton 2021-05-04 13:31:50 BST
commit 5919b89de8a6f1bb7fce42c8cacd9dd38f126901 (HEAD -> master)
Author: Luke Kenneth Casson Leighton <lkcl@lkcl.net>
Date:   Tue May 4 13:31:35 2021 +0100

    add option to add exception type to FUBaseData (pipe_data)
Comment 3 Luke Kenneth Casson Leighton 2021-05-04 13:36:06 BST
commit 68fb6b858b7cabc4fbc2b7c66be409aa391c8153 (HEAD -> master)
Author: Luke Kenneth Casson Leighton <lkcl@lkcl.net>
Date:   Tue May 4 13:35:54 2021 +0100

    add LDSTException class to LDSTOutputData
Comment 4 Luke Kenneth Casson Leighton 2021-05-04 17:03:04 BST
commit 7d8165c511127319183db8763a65c87ee7e25ea7 (HEAD -> master)
Author: Luke Kenneth Casson Leighton <lkcl@lkcl.net>
Date:   Tue May 4 17:02:49 2021 +0100

    note a way to see if an exception happened, in TestIssuer
Comment 5 Luke Kenneth Casson Leighton 2021-05-04 17:23:03 BST
renamed PowerDecoder2.exc to PowerDecoder2.ldst_exc

https://git.libre-soc.org/?p=openpower-isa.git;a=commitdiff;h=fc909b841a99f27117d322f3c8ffd02f1c01cb4b

the exception is given *top priority* in *re-writing* the instruction
in PowerDecoder2:

https://git.libre-soc.org/?p=openpower-isa.git;a=blob;f=src/openpower/decoder/power_decoder2.py;h=63b0796bc258c8bed4ef800b563835c5d243b85d;hb=fc909b841a99f27117d322f3c8ffd02f1c01cb4b#l1255

(there is a list of if-elif-elif statements, there: LDST exception is top
priority)
Comment 6 Luke Kenneth Casson Leighton 2021-05-04 19:53:39 BST
this is nowhere near sophisticated enough, and may leave some latches hi after an exception

https://git.libre-soc.org/?p=soc.git;a=blob;f=src/soc/experiment/pimem.py;hb=HEAD#l294
Comment 7 Luke Kenneth Casson Leighton 2021-05-04 21:26:30 BST
base_input_record.py CompALUBaseOp is probably the best location to auto-extend the op instance with necessary global flags such as predicate mask, zeroing options, subvl, saturation modes etc.

this should really be done in a way that does not require huge manual intervention and maintenance to update: similar technique to PowerOp and PowerDecoder2.do_copy().

in fact, with do_copy() already hooking into the CompOpSubset record it is harder *not* to use do_copy().
Comment 8 Luke Kenneth Casson Leighton 2021-05-04 21:31:32 BST
https://git.libre-soc.org/?p=soc.git;a=blob;f=src/soc/fu/alu/alu_input_record.py;hb=HEAD

example, derived from CompOpSubsetBase.

perhaps overthinking this.  just define a list of SV layout properties that the input records need to have, and extend the  input records in their constructor.

makes it clear what each  input record actually has.
Comment 9 Luke Kenneth Casson Leighton 2021-05-05 12:52:26 BST
should be as simple as this:

commit 73165df2e3ed5c33248141f66c8c8f37c2a18235 (HEAD -> master)
Author: Luke Kenneth Casson Leighton <lkcl@lkcl.net>
Date:   Wed May 5 12:51:26 2021 +0100

    add SVP64 RM fields to ALU input record


where the fields to be added are listed in power_svp64_rm.py

sv_input_record_layout = [
        ('sv_pred_sz', 1), # predicate source zeroing
        ('sv_pred_dz', 1), # predicate dest zeroing
        ('sv_saturate', SVP64sat),
        #('sv_RC1', 1),
    ]
Comment 10 Luke Kenneth Casson Leighton 2021-05-05 13:39:19 BST
decided it needed to go onto CompOpSubsetBase after all

--- a/src/soc/fu/base_input_record.py
+++ b/src/soc/fu/base_input_record.py
@@ -1,6 +1,9 @@
 from nmigen.hdl.rec import Record, Layout
 from nmigen import Signal
 
+# needed for SVP64 information at the pipeline
+from openpower.decoder.power_svp64_rm import sv_input_record_layout
+
 
 class CompOpSubsetBase(Record):
     """CompOpSubsetBase
@@ -15,6 +18,7 @@ class CompOpSubsetBase(Record):
             assert name.endswith("OpSubset")
             name = name[4:-8].lower() + "_op"
 
+        layout = list(layout) + sv_input_record_layout
         Record.__init__(self, Layout(layout), name=name)
 
         # grrr.  Record does not have kwargs
Comment 11 Luke Kenneth Casson Leighton 2021-05-05 16:35:38 BST
this may need some additional checking, esp. for 3-operand
(and RS)


commit c8dbc9446617f210d06bd796c7ff5a5a026d6c87 (HEAD -> master)
Author: Luke Kenneth Casson Leighton <lkcl@lkcl.net>
Date:   Wed May 5 16:33:48 2021 +0100

    if zeroing is set, put zero into input or output as requested

+Subproject commit 227f39952a4529cea7f5da76c361bf6b650adff3-dirty
diff --git a/src/soc/fu/common_input_stage.py b/src/soc/fu/common_input_stage.py
index 09a02006..53e023ad 100644
--- a/src/soc/fu/common_input_stage.py
+++ b/src/soc/fu/common_input_stage.py
@@ -31,7 +31,9 @@ class CommonInputStage(PipeModBase):
         else:
             comb += a.eq(self.i.a)
 
-        comb += self.o.a.eq(a)
+        # SV zeroing on predicate source zeros the input
+        with m.If(~op.sv_pred_sz):
+            comb += self.o.a.eq(a)
 
         ##### operand B #####
 
@@ -46,7 +48,9 @@ class CommonInputStage(PipeModBase):
         else:
             comb += b.eq(self.i.b)
 
-        comb += self.o.b.eq(b)
+        # SV zeroing on predicate source zeros the input
+        with m.If(~op.sv_pred_sz):
+            comb += self.o.b.eq(b)
 
         ##### carry-in #####
Comment 12 Luke Kenneth Casson Leighton 2021-05-06 17:26:31 BST
(In reply to Luke Kenneth Casson Leighton from comment #11)
> this may need some additional checking, esp. for 3-operand
> (and RS)

nope, won't work quite correctly (for dest zeroing), the
CR has to be checked if the result is equal to zero.