4 * <https://bugs.libre-soc.org/show_bug.cgi?id=1074>
5 * <https://libre-soc.org/openpower/sv/biginteger/> for format and
6 information about implicit RS/FRS
7 * <https://git.libre-soc.org/?p=openpower-isa.git;a=blob;f=src/openpower/decoder/isa/test_caller_svp64_dct.py;hb=HEAD>
8 * [[openpower/isa/svfparith]]
9 * [[openpower/isa/svfixedarith]]
12 # Rationale for Twin Butterfly Integer DCT Instruction(s)
14 The number of general-purpose uses for DCT is huge. The
15 number of instructions needed instead of these Twin-Butterfly
16 instructions is also huge (**eight**) and given that it is
17 extremely common to explicitly loop-unroll them quantity
18 hundreds to thousands of instructions are dismayingly common
21 The goal is to implement instructions that calculate the expression:
24 fdct_round_shift((a +/- b) * c)
27 For the single-coefficient butterfly instruction, and:
30 fdct_round_shift(a * c1 +/- b * c2)
33 For the double-coefficient butterfly instruction.
35 `fdct_round_shift` is defined as `ROUND_POWER_OF_TWO(x, 14)`
38 #define ROUND_POWER_OF_TWO(value, n) (((value) + (1 << ((n)-1))) >> (n))
41 These instructions are at the core of **ALL** FDCT calculations in many major video codecs, including -but not limited to- VP8/VP9, AV1, etc.
42 Arm includes special instructions to optimize these operations, although they are limited in precision: `vqrdmulhq_s16`/`vqrdmulhq_s32`.
44 The suggestion is to have a single instruction to calculate both values `((a + b) * c) >> N`, and `((a - b) * c) >> N`.
45 The instruction will run in accumulate mode, so in order to calculate the 2-coeff version one would just have to call the same instruction with different order a, b and a different constant c.
47 ## Integer Butterfly Multiply Add/Sub FFT/DCT
49 **Add the following to Book I Section 3.3.9.1**
54 |0 |6 |11 |16 |21 |26 |31 |
55 | PO | RT | RA | RB | SH | XO |/ |
59 * maddsubrs RT,RA,SH,RB
67 prod1 <- MULS(RB, sum)[XLEN:(XLEN*2)-1]
68 prod2 <- MULS(RB, diff)[XLEN:(XLEN*2)-1]
69 res1 <- ROTL64(prod1, XLEN-n)
70 res2 <- ROTL64(prod2, XLEN-n)
71 m <- MASK(n, (XLEN-1))
74 smask1 <- ([signbit1]*XLEN) & ¬m
75 smask2 <- ([signbit2]*XLEN) & ¬m
76 s64_1 <- [0]*(XLEN-1) || signbit1
77 s64_2 <- [0]*(XLEN-1) || signbit2
78 RT <- (res1 & m | smask1) + s64_1
79 RS <- (res2 & m | smask2) + s64_2
82 Special Registers Altered:
88 # Twin Butterfly Integer DCT Instruction(s)
90 ## Floating Twin Multiply-Add DCT [Single]
92 **Add the following to Book I Section 4.6.6.3 **
97 |0 |6 |11 |16 |21 |31 |
98 | PO | FRT | FRA | FRB | XO |/ |
101 * fdmadds FRT,FRA,FRB (Rc=0)
106 FRS <- FPADD32(FRT, FRB)
107 sub <- FPSUB32(FRT, FRB)
108 FRT <- FPMUL32(FRA, sub)
111 Special Registers Altered:
119 ## Floating Multiply-Add FFT [Single]
121 **Add the following to Book I Section 4.6.6.3 **
126 |0 |6 |11 |16 |21 |31 |
127 | PO | FRT | FRA | FRB | XO |/ |
130 * ffmadds FRT,FRA,FRB (Rc=0)
135 FRS <- FPMULADD32(FRT, FRA, FRB, -1, 1)
136 FRT <- FPMULADD32(FRT, FRA, FRB, 1, 1)
139 Special Registers Altered: