Added immediate-field decoding diagrams for all instruction types.

This commit is contained in:
John Winans 2020-02-16 23:28:46 -06:00
parent 8746aad3f0
commit 55cb675205
2 changed files with 381 additions and 58 deletions

View File

@ -280,11 +280,12 @@
% \textbf{#1}\\ % \textbf{#1}\\
{\large #1} {\large #1}
} }
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% #1 the binary encoding \newcommand\DrawInsnTypeB[1]{
\newcommand\DrawInsnTypeBTikz[1]{
\BeginTikzPicture
\StrLen{#1}[\numchars] \StrLen{#1}[\numchars]
\begin{scope}[shift={(0,.75)}]
\DrawInsnBitstring{\numchars}{#1}{\hyperref[insnformat:btype]{B-type}} \DrawInsnBitstring{\numchars}{#1}{\hyperref[insnformat:btype]{B-type}}
\DrawInsnBoxSeg{\numchars}{31}{25}{imm[12\textbar10:5]} \DrawInsnBoxSeg{\numchars}{31}{25}{imm[12\textbar10:5]}
\DrawInsnBoxSeg{\numchars}{24}{20}{rs2} \DrawInsnBoxSeg{\numchars}{24}{20}{rs2}
@ -296,8 +297,16 @@
% add some hint bits in for imm fields % add some hint bits in for imm fields
\draw {[rounded corners=\SignBoxCornerRadius] (1.35, -.6) -- (1.35, .6) -- (.65, .6) -- (.65, -.6) -- cycle}; % sign bit \draw {[rounded corners=\SignBoxCornerRadius] (1.35, -.6) -- (1.35, .6) -- (.65, .6) -- (.65, -.6) -- cycle}; % sign bit
\draw (32-7-.5, -.75) -- (32-7-.5, .1); % imm[11] \draw (32-7-.5, -.75) -- (32-7-.5, .1); % imm[11]
\end{scope}
\DrawHexMarkers{\numchars} \DrawHexMarkersRel{\numchars}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% #1 the binary encoding
\newcommand\DrawInsnTypeBTikz[1]{
\BeginTikzPicture
\DrawInsnTypeB{#1}
\EndTikzPicture \EndTikzPicture
} }
@ -309,9 +318,9 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% #1 the binary encoding % #1 the binary encoding
\newcommand\DrawInsnTypeUTikz[1]{ \newcommand\DrawInsnTypeU[1]{
\BeginTikzPicture
\StrLen{#1}[\numchars] \StrLen{#1}[\numchars]
\begin{scope}[shift={(0,.75)}]
\DrawInsnBitstring{\numchars}{#1}{\hyperref[insnformat:utype]{U-type}} \DrawInsnBitstring{\numchars}{#1}{\hyperref[insnformat:utype]{U-type}}
\DrawInsnBoxSeg{\numchars}{31}{12}{imm[31:12]} \DrawInsnBoxSeg{\numchars}{31}{12}{imm[31:12]}
\DrawInsnBoxSeg{\numchars}{11}{7}{rd} \DrawInsnBoxSeg{\numchars}{11}{7}{rd}
@ -319,8 +328,15 @@
% add some hint bits in for imm fields % add some hint bits in for imm fields
\draw {[rounded corners=\SignBoxCornerRadius] (1.35, -.6) -- (1.35, .6) -- (.65, .6) -- (.65, -.6) -- cycle}; % sign bit \draw {[rounded corners=\SignBoxCornerRadius] (1.35, -.6) -- (1.35, .6) -- (.65, .6) -- (.65, -.6) -- cycle}; % sign bit
\end{scope}
\DrawHexMarkers{\numchars} \DrawHexMarkersRel{\numchars}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% #1 the binary encoding
\newcommand\DrawInsnTypeUTikz[1]{
\BeginTikzPicture
\DrawInsnTypeU{#1}
\EndTikzPicture \EndTikzPicture
} }
@ -343,7 +359,7 @@
\end{scope} \end{scope}
% add some hint bits in for imm fields % add some hint bits in for imm fields
\draw {[rounded corners=\SignBoxCornerRadius] (1.35, .15) -- (1.35, 1.35) -- (.65, 1.36) -- (.65, .15) -- cycle}; % sign bit \draw {[rounded corners=\SignBoxCornerRadius] (1.35, .15) -- (1.35, 1.35) -- (.65, 1.35) -- (.65, .15) -- cycle}; % sign bit
\draw (32-19-.5, 0) -- (32-19.5, .85); % imm[19:12] \draw (32-19-.5, 0) -- (32-19.5, .85); % imm[19:12]
\draw (32-20-.5, 0) -- (32-20.5, .85); % imm[11] \draw (32-20-.5, 0) -- (32-20.5, .85); % imm[11]
\DrawHexMarkersRel{\numchars} \DrawHexMarkersRel{\numchars}
@ -378,6 +394,7 @@
% #1 the binary encoding % #1 the binary encoding
\newcommand\DrawInsnTypeI[1]{ \newcommand\DrawInsnTypeI[1]{
\StrLen{#1}[\numchars] \StrLen{#1}[\numchars]
\begin{scope}[shift={(0,.75)}]
\DrawInsnBitstring{\numchars}{#1}{\hyperref[insnformat:itype]{I-type}} \DrawInsnBitstring{\numchars}{#1}{\hyperref[insnformat:itype]{I-type}}
\DrawInsnBoxSeg{\numchars}{31}{20}{imm[11:0]} \DrawInsnBoxSeg{\numchars}{31}{20}{imm[11:0]}
\DrawInsnBoxSeg{\numchars}{19}{15}{rs1} \DrawInsnBoxSeg{\numchars}{19}{15}{rs1}
@ -387,13 +404,15 @@
% add some hint bits in for imm fields % add some hint bits in for imm fields
\draw {[rounded corners=\SignBoxCornerRadius] (1.35, -.6) -- (1.35, .6) -- (.65, .6) -- (.65, -.6) -- cycle}; % sign bit \draw {[rounded corners=\SignBoxCornerRadius] (1.35, -.6) -- (1.35, .6) -- (.65, .6) -- (.65, -.6) -- cycle}; % sign bit
\end{scope}
\DrawHexMarkersRel{\numchars}
} }
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% #1 the binary encoding % #1 the binary encoding
\newcommand\DrawInsnTypeITikz[1]{ \newcommand\DrawInsnTypeITikz[1]{
\BeginTikzPicture \BeginTikzPicture
\DrawInsnTypeI{#1} \DrawInsnTypeI{#1}
\DrawHexMarkers{\numchars} % \DrawHexMarkers{\numchars}
\EndTikzPicture \EndTikzPicture
} }
\newcommand\DrawInsnTypeIPicture[2]{ \newcommand\DrawInsnTypeIPicture[2]{
@ -403,9 +422,9 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% #1 the binary encoding % #1 the binary encoding
\newcommand\DrawInsnTypeSTikz[1]{ \newcommand\DrawInsnTypeS[1]{
\BeginTikzPicture
\StrLen{#1}[\numchars] \StrLen{#1}[\numchars]
\begin{scope}[shift={(0,.75)}]
\DrawInsnBitstring{\numchars}{#1}{\hyperref[insnformat:stype]{S-type}} \DrawInsnBitstring{\numchars}{#1}{\hyperref[insnformat:stype]{S-type}}
\DrawInsnBoxSeg{\numchars}{31}{25}{imm[11:5]} \DrawInsnBoxSeg{\numchars}{31}{25}{imm[11:5]}
\DrawInsnBoxSeg{\numchars}{24}{20}{rs2} \DrawInsnBoxSeg{\numchars}{24}{20}{rs2}
@ -416,8 +435,15 @@
% add some hint bits in for imm fields % add some hint bits in for imm fields
\draw {[rounded corners=\SignBoxCornerRadius] (1.35, -.6) -- (1.35, .6) -- (.65, .6) -- (.65, -.6) -- cycle}; % sign bit \draw {[rounded corners=\SignBoxCornerRadius] (1.35, -.6) -- (1.35, .6) -- (.65, .6) -- (.65, -.6) -- cycle}; % sign bit
\end{scope}
\DrawHexMarkers{\numchars} \DrawHexMarkersRel{\numchars}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% #1 the binary encoding
\newcommand\DrawInsnTypeSTikz[1]{
\BeginTikzPicture
\DrawInsnTypeS{#1}
\EndTikzPicture \EndTikzPicture
} }
@ -1020,60 +1046,51 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% #1 MSB position % #1 MSB position
% #2 width % #2 LSB position
\newcommand\InsnBoxFieldWidthArrow[2]{ \newcommand\InsnBoxFieldWidthArrow[2]{
\pgfmathsetmacro\result{int(31-#1)} % Calculate the left end position \pgfmathsetmacro\leftpos{int(31-#1)} % Calculate the left end position
\begin{scope}[shift={(\result,-.5)}] % Move to left end of arrow & below origin \pgfmathsetmacro\wid{int(#1-#2+1)} % calculate the width
\pgfmathsetmacro\result{#2*.5+.5} % the center position \begin{scope}[shift={(\leftpos,-.5)}] % Move to left end of arrow & below origin
\node at (\result,0) {\tiny#2}; % size below the box \pgfmathsetmacro\result{\wid*.5+.5} % the center position
\node at (\result,0) {\tiny\wid}; % size below the box
\ifthenelse{#2 > 9} \ifthenelse{\wid > 9}
{ \pgfmathsetmacro\Inset{0.4} } { \pgfmathsetmacro\Inset{0.4} }
{ {
\ifthenelse{#2 > 1} \ifthenelse{\wid > 1}
{ \pgfmathsetmacro\Inset{0.25} } { \pgfmathsetmacro\Inset{0.25} }
{ \pgfmathsetmacro\Inset{0.15} } { \pgfmathsetmacro\Inset{0.15} }
} }
\draw[->] (\result+\Inset,0) -- (#2+.49,0); % arrow to the right \draw[->] (\result+\Inset,0) -- (\wid+.49,0); % arrow to the right
\draw[->] (\result-\Inset,0) -- (.51,0); % arrow to the left \draw[->] (\result-\Inset,0) -- (.51,0); % arrow to the left
\end{scope} \end{scope}
} }
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand\DrawInsnOpJTypeDecoding{ \newcommand\DrawInsnOpJTypeDecoding{
\BeginTikzPicture \BeginTikzPicture
% \begin{scope}[shift={(0,1.5)}]\DrawInsnBoxCastleJtype\end{scope}
% \begin{scope}[shift={(0,0)}]\DrawInsnOpJType{1101111}{\hyperref[insn:jal]{jal}}\end{scope}
\begin{scope}[shift={(0,-1.5)}] \begin{scope}[shift={(0,-1.5)}]
% \DrawInsnBoxRel{31}{12}{}
% \DrawInsnBoxRel{11}{7}{rd}
% \DrawInsnBoxRel{6}{0}{}
% \draw(33,.75) node[right]{jal};
% \begin{scope}[shift={(31-6,0)}]\DrawBitstringX{1101111}\end{scope}
% \begin{scope}[shift={(31-31,0)}]\DrawBitstringX{abcdefghijklmnopqrst}\end{scope} \DrawInsnTypeJ{abcdefghjkmnpqrstuvw001111101111}
\DrawInsnTypeJ{abcdefghijklmnopqrst001111101111}
\pgfmathsetmacro\ArrowNorth{\BitBoxArrowInset} \pgfmathsetmacro\ArrowNorth{\BitBoxArrowInset}
\pgfmathsetmacro\ArrowSouth{-16-\BitBoxArrowInset} \pgfmathsetmacro\ArrowSouth{-16-\BitBoxArrowInset}
\draw[blue,->](1,\ArrowNorth)to[out=270,in=90](1,\ArrowSouth); % 20 \draw[red,->](1,\ArrowNorth)to[out=270,in=90](1,\ArrowSouth); % 20
\draw[blue,->](1,\ArrowNorth)to[out=270,in=90](2,\ArrowSouth); % sign extend \draw[red,->](1,\ArrowNorth)to[out=270,in=90](2,\ArrowSouth); % sign extend
\draw[blue,->](1,\ArrowNorth)to[out=270,in=90](3,\ArrowSouth); % sign extend \draw[red,->](1,\ArrowNorth)to[out=270,in=90](3,\ArrowSouth); % sign extend
\draw[blue,->](1,\ArrowNorth)to[out=270,in=90](4,\ArrowSouth); % sign extend \draw[red,->](1,\ArrowNorth)to[out=270,in=90](4,\ArrowSouth); % sign extend
\draw[blue,->](1,\ArrowNorth)to[out=270,in=90](5,\ArrowSouth); % sign extend \draw[red,->](1,\ArrowNorth)to[out=270,in=90](5,\ArrowSouth); % sign extend
\draw[blue,->](1,\ArrowNorth)to[out=270,in=90](6,\ArrowSouth); % sign extend \draw[red,->](1,\ArrowNorth)to[out=270,in=90](6,\ArrowSouth); % sign extend
\draw[blue,->](1,\ArrowNorth)to[out=270,in=90](7,\ArrowSouth); % sign extend \draw[red,->](1,\ArrowNorth)to[out=270,in=90](7,\ArrowSouth); % sign extend
\draw[blue,->](1,\ArrowNorth)to[out=270,in=90](8,\ArrowSouth); % sign extend \draw[red,->](1,\ArrowNorth)to[out=270,in=90](8,\ArrowSouth); % sign extend
\draw[blue,->](1,\ArrowNorth)to[out=270,in=90](9,\ArrowSouth); % sign extend \draw[red,->](1,\ArrowNorth)to[out=270,in=90](9,\ArrowSouth); % sign extend
\draw[blue,->](1,\ArrowNorth)to[out=270,in=90](10,\ArrowSouth); % sign extend \draw[red,->](1,\ArrowNorth)to[out=270,in=90](10,\ArrowSouth); % sign extend
\draw[blue,->](1,\ArrowNorth)to[out=270,in=90](11,\ArrowSouth); % sign extend \draw[red,->](1,\ArrowNorth)to[out=270,in=90](11,\ArrowSouth); % sign extend
\draw[blue,->](1,\ArrowNorth)to[out=270,in=90](12,\ArrowSouth); % sign extend
\draw[blue,->](1,\ArrowNorth)to[out=270,in=90](12,\ArrowSouth); % 20
\draw[blue,->](13,\ArrowNorth)to[out=270,in=90](13,\ArrowSouth); % 19 \draw[blue,->](13,\ArrowNorth)to[out=270,in=90](13,\ArrowSouth); % 19
\draw[blue,->](14,\ArrowNorth)to[out=270,in=90](14,\ArrowSouth); % 18 \draw[blue,->](14,\ArrowNorth)to[out=270,in=90](14,\ArrowSouth); % 18
\draw[blue,->](15,\ArrowNorth)to[out=270,in=90](15,\ArrowSouth); % 17 \draw[blue,->](15,\ArrowNorth)to[out=270,in=90](15,\ArrowSouth); % 17
@ -1096,15 +1113,18 @@
\draw[blue,->](10,\ArrowNorth)to[out=270,in=90](30,\ArrowSouth); % 2 \draw[blue,->](10,\ArrowNorth)to[out=270,in=90](30,\ArrowSouth); % 2
\draw[blue,->](11,\ArrowNorth)to[out=270,in=90](31,\ArrowSouth); % 1 \draw[blue,->](11,\ArrowNorth)to[out=270,in=90](31,\ArrowSouth); % 1
\draw[blue,->](32,\ArrowSouth+1)to[out=270,in=90](32,\ArrowSouth); % 0 (special case) \draw[red,->](34,\ArrowSouth+5)to[out=180,in=90](32,\ArrowSouth); % 0 (special case)
\node at (32,\ArrowSouth+2) {0}; \node at (34.5,\ArrowSouth+5) {0};
% \draw[blue,->](32,\ArrowSouth+1)to[out=270,in=90](32,\ArrowSouth); % 0 (special case)
% \node at (32,\ArrowSouth+2) {0};
\begin{scope}[shift={(0,0)}]\DrawHexMarkersRel{32}\end{scope} \begin{scope}[shift={(0,0)}]\DrawHexMarkersRel{32}\end{scope}
\end{scope} \end{scope}
\begin{scope}[shift={(0,-19.75)}] \begin{scope}[shift={(0,-19.75)}]
\begin{scope}[shift={(0,1.5)}] \begin{scope}[shift={(0,1.5)}]
\DrawInsnBoxCastle{31}{20} \DrawInsnBoxCastle{31}{21}
\DrawInsnBoxCastle{20}{20}
\DrawInsnBoxCastle{19}{12} \DrawInsnBoxCastle{19}{12}
\DrawInsnBoxCastle{11}{11} \DrawInsnBoxCastle{11}{11}
\DrawInsnBoxCastle{10}{1} \DrawInsnBoxCastle{10}{1}
@ -1112,19 +1132,301 @@
\end{scope} \end{scope}
\DrawInsnBoxRel{31}{0}{} \DrawInsnBoxRel{31}{0}{}
\begin{scope}[shift={(0,0)}]\DrawBitstringX{aaaaaaaaaaaamnopqrstlbcdefghijk0}\end{scope} \begin{scope}[shift={(0,0)}]\DrawBitstringX{aaaaaaaaaaaapqrstuvwnbcdefghjkm0}\end{scope}
\begin{scope}[shift={(0,0)}]\DrawHexMarkersRel{32}\end{scope}
\InsnBoxFieldWidthArrow{31}{21}
\InsnBoxFieldWidthArrow{20}{20}
\InsnBoxFieldWidthArrow{19}{12}
\InsnBoxFieldWidthArrow{11}{11}
\InsnBoxFieldWidthArrow{10}{1}
\InsnBoxFieldWidthArrow{0}{0}
\end{scope}
\EndTikzPicture
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand\DrawInsnOpBTypeDecoding{
\BeginTikzPicture
\begin{scope}[shift={(0,-1.5)}]
\DrawInsnTypeB{abcdefg0111100011000hjkmn1100011}
\pgfmathsetmacro\ArrowNorth{\BitBoxArrowInset}
\pgfmathsetmacro\ArrowSouth{-16-\BitBoxArrowInset}
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](1,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](2,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](3,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](4,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](5,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](6,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](7,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](8,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](9,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](10,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](11,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](12,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](13,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](14,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](15,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](16,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](17,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](18,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](19,\ArrowSouth); % sign extend
\draw[blue,->](1,\ArrowNorth)to[out=270,in=90](20,\ArrowSouth); % 12
\draw[blue,->](25,\ArrowNorth)to[out=270,in=90](21,\ArrowSouth); % 11
\draw[blue,->](2,\ArrowNorth)to[out=270,in=90](22,\ArrowSouth); % 10
\draw[blue,->](3,\ArrowNorth)to[out=270,in=90](23,\ArrowSouth); % 9
\draw[blue,->](4,\ArrowNorth)to[out=270,in=90](24,\ArrowSouth); % 8
\draw[blue,->](5,\ArrowNorth)to[out=270,in=90](25,\ArrowSouth); % 7
\draw[blue,->](6,\ArrowNorth)to[out=270,in=90](26,\ArrowSouth); % 6
\draw[blue,->](7,\ArrowNorth)to[out=270,in=90](27,\ArrowSouth); % 5
\draw[blue,->](21,\ArrowNorth)to[out=270,in=90](28,\ArrowSouth); % 4
\draw[blue,->](22,\ArrowNorth)to[out=270,in=90](29,\ArrowSouth); % 3
\draw[blue,->](23,\ArrowNorth)to[out=270,in=90](30,\ArrowSouth); % 2
\draw[blue,->](24,\ArrowNorth)to[out=270,in=90](31,\ArrowSouth); % 1
\draw[red,->](34,\ArrowSouth+5)to[out=180,in=90](32,\ArrowSouth); % 0 (special case)
\node at (34.5,\ArrowSouth+5) {0};
% \draw[blue,->](32,\ArrowSouth+1)to[out=270,in=90](32,\ArrowSouth); % 0 (special case)
% \node at (32,\ArrowSouth+2) {0};
\begin{scope}[shift={(0,0)}]\DrawHexMarkersRel{32}\end{scope}
\end{scope}
\begin{scope}[shift={(0,-19.75)}]
\begin{scope}[shift={(0,1.5)}]
\DrawInsnBoxCastle{31}{13}
\DrawInsnBoxCastle{12}{12}
\DrawInsnBoxCastle{11}{11}
\DrawInsnBoxCastle{10}{5}
\DrawInsnBoxCastle{4}{1}
\DrawInsnBoxCastle{0}{0}
\end{scope}
\DrawInsnBoxRel{31}{0}{}
\begin{scope}[shift={(0,0)}]\DrawBitstringX{aaaaaaaaaaaaaaaaaaaanbcdefghjkm0}\end{scope}
\begin{scope}[shift={(0,0)}]\DrawHexMarkersRel{32}\end{scope}
\InsnBoxFieldWidthArrow{31}{13}
\InsnBoxFieldWidthArrow{12}{12}
\InsnBoxFieldWidthArrow{11}{11}
\InsnBoxFieldWidthArrow{10}{5}
\InsnBoxFieldWidthArrow{4}{1}
\InsnBoxFieldWidthArrow{0}{0}
\end{scope}
\EndTikzPicture
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand\DrawInsnOpSTypeDecoding{
\BeginTikzPicture
\begin{scope}[shift={(0,-1.5)}]
\DrawInsnTypeS{abcdefg0111100011000hjkmn0100011}
\pgfmathsetmacro\ArrowNorth{\BitBoxArrowInset}
\pgfmathsetmacro\ArrowSouth{-16-\BitBoxArrowInset}
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](1,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](2,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](3,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](4,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](5,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](6,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](7,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](8,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](9,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](10,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](11,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](12,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](13,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](14,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](15,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](16,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](17,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](18,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](19,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](20,\ArrowSouth); % sign extend
\draw[blue,->](1,\ArrowNorth)to[out=270,in=90](21,\ArrowSouth); % 11
\draw[blue,->](2,\ArrowNorth)to[out=270,in=90](22,\ArrowSouth); % 10
\draw[blue,->](3,\ArrowNorth)to[out=270,in=90](23,\ArrowSouth); % 9
\draw[blue,->](4,\ArrowNorth)to[out=270,in=90](24,\ArrowSouth); % 8
\draw[blue,->](5,\ArrowNorth)to[out=270,in=90](25,\ArrowSouth); % 7
\draw[blue,->](6,\ArrowNorth)to[out=270,in=90](26,\ArrowSouth); % 6
\draw[blue,->](7,\ArrowNorth)to[out=270,in=90](27,\ArrowSouth); % 5
\draw[blue,->](21,\ArrowNorth)to[out=270,in=90](28,\ArrowSouth); % 4
\draw[blue,->](22,\ArrowNorth)to[out=270,in=90](29,\ArrowSouth); % 3
\draw[blue,->](23,\ArrowNorth)to[out=270,in=90](30,\ArrowSouth); % 2
\draw[blue,->](24,\ArrowNorth)to[out=270,in=90](31,\ArrowSouth); % 1
\draw[blue,->](25,\ArrowNorth)to[out=270,in=90](32,\ArrowSouth); % 0
\begin{scope}[shift={(0,0)}]\DrawHexMarkersRel{32}\end{scope}
\end{scope}
\begin{scope}[shift={(0,-19.75)}]
\begin{scope}[shift={(0,1.5)}]
\DrawInsnBoxCastle{31}{12}
\DrawInsnBoxCastle{11}{5}
\DrawInsnBoxCastle{4}{0}
\end{scope}
\DrawInsnBoxRel{31}{0}{}
\begin{scope}[shift={(0,0)}]\DrawBitstringX{aaaaaaaaaaaaaaaaaaaaabcdefghjkmn}\end{scope}
\begin{scope}[shift={(0,0)}]\DrawHexMarkersRel{32}\end{scope} \begin{scope}[shift={(0,0)}]\DrawHexMarkersRel{32}\end{scope}
\InsnBoxFieldWidthArrow{31}{12} \InsnBoxFieldWidthArrow{31}{12}
% \InsnBoxFieldWidthArrow{20}{1} \InsnBoxFieldWidthArrow{11}{5}
\InsnBoxFieldWidthArrow{19}{8} \InsnBoxFieldWidthArrow{4}{0}
\InsnBoxFieldWidthArrow{11}{1}
\InsnBoxFieldWidthArrow{10}{10}
\InsnBoxFieldWidthArrow{0}{1}
\end{scope} \end{scope}
\EndTikzPicture
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand\DrawInsnOpITypeDecoding{
\BeginTikzPicture
\begin{scope}[shift={(0,-1.5)}]
\DrawInsnTypeI{abcdefghjkmn00011000001110000011}
\pgfmathsetmacro\ArrowNorth{\BitBoxArrowInset}
\pgfmathsetmacro\ArrowSouth{-16-\BitBoxArrowInset}
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](1,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](2,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](3,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](4,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](5,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](6,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](7,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](8,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](9,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](10,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](11,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](12,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](13,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](14,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](15,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](16,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](17,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](18,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](19,\ArrowSouth); % sign extend
\draw[red,->](1,\ArrowNorth)to[out=270,in=90](20,\ArrowSouth); % sign extend
\draw[blue,->](1,\ArrowNorth)to[out=270,in=90](21,\ArrowSouth); % 11
\draw[blue,->](2,\ArrowNorth)to[out=270,in=90](22,\ArrowSouth); % 10
\draw[blue,->](3,\ArrowNorth)to[out=270,in=90](23,\ArrowSouth); % 9
\draw[blue,->](4,\ArrowNorth)to[out=270,in=90](24,\ArrowSouth); % 8
\draw[blue,->](5,\ArrowNorth)to[out=270,in=90](25,\ArrowSouth); % 7
\draw[blue,->](6,\ArrowNorth)to[out=270,in=90](26,\ArrowSouth); % 6
\draw[blue,->](7,\ArrowNorth)to[out=270,in=90](27,\ArrowSouth); % 5
\draw[blue,->](8,\ArrowNorth)to[out=270,in=90](28,\ArrowSouth); % 4
\draw[blue,->](9,\ArrowNorth)to[out=270,in=90](29,\ArrowSouth); % 3
\draw[blue,->](10,\ArrowNorth)to[out=270,in=90](30,\ArrowSouth); % 2
\draw[blue,->](11,\ArrowNorth)to[out=270,in=90](31,\ArrowSouth); % 1
\draw[blue,->](12,\ArrowNorth)to[out=270,in=90](32,\ArrowSouth); % 0
\begin{scope}[shift={(0,0)}]\DrawHexMarkersRel{32}\end{scope}
\end{scope}
\begin{scope}[shift={(0,-19.75)}]
\begin{scope}[shift={(0,1.5)}]
\DrawInsnBoxCastle{31}{12}
\DrawInsnBoxCastle{11}{5}
\DrawInsnBoxCastle{4}{0}
\end{scope}
\DrawInsnBoxRel{31}{0}{}
\begin{scope}[shift={(0,0)}]\DrawBitstringX{aaaaaaaaaaaaaaaaaaaaabcdefghjkmn}\end{scope}
\begin{scope}[shift={(0,0)}]\DrawHexMarkersRel{32}\end{scope}
\InsnBoxFieldWidthArrow{31}{12}
\InsnBoxFieldWidthArrow{11}{5}
\InsnBoxFieldWidthArrow{4}{0}
\end{scope}
\EndTikzPicture
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand\DrawInsnOpUTypeDecoding{
\BeginTikzPicture
\begin{scope}[shift={(0,-1.5)}]
\DrawInsnTypeU{abcdefghjkmnpqrstuvw001010110111}
\pgfmathsetmacro\ArrowNorth{\BitBoxArrowInset}
\pgfmathsetmacro\ArrowSouth{-16-\BitBoxArrowInset}
\draw[blue,->](1,\ArrowNorth)to[out=270,in=90](1,\ArrowSouth); %
\draw[blue,->](2,\ArrowNorth)to[out=270,in=90](2,\ArrowSouth); %
\draw[blue,->](3,\ArrowNorth)to[out=270,in=90](3,\ArrowSouth); %
\draw[blue,->](4,\ArrowNorth)to[out=270,in=90](4,\ArrowSouth); %
\draw[blue,->](5,\ArrowNorth)to[out=270,in=90](5,\ArrowSouth); %
\draw[blue,->](6,\ArrowNorth)to[out=270,in=90](6,\ArrowSouth); %
\draw[blue,->](7,\ArrowNorth)to[out=270,in=90](7,\ArrowSouth); %
\draw[blue,->](8,\ArrowNorth)to[out=270,in=90](8,\ArrowSouth); %
\draw[blue,->](9,\ArrowNorth)to[out=270,in=90](9,\ArrowSouth); %
\draw[blue,->](10,\ArrowNorth)to[out=270,in=90](10,\ArrowSouth); %
\draw[blue,->](11,\ArrowNorth)to[out=270,in=90](11,\ArrowSouth); %
\draw[blue,->](12,\ArrowNorth)to[out=270,in=90](12,\ArrowSouth); %
\draw[blue,->](13,\ArrowNorth)to[out=270,in=90](13,\ArrowSouth); %
\draw[blue,->](14,\ArrowNorth)to[out=270,in=90](14,\ArrowSouth); %
\draw[blue,->](15,\ArrowNorth)to[out=270,in=90](15,\ArrowSouth); %
\draw[blue,->](16,\ArrowNorth)to[out=270,in=90](16,\ArrowSouth); %
\draw[blue,->](17,\ArrowNorth)to[out=270,in=90](17,\ArrowSouth); %
\draw[blue,->](18,\ArrowNorth)to[out=270,in=90](18,\ArrowSouth); %
\draw[blue,->](19,\ArrowNorth)to[out=270,in=90](19,\ArrowSouth); %
\draw[blue,->](20,\ArrowNorth)to[out=270,in=90](20,\ArrowSouth); %
\draw[red,->](34,\ArrowSouth+5)to[out=180,in=90](21,\ArrowSouth); %
\draw[red,->](34,\ArrowSouth+5)to[out=180,in=90](22,\ArrowSouth); %
\draw[red,->](34,\ArrowSouth+5)to[out=180,in=90](23,\ArrowSouth); %
\draw[red,->](34,\ArrowSouth+5)to[out=180,in=90](24,\ArrowSouth); %
\draw[red,->](34,\ArrowSouth+5)to[out=180,in=90](25,\ArrowSouth); %
\draw[red,->](34,\ArrowSouth+5)to[out=180,in=90](26,\ArrowSouth); %
\draw[red,->](34,\ArrowSouth+5)to[out=180,in=90](27,\ArrowSouth); %
\draw[red,->](34,\ArrowSouth+5)to[out=180,in=90](28,\ArrowSouth); %
\draw[red,->](34,\ArrowSouth+5)to[out=180,in=90](29,\ArrowSouth); %
\draw[red,->](34,\ArrowSouth+5)to[out=180,in=90](30,\ArrowSouth); %
\draw[red,->](34,\ArrowSouth+5)to[out=180,in=90](31,\ArrowSouth); %
\draw[red,->](34,\ArrowSouth+5)to[out=180,in=90](32,\ArrowSouth); % 0 (special case)
\node at (34.5,\ArrowSouth+5) {0};
\begin{scope}[shift={(0,0)}]\DrawHexMarkersRel{32}\end{scope}
\end{scope}
\begin{scope}[shift={(0,-19.75)}]
\begin{scope}[shift={(0,1.5)}]
\DrawInsnBoxCastle{31}{12}
\DrawInsnBoxCastle{11}{0}
\end{scope}
\DrawInsnBoxRel{31}{0}{}
\begin{scope}[shift={(0,0)}]\DrawBitstringX{abcdefghjkmnpqrstuvw000000000000}\end{scope}
\begin{scope}[shift={(0,0)}]\DrawHexMarkersRel{32}\end{scope}
\InsnBoxFieldWidthArrow{31}{12}
\InsnBoxFieldWidthArrow{11}{0}
\end{scope}
\EndTikzPicture \EndTikzPicture
} }

View File

@ -298,10 +298,15 @@ using the {\em imm} operand for bits 31:12 and then sign-extending it
to the left\footnote{When XLEN is larger than 32.} and zero-extending to the left\footnote{When XLEN is larger than 32.} and zero-extending
the LSBs as discussed in \autoref{extension:zr}. the LSBs as discussed in \autoref{extension:zr}.
If \Gls{xlen}=32 then the imm value in this example will be If \Gls{xlen}=32 then the {\em imm} value example will extracted from the instruction
converted as shown below. and converted as shown below.
\DrawBitBoxSignLeftZeroRightExtendedPicture{32}{11010110000000000011}{12} \DrawInsnOpUTypeDecoding
%If \Gls{xlen}=32 then the imm value in this example will be
%converted as shown below.
%
%\DrawBitBoxSignLeftZeroRightExtendedPicture{32}{11010110000000000011}{12}
Notice that the 20-bits of the imm field are mapped in the same order and Notice that the 20-bits of the imm field are mapped in the same order and
in the same relative position that they appear in the instruction when in the same relative position that they appear in the instruction when
@ -356,8 +361,8 @@ and the value in bit-position 20 will be replicated to sign-extend the
value to \Gls{xlen} bits as discussed in \autoref{extension:slzr}. value to \Gls{xlen} bits as discussed in \autoref{extension:slzr}.
If \Gls{xlen}=32 then the {\em imm} value in this example will be converted as If \Gls{xlen}=32 then the {\em imm} value example will extracted from the instruction
shown below. and converted as shown below.
\DrawInsnOpJTypeDecoding \DrawInsnOpJTypeDecoding
@ -395,16 +400,32 @@ representing the number of bit positions to shift:
\label{insnformat:itype} \label{insnformat:itype}
\DrawInsnTypeITikz{00000000010000011000001110000011} \DrawInsnTypeITikz{00000000010000011000001110000011}
If \Gls{xlen}=32 then the {\em imm} value example will extracted from the instruction
and converted as shown below.
\DrawInsnOpITypeDecoding
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{S Type} \subsection{S Type}
\label{insnformat:stype} \label{insnformat:stype}
\DrawInsnTypeSTikz{00000000111100011000100110100011} \DrawInsnTypeSTikz{00000000111100011000100110100011}
If \Gls{xlen}=32 then the {\em imm} value example will extracted from the instruction
and converted as shown below.
\DrawInsnOpSTypeDecoding
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{B Type} \subsection{B Type}
\label{insnformat:btype} \label{insnformat:btype}
\DrawInsnTypeBTikz{00000000111100011000100011100011} \DrawInsnTypeBTikz{00000000111100011000100011100011}
If \Gls{xlen}=32 then the {\em imm} value example will extracted from the instruction
and converted as shown below.
\DrawInsnOpBTypeDecoding
%insnTypeF %insnTypeF
%insnTypeCSRR %insnTypeCSRR