https://bugs.libre-soc.org/show_bug.cgi?id=985 master
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Wed, 5 Jun 2024 13:45:56 +0000 (14:45 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Wed, 5 Jun 2024 13:45:56 +0000 (14:45 +0100)
lkcl/20240602_185401.jpg [new file with mode: 0644]
lkcl/saxon_dr_2024_04_06.mdwn [new file with mode: 0644]
lkcl/will.mdwn [new file with mode: 0644]
meetings/sync_up/sync_up_2024-05-14.mdwn [new file with mode: 0644]
meetings/sync_up/sync_up_2024-05-21.mdwn [new file with mode: 0644]
meetings/sync_up/sync_up_2024-05-28.mdwn [new file with mode: 0644]
nlnet_2021_crypto_router.mdwn
nlnet_proposals.mdwn
openpower/sv/cookbook/ed25519.mdwn [new file with mode: 0644]
openpower/sv/cookbook/poly1305.mdwn [new file with mode: 0644]
openpower/test_api.mdwn [new file with mode: 0644]

diff --git a/lkcl/20240602_185401.jpg b/lkcl/20240602_185401.jpg
new file mode 100644 (file)
index 0000000..1796fb8
Binary files /dev/null and b/lkcl/20240602_185401.jpg differ
diff --git a/lkcl/saxon_dr_2024_04_06.mdwn b/lkcl/saxon_dr_2024_04_06.mdwn
new file mode 100644 (file)
index 0000000..19b506e
--- /dev/null
@@ -0,0 +1,295 @@
+# meeting with doctors saxon house 4 jun 2024
+
+attendees:
+
+* luke
+* aaron
+* thagadur 5208861
+* catherine OT.
+* dr bonnu 7915239 
+* erika
+* claire nurse
+* dr nina refusing to provide GMC number
+* dr arya 8016135 - not received responses
+* alisha
+
+# Questions
+
+1. Why was I given an anti-psychotic medication Olanzapine immediately
+ with no consultation with myself?
+2. What evidence is there of psychosis which justifies its **immediate**
+ proscription?
+3. Why was my stepfather informed that the dose is 2.5 ug but the nurses
+ inform me it is 5.0?
+4. Have you received my urgent repeated communication regarding massive
+ dangerous reaction to forced medication? Why have I been refused access
+ to a doctor when the warnings are very clear on side-effects? Nurses
+ have *NOT* called a Doctor.
+5. Why have my dietary requirements not been met despite notifying
+ you in writing on 26th May 2024, and why I am being deprived of the
+ food that I bring in that is part of my medical diet?
+6. Allowed a Solicitor and also protected under Mental Health Act re: autism.
+7. Why have I been deprived of doing the things that I love and my interests?
+  (being in nature, being with friends, riding my motorcycle, doing "poi",
+   feeding birds and squirrels, which I regularly do).
+
+Notes of things to say
+
+Olanzapine:
+
+    If "line of thinking" is in "disagreement" it can be viewed
+    as "psychosis"
+
+Dietary requirements:
+
+    (Aaron to ask pointedly - his son is on ketogenic diet and gets
+    them on *presciption* whereas Luke is buying medical diet food items
+    himself) How can people get better if they do not have the nutrition
+    they need?
+
+    What possible reason could they take away Celtic Salt?
+    Has anyone "overdosed" on minerals?
+
+Reaction to Olanzapine:
+
+    * Dizziness
+    * Tourette's as well as eye unfocussing, precisely on heart-beat
+    * Unable to walk straight
+    * slurred speech, drooped face (left side)
+    * One hour continuous coughing and spitting up with breathing difficulties
+    * Sore glands and throat.
+
+    Doctor not called, but even when I felt I needed one I was too busy
+    concentrating on staying alive due to severity of breathing difficulties
+    to answer them.
+
+    except 03 Jun 2024:
+
+    * dizziness
+    * eyes crossing, unfocussed
+
+    (Question is: why? Notes taken so can be analysed and tested afterwards)
+
+Autism
+
+    * <https://www.autism.org.uk/what-we-do/news/breaking-news-government-publishes-draft-mental-he>
+# Log
+
+Deprivation
+
+    * Sleep deprivation during first few days (sound of shutter, torch)
+    * Affecting my mental health and well-being
+
+```
+
+14:37 Aaron prohibited from entering.
+14:38 informed them i have autism and request his attendance.
+14:41 thagadur thanks, remind aaron of confidentiality
+aaron: is it normal that there are this many people? (answer sometimes).
+14:42 i have questions, interupted by Thagadur stating "we don't havve all day"
+14:43 proscribed 
+   feeling psychotic
+14::43 "you tell us"
+   had
+   homeless
+   "you tell us"
+A: it take 90 minutes.
+Q: ghave you got 90 minutes?
+A: no
+14:44 "we spent 90 minutes"
+   "not just that - whole presentation. referred to EIP by GP
+    was NOT aware of referral to EIP."
+14:45 learning first time
+14:46 BE QUIET
+   PLEASE DO NOT TALK TO ME AS IF I AM NOT HERE. DEEPLY UNPROFESSIONAL.
+
+"T: we have already discussed with you 90 minutes"
+"no you have not"
+"that is your opinion" - Q2 - not answered.
+
+Q: number of times to A&E? so we can find out "why you are psychotic"
+
+Q: why are you going to A&E repeatedly?
+A: "have you got 90 minutes?"
+
+T: statement "we need to stop, it is not productive"
+
+Aaron: basis undiagnosed conditions.  i know luke and see luke,
+       when he has these episodes because he is in fear of his life.
+       what's been done? brain scans? has anyone looked into his
+       condition?
+
+T: CT scan in february.
+
+L: CT scan done AFTER rest.
+
+T: so you are saying "i HAVE E & CB"
+
+A: NO.
+
+T: assess under MHA 2
+
+EIP feel belief that i have these conditions
+
+risk of death
+
+T: believes they are DELUSIONS.
+
+Q: would you like to see the videos?
+
+T Answer:: no i do not
+
+Aaron: tested everything?
+
+tests
+
+How do you test for Encephalitis?
+
+A: did not answer.
+
+"When willing to have a productive conversation"
+
+petition signed
+
+Thag: Tribunal 
+
+not read notes from side-effects.
+
+talking to me "as if i am not here".
+
+Aaron: this is 
+
+glad angry 
+
+what evidence of psychosis?
+
+"my 
+
+absurdity of abuse"
+
+Thag apologised
+
+Thag conversation has ended
+
+Aaron: could not answer even one question
+
+"suspected" psychosis.
+
+Aaron: ridiculous
+
+and in the meadication forced 
+
+"cannot bear the shouting" - forced removal from MTD 15:01
+
+L: request Dr Arya to review and continue conversation.
+(catching-up: Dr Arya did NOT receive my notes - he said he had
+ not been passed my letters).
+
+```
+
+Post-analysis by Aaron: I think you'll get out pretty quick.
+"Get" me by asking aggressive confrontational questions.
+was making them worried and uncomfortable that i was taking notes.
+Thagadur attempted to end the meeting three times, because he
+didn't want to answer the 2nd question.
+
+L: 3rd question "why deprived of medical diet"? Sunday? was
+why Thagadur threw me out.
+
+Aaron: he looked scared. Didn't like that there was someone with me.
+
+15:06 L: slightly shaking, adrenaline rush (a bit).
+
+Conversation got out-of-hand, unable to keep up with notes, remember
+Aaron mentioning petition of 20 people.
+
+15:10 L: recall T looked scared during original interview, Friday 24th
+
+15:12 A: need a wee. L: get back to ward, meet Erica / Claire(?)
+say "what did you think?"
+
+Medical Condition
+
+Aaron: hypchondriac is a psychiatric disorder
+
+L: but did you notice he refused to answer my questions "what evidence do
+you have of psychosis / hypchondria?"
+
+15:18 notified them in writing that i have earned EUR 20,000 in the
+past 3 weeks, and i am NOT homeless. met Erika in corridor, said
+something like "how did i do?" she said something like "good performance"
+but i am not sure if this was a joke or if she was implying i was not
+"serious" - i.e. the implication is **i was acting** (!!!!!)
+
+A: "i know where he is going with that. you lost your job and your home
+therefore you are psychotic".  they *should* understand that anyone is
+frustrated and angry in that situation.
+
+L: did you notice that when i attempted to "empathise" with him, he
+shut the conversation down?
+
+A: yyep.
+
+L: observation: "that is not a well man"
+A: yes, he was probably questioning "why is this person in here?
+as he is clearly not displaying the symptoms of psychosis"
+
+A: observation: Logged journal is not "normal" for people with mental disorders
+
+L: did you notice he refused to review the video evidence?
+A: yyeah.
+L: that would blow him away
+A: he didn't like that i took control of the meeting. looked like a lost
+boy in a playground first day at school. rabbit in headlignts.
+
+15:23
+
+forgot to note: meanwhile i am forced medication when there is risk of death
+due to violent reaction. ONE HOUR coughing up and spitting out white flegm.
+requested other doctors present to look it up.
+
+Aaron: how intimidating to have that many people. invite for a meeting and
+have a group.
+
+L: when i SPECIFICALLY told them in writing, in my notes on Tuesday,
+that i prefer and am comfortable only with small numbers of people because
+i feel threatened!
+
+A: that's why they do it - because they want people to feel threatened and
+small. (push their agenda - less likely to disagree, if they are backing
+each other up).
+
+L: that's why i took notes...
+
+Aaron: in his head, "someone raising their voice is abusing HIM".
+fxxxxg clowns.
+
+L: observation that they may have been thinking i was "acting".
+ Erika would not have stated that if it had not been discussed
+ during the meeting.
+
+15:34
+
+Aaron spotted nurse that laughed about the abuse going on in Hants MH
+
+Aaron: reckoned she said what she said in order to let me know what they
+think?
+
+L: honestly don't know, no evidence either way but it is a "slip"
+
+Aaron: suspect they play good-cop bad-cop.  Yeah guaranteed.
+
+L: need blueberries.  need things that will slip past their radar.
+they deprived me of bio-available Ashwaganda, MCT Oil (bulletproof)
+and Electrolyte drops
+
+Aaron: but they PROSCRIBE MCT oil to people on ketogenic diets!!
+
+L: need coconut water.
+
+15:39 
+
+Aaron: licenses get taken away when they say "i can cure cancer".
+
+(L: sigh :) )
+
diff --git a/lkcl/will.mdwn b/lkcl/will.mdwn
new file mode 100644 (file)
index 0000000..6d4712c
--- /dev/null
@@ -0,0 +1,39 @@
+```
+This document is my will as of Sunday 2nd January 202r. It represents my
+final wishes, and it invalidates all prior wills written by me.
+
+All my Intellectual Property - all patents trademarks copyright ideas and
+designs - irrevocably immediately and automatically transfer to the
+Free Software Foundation (https://fsf.org) without right of transfer to
+any other party, and without any right of re-licensing under any License
+other than those already established by those works.
+
+All physical property and bank accounts shall transfer to my daughter,
+Lilyana Leighton.  I wish my friends, Aaron Mackie and Alain Williams,
+to look after Lilyana until she is 18.  I instruct Aaron Mackie and
+Alain Williams to be the Executors of my estate.
+
+I also give instruction for a private post mortem and
+pathologist reports on my condition and cause of death with my body
+in the care of Dr Alex Hankey or his personal representative.
+The Coroner's Report shall be published in full both online and
+in newspapers and the General Medical Council notified.
+
+Signed this date and electronically committed to the Libre-SOC
+Repository with my public key
+
+    ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAuYQ7BAFX2cGZFEEeeR9HWGiqEbQgdNu
+    E60TxaZBH2mZLDr68FQAovSJtDM6RBYSytyBi7kUs3RkGONGJzP1UvoodT23LbsveMY
+    Cie0VG4rvPyvcM9IKirtW72GxHXavnWB0E04YY1O2mUhoX97GhCtM3J9h+8hjikCweh
+    TnZ8sHaesBfbh88WaPM+6limb9wGUPeCpaNUUHgYEIGl0zD5c68ze3gRV8hhP1C+mxy
+    p2Y0E9qM85rB+p92ZFGQgxHG7wKC/HAIHMgltvGNB9JZrQep0Cv/JHNM+370eJ5RrJu
+    KelM4hm/4ffePLEKbVCx2WZqD4IJmTYHIatcSJnMYPw== lkcl@teenymac
+
+
+
+Signature: ______________________________
+
+
+Date:      ______________________________
+
+```
diff --git a/meetings/sync_up/sync_up_2024-05-14.mdwn b/meetings/sync_up/sync_up_2024-05-14.mdwn
new file mode 100644 (file)
index 0000000..01d1c06
--- /dev/null
@@ -0,0 +1,32 @@
+# Tuesday 14th May 16:00 UTC
+
+* Previous notes: [[/meetings/sync_up/sync_up_2024-05-07]]
+* Next week's notes: [[/meetings/sync_up/sync_up_2024-05-21]]
+
+# Main Agenda
+
+Meeting notes:
+
+# Cesar
+
+Attended. 
+
+Figured out criteria and bug list for Jacob to do RFPs.
+See thread starting at
+[[https://lists.libre-soc.org/pipermail/libre-soc-dev/2024-May/006209.html]].
+
+# Jacob
+
+Absent. Worked on getting ready for and submitting an RFP.
+
+# Luke
+
+Absent.
+
+# Dmitry
+
+Absent.
+
+# Rita
+
+Present. Had research interviews with people and with Luke.
diff --git a/meetings/sync_up/sync_up_2024-05-21.mdwn b/meetings/sync_up/sync_up_2024-05-21.mdwn
new file mode 100644 (file)
index 0000000..d3c9a6c
--- /dev/null
@@ -0,0 +1,29 @@
+# Tuesday 21th May 16:00 UTC
+
+* Previous notes: [[/meetings/sync_up/sync_up_2024-05-14]]
+* Next week's notes: [[/meetings/sync_up/sync_up_2024-05-28]]
+
+# Main Agenda
+
+Meeting notes:
+
+# Cesar
+
+Attended.
+Worked on pin definitions for Nexys Video ([bug #1004](https://bugs.libre-soc.org/show_bug.cgi?id=1004)). Added audio codec and Ethernet.
+
+# Jacob
+
+Absent. Planning on submitting the RFP for the gfb* instructions Tuesday night.
+
+# Luke
+
+Absent.
+
+# Dmitry
+
+Absent.
+
+# Rita
+
+Present. Working on my data and article.
diff --git a/meetings/sync_up/sync_up_2024-05-28.mdwn b/meetings/sync_up/sync_up_2024-05-28.mdwn
new file mode 100644 (file)
index 0000000..df7272a
--- /dev/null
@@ -0,0 +1,28 @@
+# Tuesday 28th May 16:00 UTC
+
+* Previous notes: [[/meetings/sync_up/sync_up_2024-05-21]]
+* Next week's notes: [[/meetings/sync_up/sync_up_2024-06-04]]
+
+# Main Agenda
+
+Meeting notes:
+
+# Cesar
+
+Attended. Nothing new, sorry.
+
+# Jacob
+
+Absent. Submitted RFP for the gfb* instructions.
+
+# Luke
+
+Present. Worked on the documentation for poly1305 and ed25519, submitted RFPs. Total work for the Cryptorouter grant is now completed.
+
+# Dmitry
+
+Absent.
+
+# Rita
+
+Absent.
index bfa7f5f5f999c6863005a88ed7e9a365ab421807..5043aa14713c7e1dde6f8f97467a753d91b5b48b 100644 (file)
@@ -1,8 +1,8 @@
-# NL.net proposal 2021-02-052
+# NL.net proposal 2021-02A-052
 
 * [[nlnet_2021_crypto_router/discussion]]
-
-top-level bugreport: <https://bugs.libre-soc.org/show_bug.cgi?id=589>
+* completed 2024may30
+top-level bugreport: <https://bugs.libre-soc.org/show_bug.cgi?id=589>
 
 ## Project name
 
index 26ae58b8eb43a21bb7e3a388635cc09421ab6f58..6afda9d07fe4af18e891ad18511e83d2291afd32 100644 (file)
 * [[nlnet_2019_wishbone_streaming]] - submitted 2019sep26 - submitter found (hank)  - accepted 20dec2019, MOU done
 * [[nlnet_2019_standards]] - submitted 2019sep27 - submitter found (phcomp)  - accepted 20dec2019, MOU done
 * [[nlnet_2021_lip6_vlsi]] LIP6 VLSI tools - submitted 29jul2021 - Ref 2021-08-049 - accepted 09nov2021 - MOU TODO - transferred to LIP6
+* [[nlnet_2021_crypto_router]] - 12jan2021 draft - submitter found (jan) submitted 24jan2021 - MOU done
 
 # accepted
 
-* [[nlnet_2021_crypto_router]] - 12jan2021 draft - submitter found (jan) submitted 24jan2021 - MOU done
 * [[nlnet_2021_3mdeb_cavatools]] 3mdeb Power ISA Simulator - submitted 31jul2021 - Ref 2021-08-071 - accepted 09nov2021 - MOU signed 2023mar06
 * [[nlnet_2022_opf_isa_wg]] - 2022-08-051 - submitted 2022jul27 - approved 24oct2022 - MOU signed 2023jun22
 * [[nlnet_2022_ongoing]] - 2022-08-107 - submitted 2022jul31 - approved 24oct2022
diff --git a/openpower/sv/cookbook/ed25519.mdwn b/openpower/sv/cookbook/ed25519.mdwn
new file mode 100644 (file)
index 0000000..61d7ba1
--- /dev/null
@@ -0,0 +1,62 @@
+# Elliptic Curve ed25519
+
+Links:
+
+* bugrepoet: <https://bugs.libre-soc.org/show_bug.cgi?id=1166>
+* [ed25519_mul.py](https://git.libre-soc.org/?p=openpower-isa.git;a=blob_plain;f=src/openpower/decoder/isa/ed25519/curve25519_mul.py;hb=de10b86f7b3)
+* [donna-ed25519](https://bugs.libre-soc.org/show_bug.cgi?id=773#c1)
+* [Triangular REMAP discussion](https://lists.libre-soc.org/pipermail/libre-soc-dev/2022-May/004881.html)
+
+ed25519 is strategically important as its implementation was highly optimised
+during its design, for high security.
+[Edwards-curve Digital Signature Algorithm (EdDSA)](https://en.wikipedia.org/wiki/EdDSA#Ed25519)
+was also designed to be fast.
+
+In the donna-ed25519 implementation, key functions such as ed25519_mul
+are laid out explicitly by loop-unrolling:
+
+```
+t[0]  =  r0 * s0
+t[1]  =  r0 * s1 + r1 * s0;
+t[2]  =  r0 * s2 + r1 * s1 + r2 * s0;
+t[3]  =  r0 * s3 + r1 * s2 + r2 * s1 + r3 * s0;
+t[4]  =  r0 * s4 + r1 * s3 + r2 * s2 + r3 * s1 + r4 * s0;
+```
+
+Note the very obvious patterns here which are triangular in nature.
+With the very existence of Simple-V's REMAP subsystem it is quite
+natural to see if triangular remapping can be added and used.
+It turns out to be quite easy, and there are two possible techniques:
+Vertical-First and Horizontal-First.
+
+With Vertical-First, the multiply is done first as a scalar item,
+into a temporary register, followed by an addition of the scalar
+into the actual target (t0 thru t4)
+
+```
+sv.mul temp, *r, *s   # temporary target scalar register
+sv.add *t,*t,temp     # add temporary scalar onto target vector
+```
+
+With Horizontal-First it is extremely simple: use `madd` -
+integer multiply-and-accumulate:
+
+```
+sv.madd *t, *r, *s
+```
+
+In both cases, all three target registers are set up with the
+same REMAP Schedules.  Additionally in both cases, t0-t4 must
+be pre-initialised to zeros.
+
+As always with Simple-V, the power of simplicity comes primarily
+from the REMAP subsystem. However in a secure environment,
+reduced instruction count is also critical not just for power
+consumption but to get the size of the binary down small enough
+that it could fit easily into a few lines of L1 Cache.
+If a huge number of loop-unrolled instructions (the normal
+way of handing these algorithms) are reduced down to a
+bare handful, with the looping covered in hardware, then it
+is easy to understand how valuable Simple-V and REMAP is.
+
+[[!tag svp64_cookbook ]]
diff --git a/openpower/sv/cookbook/poly1305.mdwn b/openpower/sv/cookbook/poly1305.mdwn
new file mode 100644 (file)
index 0000000..27a3257
--- /dev/null
@@ -0,0 +1,118 @@
+# Implementation strategy for poly1305 on Simple-V
+
+Links:
+
+* [Poly1305's design](https://loup-vaillant.fr/tutorials/poly1305-design)
+* [Python reference](https://git.libre-soc.org/?p=openpower-isa.git;a=blob;f=src/openpower/decoder/isa/poly1305-donna.py;hb=HEAD)
+* Bugreport <https://bugs.libre-soc.org/show_bug.cgi?id=1158>
+
+Poly1305 is a fast and surprisingly simple provably-secure one-time
+authenticator. A huge amount of detailed mathematical analysis has
+been done on it, demonstrating and implementing tricks of modulo
+arithmetic that can be exploited to good effect and need not be
+repeated here: the primary purpose of this document is to show that
+it is possible to use Simple-V REMAP when patterns are identified,
+instead of standard implementations on Scalar / SIMD ISAs that are
+loop-unrolled in order to ensure no branching (and definitely no
+conditional-branching) is utilised.
+
+For example: this entire function, from Loup Vaillant's tutorial
+may be carried out with some REMAPs, a mul and a madd instruction.
+
+```
+void mult(uint64_t p[5], const uint32_t a[5], const uint32_t b[5])
+{
+    uint64_t a0 = a[0];  uint64_t b0 = b[0];
+    uint64_t a1 = a[1];  uint64_t b1 = b[1];
+    uint64_t a2 = a[2];  uint64_t b2 = b[2];
+    uint64_t a3 = a[3];  uint64_t b3 = b[3];
+    uint64_t a4 = a[4];  uint64_t b4 = b[4];
+    p[0] = a0*b0 + a1*b4*5 + a2*b3*5 + a3*b2*5 + a4*b1*5;
+    p[1] = a0*b1 + a1*b0   + a2*b4*5 + a3*b3*5 + a4*b2*5;
+    p[2] = a0*b2 + a1*b1   + a2*b0   + a3*b4*5 + a4*b3*5;
+    p[3] = a0*b3 + a1*b2   + a2*b1   + a3*b0   + a4*b4*5;
+    p[4] = a0*b4 + a1*b3   + a2*b2   + a3*b1   + a4*b0  ;
+}
+```
+
+Above, the patterns are quite clear: it can be expressed
+as a pair of loops (which is normally avoided like the plague),
+
+```
+for ai = 0 to 4
+    for bi = 0 to 4
+        if ai < bi then const = 5 else 1
+        p[ai] += a[ai] * b[(bi+ai)%5] * const
+```
+
+This can be covered in Simple-V by having
+
+* one REMAP for the constant (5 or 1), which
+  is simplest done by a Triangle REMAP that
+  selects from a Vector. (otherwise, Indexed
+  REMAP is necessary)
+* a second REMAP for the loop `ai` above
+* a third REMAP for the loop value `bi+ai` modulo 5
+
+Then - using Vertical-First - the loop is four
+instructions: mul, madd, svstep and bc.
+
+Fast-forwarding to the python implementation, let us look at this:
+
+```
+ 186    h0 = (h0 & c) | g0;
+ 187    h1 = (h1 & c) | g1;
+ 188    h2 = (h2 & c) | g2;
+```
+
+This again is a simple parallel operation, so can be done
+as two Vertical-First instructions:
+
+```
+sv.and *h, *h, c
+sv.or  *h, *h, *g
+```
+
+This section however gets more complex, and also requires
+a new instruction (Double-Shift-and-add, where previous
+instructions designed are Double-Shift-and-or):
+
+```
+ 110    h0 += (( t0                    ) & 0xfffffffffff);
+ 111    h1 += (((t0 >> 44) | (t1 << 20)) & 0xfffffffffff);
+ 112    h2 += (((t1 >> 24)             ) & 0x3ffffffffff) | hibit;
+```
+
+Here, a "cheat" is required - slightly - to bring in some extra
+variables that are set to zero: t2 and t-minus-one (which we name tm):
+
+```
+ 110    h0 += (((t0 >> 0 ) | (tm << 64)) & 0xfffffffffff);
+ 111    h1 += (((t0 >> 44) | (t1 << 20)) & 0xfffffffffff);
+ 112    h2 += (((t1 >> 24) | (t2 << 40 ) & 0x3ffffffffff);
+ 112    h2 |= hibit;
+```
+
+Both tm and t2 are set to zero: strictly speaking tm shifted by 64
+will always be zero.  Now it becomes possible to identify the
+pattern, and also split out the AND part:
+
+```
+        h[N] += (((t[N] >> s[N] ) | (t[N-1] << (64-s[N]))
+        h[N] &= const[N]
+```
+
+Where it is clear that the shift amount `s[N]` and `const[N]`
+can be set up as Vectors. Now it is possible to utilise a
+proposed new instruction, "double-shift-and-add" for the first
+part, and a straight `sv.add *h, *h, *const` for the second.
+
+In this way, again we have identified very simple regular patterns,
+and applied Vectorisation to them to reduce instruction count.
+Interestingly in this case, unlike many algorithms converted
+there is not anticipated to be a huge reduction in instruction
+count, but the key is that the core of the algorithm is preserved
+and thus is easy to validate.
+
+[[!tag svp64_cookbook ]]
+
diff --git a/openpower/test_api.mdwn b/openpower/test_api.mdwn
new file mode 100644 (file)
index 0000000..1403cac
--- /dev/null
@@ -0,0 +1,115 @@
+# Libre-SOC Test API
+
+A problem with complex specifications is ensuring Compliance.
+Whilst having Compliance Documentation is obviously
+critical (stating in writing
+what results are expected when an instruction is executed)
+actually *checking* that the results are as expected is both
+tedious, protracted and required to be meticulous to such
+an extreme extent that to expect it to be carried out manually
+is absurd.
+The sensible thing to do is to *automate* the process of testing
+Compliance, with a Test Suite.
+
+However even if a Test Suite is available, it firstly may be
+specific to one implementation, or only be installable on one
+type of system, or only work under other certain very specific
+circumstances (such as requiring a bare metal machine but not
+function fully under a Virtual Machine, or vice-versa).
+
+It is clearly of benefit to make it easy to run a
+Compliance Test Suite for a given Instruction Set Architecture,
+but more than that it is important to make it easy to run
+against *multiple* disparate systems, all of which implement
+that same ISA.
+
+Thus we have some requirements: in Software Engineering terms
+we have a Requirements Specification. The Test API must:
+
+1. be comprehensive and thorough
+2. run a full suite of tests sufficient to confirm that an implementation
+ is 100% Compliant with every instruction to be implemented
+3. be generic (runnable or adaptable to run on multiple systems)
+4. be **open** so as to encourage wider adoption, increasing
+ the probability of its use and thus avoiding catastrophic
+ implementation mistakes.
+
+The beginnings of this API came out of a need to "bootstrap"
+the Libre-SOC implementation of:
+
+* the Machine-readable Specification - semi-automated conversion
+ of the Power ISA 3.0 PDF pseudo-code to an actual executable
+ language - which produced a slow but functional python-based
+ Simulator (ineptly named ISACaller)
+* the nmigen-based hardware implementation (several variants)
+ again ineptly named TestIssuer
+* QEMU
+
+The reason chosen right at the start of the project for including
+QEMU in the list is because it is a functional bare-metal "executor" of
+Power ISA instructions, known and confirmed (for the most part) to
+be accurate in its implementation (caveat: the Floating-Point
+execution is in no way accurate, relying on the *underlying*
+Host Operating System and Hardware. Therefore if executed on
+a PowerPC system the FP guest execution produces correct answers
+but if executed on an Intel AMD or ARM system the guest produces
+*wrong answers* in certain cases).
+
+As the test suite grew (list of "known-good answers to certain instructions"
+grew) this list became "expected" results, and in and of themselves
+became an important integral part of the API. Initial exploration
+was to simply bootstrap against *other implementations* - run a
+test against QEMU, then run the exact same instruction(s) against
+ISACaller, and if there are discrepancies find out why and fix them.
+
+However when errors in *QEMU* were discovered, this was the point
+where it was realised that "expected results" needed to be meticulously
+and laboriously created. The context here : the official IBM / OpenPOWER
+ISA Compliance Test Suite is in a **non-machine-readable** format
+that would take months to massage into a machine-readable form.
+It is deemed that this is too risky to do because it should be
+obvious that simple "transcription" errors from manual typing
+or mis-reading could be catastrophic. Therefore the Official
+Compliance Test Suite is *excluded* until such time as IBM / OpenPOWER
+releases a machine-readable Compliance Test Suite.
+
+At present (time of writing) the Test API can (very slowly) run
+tests against QEMU and also run the exact same test(s) against
+ISACaller and TestIssuer. Over time a suite of "expected results"
+was also extracted from the organically-evolving API into a more
+rigorous format, which gives:
+
+* the starting state of the implementation being tested
+ (memory contents, register contents, Program Counter)
+* the instructions to be executed
+* the expected ending-state of both memory and registers,
+ post-execution.
+
+Thus it is expected that each implementation helps verify others,
+and, ironically and just as importantly, verify that the actual
+Power ISA specification is correct and its Compliance Suite also
+sufficiently comprehensive to ensure implementation mistakes do
+not occur!
+
+The next most logically-obvious thing to do is to extend the API
+to allow additional implementations to easily be included, in a
+modular extensible fashion, and to formalise and document the API
+itself. This was where bug
+[985](https://bugs.libre-soc.org/show_bug.cgi?id=985)
+came into play: to add the expected new Simulator (cavatools)
+in as another option to triage against.
+
+Cavatools already has the same gdb debug interface as QEMU,
+so it is expected to be reasonably straightforward to add.
+The qemu interaction utilises a python-based gdbremote client
+to first upload a binary into memory, followed by commands
+to set the contents of registers, including the Program Counter.
+A breakpoint is set, at the end of the program.
+Finally QEMU is permitted to run, and following the trigger of
+the breakpoint, memory contents and register contents are
+dumped (over the gdb-remote interfacce) and from that they
+can be compared against other implementations - or the Expected
+Results - or the Compliance Test Suite expected responses.
+Cavatools is expected to follow the exact same process, using
+the exact same python-based gdbremote client.
+