1 <!-- This defines Draft SVP64 instructions to augment PowerISA Version 3.0 -->
2 <!-- These are not described in book 1 -->
8 * svstep RT,SVi,vf (Rc=0)
9 * svstep. RT,SVi,vf (Rc=1)
13 if SVi[3:4] = 0b11 then
14 # store subvl, pack and unpack in SVSTATE
17 RT <- [0]*62 || SVSTATE[53:54]
19 step <- SVSTATE_NEXT(SVi, vf)
22 Special Registers Altered:
30 * setvl RT,RA,SVi,vf,vs,ms (Rc=0)
31 * setvl. RT,RA,SVi,vf,vs,ms (Rc=1)
36 if (vf & (¬vs) & ¬(ms)) = 1 then
37 step <- SVSTATE_NEXT(SVi, 0b0)
39 GPR(_RT) <- [0]*57 || step
43 if ms = 1 then MVL <- VLimm[0:6]
44 else MVL <- SVSTATE[0:6]
46 if vs = 0 then VL <- SVSTATE[7:13]
48 if (RA) >u 0b1111111 then
51 else VL <- (RA)[57:63]
52 else if _RA != 0 then VL <- (RA)[57:63]
53 else if _RT = 0 then VL <- VLimm[0:6]
54 else if CTR >u 0b1111111 then
58 # limit VL to within MVL
65 GPR(_RT) <- [0]*57 || VL
66 if ((¬vs) & ¬(ms)) = 0 then
67 # set requested Vertical-First mode, clear persist
71 Special Registers Altered:
79 * svremap SVme,mi0,mi1,mi2,mo0,mo1,pst
83 # registers RA RB RC RT EA/FRS SVSHAPE0-3 indices
89 # enable bit for RA RB RC RT EA/FRS
90 SVSTATE[42:46] <- SVme
91 # persistence bit (applies to more than one instruction)
94 Special Registers Altered:
102 * svshape SVxd,SVyd,SVzd,SVrm,vf
106 # for convenience, VL to be calculated and stored in SVSTATE
108 itercount[0:6] <- [0] * 7
109 SVSTATE[0:31] <- [0] * 32
110 # only overwrite REMAP if "persistence" is zero
111 if (SVSTATE[62] = 0b0) then
112 SVSTATE[32:33] <- 0b00
113 SVSTATE[34:35] <- 0b00
114 SVSTATE[36:37] <- 0b00
115 SVSTATE[38:39] <- 0b00
116 SVSTATE[40:41] <- 0b00
117 SVSTATE[42:46] <- 0b00000
120 # clear out all SVSHAPEs
121 SVSHAPE0[0:31] <- [0] * 32
122 SVSHAPE1[0:31] <- [0] * 32
123 SVSHAPE2[0:31] <- [0] * 32
124 SVSHAPE3[0:31] <- [0] * 32
125 # set schedule up for multiply
126 if (SVrm = 0b0000) then
127 # VL in Matrix Multiply is xd*yd*zd
128 n <- (0b00 || SVxd) * (0b00 || SVyd) * (0b00 || SVzd)
129 vlen[0:6] <- n[14:20]
130 # set up template in SVSHAPE0, then copy to 1-3
131 SVSHAPE0[0:5] <- (0b0 || SVxd) # xdim
132 SVSHAPE0[6:11] <- (0b0 || SVyd) # ydim
133 SVSHAPE0[12:17] <- (0b0 || SVzd) # zdim
134 SVSHAPE0[28:29] <- 0b11 # skip z
136 SVSHAPE1[0:31] <- SVSHAPE0[0:31]
137 SVSHAPE2[0:31] <- SVSHAPE0[0:31]
138 SVSHAPE3[0:31] <- SVSHAPE0[0:31]
140 SVSHAPE1[18:20] <- 0b001 # permute x,z,y
141 SVSHAPE1[28:29] <- 0b01 # skip z
143 SVSHAPE2[18:20] <- 0b001 # permute x,z,y
144 SVSHAPE2[28:29] <- 0b11 # skip y
145 # set schedule up for FFT butterfly
146 if (SVrm = 0b0001) then
147 # calculate O(N log2 N)
150 if SVxd[4-n] = 0 then
153 n <- ((0b0 || SVxd) + 1) * n
155 # set up template in SVSHAPE0, then copy to 1-3
157 SVSHAPE0[0:5] <- (0b0 || SVxd) # xdim
158 SVSHAPE0[30:31] <- 0b01 # Butterfly mode
160 SVSHAPE1[0:31] <- SVSHAPE0[0:31]
161 SVSHAPE2[0:31] <- SVSHAPE0[0:31]
163 SVSHAPE1[28:29] <- 0b01 # j+halfstep schedule
165 SVSHAPE2[28:29] <- 0b10 # k schedule
166 # set schedule up for (i)DCT Inner butterfly
167 # SVrm Mode 2 (Mode 6 for iDCT) is for pre-calculated coefficients,
168 # SVrm Mode 4 (Mode 12 for iDCT) is for on-the-fly (Vertical-First Mode)
169 if ((SVrm = 0b0010) | (SVrm = 0b0100) |
170 (SVrm = 0b1010) | (SVrm = 0b1100)) then
171 # calculate O(N log2 N)
174 if SVxd[4-n] = 0 then
177 n <- ((0b0 || SVxd) + 1) * n
179 # set up template in SVSHAPE0, then copy to 1-3
181 SVSHAPE0[0:5] <- (0b0 || SVxd) # xdim
182 if (SVrm = 0b1010) | (SVrm = 0b1100) then
183 SVSHAPE0[30:31] <- 0b11 # iDCT mode
184 SVSHAPE0[18:20] <- 0b011 # iDCT Inner Butterfly sub-mode
186 SVSHAPE0[30:31] <- 0b01 # DCT mode
187 SVSHAPE0[18:20] <- 0b001 # DCT Inner Butterfly sub-mode
188 SVSHAPE0[21:23] <- 0b001 # "inverse" on outer loop
189 if (SVrm = 0b1100) | (SVrm = 0b0100) then
190 SVSHAPE0[6:11] <- 0b000011 # (i)DCT Inner Butterfly mode 4
192 SVSHAPE0[6:11] <- 0b000001 # (i)DCT Inner Butterfly mode 2
194 SVSHAPE1[0:31] <- SVSHAPE0[0:31]
195 SVSHAPE2[0:31] <- SVSHAPE0[0:31]
196 if (SVrm != 0b0100) & (SVrm != 0b1100) then
197 SVSHAPE3[0:31] <- SVSHAPE0[0:31]
199 SVSHAPE0[28:29] <- 0b01 # j+halfstep schedule
200 # for cos coefficient
201 SVSHAPE2[28:29] <- 0b10 # ci (k for mode 4) schedule
202 if (SVrm != 0b0100) & (SVrm != 0b1100) then
203 SVSHAPE3[28:29] <- 0b11 # size schedule
204 # set schedule up for (i)DCT Outer butterfly
205 if (SVrm = 0b0011) | (SVrm = 0b1011) then
206 # calculate O(N log2 N) number of outer butterfly overlapping adds
210 itercount[0:6] <- (0b00 || SVxd) + 0b0000001
211 itercount[0:6] <- (0b0 || itercount[0:5])
213 if SVxd[4-n] = 0 then
216 count <- (itercount - 0b0000001) * size
217 vlen[0:6] <- vlen + count[7:13]
218 size[0:6] <- (size[1:6] || 0b0)
219 itercount[0:6] <- (0b0 || itercount[0:5])
220 # set up template in SVSHAPE0, then copy to 1-3
222 SVSHAPE0[0:5] <- (0b0 || SVxd) # xdim
223 if (SVrm = 0b1011) then
224 SVSHAPE0[30:31] <- 0b11 # iDCT mode
225 SVSHAPE0[18:20] <- 0b011 # iDCT Outer Butterfly sub-mode
226 SVSHAPE0[21:23] <- 0b101 # "inverse" on outer and inner loop
228 SVSHAPE0[30:31] <- 0b01 # DCT mode
229 SVSHAPE0[18:20] <- 0b100 # DCT Outer Butterfly sub-mode
230 SVSHAPE0[6:11] <- 0b000010 # DCT Butterfly mode
232 SVSHAPE1[0:31] <- SVSHAPE0[0:31]
233 SVSHAPE2[0:31] <- SVSHAPE0[0:31]
235 SVSHAPE1[28:29] <- 0b01 # j+halfstep schedule
236 # set schedule up for DCT COS table generation
237 if (SVrm = 0b0101) | (SVrm = 0b1101) then
238 # calculate O(N log2 N)
240 itercount[0:6] <- (0b00 || SVxd) + 0b0000001
241 itercount[0:6] <- (0b0 || itercount[0:5])
244 if SVxd[4-n] = 0 then
247 vlen[0:6] <- vlen + itercount
248 itercount[0:6] <- (0b0 || itercount[0:5])
249 # set up template in SVSHAPE0, then copy to 1-3
251 SVSHAPE0[0:5] <- (0b0 || SVxd) # xdim
252 SVSHAPE0[30:31] <- 0b01 # DCT/FFT mode
253 SVSHAPE0[6:11] <- 0b000100 # DCT Inner Butterfly COS-gen mode
254 if (SVrm = 0b0101) then
255 SVSHAPE0[21:23] <- 0b001 # "inverse" on outer loop for DCT
257 SVSHAPE1[0:31] <- SVSHAPE0[0:31]
258 SVSHAPE2[0:31] <- SVSHAPE0[0:31]
259 # for cos coefficient
260 SVSHAPE1[28:29] <- 0b10 # ci schedule
261 SVSHAPE2[28:29] <- 0b11 # size schedule
262 # set schedule up for iDCT / DCT inverse of half-swapped ordering
263 if (SVrm = 0b0110) | (SVrm = 0b1110) | (SVrm = 0b1111) then
264 vlen[0:6] <- (0b00 || SVxd) + 0b0000001
265 # set up template in SVSHAPE0
266 SVSHAPE0[0:5] <- (0b0 || SVxd) # xdim
267 if (SVrm = 0b1110) then
268 SVSHAPE0[18:20] <- 0b001 # DCT opposite half-swap
269 if (SVrm = 0b1111) then
270 SVSHAPE0[30:31] <- 0b01 # FFT mode
272 SVSHAPE0[30:31] <- 0b11 # DCT mode
273 SVSHAPE0[6:11] <- 0b000101 # DCT "half-swap" mode
274 # set schedule up for parallel reduction
275 if (SVrm = 0b0111) then
276 # calculate the total number of operations (brute-force)
278 itercount[0:6] <- (0b00 || SVxd) + 0b0000001
279 step[0:6] <- 0b0000001
281 do while step <u itercount
282 newstep <- step[1:6] || 0b0
284 do while (j+step <u itercount)
288 # VL in Parallel-Reduce is the number of operations
290 # set up template in SVSHAPE0, then copy to 1. only 2 needed
291 SVSHAPE0[0:5] <- (0b0 || SVxd) # xdim
292 SVSHAPE0[30:31] <- 0b10 # parallel reduce submode
294 SVSHAPE1[0:31] <- SVSHAPE0[0:31]
295 # set up right operand (left operand 28:29 is zero)
296 SVSHAPE1[28:29] <- 0b01 # right operand
297 # set VL, MVL and Vertical-First
299 SVSTATE[7:13] <- vlen
302 Special Registers Altered:
310 * svindex SVG,rmm,SVd,ew,SVyx,mm,sk
314 # based on nearest MAXVL compute other dimension
318 do while d*dim <u ([0]*4 || MVL)
320 # set up template, then copy once location identified
322 shape[30:31] <- 0b00 # mode
324 shape[18:20] <- 0b110 # indexed xd/yd
325 shape[0:5] <- (0b0 || SVd) # xdim
326 if sk = 0 then shape[6:11] <- 0 # ydim
327 else shape[6:11] <- 0b111111 # ydim max
329 shape[18:20] <- 0b111 # indexed yd/xd
330 if sk = 1 then shape[6:11] <- 0 # ydim
331 else shape[6:11] <- d-1 # ydim max
332 shape[0:5] <- (0b0 || SVd) # ydim
333 shape[12:17] <- (0b0 || SVG) # SVGPR
334 shape[28:29] <- ew # element-width override
335 if sk = 1 then shape[28:29] <- 0b01 # skip 1st dimension
336 else shape[28:29] <- 0b00 # no skipping
337 # select the mode for updating SVSHAPEs
338 SVSTATE[62] <- mm # set or clear persistence
340 # clear out all SVSHAPEs first
341 SVSHAPE0[0:31] <- [0] * 32
342 SVSHAPE1[0:31] <- [0] * 32
343 SVSHAPE2[0:31] <- [0] * 32
344 SVSHAPE3[0:31] <- [0] * 32
345 SVSTATE[32:41] <- [0] * 10 # clear REMAP.mi/o
346 SVSTATE[42:46] <- rmm # rmm exactly REMAP.SVme
350 # activate requested shape
351 if idx = 0 then SVSHAPE0 <- shape
352 if idx = 1 then SVSHAPE1 <- shape
353 if idx = 2 then SVSHAPE2 <- shape
354 if idx = 3 then SVSHAPE3 <- shape
355 SVSTATE[bit*2+32:bit*2+33] <- idx
356 # increment shape index, modulo 4
357 if idx = 3 then idx <- 0
360 # refined SVSHAPE/REMAP update mode
363 if idx = 0 then SVSHAPE0 <- shape
364 if idx = 1 then SVSHAPE1 <- shape
365 if idx = 2 then SVSHAPE2 <- shape
366 if idx = 3 then SVSHAPE3 <- shape
367 SVSTATE[bit*2+32:bit*2+33] <- idx
370 Special Registers Altered:
378 * svshape2 SVo,SVyx,rmm,SVd,sk,mm
382 # based on nearest MAXVL compute other dimension
386 do while d*dim <u ([0]*4 || MVL)
388 # set up template, then copy once location identified
390 shape[30:31] <- 0b00 # mode
391 shape[0:5] <- (0b0 || SVd) # x/ydim
393 shape[18:20] <- 0b000 # ordering xd/yd(/zd)
394 if sk = 0 then shape[6:11] <- 0 # ydim
395 else shape[6:11] <- 0b111111 # ydim max
397 shape[18:20] <- 0b010 # ordering yd/xd(/zd)
398 if sk = 1 then shape[6:11] <- 0 # ydim
399 else shape[6:11] <- d-1 # ydim max
400 # offset (the prime purpose of this instruction)
401 shape[24:27] <- SVo # offset
402 if sk = 1 then shape[28:29] <- 0b01 # skip 1st dimension
403 else shape[28:29] <- 0b00 # no skipping
404 # select the mode for updating SVSHAPEs
405 SVSTATE[62] <- mm # set or clear persistence
407 # clear out all SVSHAPEs first
408 SVSHAPE0[0:31] <- [0] * 32
409 SVSHAPE1[0:31] <- [0] * 32
410 SVSHAPE2[0:31] <- [0] * 32
411 SVSHAPE3[0:31] <- [0] * 32
412 SVSTATE[32:41] <- [0] * 10 # clear REMAP.mi/o
413 SVSTATE[42:46] <- rmm # rmm exactly REMAP.SVme
417 # activate requested shape
418 if idx = 0 then SVSHAPE0 <- shape
419 if idx = 1 then SVSHAPE1 <- shape
420 if idx = 2 then SVSHAPE2 <- shape
421 if idx = 3 then SVSHAPE3 <- shape
422 SVSTATE[bit*2+32:bit*2+33] <- idx
423 # increment shape index, modulo 4
424 if idx = 3 then idx <- 0
427 # refined SVSHAPE/REMAP update mode
430 if idx = 0 then SVSHAPE0 <- shape
431 if idx = 1 then SVSHAPE1 <- shape
432 if idx = 2 then SVSHAPE2 <- shape
433 if idx = 3 then SVSHAPE3 <- shape
434 SVSTATE[bit*2+32:bit*2+33] <- idx
437 Special Registers Altered: