RISC-V "V" Vector Extension

RISC-V "V" Vector Extension

RISC-V "V" Vector Extension Version 0.8 Table of Contents 1. Introduction 2. Implementation-dened Constant Parameters 3. Vector Extension Programmer’s Model 3.1. Vector Registers 3.2. Vector Context Status in mstatus 3.3. Vector type register, vtype 3.4. Vector Length Register vl 3.5. Vector Byte Length vlenb 3.6. Vector Start Index CSR vstart 3.7. Vector Fixed-Point Rounding Mode Register vxrm 3.8. Vector Fixed-Point Saturation Flag vxsat 3.9. Vector Fixed-Point Fields in fcsr 3.10. State of Vector Extension at Reset 4. Mapping of Vector Elements to Vector Register State 4.1. Mapping with LMUL=1 4.2. Mapping with LMUL > 1 4.3. Mapping across Mixed-Width Operations 4.4. Mask Register Layout 5. Vector Instruction Formats 5.1. Scalar Operands 5.2. Vector Operands 5.3. Vector Masking 5.4. Prestart, Active, Inactive, Body, and Tail Element Denitions 6. Conguration-Setting Instructions 6.1. vsetvli/vsetvl instructions 6.2. Constraints on Setting vl 6.3. vsetvl Instruction 6.4. Examples 7. Vector Loads and Stores 7.1. Vector Load/Store Instruction Encoding 7.2. Vector Load/Store Addressing Modes 7.3. Vector Load/Store Width Encoding 7.4. Vector Unit-Stride Instructions 7.5. Vector Strided Instructions 7.6. Vector Indexed Instructions 7.7. Unit-stride Fault-Only-First Loads 7.8. Vector Load/Store Segment Instructions (Zvlsseg) 7.9. Vector Load/Store Whole Register Instructions 8. Vector AMO Operations (Zvamo) 9. Vector Memory Alignment Constraints 10. Vector Memory Consistency Model 11. Vector Arithmetic Instruction Formats 11.1. Vector Arithmetic Instruction encoding 11.2. Widening Vector Arithmetic Instructions 11.3. Narrowing Vector Arithmetic Instructions 12. Vector Integer Arithmetic Instructions 12.1. Vector Single-Width Integer Add and Subtract 12.2. Vector Widening Integer Add/Subtract 12.3. Vector Integer Add-with-Carry / Subtract-with-Borrow Instructions 12.4. Vector Bitwise Logical Instructions 12.5. Vector Single-Width Bit Shift Instructions 12.6. Vector Narrowing Integer Right Shift Instructions 12.7. Vector Integer Comparison Instructions 12.8. Vector Integer Min/Max Instructions 12.9. Vector Single-Width Integer Multiply Instructions 12.10. Vector Integer Divide Instructions 12.11. Vector Widening Integer Multiply Instructions 12.12. Vector Single-Width Integer Multiply-Add Instructions 12.13. Vector Widening Integer Multiply-Add Instructions 12.14. Vector Quad-Widening Integer Multiply-Add Instructions (Extension Zvqmac) 12.15. Vector Integer Merge Instructions 12.16. Vector Integer Move Instructions 13. Vector Fixed-Point Arithmetic Instructions 13.1. Vector Single-Width Saturating Add and Subtract 13.2. Vector Single-Width Averaging Add and Subtract 13.3. Vector Single-Width Fractional Multiply with Rounding and Saturation 13.4. Vector Single-Width Scaling Shift Instructions 13.5. Vector Narrowing Fixed-Point Clip Instructions 14. Vector Floating-Point Instructions 14.1. Vector Floating-Point Exception Flags 14.2. Vector Single-Width Floating-Point Add/Subtract Instructions 14.3. Vector Widening Floating-Point Add/Subtract Instructions 14.4. Vector Single-Width Floating-Point Multiply/Divide Instructions 14.5. Vector Widening Floating-Point Multiply 14.6. Vector Single-Width Floating-Point Fused Multiply-Add Instructions 14.7. Vector Widening Floating-Point Fused Multiply-Add Instructions 14.8. Vector Floating-Point Square-Root Instruction 14.9. Vector Floating-Point MIN/MAX Instructions 14.10. Vector Floating-Point Sign-Injection Instructions 14.11. Vector Floating-Point Compare Instructions 14.12. Vector Floating-Point Classify Instruction 14.13. Vector Floating-Point Merge Instruction 14.14. Vector Floating-Point Move Instruction 14.15. Single-Width Floating-Point/Integer Type-Convert Instructions 14.16. Widening Floating-Point/Integer Type-Convert Instructions 14.17. Narrowing Floating-Point/Integer Type-Convert Instructions 15. Vector Reduction Operations 15.1. Vector Single-Width Integer Reduction Instructions 15.2. Vector Widening Integer Reduction Instructions 15.3. Vector Single-Width Floating-Point Reduction Instructions 15.4. Vector Widening Floating-Point Reduction Instructions 16. Vector Mask Instructions 16.1. Vector Mask-Register Logical Instructions 16.2. Vector mask population count vpopc 16.3. vfirst nd-rst-set mask bit 16.4. vmsbf.m set-before-rst mask bit 16.5. vmsif.m set-including-rst mask bit 16.6. vmsof.m set-only-rst mask bit 16.7. Example using vector mask instructions 16.8. Vector Iota Instruction 16.9. Vector Element Index Instruction 17. Vector Permutation Instructions 17.1. Integer Scalar Move Instructions 17.2. Floating-Point Scalar Move Instructions 17.3. Vector Slide Instructions 17.4. Vector Register Gather Instruction 17.5. Vector Compress Instruction 17.6. Whole Vector Register Move 18. Exception Handling 18.1. Precise vector traps 18.2. Imprecise vector traps 18.3. Selectable precise/imprecise traps 18.4. Swappable traps 19. Divided Element Extension ('Zvediv') 19.1. Instructions not affected by EDIV 19.2. Instructions Affected by EDIV 19.3. Vector Integer Dot-Product Instruction 19.4. Vector Floating-Point Dot Product Instruction 20. Vector Instruction Listing Appendix A: Vector Assembly Code Examples A.1. Vector-vector add example A.2. Example with mixed-width mask and compute. A.3. Memcpy example A.4. Conditional example A.5. SAXPY example A.6. SGEMM example Appendix B: Calling Convention Contributors include: Alon Amid, Krste Asanovic, Allen Baum, Alex Bradbury, Tony Brewer, Chris Celio, Aliak- sei Chapyzhenka, Silviu Chiricescu, Ken Dockser, Bob Dreyer, Roger Espasa, Sean Halle, John Hauser, David Horner, Bruce Hoult, Bill Huffman, Constantine Korikov, Ben Korpan, Robin Kruppe, Yunsup Lee, Guy Lemieux, Filip Moc, Rich Newell, Albert Ou, David Patterson, Colin Schmidt, Alex Solomatnikov, Steve Wallach, Andrew Waterman, Jim Wilson. Known issues with current version: encoding needs better formatting vector memory consistency model needs to be claried interaction with privileged architectures 1. Introduction This document describes the draft of the RISC-V base vector extension. The document describes all the indi- vidual features of the base vector extension. This is a draft of a stable proposal for the vector specication to be used for implementation and evaluation. Once the draft label is removed, version 0.8 is intended to be stable enough to begin developing toolchains, functional simulators, and initial implementa- tions, though will continue to evolve with minor changes and updates. The term base vector extension is used informally to describe the standard set of vector ISA components. This draft spec is intended to capture how a certain vector function will be implemented as vector instruc- tions, but to not yet determine what set of vector instructions are mandatory for a given platform. Each actual platform prole will formally specify the mandatory components of any vector extension adopted by that platform. The base vector extension given the single letter name "V" will be that intended for use in standard server/application-processor plat- form proles. Other platforms, including embedded platforms, may choose to implement subsets of these extensions. The exact set of mandatory supported instructions for an implementation to be compliant with a given prole is subject to change until each pro- le spec is ratied. The base vector extension is designed to act as a base for additional vector extensions in various domains, in- cluding cryptography and machine learning. 2. Implementation-dened Constant Parameters Each hart supporting the vector extension denes three parameters: 1. The maximum size of a single vector element in bits, ELEN, which must be a power of 2. 2. The number of bits in a vector register, VLEN ≥ ELEN, which must be a power of 2. 3. The striping distance in bits, SLEN, which must be VLEN ≥ SLEN ≥ 32, and which must be a power of 2. Platform proles may set further constraints on these parameters, for example, requiring that ELEN ≥ max(XLEN,FLEN), or requiring a minimum VLEN value, or setting an SLEN value. There is a proposal to drop the constraint that VLEN must be a power of two. There is a proposal to allow ELEN to vary with LMUL. The ISA supports writing binary code that under certain constraints will execute portably on harts with differ- ent values for these parameters. Code can be written that will expose differences in implementation parameters. Thread contexts with active vector state cannot be migrated during execution between harts that have any difference in VLEN, ELEN, or SLEN parameters. 3. Vector Extension Programmer’s Model The vector extension adds 32 vector registers, and six unprivileged CSRs (vstart, vxsat, vxrm, vtype, vl, vlenb) to a base scalar RISC-V ISA. If the base scalar ISA does not include floating-point, then a fcsr regis- ter is also added to hold mirrors of the vxsat and vxrm CSRs as explained below. Table 1. New vector CSRs Address Privilege Name Description 0x008 URW vstart Vector start position 0x009 URW vxsat Fixed-Point Saturate Flag 0x00A URW vxrm Fixed-Point Rounding Mode 0xC20 URO vl Vector length 0xC21 URO vtype Vector data type register 0xC22 URO vlenb VLEN/8 (vector register length in bytes) 3.1. Vector Registers The vector extension adds 32 architectural vector registers, v0-v31 to the base scalar RISC-V ISA. Each vector register has a xed VLEN bits of state. Znx ("F in X") is a new ISA option under consideration where floating-point instructions take their arguments from the integer regis- ter le. The 0.8 vector extension is also compatible with this option. 3.2. Vector Context Status in mstatus A vector context status eld, VS, is added to mstatus[24:23] and shadowed in sstatus[24:23]. It is de- ned analogously to the floating-point context status eld, FS. Attempts to execute any vector instruction, or to access the vl, vtype, vlenb, or vstart CSRs, raise an ille- gal-instruction exception when the VS eld is set to Off.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    103 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us