add RVV ISA table
[libreriscv.git] / simple_v_extension.mdwn
1 # Variable-width Variable-packed SIMD / Simple-V / Parallelism Extension Proposal
2
3 This proposal exists so as to be able to satisfy several disparate
4 requirements: power-conscious, area-conscious, and performance-conscious
5 designs all pull an ISA and its implementation in different conflicting
6 directions, as do the specific intended uses for any given implementation.
7
8 Additionally, the existing P (SIMD) proposal and the V (Vector) proposals,
9 whilst each extremely powerful in their own right and clearly desirable,
10 are also:
11
12 * Clearly independent in their origins (Cray and AndeStar v3 respectively)
13 so need work to adapt to the RISC-V ethos and paradigm
14 * Are sufficiently large so as to make adoption (and exploration for
15 analysis and review purposes) prohibitively expensive
16 * Both contain partial duplication of pre-existing RISC-V instructions
17 (an undesirable characteristic)
18 * Both have independent and disparate methods for introducing parallelism
19 at the instruction level.
20 * Both require that their respective parallelism paradigm be implemented
21 along-side and integral to their respective functionality *or not at all*.
22 * Both independently have methods for introducing parallelism that
23 could, if separated, benefit
24 *other areas of RISC-V not just DSP or Floating-point respectively*.
25
26 Therefore it makes a huge amount of sense to have a means and method
27 of introducing instruction parallelism in a flexible way that provides
28 implementors with the option to choose exactly where they wish to offer
29 performance improvements and where they wish to optimise for power
30 and/or area (and if that can be offered even on a per-operation basis that
31 would provide even more flexibility).
32
33 Additionally it makes sense to *split out* the parallelism inherent within
34 each of P and V, and to see if each of P and V then, in *combination* with
35 a "best-of-both" parallelism extension, would work well.
36
37 **TODO**: reword this to better suit this document:
38
39 Having looked at both P and V as they stand, they're _both_ very much
40 "separate engines" that, despite both their respective merits and
41 extremely powerful features, don't really cleanly fit into the RV design
42 ethos (or the flexible extensibility) and, as such, are both in danger
43 of not being widely adopted. I'm inclined towards recommending:
44
45 * splitting out the DSP aspects of P-SIMD to create a single-issue DSP
46 * splitting out the polymorphism, esoteric data types (GF, complex
47 numbers) and unusual operations of V to create a single-issue "Esoteric
48 Floating-Point" extension
49 * splitting out the loop-aspects, vector aspects and data-width aspects
50 of both P and V to a *new* "P-SIMD / Simple-V" and requiring that they
51 apply across *all* Extensions, whether those be DSP, M, Base, V, P -
52 everything.
53
54 **TODO**: propose overflow registers be actually one of the integer regs
55 (flowing to multiple regs).
56
57 **TODO**: propose "mask" (predication) registers likewise. combination with
58 standard RV instructions and overflow registers extremely powerful
59
60 **TODO**: propose two LOAD/STORE offset CSRs, which mark a particular
61 register as being "if you use this reg in LOAD/STORE, use the offset
62 amount CSRoffsN (N=0,1) instead of treating LOAD/STORE as contiguous".
63 can be used for matrix spanning.
64
65
66 # Analysis and discussion of Vector vs SIMD
67
68 There are four combined areas between the two proposals that help with
69 parallelism without over-burdening the ISA with a huge proliferation of
70 instructions:
71
72 * Fixed vs variable parallelism (fixed or variable "M" in SIMD)
73 * Implicit vs fixed instruction bit-width (integral to instruction or not)
74 * Implicit vs explicit type-conversion (compounded on bit-width)
75 * Implicit vs explicit inner loops.
76 * Masks / tagging (selecting/preventing certain indexed elements from execution)
77
78 The pros and cons of each are discussed and analysed below.
79
80 ## Fixed vs variable parallelism length
81
82 In David Patterson and Andrew Waterman's analysis of SIMD and Vector
83 ISAs, the analysis comes out clearly in favour of (effectively) variable
84 length SIMD. As SIMD is a fixed width, typically 4, 8 or in extreme cases
85 16 or 32 simultaneous operations, the setup, teardown and corner-cases of SIMD
86 are extremely burdensome except for applications whose requirements
87 *specifically* match the *precise and exact* depth of the SIMD engine.
88
89 Thus, SIMD, no matter what width is chosen, is never going to be acceptable
90 for general-purpose computation, and in the context of developing a
91 general-purpose ISA, is never going to satisfy 100 percent of implementors.
92
93 That basically leaves "variable-length vector" as the clear *general-purpose*
94 winner, at least in terms of greatly simplifying the instruction set,
95 reducing the number of instructions required for any given task, and thus
96 reducing power consumption for the same.
97
98 ## Implicit vs fixed instruction bit-width
99
100 SIMD again has a severe disadvantage here, over Vector: huge proliferation
101 of specialist instructions that target 8-bit, 16-bit, 32-bit, 64-bit, and
102 have to then have operations *for each and between each*. It gets very
103 messy, very quickly.
104
105 The V-Extension on the other hand proposes to set the bit-width of
106 future instructions on a per-register basis, such that subsequent instructions
107 involving that register are *implicitly* of that particular bit-width until
108 otherwise changed or reset.
109
110 This has some extremely useful properties, without being particularly
111 burdensome to implementations, given that instruction decode already has
112 to direct the operation to a correctly-sized width ALU engine, anyway.
113
114 Not least: in places where an ISA was previously constrained (due for
115 whatever reason, including limitations of the available operand spcace),
116 implicit bit-width allows the meaning of certain operations to be
117 type-overloaded *without* pollution or alteration of frozen and immutable
118 instructions, in a fully backwards-compatible fashion.
119
120 ## Implicit and explicit type-conversion
121
122 The Draft 2.3 V-extension proposal has (deprecated) polymorphism to help
123 deal with over-population of instructions, such that type-casting from
124 integer (and floating point) of various sizes is automatically inferred
125 due to "type tagging" that is set with a special instruction. A register
126 will be *specifically* marked as "16-bit Floating-Point" and, if added
127 to an operand that is specifically tagged as "32-bit Integer" an implicit
128 type-conversion will take placce *without* requiring that type-conversion
129 to be explicitly done with its own separate instruction.
130
131 However, implicit type-conversion is not only quite burdensome to
132 implement (explosion of inferred type-to-type conversion) but also is
133 never really going to be complete. It gets even worse when bit-widths
134 also have to be taken into consideration.
135
136 Overall, type-conversion is generally best to leave to explicit
137 type-conversion instructions, or in definite specific use-cases left to
138 be part of an actual instruction (DSP or FP)
139
140 ## Zero-overhead loops vs explicit loops
141
142 The initial Draft P-SIMD Proposal by Chuanhua Chang of Andes Technology
143 contains an extremely interesting feature: zero-overhead loops. This
144 proposal would basically allow an inner loop of instructions to be
145 repeated indefinitely, a fixed number of times.
146
147 Its specific advantage over explicit loops is that the pipeline in a
148 DSP can potentially be kept completely full *even in an in-order
149 implementation*. Normally, it requires a superscalar architecture and
150 out-of-order execution capabilities to "pre-process" instructions in order
151 to keep ALU pipelines 100% occupied.
152
153 This very simple proposal offers a way to increase pipeline activity in the
154 one key area which really matters: the inner loop.
155
156 ## Mask and Tagging
157
158 *TODO: research masks as they can be superb and extremely powerful.
159 If B-Extension is implemented and provides Bit-Gather-Scatter it
160 becomes really cool and easy to switch out certain indexed values
161 from an array of data, but actually BGS **on its own** might be
162 sufficient. Bottom line, this is complex, and needs a proper analysis.
163 The other sections are pretty straightforward.*
164
165 ## Conclusions
166
167 In the above sections the four different ways where parallel instruction
168 execution has closely and loosely inter-related implications for the ISA and
169 for implementors, were outlined. The pluses and minuses came out as
170 follows:
171
172 * Fixed vs variable parallelism: <b>variable</b>
173 * Implicit (indirect) vs fixed (integral) instruction bit-width: <b>indirect</b>
174 * Implicit vs explicit type-conversion: <b>explicit</b>
175 * Implicit vs explicit inner loops: <b>implicit</b>
176 * Tag or no-tag: <b>TODO</b>
177
178 In particular: variable-length vectors came out on top because of the
179 high setup, teardown and corner-cases associated with the fixed width
180 of SIMD. Implicit bit-width helps to extend the ISA to escape from
181 former limitations and restrictions (in a backwards-compatible fashion),
182 and implicit (zero-overhead) loops provide a means to keep pipelines
183 potentially 100% occupied *without* requiring a super-scalar or out-of-order
184 architecture.
185
186 Constructing a SIMD/Simple-Vector proposal based around even only these four
187 (five?) requirements would therefore seem to be a logical thing to do.
188
189 # Instruction Format
190
191 **TODO** *basically borrow from both P and V, which should be quite simple
192 to do, with the exception of Tag/no-tag, which needs a bit more
193 thought. V's Section 17.19 of Draft V2.3 spec is reminiscent of B's BGS
194 gather-scatterer, and, if implemented, could actually be a really useful
195 way to span 8-bit up to 64-bit groups of data, where BGS as it stands
196 and described by Clifford does **bits** of up to 16 width. Lots to
197 look at and investigate!*
198
199 # Note on implementation of parallelism
200
201 One extremely important aspect of this proposal is to respect and support
202 implementors desire to focus on power, area or performance. In that regard,
203 it is proposed that implementors be free to choose whether to implement
204 the Vector (or variable-width SIMD) parallelism as sequential operations
205 with a single ALU, fully parallel (if practical) with multiple ALUs, or
206 a hybrid combination of both.
207
208 In Broadcom's Videocore-IV, they chose hybrid, and called it "Virtual
209 Parallelism". They achieve a 16-way SIMD at an **instruction** level
210 by providing a combination of a 4-way parallel ALU *and* an externally
211 transparent loop that feeds 4 sequential sets of data into each of the
212 4 ALUs.
213
214 Also in the same core, it is worth noting that particularly uncommon
215 but essential operations (Reciprocal-Square-Root for example) are
216 *not* part of the 4-way parallel ALU but instead have a *single* ALU.
217 Under the proposed Vector (varible-width SIMD) implementors would
218 be free to do precisely that: i.e. free to choose *on a per operation
219 basis* whether and how much "Virtual Parallelism" to deploy.
220
221 It is absolutely critical to note that it is proposed that such choices MUST
222 be **entirely transparent** to the end-user and the compiler. Whilst
223 a Vector (varible-width SIM) may not precisely match the width of the
224 parallelism within the implementation, the end-user **should not care**
225 and in this way the performance benefits are gained but the ISA remains
226 simple. All that happens at the end of an instruction run is: some
227 parallel units (if there are any) would remain offline, completely
228 transparently to the ISA, the program, and the compiler.
229
230 The "SIMD considered harmful" trap of having huge complexity and extra
231 instructions to deal with corner-cases is thus avoided, and implementors
232 get to choose precisely where to focus and target the benefits of their
233 implementationefforts..
234
235 # V-Extension to Simple-V Comparative Analysis
236
237 This section covers the ways in which Simple-V is comparable
238 to, or more flexible than, V-Extension (V2.3-draft). Also covered is
239 one major weak-point (register files are fixed size, where V is
240 arbitrary length), and how best to deal with that, should V be adapted
241 to be on top of Simple-V.
242
243 The first stages of this section go over each of the sections of V2.3-draft V
244 where appropriate
245
246 ## 17.3 Shape Encoding
247
248 Simple-V's proposed means of expressing whether a register (from the
249 standard integer or the standard floating-point file) is a scalar or
250 a vector is to simply set the vector length to 1. The instruction
251 would however have to specify which register file (integer or FP) that
252 the vector-length was to be applied to.
253
254 Extended shapes (2-D etc) would not be part of Simple-V at all.
255
256 ## 17.4 Representation Encoding
257
258 Simple-V would not have representation-encoding. This is part of
259 polymorphism, which is considered too complex to implement (TODO: confirm?)
260
261 ## 17.5 Element Bitwidth
262
263 This is directly equivalent to Simple-V's "Packed", and implies that
264 integer (or floating-point) are divided down into vector-indexable
265 chunks of size Bitwidth.
266
267 In this way it becomes possible to have ADD effectively and implicitly
268 turn into ADDb (8-bit add), ADDw (16-bit add) and so on, and where
269 vector-length has been set to greater than 1, it becomes a "Packed"
270 (SIMD) instruction.
271
272 It remains to be decided what should be done when RV32 / RV64 ADD (sized)
273 opcodes are used. One useful idea would be, on an RV64 system where
274 a 32-bit-sized ADD was performed, to simply use the least significant
275 32-bits of the register (exactly as is currently done) but at the same
276 time to *respect the packed bitwidth as well*.
277
278 The extended encoding (Table 17.6) would not be part of Simple-V.
279
280 ## 17.6 Base Vector Extension Supported Types
281
282 TODO: analyse. probably exactly the same.
283
284 ## 17.7 Maximum Vector Element Width
285
286 No equivalent in Simple-V
287
288 ## 17.8 Vector Configuration Registers
289
290 TODO: analyse.
291
292 ## 17.9 Legal Vector Unit Configurations
293
294 TODO: analyse
295
296 ## 17.10 Vector Unit CSRs
297
298 TODO: analyse
299
300 > Ok so this is an aspect of Simple-V that I hadn't thought through,
301 > yet (proposal / idea only a few days old!).  in V2.3-Draft ISA Section
302 > 17.10 the CSRs are listed.  I note that there's some general-purpose
303 > CSRs (including a global/active vector-length) and 16 vcfgN CSRs.  i
304 > don't precisely know what those are for.
305
306 >  In the Simple-V proposal, *every* register in both the integer
307 > register-file *and* the floating-point register-file would have at
308 > least a 2-bit "data-width" CSR and probably something like an 8-bit
309 > "vector-length" CSR (less in RV32E, by exactly one bit).
310
311 >  What I *don't* know is whether that would be considered perfectly
312 > reasonable or completely insane.  If it turns out that the proposed
313 > Simple-V CSRs can indeed be stored in SRAM then I would imagine that
314 > adding somewhere in the region of 10 bits per register would be... okay? 
315 > I really don't honestly know.
316
317 >  Would these proposed 10-or-so-bit per-register Simple-V CSRs need to
318 > be multi-ported? No I don't believe they would.
319
320 ## 17.11 Maximum Vector Length (MVL)
321
322 Basically implicitly this is set to the maximum size of the register
323 file multiplied by the number of 8-bit packed ints that can fit into
324 a register (4 for RV32, 8 for RV64 and 16 for RV128).
325
326 ## !7.12 Vector Instruction Formats
327
328 No equivalent in Simple-V because *all* instructions of *all* Extensions
329 are implicitly parallelised (and packed).
330
331 ## 17.13 Polymorphic Vector Instructions
332
333 Polymorphism (implicit type-casting) is deliberately not supported
334 in Simple-V.
335
336 ## 17.14 Rapid Configuration Instructions
337
338 TODO: analyse if this is useful to have an equivalent in Simple-V
339
340 ## 17.15 Vector-Type-Change Instructions
341
342 TODO: analyse if this is useful to have an equivalent in Simple-V
343
344 ## 17.16 Vector Length
345
346 Has a direct corresponding equivalent.
347
348 ## 17.17 Predicated Execution
349
350 Predicated Execution is another name for "masking" or "tagging". Masked
351 (or tagged) implies that there is a bit field which is indexed, and each
352 bit associated with the corresponding indexed offset register within
353 the "Vector". If the tag / mask bit is 1, when a parallel operation is
354 issued, the indexed element of the vector has the operation carried out.
355 However if the tag / mask bit is *zero*, that particular indexed element
356 of the vector does *not* have the requested operation carried out.
357
358 In V2.3-draft V, there is a significant (not recommended) difference:
359 the zero-tagged elements are *set to zero*. This loses a *significant*
360 advantage of mask / tagging, particularly if the entire mask register
361 is itself a general-purpose register, as that general-purpose register
362 can be inverted, shifted, and'ed, or'ed and so on. In other words
363 it becomes possible, especially if Carry/Overflow from each vector
364 operation is also accessible, to do conditional (step-by-step) vector
365 operations including things like turn vectors into 1024-bit or greater
366 operands with very few instructions, by treating the "carry" from
367 one instruction as a way to do "Conditional add of 1 to the register
368 next door". If V2.3-draft V sets zero-tagged elements to zero, such
369 extremely powerful techniques are simply not possible.
370
371 It is noted that there is no mention of an equivalent to BEXT (element
372 skipping) which would be particularly fascinating and powerful to have.
373 In this mode, the "mask" would skip elements where its mask bit was zero
374 in either the source or the destination operand.
375
376 Lots to be discussed.
377
378 ## 17.18 Vector Load/Store Instructions
379
380 These may not have a direct equivalent in Simple-V, except if mask/tagging
381 is to be deployed.
382
383 To be discussed.
384
385 ## 17.19 Vector Register Gather
386
387 TODO
388
389 ## TODO, sort
390
391 > However, there are also several features that go beyond simply attaching VL
392 > to a scalar operation and are crucial to being able to vectorize a lot of
393 > code. To name a few:
394 > - Conditional execution (i.e., predicated operations)
395 > - Inter-lane data movement (e.g. SLIDE, SELECT)
396 > - Reductions (e.g., VADD with a scalar destination)
397
398 Ok so the Conditional and also the Reductions is one of the reasons
399 why as part of SimpleV / variable-SIMD / parallelism (gah gotta think
400 of a decent name) i proposed that it be implemented as "if you say r0
401 is to be a vector / SIMD that means operations actually take place on
402 r0,r1,r2... r(N-1)".
403
404 Consequently any parallel operation could be paused (or... more
405 specifically: vectors disabled by resetting it back to a default /
406 scalar / vector-length=1) yet the results would actually be in the
407 *main register file* (integer or float) and so anything that wasn't
408 possible to easily do in "simple" parallel terms could be done *out*
409 of parallel "mode" instead.
410
411 I do appreciate that the above does imply that there is a limit to the
412 length that SimpleV (whatever) can be parallelised, namely that you
413 run out of registers! my thought there was, "leave space for the main
414 V-Ext proposal to extend it to the length that V currently supports".
415 Honestly i had not thought through precisely how that would work.
416
417 Inter-lane (SELECT) i saw 17.19 in V2.3-Draft p117, I liked that,
418 it reminds me of the discussion with Clifford on bit-manipulation
419 (gather-scatter except not Bit Gather Scatter, *data* gather scatter): if
420 applied "globally and outside of V and P" SLIDE and SELECT might become
421 an extremely powerful way to do fast memory copy and reordering [2[.
422
423 However I haven't quite got my head round how that would work: i am
424 used to the concept of register "tags" (the modern term is "masks")
425 and i *think* if "masks" were applied to a Simple-V-enhanced LOAD /
426 STORE you would get the exact same thing as SELECT.
427
428 SLIDE you could do simply by setting say r0 vector-length to say 16
429 (meaning that if referred to in any operation it would be an implicit
430 parallel operation on *all* registers r0 through r15), and temporarily
431 set say.... r7 vector-length to say... 5. Do a LOAD on r7 and it would
432 implicitly mean "load from memory into r7 through r11". Then you go
433 back and do an operation on r0 and ta-daa, you're actually doing an
434 operation on a SLID {SLIDED?) vector.
435
436 The advantage of Simple-V (whatever) over V would be that you could
437 actually do *operations* in the middle of vectors (not just SLIDEs)
438 simply by (as above) setting r0 vector-length to 16 and r7 vector-length
439 to 5. There would be nothing preventing you from doing an ADD on r0
440 (which meant do an ADD on r0 through r15) followed *immediately in the
441 next instruction with no setup cost* a MUL on r7 (which actually meant
442 "do a parallel MUL on r7 through r11").
443
444 btw it's worth mentioning that you'd get scalar-vector and vector-scalar
445 implicitly by having one of the source register be vector-length 1
446 (the default) and one being N > 1. but without having special opcodes
447 to do it. i *believe* (or more like "logically infer or deduce" as
448 i haven't got access to the spec) that that would result in a further
449 opcode reduction when comparing [draft] V-Ext to [proposed] Simple-V.
450
451 Also, Reduction *might* be possible by specifying that the destination be
452 a scalar (vector-length=1) whilst the source be a vector. However... it
453 would be an awful lot of work to go through *every single instruction*
454 in *every* Extension, working out which ones could be parallelised (ADD,
455 MUL, XOR) and those that definitely could not (DIV, SUB). Is that worth
456 the effort? maybe. Would it result in huge complexity? probably.
457 Could an implementor just go "I ain't doing *that* as parallel!
458 let's make it virtual-parallelism (sequential reduction) instead"?
459 absolutely. So, now that I think it through, Simple-V (whatever)
460 covers Reduction as well. huh, that's a surprise.
461
462
463 > - Vector-length speculation (making it possible to vectorize some loops with
464 > unknown trip count) - I don't think this part of the proposal is written
465 > down yet.
466
467 Now that _is_ an interesting concept. A little scary, i imagine, with
468 the possibility of putting a processor into a hard infinite execution
469 loop... :)
470
471
472 > Also, note the vector ISA consumes relatively little opcode space (all the
473 > arithmetic fits in 7/8ths of a major opcode). This is mainly because data
474 > type and size is a function of runtime configuration, rather than of opcode.
475
476 yes. i love that aspect of V, i am a huge fan of polymorphism [1]
477 which is why i am keen to advocate that the same runtime principle be
478 extended to the rest of the RISC-V ISA [3]
479
480 Yikes that's a lot. I'm going to need to pull this into the wiki to
481 make sure it's not lost.
482
483 [1] inherent data type conversion: 25 years ago i designed a hypothetical
484 hyper-hyper-hyper-escape-code-sequencing ISA based around 2-bit
485 (escape-extended) opcodes and 2-bit (escape-extended) operands that
486 only required a fixed 8-bit instruction length. that relied heavily
487 on polymorphism and runtime size configurations as well. At the time
488 I thought it would have meant one HELL of a lot of CSRs... but then I
489 met RISC-V and was cured instantly of that delusion^Wmisapprehension :)
490
491 [2] Interestingly if you then also add in the other aspect of Simple-V
492 (the data-size, which is effectively functionally orthogonal / identical
493 to "Packed" of Packed-SIMD), masked and packed *and* vectored LOAD / STORE
494 operations become byte / half-word / word augmenters of B-Ext's proposed
495 "BGS" i.e. where B-Ext's BGS dealt with bits, masked-packed-vectored
496 LOAD / STORE would deal with 8 / 16 / 32 bits at a time. Where it
497 would get really REALLY interesting would be masked-packed-vectored
498 B-Ext BGS instructions. I can't even get my head fully round that,
499 which is a good sign that the combination would be *really* powerful :)
500
501 [3] ok sadly maybe not the polymorphism, it's too complicated and I
502 think would be much too hard for implementors to easily "slide in" to an
503 existing non-Simple-V implementation.  i say that despite really *really*
504 wanting IEEE 704 FP Half-precision to end up somewhere in RISC-V in some
505 fashion, for optimising 3D Graphics.  *sigh*.
506
507 ## TODO: instructions (based on Hwacha) V-Ext duplication analysis
508
509 This is partly speculative due to lack of access to an up-to-date
510 V-Ext Spec (V2.3-draft RVV 0.4-Draft at the time of writing). However
511 basin an analysis instead on Hwacha, a cursory examination shows over
512 an **85%** duplication of V-Ext operand-related instructions when
513 compared to Simple-V on a standard RG64G base. Even Vector Fetch
514 is analogous to "zero-overhead loop".
515
516 Exceptions are:
517
518 * Vector Indexed Memory Instructions (non-contiguous)
519 * Vector Atomic Memory Instructions.
520 * Some of the Vector Arithmetic ops: MADD, MSUB,
521 VSRL, VSRA, VEIDX, VFIRST, VSGNJN, VFSGNJX and potentially more.
522 * Consensual Jump
523
524 Table of RV32V Instructions
525
526 | RV32V | |
527 | ----- | --- |
528 | VADD | |
529 | VSUB | |
530 | VSL | |
531 | VSR | |
532 | VAND | |
533 | VOR | |
534 | VXOR | |
535 | VSEQ | |
536 | VSNE | |
537 | VSLT | |
538 | VSGE | |
539 | VCLIP | |
540 | VCVT | |
541 | VMPOP | |
542 | VMFIRST | |
543 | VEXTRACT | |
544 | VINSERT | |
545 | VMERGE | |
546 | VSELECT | |
547 | VSLIDE | |
548 | VDIV | |
549 | VREM | |
550 | VMUL | |
551 | VMULH | |
552 | VMIN | |
553 | VMAX | |
554 | VSGNJ | |
555 | VSGNJN | |
556 | VSGNJX | |
557 | VSQRT | |
558 | VCLASS | |
559 | VPOPC | |
560 | VADDI | |
561 | VSLI | |
562 | VSRI | |
563 | VANDI | |
564 | VORI | |
565 | VXORI | |
566 | VCLIPI | |
567 | VMADD | |
568 | VMSUB | |
569 | VNMADD | |
570 | VNMSUB | |
571 | VLD | |
572 | VLDS | |
573 | VLDX | |
574 | VST | |
575 | VSTS | |
576 | VSTX | |
577 | VAMOSWAP | |
578 | VAMOADD | |
579 | VAMOAND | |
580 | VAMOOR | |
581 | VAMOXOR | |
582 | VAMOMIN | |
583 | VAMOMAX | |
584
585 ## TODO: sort
586
587 > I suspect that the "hardware loop" in question is actually a zero-overhead
588 > loop unit that diverts execution from address X to address Y if a certain
589 > condition is met.
590
591  not quite.  The zero-overhead loop unit interestingly would be at
592 an [independent] level above vector-length.  The distinctions are
593 as follows:
594
595 * Vector-length issues *virtual* instructions where the register
596 operands are *specifically* altered (to cover a range of registers),
597 whereas zero-overhead loops *specifically* do *NOT* alter the operands
598 in *ANY* way.
599
600 * Vector-length-driven "virtual" instructions are driven by *one*
601 and *only* one instruction (whether it be a LOAD, STORE, or pure
602 one/two/three-operand opcode) whereas zero-overhead loop units
603 specifically apply to *multiple* instructions.
604
605 Where vector-length-driven "virtual" instructions might get conceptually
606 blurred with zero-overhead loops is LOAD / STORE.  In the case of LOAD /
607 STORE, to actually be useful, vector-length-driven LOAD / STORE should
608 increment the LOAD / STORE memory address to correspondingly match the
609 increment in the register bank.  example:
610
611 * set vector-length for r0 to 4
612 * issue RV32 LOAD from addr 0x1230 to r0
613
614 translates effectively to:
615
616 * RV32 LOAD from addr 0x1230 to r0
617 * ...
618 * ...
619 * RV32 LOAD from addr 0x123B to r3
620
621 # P-Ext ISA
622
623 ## 16-bit Arithmetic
624
625 | Mnemonic | 16-bit Instruction | Simple-V Equivalent |
626 | ------------------ | ------------------------- | ------------------- |
627 | ADD16 rt, ra, rb | add | RV ADD (bitwidth=16) |
628 | RADD16 rt, ra, rb | Signed Halving add | |
629 | URADD16 rt, ra, rb | Unsigned Halving add | |
630 | KADD16 rt, ra, rb | Signed Saturating add | |
631 | UKADD16 rt, ra, rb | Unsigned Saturating add | |
632 | SUB16 rt, ra, rb | sub | RV SUB (bitwidth=16) |
633 | RSUB16 rt, ra, rb | Signed Halving sub | |
634 | URSUB16 rt, ra, rb | Unsigned Halving sub | |
635 | KSUB16 rt, ra, rb | Signed Saturating sub | |
636 | UKSUB16 rt, ra, rb | Unsigned Saturating sub | |
637 | CRAS16 rt, ra, rb | Cross Add & Sub | |
638 | RCRAS16 rt, ra, rb | Signed Halving Cross Add & Sub | |
639 | URCRAS16 rt, ra, rb| Unsigned Halving Cross Add & Sub | |
640 | KCRAS16 rt, ra, rb | Signed Saturating Cross Add & Sub | |
641 | UKCRAS16 rt, ra, rb| Unsigned Saturating Cross Add & Sub | |
642 | CRSA16 rt, ra, rb | Cross Sub & Add | |
643 | RCRSA16 rt, ra, rb | Signed Halving Cross Sub & Add | |
644 | URCRSA16 rt, ra, rb| Unsigned Halving Cross Sub & Add | |
645 | KCRSA16 rt, ra, rb | Signed Saturating Cross Sub & Add | |
646 | UKCRSA16 rt, ra, rb| Unsigned Saturating Cross Sub & Add | |
647
648 ## 8-bit Arithmetic
649
650 | Mnemonic | 16-bit Instruction | Simple-V Equivalent |
651 | ------------------ | ------------------------- | ------------------- |
652 | ADD8 rt, ra, rb | add | RV ADD (bitwidth=8)|
653 | RADD8 rt, ra, rb | Signed Halving add | |
654 | URADD8 rt, ra, rb | Unsigned Halving add | |
655 | KADD8 rt, ra, rb | Signed Saturating add | |
656 | UKADD8 rt, ra, rb | Unsigned Saturating add | |
657 | SUB8 rt, ra, rb | sub | RV SUB (bitwidth=8)|
658 | RSUB8 rt, ra, rb | Signed Halving sub | |
659 | URSUB8 rt, ra, rb | Unsigned Halving sub | |
660
661
662
663 # References
664
665 * SIMD considered harmful <https://www.sigarch.org/simd-instructions-considered-harmful/>
666 * Link to first proposal <https://groups.google.com/a/groups.riscv.org/forum/#!topic/isa-dev/GuukrSjgBH8>
667 * Recommendation by Jacob Bachmeyer to make zero-overhead loop an
668 "implicit program-counter" <https://groups.google.com/a/groups.riscv.org/d/msg/isa-dev/vYVi95gF2Mo/SHz6a4_lAgAJ>
669 * Re-continuing P-Extension proposal <https://groups.google.com/a/groups.riscv.org/forum/#!msg/isa-dev/IkLkQn3HvXQ/SEMyC9IlAgAJ>
670 * First Draft P-SIMD (DSP) proposal <https://groups.google.com/a/groups.riscv.org/forum/#!topic/isa-dev/vYVi95gF2Mo>
671 * B-Extension discussion <https://groups.google.com/a/groups.riscv.org/forum/#!topic/isa-dev/zi_7B15kj6s>
672 * Broadcom VideoCore-IV <https://docs.broadcom.com/docs/12358545>
673 Figure 2 P17 and Section 3 on P16.
674 * Hwacha <https://www2.eecs.berkeley.edu/Pubs/TechRpts/2015/EECS-2015-262.html>
675 * Hwacha <https://www2.eecs.berkeley.edu/Pubs/TechRpts/2015/EECS-2015-263.html>