forked from riscv/riscv-p-spec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathP-ext-proposal.adoc
21336 lines (14934 loc) · 530 KB
/
P-ext-proposal.adoc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
= RISC-V "P" Extension Proposal
Version 0.9.11-draft-20211209
This document is in the Development state. Assume anything can change.
:doctype: book
:encoding: utf-8
:lang: en
:toc: left
:toclevels: 4
:numbered:
:stem: latexmath
:xrefstyle: short
:le: ≤
:rarr: ⇒
:imagesdir: images
:title-logo-image: image:risc-v_logo.png[pdfwidth=3.25in,align=center]
[preface]
== Revision History
[cols="^.^10,^.^15,^.^15,<.^60", options="header"]
|===
|Rev.|Revision Date|Author|Revised Content
| v0.9.11 | 2021/12/09 | Chuanhua Chang
a|
* Changed source operand data type of KADDH/UKADDH/KSUBH/UKSUBH from 32-bit to 16-bit.
* Changed intrinsic data type of MAX/MIN from int32_t to intXLEN_t.
| v0.9.10 | 2021/10/27 | Chuanhua Chang
a|
* Removed RV32 PKBB16/PKTT16 encoding and Replaced them with PACK/PACKU encoding.
* Removed RV64 PKBB32/PKTT32 encoding and Replaced them with PACK/PACKU encoding.
* Enhanced PKBB*/PKTT* syntax description in relation to PACK/PACKU syntax.
(<<pkxx16>> and <<pkxx32>>)
| v0.9.9 | 2021/10/08 | Chuanhua Chang
a|
* Added implementation and access rules for vxsat CSR. (<<vxsat>>)
| v0.9.8 | 2021/09/27 | Chuanhua Chang
a|
* Removed ADD64 and SUB64 from RV64 Zpsfoperand
| v0.9.7 | 2021/09/15 | Chuanhua Chang
a|
* Added Zbpbo extension for RVB overlaps.
* Added notes for Zbpbo-replaced instructions.
| v0.9.6 | 2021/09/08 | Chuanhua Chang
a|
* Merged Zprvsfextra into Zpn
* Removed CLO* instructions based on github issue #60
* Changed intrinsic prefix from \\__rv__ to \__rv_
| v0.9.5 | 2021/06/17 | Chuanhua Chang
a|
* Synced RV32 paired register scheme with Zdinx.
| v0.9.4 | 2021/04/29 | Chuanhua Chang
a|
* Fixed few typos and enhanced precision descriptions on imtermediate results.
* Fixed/Changed data types for some intrinsic functions.
* Removed "RV32 Only" for Zpsfoperand.
| v0.9.3 | 2021/03/25 | Chuanhua Chang
a|
* Changed Zp64 name to Zpsfoperand.
* Added Zprvsfextra for RV64 only instructions.
* Removed SWAP16 encoding. It is an alias for PKBT16.
* Fixed few typos and enhanced precision descriptions on imtermediate results.
| v0.9.2 | 2021/02/02 | Chuanhua Chang
a|
* Changed major opcode "GE80B 1111111" to "OP-P 1110111".
* Added Zpn for instructins not belonging to Zpsfoperand.
* Fixed several typos and inconsistencies.
| v0.9.1 | 2021/01/26 | Chuanhua Chang
| Maintainance update; fixed several format issues and typos.
| v0.9 | 2020/09/04 | Chuanhua Chang
| Fixed several typos and encoding inconsistencies between encoding table and instruction format.
| v0.8 | 2020/08/07 | Chuanhua Chang
a|
* Changed ucode (0x801) CSR to vxsat CSR (0x009)
* Changed intrinsic prefix from \\__nds__ to \\__rv__
| v0.7 | 2020/07/14 | Chuanhua Chang
a|
* Added endian-related data layout descriptions for RV32 register pair of 64-bit operand.
* Removed khm32/khmx32 errors from the encoding table.
| v0.6 | 2020/06/01 | Chuanhua Chang
a|
* Fixed descriptions/pseudo code for all unsigned halving operations to reduce confusion.
* Added intXLEN_t and uintXLEN_t as data types for intrinsic functions.
| v0.5.4 | 2020/03/02 | Chuanhua Chang
| Added P subset extensions (<<pext_subset>>)
| v0.5.3 | 2019/11/8 | Chuanhua Chang
| Adjusted BPICK encoding along with the following 20 instructions:
STAS16, RSTAS16, KSTAS16, URSTAS16, UKSTAS16, STSA16, RSTSA16, KSTSA16,
URSTSA16, UKSTSA16, STAS32, RSTAS32, KSTAS32, URSTAS32, UKSTAS32, STSA32,
RSTSA32, KSTSA32, URSTSA32, UKSTSA32. (<<pext_encode>>)
| v0.5.2 | 2019/10/17 | Chuanhua Chang
| Fixed SRAIW.u operation typo. (<<sraiw_u>>)
| v0.5.1 | 2019/10/8 | Chuanhua Chang
| Fixed SLLI32 encoding. (<<slli32>>)
| v0.5.0 | 2019/4/26 | Chuanhua Chang
| Initial Release.
|===
<<<
== Introduction
Digital Signal Processing (DSP), has emerged as an important technology for modern
electronic systems. A wide range of modern applications employ DSP algorithms to
solve problems in their particular domains, including sensor fusion, servo motor
control, audio decode/encode, speech synthesis and coding, MPEG4 decode, medical
imaging, computer vision, embedded control, robotics, human interface, etc.
The proposed P instruction set extension increases the DSP algorithm processing
capabilities of the RISC-V CPU IP products. With the addition of the RISC-V P instruction
set extension, the RISC-V CPUs can now run these various DSP applications with lower
power and higher performance.
<<<
== Shorthand Definitions and Terminology
=== Shorthand Definitions
* r.H == rH1: r[31:16], r.L == r.H0: r[15:0]
* r.B3: r[31:24], r.B2: r[23:16], r.B1: r[15:8], r.B0: r[7:0]
* r.B[x]: r[(x*8+7):(x*8+0)]
* r.H[x]: r[(x*16+15):(x*16+0)]
* r.W[x]: r[(x*32+31):(x*32+0)]
* r.D[x]: r[(x*64+63):(x*64+0)]
* r[xU]: the upper 32-bit of a 64-bit number; xU represents the GPR number that contains this upper part 32-bit value.
* r[xL]: the lower 32-bit of a 64-bit number; xL represents the GPR number that contains this lower part 32-bit value.
* r[xU].r[xL]: a 64-bit number that is formed from a pair of GPRs.
* s>>: signed arithmetic right shift.
* u>>: unsigned logical right shift.
* u<<: logical left shift, shifting in 0 from the right side.
* SAT.Qn(): Saturate to the range of [-2^n^, 2^n^-1], if saturation happens, set OV flag.
* SAT.Um(): Saturate to the range of [0, 2^m^-1], if saturation happens, set OV flag.
* ROUND(): Indicate “rounding”, i.e., add 1 to the most significant discarded bit for right shift or MSW-type multiplication instructions.
* SUM(): Summation of all data elements.
* Sign or Zero Extending functions:
** SEm(data): Sign-Extend data to m-bit.
** SE_XLEN(data): Sign-Extend data to XLEN-bit.
** ZEm(data): Zero-Extend data to m-bit.
** ZE_XLEN(data): Zero-Extend data to XLEN-bit.
* ABS(x): Calculate the absolute value of “x”.
* CONCAT(x,y): Concatinate “x” and “y” to form a value.
* u<: Unsigned less than comparison.
* u{le}: Unsigned less than & equal comparison.
* u>: Unsigned greater than comparison.
* s<: Signed less than comparison.
* s{le}: Signed less than & equal comparison.
* s>: Signed greater than comparison.
* s*: Signed multiplication.
* u*: Unsigned multiplication.
* su*: Signed and Unsigned multiplication.
=== Terminology
* GPR: General purpose register.
* Q-format (Qm.n): It describes a signed binary fixed point number format. "m" is the number of bits, including the sign bit and integer bits, before a notional binary point, and "n" is the number of fraction bits that follow it. This notation represents a signed binary fixed point value in the range of -2^(m-1) (inclusive) and 2^(m-1) (exclusive), with 2^(m+n) unique values available in that range. For example, Q1.15 represents a number in the range of -1 (inclusive) and 1 (exclusive), with 65536 unique values available in that range.
* Qn: A shorthand format for Q1.n. For example, Q7, Q15, Q31, Q63.
* Um: It represents an unsigned binary number in the range of 0 and (2^m)-1.
<<<
== RISC-V P Extension Instruction Summary
=== SIMD Data Processing Instructions
==== 16-bit Addition & Subtraction Instructions
Based on the combination of the types of the two 16-bit arithmetic operations within a 32-bit word element, the SIMD 16-bit add/subtract instructions can be classified into 6 main categories: Addition (two 16-bit addition), Subtraction (two 16-bit subtraction), Crossed Add & Sub (one addition and one subtraction), and Crossed Sub & Add (one subtraction and one addition), Straight Add & Sub (one addition and one subtraction), and Straight Sub & Add (one subtraction and one addition).
Based on the way of how an overflow condition is handled, the SIMD 16-bit add/subtract instructions can be classified into 5 groups: Wrap-around (dropping overflow), Signed Halving (keeping overflow by dropping 1 LSB bit), Unsigned Halving, Signed Saturation (clipping overflow), and Unsigned Saturation.
Together, there are 30 SIMD 16-bit add/subtract instructions.
.SIMD 16-bit Add/Subtract Instructions
[cols="^.^1,<.^2,<.^2,<.^4",options="header",]
|===
^.^|No. ^.^|Mnemonic ^.^|Instruction ^.^|Operation
|1 |ADD16 rd, rs1, rs2 |16-bit Addition a|
....
rd.H[x] = rs1.H[x] + rs2.H[x];
(RV32: x=1..0, RV64: x=3..0)
....
|2 |RADD16 rd, rs1, rs2 |16-bit Signed Halving Addition a|
....
a17[x] = SE17(rs1.H[x]);
b17[x] = SE17(rs2.H[x]);
t17[x] = a17[x] + b17[x];
rd.H[x] = t17[x] s>> 1;
(RV32: x=1..0, RV64: x=3..0)
....
|3 |URADD16 rd, rs1, rs2 |16-bit Unsigned Halving Addition a|
....
a17[x] = ZE17(rs1.H[x]);
b17[x] = ZE17(rs2.H[x]);
t17[x] = a17[x] + b17[x];
rd.H[x] = t17[x] u>> 1;
(RV32: x=1..0, RV64: x=3..0)
....
|4 |KADD16 rd, rs1, rs2 |16-bit Signed Saturating Addition a|
....
a17[x] = SE17(rs1.H[x]);
b17[x] = SE17(rs2.H[x]);
t17[x] = a17[x] + b17[x];
rd.H[x] = SAT.Q15(t17[x]);
(RV32: x=1..0, RV64: x=3..0)
....
|5 |UKADD16 rd, rs1, rs2 |16-bit Unsigned Saturating Addition a|
....
a17[x] = ZE17(rs1.H[x]);
b17[x] = ZE17(rs2.H[x]);
t17[x] = a17[x] + b17[x];
rd.H[x] = SAT.U16(t17[x]);
(RV32: x=1..0, RV64: x=3..0)
....
|6 |SUB16 rd, rs1, rs2 |16-bit Subtraction a|
....
rd.H[x] = rs1.H[x] - rs2.H[x];
(RV32: x=1..0, RV64: x=3..0)
....
|7 |RSUB16 rd, rs1, rs2 |16-bit Signed Halving Subtraction a|
....
a17[x] = SE17(rs1.H[x]);
b17[x] = SE17(rs2.H[x]);
t17[x] = a17[x] - b17[x];
rd.H[x] = t17[x] s>> 1;
(RV32: x=1..0, RV64: x=3..0)
....
|8 |URSUB16 rd, rs1, rs2 |16-bit Unsigned Halving Subtraction a|
....
a17[x] = ZE17(rs1.H[x]);
b17[x] = ZE17(rs2.H[x]);
t17[x] = a17[x] - b17[x];
rd.H[x] = t17[x] u>> 1;
(RV32: x=1..0, RV64: x=3..0)
....
|9 |KSUB16 rd, rs1, rs2 |16-bit Signed Saturating Subtraction a|
....
a17[x] = SE17(rs1.H[x]);
b17[x] = SE17(rs2.H[x]);
t17[x] = a17[x] - b17[x];
rd.H[x] = SAT.Q15(t17[x]);
(RV32: x=1..0, RV64: x=3..0)
....
|10 |UKSUB16 rd, rs1, rs2 |16-bit Unsigned Saturating Subtraction a|
....
a17[x] = ZE17(rs1.H[x]);
b17[x] = ZE17(rs2.H[x]);
t17[x] = a17[x] - b17[x];
rd.H[x] = SAT.U16(t17[x]);
(RV32: x=1..0, RV64: x=3..0)
....
|11 |CRAS16 rd, rs1, rs2 |16-bit Cross Add & Sub a|
....
rd.H[x] = rs1.H[x] + rs2.H[x-1];
rd.H[x-1] = rs1.H[x-1] – rs2.H[x];
(RV32: x=1, RV64: x=1,3)
....
|12 |RCRAS16 rd, rs1, rs2 |16-bit Signed Halving Cross Add & Sub a|
....
ah17[x] = SE17(rs1.H[x]);
bh17[x] = SE17(rs2.H[x]);
al17[x] = SE17(rs1.H[x-1]);
bl17[x] = SE17(rs2.H[x-1]);
e17[x] = ah17[x] + bl17[x];
f17[x] = al17[x] – bh17[x];
rd.H[x] = e17[x] s>> 1;
rd.H[x-1] = f17[x] s>> 1;
(RV32: x=1, RV64: x=1,3)
....
|13 |URCRAS16 rd, rs1, rs2 |16-bit Unsigned Halving Cross Add & Sub a|
....
ah17[x] = ZE17(rs1.H[x]);
bh17[x] = ZE17(rs2.H[x]);
al17[x] = ZE17(rs1.H[x-1]);
bl17[x] = ZE17(rs2.H[x-1]);
th17[x] = ah17[x] + bl17[x];
tl17[x] = al17[x] – bh17[x];
rd.H[x] = th17[x] u>> 1;
rd.H[x-1] = tl17[x] u>> 1;
(RV32: x=1, RV64: x=1,3)
....
|14 |KCRAS16 rd, rs1, rs2 |16-bit Signed Saturating Cross Add & Sub a|
....
ah17[x] = SE17(rs1.H[x]);
bh17[x] = SE17(rs2.H[x]);
al17[x] = SE17(rs1.H[x-1]);
bl17[x] = SE17(rs2.H[x-1]);
th17[x] = ah17[x] + bl17[x];
tl17[x] = al17[x] – bh17[x];
rd.H[x] = SAT.Q15(th17[x]);
rd.H[x-1] = SAT.Q15(tl17[x]);
(RV32: x=1, RV64: x=1,3)
....
|15 |UKCRAS16 rd, rs1, rs2 |16-bit Unsigned Saturating Cross Add & Sub a|
....
ah17[x] = ZE17(rs1.H[x]);
bh17[x] = ZE17(rs2.H[x]);
al17[x] = ZE17(rs1.H[x-1]);
bl17[x] = ZE17(rs2.H[x-1]);
th17[x] = ah17[x] + bl17[x];
tl17[x] = al17[x] – bh17[x];
rd.H[x] = SAT.U16(th17[x]);
rd.H[x-1] = SAT.U16(tl17[x]);
(RV32: x=1, RV64: x=1,3)
....
|16 |CRSA16 rd, rs1, rs2 |16-bit Cross Sub & Add a|
....
rd.H[x] = rs1.H[x] - rs2.H[x-1];
rd.H[x-1] = rs1.H[x-1] + rs2.H[x];
(RV32: x=1, RV64: x=1,3)
....
|17 |RCRSA16 rd, rs1, rs2 |16-bit Signed Halving Cross Sub & Add a|
....
ah17[x] = SE17(rs1.H[x]);
bh17[x] = SE17(rs2.H[x]);
al17[x] = SE17(rs1.H[x-1]);
bl17[x] = SE17(rs2.H[x-1]);
th17[x] = ah17[x] - bl17[x];
tl17[x] = al17[x] + bh17[x];
rd.H[x] = th17[x] s>> 1;
rd.H[x-1] = tl17[x] s>> 1;
(RV32: x=1, RV64: x=1,3)
....
|18 |URCRSA16 rd, rs1, rs2 |16-bit Unsigned Halving Cross Sub & Add a|
....
ah17[x] = ZE17(rs1.H[x]);
bh17[x] = ZE17(rs2.H[x]);
al17[x] = ZE17(rs1.H[x-1]);
bl17[x] = ZE17(rs2.H[x-1]);
th17[x] = ah17[x] - bl17[x];
tl17[x] = al17[x] + bh17[x];
rd.H[x] = th17[x] u>> 1;
rd.H[x-1] = tl17[x] u>> 1;
(RV32: x=1, RV64: x=1,3)
....
|19 |KCRSA16 rd, rs1, rs2 |16-bit Signed Saturating Cross Sub & Add a|
....
ah17[x] = SE17(rs1.H[x]);
bh17[x] = SE17(rs2.H[x]);
al17[x] = SE17(rs1.H[x-1]);
bl17[x] = SE17(rs2.H[x-1]);
th17[x] = ah17[x] - bl17[x];
tl17[x] = al17[x] + bh17[x];
rd.H[x] = SAT.Q15(th17[x]);
rd.H[x-1] = SAT.Q15(tl17[x]);
(RV32: x=1, RV64: x=1,3)
....
|20 |UKCRSA16 rd, rs1, rs2 |16-bit Unsigned Saturating Cross Sub & Add a|
....
ah17[x] = ZE17(rs1.H[x]);
bh17[x] = ZE17(rs2.H[x]);
al17[x] = ZE17(rs1.H[x-1]);
bl17[x] = ZE17(rs2.H[x-1]);
th17[x] = ah17[x] - bl17[x];
tl17[x] = al17[x] + bh17[x];
rd.H[x] = SAT.U16(th17[x]);
rd.H[x-1] = SAT.U16(tl17[x]);
(RV32: x=1, RV64: x=1,3)
....
|21 |STAS16 rd, rs1, rs2 |16-bit Straight Add & Sub a|
....
rd.H[x] = rs1.H[x] + rs2.H[x];
rd.H[x-1] = rs1.H[x-1] – rs2.H[x-1];
(RV32: x=1, RV64: x=1,3)
....
|22 |RSTAS16 rd, rs1, rs2 |16-bit Signed Halving Straight Add & Sub a|
....
ah17[x] = SE17(rs1.H[x]);
bh17[x] = SE17(rs2.H[x]);
al17[x] = SE17(rs1.H[x-1]);
bl17[x] = SE17(rs2.H[x-1]);
th17[x] = ah17[x] + bh17[x];
tl17[x] = al17[x] - bl17[x];
rd.H[x] = th17[x] s>> 1;
rd.H[x-1] = tl17[x] s>> 1;
(RV32: x=1, RV64: x=1,3)
....
|23 |URSTAS16 rd, rs1, rs2 |16-bit Unsigned Halving Straight Add & Sub a|
....
ah17[x] = ZE17(rs1.H[x]);
bh17[x] = ZE17(rs2.H[x]);
al17[x] = ZE17(rs1.H[x-1]);
bl17[x] = ZE17(rs2.H[x-1]);
th17[x] = ah17[x] + bh17[x];
tl17[x] = al17[x] – bl17[x];
rd.H[x] = th17[x] u>> 1;
rd.H[x-1] = tl17[x] u>> 1;
(RV32: x=1, RV64: x=1,3)
....
|24 |KSTAS16 rd, rs1, rs2 |16-bit Signed Saturating Straight Add & Sub a|
....
ah17[x] = SE17(rs1.H[x]);
bh17[x] = SE17(rs2.H[x]);
al17[x] = SE17(rs1.H[x-1]);
bl17[x] = SE17(rs2.H[x-1]);
th17[x] = ah17[x] + bh17[x];
tl17[x] = al17[x] - bl17[x];
rd.H[x] = SAT.Q15(th17[x]);
rd.H[x-1] = SAT.Q15(tl17[x]);
(RV32: x=1, RV64: x=1,3)
....
|25 |UKSTAS16 rd, rs1, rs2 |16-bit Unsigned Saturating Straight Add & Sub a|
....
ah17[x] = ZE17(rs1.H[x]);
bh17[x] = ZE17(rs2.H[x]);
al17[x] = ZE17(rs1.H[x-1]);
bl17[x] = ZE17(rs2.H[x-1]);
th17[x] = ah17[x] + bh17[x];
tl17[x] = al17[x] – bl17[x];
rd.H[x] = SAT.U16(th17[x]);
rd.H[x-1] = SAT.U16(tl17[x]);
(RV32: x=1, RV64: x=1,3)
....
|26 |STSA16 rd, rs1, rs2 |16-bit Straight Sub & Add a|
....
rd.H[x] = rs1.H[x] - rs2.H[x]; +
rd.H[x-1] = rs1.H[x-1] + rs2.H[x-1];
(RV32: x=1, RV64: x=1,3)
....
|27 |RSTSA16 rd, rs1, rs2 |16-bit Signed Halving Straight Sub & Add a|
....
ah17[x] = SE17(rs1.H[x]);
bh17[x] = SE17(rs2.H[x]);
al17[x] = SE17(rs1.H[x-1]);
bl17[x] = SE17(rs2.H[x-1]);
th17[x] = ah17[x] - bh17[x];
tl17[x] = al17[x] + bl17[x];
rd.H[x] = th17[x] s>> 1;
rd.H[x-1] = tl17[x] s>> 1;
(RV32: x=1, RV64: x=1,3)
....
|28 |URSTSA16 rd, rs1, rs2 |16-bit Unsigned Halving Straight Sub & Add a|
....
ah17[x] = ZE17(rs1.H[x]);
bh17[x] = ZE17(rs2.H[x]);
al17[x] = ZE17(rs1.H[x-1]);
bl17[x] = ZE17(rs2.H[x-1]);
th17[x] = ah17[x] - bh17[x];
tl17[x] = al17[x] + bl17[x];
rd.H[x] = th17[x] u>> 1;
rd.H[x-1] = tl17[x] u>> 1;
(RV32: x=1, RV64: x=1,3)
....
|29 |KSTSA16 rd, rs1, rs2 |16-bit Signed Saturating Straight Sub & Add a|
....
ah17[x] = SE17(rs1.H[x]);
bh17[x] = SE17(rs2.H[x]);
al17[x] = SE17(rs1.H[x-1]);
bl17[x] = SE17(rs2.H[x-1]);
th17[x] = ah17[x] - bh17[x];
tl17[x] = al17[x] + bl17[x];
rd.H[x] = SAT.Q15(th17[x]);
rd.H[x-1] = SAT.Q15(tl17[x]);
(RV32: x=1, RV64: x=1,3)
....
|30 |UKSTSA16 rd, rs1, rs2 |16-bit Unsigned Saturating Straight Sub & Add a|
....
ah17[x] = ZE17(rs1.H[x]);
bh17[x] = ZE17(rs2.H[x]);
al17[x] = ZE17(rs1.H[x-1]);
bl17[x] = ZE17(rs2.H[x-1]);
th17[x] = ah17[x] - bh17[x];
tl17[x] = al17[x] + bl17[x];
rd.H[x] = SAT.U16(th17[x]);
rd.H[x-1] = SAT.U16(tl17[x]);
(RV32: x=1, RV64: x=1,3)
....
|===
<<<
==== 8-bit Addition & Subtraction Instructions
Based on the types of the four 8-bit arithmetic operations within a 32-bit word element, the SIMD 8-bit add/subtract instructions can be classified into 2 main categories: Addition (four 8-bit addition), and Subtraction (four 8-bit subtraction).
Based on the way of how an overflow condition is handled for singed or unsigned operation, the SIMD 8-bit add/subtract instructions can be classified into 5 groups: Wrap-around (dropping overflow), Signed Halving (keeping overflow by dropping 1 LSB bit), Unsigned Halving, Signed Saturation (clipping overflow), and Unsigned Saturation.
Together, there are 10 SIMD 8-bit add/subtract instructions.
.SIMD 8-bit Add/Subtract Instructions
[cols="^.^1,<.^2,<.^2,<.^4",options="header",]
|===
^.^|No. ^.^|Mnemonic ^.^|Instruction ^.^|Operation
|1 |ADD8 rd, rs1, rs2 |8-bit Addition a|
....
rd.B[x] = rs1.B[x] + rs2.B[x];
(RV32: x=3..0, RV64: x=7..0)
....
|2 |RADD8 rd, rs1, rs2 |8-bit Signed Halving Addition a|
....
a9[x] = SE9(rs1.B[x]);
b9[x] = SE9(rs2.B[x]);
t9[x] = a9[x] + b9[x];
rd.B[x] = t9[x] s>> 1;
(RV32: x=3..0, RV64: x=7..0)
....
|3 |URADD8 rd, rs1, rs2 |8-bit Unsigned Halving Addition a|
....
a9[x] = ZE9(rs1.B[x]);
b9[x] = ZE9(rs2.B[x]);
rd.B[x] = (a9[x] + b9[x]) u>> 1;
(RV32: x=3..0, RV64: x=7..0)
....
|4 |KADD8 rd, rs1, rs2 |8-bit Signed Saturating Addition a|
....
a9[x] = SE9(rs1.B[x]);
b9[x] = SE9(rs2.B[x]);
t9[x] = a9[x] + b9[x];
rd.B[x] = SAT.Q7(t9[x]);
(RV32: x=3..0, RV64: x=7..0)
....
|5 |UKADD8 rd, rs1, rs2 |8-bit Unsigned Saturating Addition a|
....
a9[x] = ZE9(rs1.B[x]);
b9[x] = ZE9(rs2.B[x]);
t9[x] = a9[x] + b9[x];
rd.H[x] = SAT.U8(t9[x]);
(RV32: x=1..0, RV64: x=3..0)
....
|6 |SUB8 rd, rs1, rs2 |8-bit Subtraction a|
....
rd.B[x] = rs1.B[x] - rs2.B[x];
(RV32: x=3..0, RV64: x=7..0)
....
|7 |RSUB8 rd, rs1, rs2 |8-bit Signed Halving Subtraction a|
....
a9[x] = SE9(rs1.B[x]);
b9[x] = SE9(rs2.B[x]);
t9[x] = a9[x] - b9[x];
rd.B[x] = t9[x] s>> 1;
(RV32: x=3..0, RV64: x=7..0)
....
|8 |URSUB8 rd, rs1, rs2 |8-bit Unsigned Halving Subtraction a|
....
a9[x] = ZE9(rs1.B[x]);
b9[x] = ZE9(rs2.B[x]);
rd.B[x] = (a9[x] - b9[x]) u>> 1;
(RV32: x=3..0, RV64: x=7..0)
....
|9 |KSUB8 rd, rs1, rs2 |8-bit Signed Saturating Subtraction a|
....
a9[x] = SE9(rs1.B[x]);
b9[x] = SE9(rs2.B[x]);
t9[x] = a9[x] - b9[x];
rd.B[x] = SAT.Q7(t9[x]);
(RV32: x=3..0, RV64: x=7..0)
....
|10 |UKSUB8 rd, rs1, rs2 |8-bit Unsigned Saturating Subtraction a|
....
a9[x] = ZE9(rs1.B[x]);
b9[x] = ZE9(rs2.B[x]);
t9[x] = a9[x] - b9[x];
rd.H[x] = SAT.U8(t9[x]);
(RV32: x=1..0, RV64: x=3..0)
....
|===
<<<
==== 16-bit Shift Instructions
There are 14 instructions here.
.SIMD 16-bit Shift Instructions
[cols="^.^1,<.^2,<.^2,<.^4",options="header",]
|===
^.^|No. ^.^|Mnemonic ^.^|Instruction ^.^|Operation
|1 |SRA16 rd, rs1, rs2 |16-bit Shift Right Arithmetic a|
....
rd.H[x] = rs1.H[x] s>> rs2[3:0];
(RV32: x=1..0, RV64: x=3..0)
....
|2 |SRAI16 rd, rs1, im4u |16-bit Shift Right Arithmetic Immediate a|
....
rd.H[x] = rs1.H[x] s>> im4u;
(RV32: x=1..0, RV64: x=3..0)
....
|3 |SRA16.u rd, rs1, rs2 |16-bit Rounding Shift Right Arithmetic a|
....
a[x] = rs1.H[x];
rd.H[x] = ROUND(a[x] s>> rs2[3:0]);
(RV32: x=1..0, RV64: x=3..0)
....
|4 |SRAI16.u rd, rs1, im4u |16-bit Rounding Shift Right Arithmetic Immediate a|
....
rd.H[x] = ROUND(rs1.H[x] s>> im4u);
(RV32: x=1..0, RV64: x=3..0)
....
|5 |SRL16 rd, rs1, rs2 |16-bit Shift Right Logical a|
....
rd.H[x] = rs1.H[x] u>> rs2[3:0];
(RV32: x=1..0, RV64: x=3..0)
....
|6 |SRLI16 rd, rs1, im4u |16-bit Shift Right Logical Immediate a|
....
rd.H[x] = rs1.H[x] u>> im4u;
(RV32: x=1..0, RV64: x=3..0)
....
|7 |SRL16.u rd, rs1, rs2 |16-bit Rounding Shift Right Logical a|
....
a[x] = rs1.H[x];
rd.H[x] = ROUND(a[x] u>> rs2[3:0]);
(RV32: x=1..0, RV64: x=3..0)
....
|8 |SRLI16.u rd, rs1, im4u |16-bit Rounding Shift Right Logical Immediate a|
....
rd.H[x] = ROUND(rs1.H[x] u>> im4u);
(RV32: x=1..0, RV64: x=3..0)
....
|9 |SLL16 rd, rs1, rs2 |16-bit Shift Left Logical a|
....
rd.H[x] = rs1.H[x] << rs2[3:0];
(RV32: x=1..0, RV64: x=3..0)
....
|10 |SLLI16 rd, rs1, im4u |16-bit Shift Left Logical Immediate a|
....
rd.H[x] = rs1.H[x] << im4u;
(RV32: x=1..0, RV64: x=3..0)
....
|11 |KSLL16 rd, rs1, rs2 |16-bit Saturating Shift Left Logical a|
....
a[x] = rs1.H[x];
rd.H[x] = SAT.Q15(a[x] << rs2[3:0]);
(RV32: x=1..0, RV64: x=3..0)
....
|12 |KSLLI16 rd, rs1, im4u |16-bit Saturating Shift Left Logical Immediate a|
....
rd.H[x] = SAT.Q15(rs1.H[x] << im4u);
(RV32: x=1..0, RV64: x=3..0)
....
|13 |KSLRA16 rd, rs1, rs2 |16-bit Shift Left Logical with Saturation & Shift Right Arithmetic a|
....
a[x] = rs1.H[x];
if (rs2[4:0] s< 0)
t[x] = a[x] s>> -rs2[4:0];
if (rs2[4:0] s> 0)
t[x] = SAT.Q15(a[x] << rs2[4:0]);
rd.H[x] = t[x];
(RV32: x=1..0, RV64: x=3..0)
....
|14 |KSLRA16.u rd, rs1, rs2 |16-bit Shift Left Logical with Saturation & Rounding Shift Right Arithmetic a|
....
a[x] = rs1.H[x];
if (rs2[4:0] s< 0)
t[x] = ROUND(a[x] s>> -rs2[4:0]);
if (rs2[4:0] s> 0)
t[x] = SAT.Q15(a[x] << rs2[4:0]);
rd.H[x] = t[x];
(RV32: x=1..0, RV64: x=3..0)
....
|===
<<<
==== 8-bit Shift Instructions
There are 14 instructions here.
.SIMD 8-bit Shift Instructions
[cols="^.^1,<.^2,<.^2,<.^4",options="header",]
|===
^.^|No. ^.^|Mnemonic ^.^|Instruction ^.^|Operation
|1 |SRA8 rd, rs1, rs2 |8-bit Shift Right Arithmetic a|
....
rd.B[x] = rs1.B[x] s>> rs2[2:0];
(RV32: x=3..0, RV64: x=7..0)
....
|2 |SRAI8 rd, rs1, im3u |8-bit Shift Right Arithmetic Immediate a|
....
rd.B[x] = rs1.B[x] s>> im3u;
(RV32: x=3..0, RV64: x=7..0)
....
|3 |SRA8.u rd, rs1, rs2 |8-bit Rounding Shift Right Arithmetic a|
....
a[x] = rs1.B[x];
rd.B[x] = ROUND(a[x] s>> rs2[2:0]);
(RV32: x=3..0, RV64: x=7..0)
....
|4 |SRAI8.u rd, rs1, im3u |8-bit Rounding Shift Right Arithmetic Immediate a|
....
rd.B[x] = ROUND(rs1.B[x] s>> im3u);
(RV32: x=3..0, RV64: x=7..0)
....
|5 |SRL8 rd, rs1, rs2 |8-bit Shift Right Logical a|
....
rd.B[x] = rs1.B[x] u>> rs2[2:0];
(RV32: x=3..0, RV64: x=7..0)
....
|6 |SRLI8 rd, rs1, im3u |8-bit Shift Right Logical Immediate a|
....
rd.B[x] = rs1.B[x] u>> im3u;
(RV32: x=3..0, RV64: x=7..0)
....
|7 |SRL8.u rd, rs1, rs2 |8-bit Rounding Shift Right Logical a|
....
a[x] = rs1.B[x];
rd.B[x] = ROUND(a[x] u>> rs2[2:0]);
(RV32: x=3..0, RV64: x=7..0)
....
|8 |SRLI8.u rd, rs1, im3u |8-bit Rounding Shift Right Logical Immediate a|
....
rd.B[x] = ROUND(rs1.B[x] u>> im3u);
(RV32: x=3..0, RV64: x=7..0)
....
|9 |SLL8 rd, rs1, rs2 |8-bit Shift Left Logical a|
....
rd.B[x] = rs1.B[x] << rs2[2:0];
(RV32: x=3..0, RV64: x=7..0)
....
|10 |SLLI8 rd, rs1, im3u |8-bit Shift Left Logical Immediate a|
....
rd.B[x] = rs1.B[x] << im3u;
(RV32: x=3..0, RV64: x=7..0)
....
|11 |KSLL8 rd, rs1, rs2 |8-bit Saturating Shift Left Logical a|
....
a[x] = rs1.B[x];
rd.B[x] = SAT.Q7(a[x] << rs2[2:0]);
(RV32: x=3..0, RV64: x=7..0)
....
|12 |KSLLI8 rd, rs1, im3u |8-bit Saturating Shift Left Logical Immediate a|
....
rd.B[x] = SAT.Q7(rs1.B[x] << im3u);
(RV32: x=3..0, RV64: x=7..0)
....
|13 |KSLRA8 rd, rs1, rs2 |8-bit Shift Left Logical with Saturation & Shift Right Arithmetic a|
....
a[x] = rs1.B[x];
if (rs2[3:0] s< 0)
t[x] = a[x] s>> -rs2[3:0];
if (rs2[3:0] s> 0)
t[x] = SAT.Q7(a[x] << rs2[3:0]);
rd.B[x] = t[x];
(RV32: x=3..0, RV64: x=7..0)
....
|14 |KSLRA8.u rd, rs1, rs2 |8-bit Shift Left Logical with Saturation & Rounding Shift Right Arithmetic a|
....
a[x] = rs1.B[x];
if (rs2[3:0] s< 0)
t[x] = ROUND(a[x] s>> -rs2[3:0]);
if (rs2[3:0] s> 0)
t[x] = SAT.Q7(a[x] << rs2[3:0]);
rd.B[x] = t[x];
(RV32: x=3..0, RV64: x=7..0)
....
|===
<<<
==== 16-bit Compare Instructions
There are 5 instructions here.
.SIMD 16-bit Compare Instructions
[cols="^.^1,<.^2,<.^2,<.^4m",options="header",]
|===
^.^|No. ^.^|Mnemonic ^.^|Instruction ^.^|Operation
|1 |CMPEQ16 rd, rs1, rs2 |16-bit Compare Equal a|
....
eq[x] = (rs1.H[x] == rs2.H[x]);
rd.H[x] = eq[x]? 0xffff : 0;
(RV32: x=1..0, RV64: x=3..0)
....
|2 |SCMPLT16 rd, rs1, rs2 |16-bit Signed Compare Less Than a|
....
lt[x] = (rs1.H[x] s< rs2.H[x]);
rd.H[x] = lt[x]? 0xffff : 0;
(RV32: x=1..0, RV64: x=3..0)
....
|3 |SCMPLE16 rd, rs1, rs2 |16-bit Signed Compare Less Than & Equal a|
....
le[x] = (rs1.H[x] s<= rs2.H[x]);
rd.H[x] = le[x]? 0xffff : 0;
(RV32: x=1..0, RV64: x=3..0)
....
|4 |UCMPLT16 rd, rs1, rs2 |16-bit Unsigned Compare Less Than a|
....
ult[x] = (rs1.H[x] u< rs2.H[x]);
rd.H[x] = ult[x]? 0xffff : 0;
(RV32: x=1..0, RV64: x=3..0)
....
|5 |UCMPLE16 rd, rs1, rs2 |16-bit Unsigned Compare Less Than & Equal a|
....
ule[x] = (rs1.H[x] u<= rs2.H[x]);
rd.H[x] = ule[x]? 0xffff : 0;
(RV32: x=1..0, RV64: x=3..0)
....
|===
<<<
==== 8-bit Compare Instructions
There are 5 instructions here.
.SIMD 8-bit Compare Instructions
[cols="^.^1,<.^2,<.^2,<.^4",options="header",]
|===
^.^|No. ^.^|Mnemonic ^.^|Instruction ^.^|Operation
|1 |CMPEQ8 rd, rs1, rs2 |8-bit Compare Equal a|
....
eq[x] = (rs1.B[x] == rs2.B[x]);
rd.B[x] = eq[x]? 0xff : 0;
(RV32: x=3..0, RV64: x=7..0)
....
|2 |SCMPLT8 rd, rs1, rs2 |8-bit Signed Compare Less Than a|
....
lt[x] = (rs1.B[x] s< rs2.B[x]);
rd.B[x] = lt[x]? 0xff : 0;
(RV32: x=3..0, RV64: x=7..0)
....
|3 |SCMPLE8 rd, rs1, rs2 |8-bit Signed Compare Less Than & Equal a|
....
le[x] = (rs1.B[x] s<= rs2.B[x]);
rd.B[x] = le[x]? 0xff : 0;
(RV32: x=3..0, RV64: x=7..0)
....
|4 |UCMPLT8 rd, rs1, rs2 |8-bit Unsigned Compare Less Than a|
....
ult[x] = (rs1.B[x] u< rs2.B[x]);
rd.B[x] = ult[x]? 0xff : 0;
(RV32: x=3..0, RV64: x=7..0)
....
|5 |UCMPLE8 rd, rs1, rs2 |8-bit Unsigned Compare Less Than & Equal a|
....
ule[x] = (rs1.B[x] u<= rs2.B[x]);
rd.B[x] = ule[x]? 0xff : 0;
(RV32: x=3..0, RV64: x=7..0)
....
|===
<<<
==== 16-bit Multiply Instructions
There are 6 instructions here.
.SIMD 16-bit Multiply Instructions
[cols="^.^1,<.^2,<.^2,<.^4",options="header",]
|===
^.^|No. ^.^|Mnemonic ^.^|Instruction ^.^|Operation
|1 |SMUL16 rd, rs1, rs2 |16-bit Signed Multiply a|
....
RV32:
r[dL] = rs1.H[0] s* rs2.H[0];
r[dU] = rs1.H[1] s* rs2.H[1];
RV64:
rd.W[0] = rs1.H[0] s* rs2.H[0];
rd.W[1] = rs1.H[1] s* rs2.H[1];
....
|2 |SMULX16 rd, rs1, rs2 |16-bit Signed Crossed Multiply a|
....
RV32:
r[dL] = rs1.H[0] s* rs2.H[1];
r[dU] = rs1.H[1] s* rs2.H[0];
RV64:
rd.W[0] = rs1.H[0] s* rs2.H[1];
rd.W[1] = rs1.H[1] s* rs2.H[0];
....
|3 |UMUL16 rd, rs1, rs2 |16-bit Unsigned Multiply a|
....
RV32:
r[dL] = rs1.H[0] u* rs2.H[0];
r[dU] = rs1.H[1] u* rs2.H[1];
RV64:
rd.W[0] = rs1.H[0] u* rs2.H[0];
rd.W[1] = rs1.H[1] u* rs2.H[1];
....
|4 |UMULX16 rd, rs1, rs2 |16-bit Unsigned Crossed Multiply a|
....
RV32:
r[dL] = rs1.H[0] u* rs2.H[1];
r[dU] = rs1.H[1] u* rs2.H[0];
RV64:
rd.W[0] = rs1.H[0] u* rs2.H[1];
rd.W[1] = rs1.H[1] u* rs2.H[0];
....
|5 |KHM16 rd, rs1, rs2 |Q15 Signed Saturating Multiply a|
....
t[x] = rs1.H[x] s* rs2.H[x];
rd.H[x] = SAT.Q15(t[x] s>> 15);
(RV32: x=1..0, RV64: x=3..0)
....
|6 |KHMX16 rd, rs1, rs2 |Q15 Signed Saturating Crossed Multiply a|
....
t[x] = rs1.H[x] s* rs2.H[y];
rd.H[x] = SAT.Q15(t[x] s>> 15);
(RV32: (x,y)=(1,0),(0,1),
RV64: (x,y)=(3,2),(2,3),
(1,0),(0,1))
....
|===
<<<
==== 8-bit Multiply Instructions
There are 6 instructions here.
.SIMD 8-bit Multiply Instructions
[cols="^.^1,<.^2,<.^2,<.^4",options="header",]
|===
^.^|No. ^.^|Mnemonic ^.^|Instruction ^.^|Operation
|1 |SMUL8 rd, rs1, rs2 |8-bit Signed Multiply a|
....
RV32:
r[dL].H[0] = rs1.B[0] s* rs2.B[0];
r[dL].H[1] = rs1.B[1] s* rs2.B[1];
r[dU].H[0] = rs1.B[2] s* rs2.B[2];
r[dU].H[1] = rs1.B[3] s* rs2.B[3];
RV64:
rd.H[0] = rs1.B[0] s* rs2.B[0];
rd.H[1] = rs1.B[1] s* rs2.B[1];
rd.H[2] = rs1.B[2] s* rs2.B[2];
rd.H[3] = rs1.B[3] s* rs2.B[3];