almost working, negative values differ by 1
authorKonstantinos Margaritis <konstantinos.margaritis@vectorcamp.gr>
Fri, 28 Apr 2023 16:03:44 +0000 (16:03 +0000)
committerKonstantinos Margaritis <konstantinos.margaritis@vectorcamp.gr>
Fri, 28 Apr 2023 16:03:44 +0000 (16:03 +0000)
openpower/sv/twin_butterfly.mdwn

index c70a48c6b695687883c704bc21b02501a3c07171..c2014930b3392527225e61ffc5336006157d352e 100644 (file)
@@ -36,19 +36,25 @@ The instruction will run in accumulate mode, so in order to calculate the 2-coef
 
 A-Form
 
-* maddsubrs  RT,RA,RB,SH
+* maddsubrs  RT,RA,SH,RB
 
 Pseudo-code:
 
 ```
-    sum <- (RT) + (RA)      # RT = a, RA = b
+    n <- SH
+    sum <- (RT) + (RA)
     diff <- (RT) - (RA)
-    prod1 <- MUL(RB, sum)   # RB = c
-    prod2 <- MUL(RB, diff)  # TODO: Pick high half?
-    res1 <- ROTL64(prod1, XLEN-SH)
-    res2 <- ROTL64(prod2, XLEN-SH)
-    RT <- (RT) + res1
-    RS <- (RS) + res2
+    prod1 <- MULS(RB, sum)[XLEN:(XLEN*2)-1]
+    prod2 <- MULS(RB, diff)[XLEN:(XLEN*2)-1]
+    res1 <- ROTL64(prod1, XLEN-n)
+    res2 <- ROTL64(prod2, XLEN-n)
+    m <- MASK(n, (XLEN-1))
+    s1 <- res1[0]
+    s2 <- res2[0]
+    smask1 <- ([s1]*XLEN) & ¬m
+    smask2 <- ([s2]*XLEN) & ¬m
+    RT <- res1 & m | smask1
+    RS <- res2 & m | smask2
 ```
 
 Special Registers Altered: