aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Waterman <andrew@sifive.com>2022-09-16 18:09:28 -0700
committerAndrew Waterman <andrew@sifive.com>2022-09-16 18:09:28 -0700
commit6ea278a45d35d41d14ec0559d1b14f75da048a61 (patch)
treeba57a5def9049d4ed044a5caa65c98ff25eb17d8
parent18f77c5cb1bf921b890cb198e15c99ca5812cf73 (diff)
downloadriscv-isa-manual-6ea278a45d35d41d14ec0559d1b14f75da048a61.zip
riscv-isa-manual-6ea278a45d35d41d14ec0559d1b14f75da048a61.tar.gz
riscv-isa-manual-6ea278a45d35d41d14ec0559d1b14f75da048a61.tar.bz2
Reorder Zfa sections per Hauser's feedback
-rw-r--r--src/zfa.tex234
1 files changed, 119 insertions, 115 deletions
diff --git a/src/zfa.tex b/src/zfa.tex
index 4b6bc99..75d1313 100644
--- a/src/zfa.tex
+++ b/src/zfa.tex
@@ -3,14 +3,117 @@ Instructions, Version 0.1}
\label{chap:zfa}
This chapter describes the Zfa standard extension, which adds instructions for
-quiet floating-point comparisons, IEEE 754-2019 minimum and maximum
-operations, and round-to-integer operations.
+immediate loads,
+IEEE 754-2019 minimum and maximum operations,
+round-to-integer operations,
+and quiet floating-point comparisons.
For RV32D, the Zfa extension also adds instructions to transfer
double-precision floating-point values to and from integer registers, and for
RV64Q, it adds analogous instructions for quad-precision floating-point
values.
The Zfa extension depends on the F extension.
+
+\section{Load-Immediate Instructions}
+
+The FLI.S instruction loads a 5-bit immediate value that represents
+a single-precision floating-point number, encoded in the {\em rs1} field, into
+floating-point register {\em rd}.
+The correspondence of {\em rs1} field values and single-precision
+floating-point values is shown in Table~\ref{tab:flis}.
+FLI.S is encoded like FMV.W.X, but with {\em rs2}=1.
+
+\begin{table}[h!]
+\center
+\begin{tabular}{|r|r|c|c|c|}
+\hline
+{\em rs1} & Value & Sign & Exponent & Significand \\
+\hline
+ 0 & $-1.0$ & {\tt 1} & {\tt 01111111} & {\tt 000...000} \\
+ 1 & {\em Minimum positive normal} & {\tt 0} & {\tt 00000001} & {\tt 000...000} \\
+ 2 & $1.0 \times 2^{-16}$ & {\tt 0} & {\tt 01101111} & {\tt 000...000} \\
+ 3 & $1.0 \times 2^{-15}$ & {\tt 0} & {\tt 01110000} & {\tt 000...000} \\
+ 4 & $1.0 \times 2^{-8}$ & {\tt 0} & {\tt 01110111} & {\tt 000...000} \\
+ 5 & $1.0 \times 2^{-7}$ & {\tt 0} & {\tt 01111000} & {\tt 000...000} \\
+ 6 & 0.0625 ($2^{-4}$) & {\tt 0} & {\tt 01111011} & {\tt 000...000} \\
+ 7 & 0.125 ($2^{-3}$) & {\tt 0} & {\tt 01111100} & {\tt 000...000} \\
+ 8 & 0.25 & {\tt 0} & {\tt 01111101} & {\tt 000...000} \\
+ 9 & 0.3125 & {\tt 0} & {\tt 01111101} & {\tt 010...000} \\
+10 & 0.375 & {\tt 0} & {\tt 01111101} & {\tt 100...000} \\
+11 & 0.4375 & {\tt 0} & {\tt 01111101} & {\tt 110...000} \\
+12 & 0.5 & {\tt 0} & {\tt 01111110} & {\tt 000...000} \\
+13 & 0.625 & {\tt 0} & {\tt 01111110} & {\tt 010...000} \\
+14 & 0.75 & {\tt 0} & {\tt 01111110} & {\tt 100...000} \\
+15 & 0.875 & {\tt 0} & {\tt 01111110} & {\tt 110...000} \\
+16 & 1.0 & {\tt 0} & {\tt 01111111} & {\tt 000...000} \\
+17 & 1.25 & {\tt 0} & {\tt 01111111} & {\tt 010...000} \\
+18 & 1.5 & {\tt 0} & {\tt 01111111} & {\tt 100...000} \\
+19 & 1.75 & {\tt 0} & {\tt 01111111} & {\tt 110...000} \\
+20 & 2.0 & {\tt 0} & {\tt 10000000} & {\tt 000...000} \\
+21 & 2.5 & {\tt 0} & {\tt 10000000} & {\tt 010...000} \\
+22 & 3 & {\tt 0} & {\tt 10000000} & {\tt 100...000} \\
+23 & 4 & {\tt 0} & {\tt 10000001} & {\tt 000...000} \\
+24 & 8 & {\tt 0} & {\tt 10000010} & {\tt 000...000} \\
+25 & 16 & {\tt 0} & {\tt 10000011} & {\tt 000...000} \\
+26 & 128 ($2^7$) & {\tt 0} & {\tt 10000110} & {\tt 000...000} \\
+27 & 256 ($2^8$) & {\tt 0} & {\tt 10000111} & {\tt 000...000} \\
+28 & $2^{15}$ & {\tt 0} & {\tt 10001110} & {\tt 000...000} \\
+29 & $2^{16}$ & {\tt 0} & {\tt 10001111} & {\tt 000...000} \\
+30 & $+\infty$ & {\tt 0} & {\tt 11111111} & {\tt 000...000} \\
+31 & {\em Canonical NaN} & {\tt 0} & {\tt 11111111} & {\tt 100...000} \\
+\hline
+\end{tabular}
+\caption{Immediate values loaded by the FLI.S instruction.}
+\label{tab:flis}
+\end{table}
+
+\begin{commentary}
+The preferred assembly syntax for entries 1, 30, and 31 is {\tt min},
+{\tt inf}, and {\tt nan}, respectively.
+For entries 0 through 29 (including entry 1), the assembler will accept
+decimal constants in C-like syntax.
+\end{commentary}
+
+\begin{commentary}
+The set of 32 constants was chosen by examining floating-point libraries,
+including the C standard math library, and to optimize fixed-point to
+floating-point conversion.
+
+Entries 8--22 follow a regular encoding pattern.
+No entry sets mantissa bits other than the two most significant ones.
+\end{commentary}
+
+If the D extension is implemented, FLI.D performs the analogous operation,
+but loads a double-precision value into floating-point register {\em rd}.
+Note that entry 1 (corresponding to the minimum positive normal value) has a
+numerically different value for double-precision than for single-precision.
+FLI.D is encoded like FLI.S, but with {\em fmt}=D.
+
+If the Q extension is implemented, FLI.Q performs the analogous operation,
+but loads a quad-precision value into floating-point register {\em rd}.
+Note that entry 1 (corresponding to the minimum positive normal value) has a
+numerically different value for quad-precision.
+FLI.Q is encoded like FLI.S, but with {\em fmt}=Q.
+
+If the Zfh or Zvfh extension is implemented, FLI.H performs the analogous
+operation, but loads a half-precision floating-point value into register
+{\em rd}.
+Note that entry 1 (corresponding to the minimum positive normal value) has a
+numerically different value for half-precision.
+Furthermore,
+since $2^{16}$ is not representable in half-precision floating-point, entry 29
+in the table instead loads positive infinity---i.e., it is redundant
+with entry 30.
+FLI.H is encoded like FLI.S, but with {\em fmt}=H.
+
+\begin{commentary}
+Additionally, since $2^{-16}$ is a subnormal in half-precision, entry 1 is numerically
+greater than entry 2 for FLI.H.
+\end{commentary}
+
+The FLI.{\em fmt} instructions never set any floating-point exception flags.
+
+
\section{Minimum and Maximum Instructions}
The FMINI.S and FMAXI.S instructions are defined like the FMIN.S and FMAX.S
@@ -97,29 +200,6 @@ processing of JavaScript {\tt Number}s.
truncate them to signed integers mod $2^{32}$.
\end{commentary}
-\section{Comparison Instructions}
-
-The FLEQ.S and FLTQ.S instructions are defined like the FLE.S and FLT.S
-instructions, except that quiet NaN inputs do not cause the invalid
-operation exception flag to be set.
-
-If the D extension is implemented, FLEQ.D and FLTQ.D instructions are
-analogously defined to operate on double-precision numbers.
-
-If the Zfh extension is implemented, FLEQ.H and FLTQ.H instructions are
-analogously defined to operate on half-precision numbers.
-
-If the Q extension is implemented, FLEQ.Q and FLTQ.Q instructions are
-analogously defined to operate on quad-precision numbers.
-
-These instructions are encoded like their FLE and FLT counterparts, but
-with instruction bit 14 set to 1.
-
-\begin{commentary}
-We do not expect analogous comparison instructions will be added to the vector
-ISA, since they can be reasonably efficiently emulated using masking.
-\end{commentary}
-
\section{Move Instructions}
@@ -162,101 +242,25 @@ FMVP.Q.X is encoded in the OP-FP major opcode with {\em funct3}=0
and {\em funct7}=1011011.
-\section{Load-Immediate Instructions}
-
-The FLI.S instruction loads a 5-bit immediate value that represents
-a single-precision floating-point number, encoded in the {\em rs1} field, into
-floating-point register {\em rd}.
-The correspondence of {\em rs1} field values and single-precision
-floating-point values is shown in Table~\ref{tab:flis}.
-FLI.S is encoded like FMV.W.X, but with {\em rs2}=1.
-
-\begin{table}[h]
-\center
-\begin{tabular}{|r|r|c|c|c|}
-\hline
-{\em rs1} & Value & Sign & Exponent & Significand \\
-\hline
- 0 & $-1.0$ & {\tt 1} & {\tt 01111111} & {\tt 000...000} \\
- 1 & {\em Minimum positive normal} & {\tt 0} & {\tt 00000001} & {\tt 000...000} \\
- 2 & $1.0 \times 2^{-16}$ & {\tt 0} & {\tt 01101111} & {\tt 000...000} \\
- 3 & $1.0 \times 2^{-15}$ & {\tt 0} & {\tt 01110000} & {\tt 000...000} \\
- 4 & $1.0 \times 2^{-8}$ & {\tt 0} & {\tt 01110111} & {\tt 000...000} \\
- 5 & $1.0 \times 2^{-7}$ & {\tt 0} & {\tt 01111000} & {\tt 000...000} \\
- 6 & 0.0625 ($2^{-4}$) & {\tt 0} & {\tt 01111011} & {\tt 000...000} \\
- 7 & 0.125 ($2^{-3}$) & {\tt 0} & {\tt 01111100} & {\tt 000...000} \\
- 8 & 0.25 & {\tt 0} & {\tt 01111101} & {\tt 000...000} \\
- 9 & 0.3125 & {\tt 0} & {\tt 01111101} & {\tt 010...000} \\
-10 & 0.375 & {\tt 0} & {\tt 01111101} & {\tt 100...000} \\
-11 & 0.4375 & {\tt 0} & {\tt 01111101} & {\tt 110...000} \\
-12 & 0.5 & {\tt 0} & {\tt 01111110} & {\tt 000...000} \\
-13 & 0.625 & {\tt 0} & {\tt 01111110} & {\tt 010...000} \\
-14 & 0.75 & {\tt 0} & {\tt 01111110} & {\tt 100...000} \\
-15 & 0.875 & {\tt 0} & {\tt 01111110} & {\tt 110...000} \\
-16 & 1.0 & {\tt 0} & {\tt 01111111} & {\tt 000...000} \\
-17 & 1.25 & {\tt 0} & {\tt 01111111} & {\tt 010...000} \\
-18 & 1.5 & {\tt 0} & {\tt 01111111} & {\tt 100...000} \\
-19 & 1.75 & {\tt 0} & {\tt 01111111} & {\tt 110...000} \\
-20 & 2.0 & {\tt 0} & {\tt 10000000} & {\tt 000...000} \\
-21 & 2.5 & {\tt 0} & {\tt 10000000} & {\tt 010...000} \\
-22 & 3 & {\tt 0} & {\tt 10000000} & {\tt 100...000} \\
-23 & 4 & {\tt 0} & {\tt 10000001} & {\tt 000...000} \\
-24 & 8 & {\tt 0} & {\tt 10000010} & {\tt 000...000} \\
-25 & 16 & {\tt 0} & {\tt 10000011} & {\tt 000...000} \\
-26 & 128 ($2^7$) & {\tt 0} & {\tt 10000110} & {\tt 000...000} \\
-27 & 256 ($2^8$) & {\tt 0} & {\tt 10000111} & {\tt 000...000} \\
-28 & $2^{15}$ & {\tt 0} & {\tt 10001110} & {\tt 000...000} \\
-29 & $2^{16}$ & {\tt 0} & {\tt 10001111} & {\tt 000...000} \\
-30 & $+\infty$ & {\tt 0} & {\tt 11111111} & {\tt 000...000} \\
-31 & {\em Canonical NaN} & {\tt 0} & {\tt 11111111} & {\tt 100...000} \\
-\hline
-\end{tabular}
-\caption{Immediate values loaded by the FLI.S instruction.}
-\label{tab:flis}
-\end{table}
-
-\begin{commentary}
-The preferred assembly syntax for entries 1, 30, and 31 is {\tt min},
-{\tt inf}, and {\tt nan}, respectively.
-For entries 0 through 29 (including entry 1), the assembler will accept
-decimal constants in C-like syntax.
-\end{commentary}
+\section{Comparison Instructions}
-\begin{commentary}
-The set of 32 constants was chosen by examining floating-point libraries,
-including the C standard math library, and to optimize fixed-point to
-floating-point conversion.
+The FLEQ.S and FLTQ.S instructions are defined like the FLE.S and FLT.S
+instructions, except that quiet NaN inputs do not cause the invalid
+operation exception flag to be set.
-Entries 8--22 follow a regular encoding pattern.
-No entry sets mantissa bits other than the two most significant ones.
-\end{commentary}
+If the D extension is implemented, FLEQ.D and FLTQ.D instructions are
+analogously defined to operate on double-precision numbers.
-If the D extension is implemented, FLI.D performs the analogous operation,
-but loads a double-precision value into floating-point register {\em rd}.
-Note that entry 1 (corresponding to the minimum positive normal value) has a
-numerically different value for double-precision than for single-precision.
-FLI.D is encoded like FLI.S, but with {\em fmt}=D.
+If the Zfh extension is implemented, FLEQ.H and FLTQ.H instructions are
+analogously defined to operate on half-precision numbers.
-If the Q extension is implemented, FLI.Q performs the analogous operation,
-but loads a quad-precision value into floating-point register {\em rd}.
-Note that entry 1 (corresponding to the minimum positive normal value) has a
-numerically different value for quad-precision.
-FLI.Q is encoded like FLI.S, but with {\em fmt}=Q.
+If the Q extension is implemented, FLEQ.Q and FLTQ.Q instructions are
+analogously defined to operate on quad-precision numbers.
-If the Zfh or Zvfh extension is implemented, FLI.H performs the analogous
-operation, but loads a half-precision floating-point value into register
-{\em rd}.
-Note that entry 1 (corresponding to the minimum positive normal value) has a
-numerically different value for half-precision.
-Furthermore,
-since $2^{16}$ is not representable in half-precision floating-point, entry 29
-in the table instead loads positive infinity---i.e., it is redundant
-with entry 30.
-FLI.H is encoded like FLI.S, but with {\em fmt}=H.
+These instructions are encoded like their FLE and FLT counterparts, but
+with instruction bit 14 set to 1.
\begin{commentary}
-Additionally, since $2^{-16}$ is a subnormal in half-precision, entry 1 is numerically
-greater than entry 2 for FLI.H.
+We do not expect analogous comparison instructions will be added to the vector
+ISA, since they can be reasonably efficiently emulated using masking.
\end{commentary}
-
-The FLI.{\em fmt} instructions never set any floating-point exception flags.