1 <https://bugs.libre-soc.org/show_bug.cgi?id=1074>
3 # [DRAFT] Twin Butterfly DCT Instruction(s)
5 The goal is to implement instructions that calculate the expression:
8 fdct_round_shift((a +/- b) * c)
11 For the single-coefficient butterfly instruction, and:
14 fdct_round_shift(a * c1 +/- b * c2)
17 For the double-coefficient butterfly instruction.
19 `fdct_round_shift` is defined as `ROUND_POWER_OF_TWO(x, 14)`
22 #define ROUND_POWER_OF_TWO(value, n) (((value) + (1 << ((n)-1))) >> (n))
25 The suggestion is to have a single instruction to calculate both values `((a + b) * c) >> N`, and `((a - b) * c) >> N`.
26 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.
29 # [DRAFT] Integer Butterfly Multiply Add/Sub FFT/DCT
33 * maddsubrs RT,RA,RB,RC,SH
41 prod2 <- MUL(RC, diff)
42 res1 <- ROTL64(prod1, SH)
43 res2 <- ROTL64(prod2, SH)
47 Special Registers Altered:
52 Where BF-Form is defined in fields.txt:
56 |0 | 6 |11 |16 |21 | 25 |30 |31 |
57 | PO | RT | RA | RB | RC | SH | XO | Rc |
61 The resulting autogenerated code is:
66 def op_maddsubrs(self, RA, RB, RC, RT):
67 RT2 = copy_assign_rhs(RT + 1)
68 sum = copy_assign_rhs(RA + RB)
69 diff = copy_assign_rhs(RA - RB)
70 prod1 = copy_assign_rhs(self.MUL(RC, sum))
71 prod2 = copy_assign_rhs(self.MUL(RC, diff))
72 res1 = copy_assign_rhs(self.ROTL64(prod1, SH))
73 res2 = copy_assign_rhs(self.ROTL64(prod2, SH))
74 RT = copy_assign_rhs(RT + res1)
75 RT2 = copy_assign_rhs(RT2 + res2)
79 The instruction has been added to `minor_59.csv`:
81 1111011111,ALU,OP_MADDSUBRS,RA,RB,RC,RT,NONE,CR1,0,0,ZERO,0,NONE,0,0,0,0,1,0,RC_ONLY,0,0,maddsubrs,A,,1,unofficial until submitted and approved/renumbered by the opf isa wg