-
Notifications
You must be signed in to change notification settings - Fork 4
/
InstructionFormats.tex
174 lines (153 loc) · 6.01 KB
/
InstructionFormats.tex
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
\chapter{Instruction Formats}
The contents of this chapter are derived from \cite{tensilica2008whitepaper,gcc,binutils,qemu}.
\phantomsection
\section {Instruction Fields}
\begin{description}[leftmargin=8em,style=nextline]
\item[op0, op1, op2] 4-bit opcode fields
\item[r, s, t] – 4-bit operand fields
\end{description}
\section {Functions}
\subsection{sign\_extend(imm)}
Extend an immediate to a 32-bit value by copying its left-most bit to all bits to the left.
\subsection{B4const(imm)}
\begin{verbatim}
int B4const(uint imm) {
const int B4constValues[16] = {-1,1,2,3,4,5,6,7,8,10,12,16,32,64,128,256};
return B4constValues[imm];
}
\end{verbatim}
\subsection{B4constu(imm)}
\begin{verbatim}
uint B4constu(uint imm) {
const int B4constuValues[16] = {32768,65536,2,3,4,5,6,7,8,10,12,16,32,64,128,256};
return B4constuValues[imm];
}
\end{verbatim}
\section {Assembler expressions}
\begin{description}[leftmargin=4em,style=nextline]
\item[ar] – general purpose register correspondence to r operand field (AR[r])
\item[as] – general purpose register correspondence to s operand field (AR[s])
\item[at] – general purpose register correspondence to t operand field (AR[t])
\item[sr] – special purpose register name
\end{description}
\section{Format descriptions}
%RRR format
\begin{table}[H]
\caption{\textbf{RRR Instruction Format}}
\begin{tabular}{llllllllllllllllllllllll}
23 & & & 20 & 19 & & & 16 & 15 & & & 12 & 11 & & & 8 & 7 & & & 4 & 3 & & & 0 \\
\hline
\multicolumn{4}{|c|}{op2} & \multicolumn{4}{c|}{op1} & \multicolumn{4}{c|}{r} & \multicolumn{4}{c|}{s} & \multicolumn{4}{c|}{t} & \multicolumn{4}{c|}{$op0$}\\
\hline
\end{tabular}
\end{table}
%RRI4 format
\begin{table}[H]
\caption{\textbf{RRI4 Instruction Format}}
\begin{tabular}{llllllllllllllllllllllll}
23 & & & 20 & 19 & & & 16 & 15 & & & 12 & 11 & & & 8 & 7 & & & 4 & 3 & & & 0 \\
\hline
\multicolumn{4}{|c|}{imm[3..0]} & \multicolumn{4}{c|}{op1} & \multicolumn{4}{c|}{r} & \multicolumn{4}{c|}{s} & \multicolumn{4}{c|}{t} & \multicolumn{4}{c|}{op0}\\
\hline
\end{tabular}
\end{table}
%RRI8 format
\begin{table}[H]
\caption{\textbf{RRI8 Instruction Format}}
\begin{tabular}{llllllllllllllllllllllll}
23 & & & & & & & 16 & 15 & & & 12 & 11 & & & 8 & 7 & & & 4 & 3 & & & 0 \\
\hline
\multicolumn{8}{|c|}{imm[7..0]} & \multicolumn{4}{c|}{r} & \multicolumn{4}{c|}{s} & \multicolumn{4}{c|}{t} & \multicolumn{4}{c|}{op0}\\
\hline
\end{tabular}
\end{table}
%RI16 format
\begin{table}[H]
\caption{\textbf{RI16 Instruction Format}}
\begin{tabular}{llllllllllllllllllllllll}
23 & & & & & & & & & & & & & & & 8 & 7 & & & 4 & 3 & & & 0 \\
\hline
\multicolumn{16}{|c|}{imm[15..0]} & \multicolumn{4}{c|}{t} & \multicolumn{4}{c|}{op0}\\
\hline
\end{tabular}
\end{table}
%RSR format
\begin{table}[H]
\caption{\textbf{RSR Instruction Format}}
\begin{tabular}{llllllllllllllllllllllll}
23 & & & 20 & 19 & & & 16 & 15 & & & & & & & 8 & 7 & & & 4 & 3 & & & 0 \\
\hline
\multicolumn{4}{|c|}{imm[3..0]} & \multicolumn{4}{c|}{op1} &\multicolumn{8}{c|}{rs} & \multicolumn{4}{c|}{t} & \multicolumn{4}{c|}{op0}\\
\hline
\end{tabular}
\end{table}
%CALL format
\begin{table}[H]
\caption{\textbf{CALL Instruction Format}}
\begin{tabular}{llllllllllllllllllllllll}
23 & & & & & & & & & & & & & & & & & 6 & 5 & 4 & 3 & & & 0 \\
\hline
\multicolumn{18}{|c|}{offset} & \multicolumn{2}{c|}{n} & \multicolumn{4}{c|}{op0}\\
\hline
\end{tabular}
\end{table}
%CALLX format
\begin{table}[H]
\caption{\textbf{CALLX Instruction Format}}
\begin{tabular}{llllllllllllllllllllllll}
23 & & & 20 & 19 & & & 16 & 15 & & & 12 & 11 & & & 8 & 7 & 6 & 5 & 4 & 3 & & & 0 \\
\hline
\multicolumn{4}{|c|}{op2} & \multicolumn{4}{c|}{op1} & \multicolumn{4}{c|}{r} & \multicolumn{4}{c|}{s} & \multicolumn{2}{c|}{m} & \multicolumn{2}{c|}{n} & \multicolumn{4}{c|}{$op0$}\\
\hline
\end{tabular}
\end{table}
%BRI8 format
\begin{table}[H]
\caption{\textbf{BRI8 Instruction Format}}
\begin{tabular}{llllllllllllllllllllllll}
23 & & & & & & & 16 & 15 & & & 12 & 11 & & & 8 & 7 & 6 & 5 & 4 & 3 & & & 0 \\
\hline
\multicolumn{8}{|c|}{imm[7..0]} & \multicolumn{4}{c|}{r} & \multicolumn{4}{c|}{s} & \multicolumn{2}{c|}{m} & \multicolumn{2}{c|}{n} & \multicolumn{4}{c|}{$op0$}\\
\hline
\end{tabular}
\end{table}
%BRI12 format
\begin{table}[H]
\caption{\textbf{BRI12 Instruction Format}}
\begin{tabular}{llllllllllllllllllllllll}
23 & & & & & & & & & & & 12 & 11 & & & 8 & 7 & 6 & 5 & 4 & 3 & & & 0 \\
\hline
\multicolumn{12}{|c|}{imm[11..0]} & \multicolumn{4}{c|}{s} & \multicolumn{2}{c|}{m} & \multicolumn{2}{c|}{n} & \multicolumn{4}{c|}{$op0$}\\
\hline
\end{tabular}
\end{table}
%RRRN format
\begin{table}[H]
\caption{\textbf{RRRN Instruction Format}}
\begin{tabular}{llllllllllllllll}
15 & & & 12 & 11 & & & 8 & 7 & & & 4 & 3 & & & 0 \\
\hline
\multicolumn{4}{|c|}{r} & \multicolumn{4}{c|}{s} & \multicolumn{4}{c|}{t} & \multicolumn{4}{c|}{$op0$}\\
\hline
\end{tabular}
\end{table}
%RI7 format
\begin{table}[H]
\caption{\textbf{RI7 Instruction Format}}
\begin{tabular}{llllllllllllllll}
15 & & & 12 & 11 & & & 8 & 7 & 6 & & 4 & 3 & & & 0 \\
\hline
\multicolumn{4}{|c|}{imm[3..0]} & \multicolumn{4}{c|}{s} & i & \multicolumn{3}{|c|}{imm[6..4]} & \multicolumn{4}{c|}{$op0$}\\
\hline
\end{tabular}
\end{table}
%RI6 format
\begin{table}[H]
\caption{\textbf{RI6 Instruction Format}}
\begin{tabular}{llllllllllllllll}
15 & & & 12 & 11 & & & 8 & 7 & 6 & 5 & 4 & 3 & & & 0 \\
\hline
\multicolumn{4}{|c|}{imm[3..0]} & \multicolumn{4}{c|}{s} & i & \multicolumn{1}{c|}{z} & \multicolumn{2}{c|}{imm[5..4]} & \multicolumn{4}{c|}{$op0$}\\
\hline
\end{tabular}
\end{table}