OpenCores
URL https://opencores.org/ocsvn/marca/marca/trunk

Subversion Repositories marca

[/] [marca/] [trunk/] [doc/] [isa.tex] - Blame information for rev 8

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 jeunes2
\documentclass[10pt, twoside, a4paper]{article}
2
\usepackage{longtable}
3
 
4
\newcommand{\shl}{\ensuremath{<\!\!<}}
5
\newcommand{\shr}{\ensuremath{>\!\!>\!\!>}}
6
\newcommand{\sar}{\ensuremath{>\!\!>}}
7
\newcommand{\at}{\ensuremath{\!\!:\!\!}}
8
 
9
\title{marca - McAdam's RISC Computer Architecture\\Instruction Set Architecture}
10
\author{Kenan Bilic, Roland Kammerer, Wolfgang Puffitsch}
11
 
12
\begin{document}
13
 
14
  \maketitle
15
 
16
  \section{General}
17
 
18
  \begin{itemize}
19
  \item 16 16-bit registers, r0 \ldots r15
20
  \item any register as return address
21
  \item flags: Z, C, V, N
22
    \begin{itemize}
23
    \item Z: all bits of the last result are zero
24
    \item C: ``17$^{th}$ bit'' of the last result
25
    \item N: 16$^{th}$ bit of the last result
26
    \item V: overflow, after sub/cmp it is $r1 \at 15 \oplus r2 \at 15
27
      \oplus N \oplus C$, the latter two according to the result,
28
      other operations accordingly
29
    \item I: allow interrupts
30
    \item P: parity of the last result
31
    \end{itemize}
32
    Flags are written where meaningful: P and Z are computed whenever
33
    a register is written, arithmetic operations may change C, N and
34
    V, interrupts clear I upon entry.
35
  \item flags are stored and restored upon interrupt entry and exit
36
    to/from ``shflags'' (shadow flags)
37
  \item separate registers for interrupt vectors - read and written
38
    through ``ldvec'' / ``stvec''
39
  \item Some parts come from the Alpha architecture. The handling of
40
    branches is inspired by the Intel x86.
41
  \item External hardware modules shall be mapped to the highest
42
    memory locations.
43
  \end{itemize}
44
 
45
  The processor uses a Harvard architecture; although it has not
46
  prevailed in mainstream-architectures, it is still used in embedded
47
  processors such as the Atmel AVR. The separation of code- and
48
  data-memory is not flexible enough for mainstream systems, but with
49
  small embedded processors the program code tends to be fixed
50
  anyway. A Harvard architecture enables the processor to make use of
51
  more memory (which is an issue when the address space is limited to
52
  64k), and the program code can be read from a ROM directly. A
53
  transient failure thus cannot destroy the program by overwriting its
54
  code section.
55
 
56
  \clearpage
57
 
58
  \section{Instruction Set}
59
 
60
  {\small
61
  \begin{longtable}{llp{.62\textwidth}}
62
    Instruction       & Opcode                & Semantics \\
63
    add r1, r2, r3    & \texttt{0000}         & $r1 + r2 \rightarrow r3$ \\
64
    sub r1, r2, r3    & \texttt{0001}         & $r1 - r2 \rightarrow r3$ \\
65
    addc r1, r2, r3   & \texttt{0010}         & $r1 + r2 + C \rightarrow r3$ \\
66
    subc r1, r2, r3   & \texttt{0011}         & $r1 - r2 - C \rightarrow r3$ \\
67
    and r1, r2, r3    & \texttt{0100}         & $r1 \wedge r2 \rightarrow r3$ \\
68
    or r1, r2, r3     & \texttt{0101}         & $r1 \vee r2 \rightarrow r3$ \\
69
    xor r1, r2, r3    & \texttt{0110}         & $r1 \oplus r2 \rightarrow r3$ \\
70
    mul r1, r2, r3    & \texttt{0111}         & $r1 * r2 \rightarrow r3$ \\
71
    div r1, r2, r3    & \texttt{1000}         & $r1 \div r2 \rightarrow r3$ \\
72
    udiv r1, r2, r3   & \texttt{1001}         & $r1 \div r2 \rightarrow r3, \textnormal{unsigned} $ \\
73
    ldil r1, n8       & \texttt{1010}         & $(r1 \wedge \texttt{0xff00}) \vee n8 \rightarrow r1, -128 \leq n8 \leq 255 $ \\
74
    ldih r1, n8       & \texttt{1011}         & $(r1 \wedge \texttt{0x00ff}) \vee (n8 \shl 8) \rightarrow r1, -128 \leq n8 \leq 255 $ \\
75
    ldib r1, n8       & \texttt{1100}         & $n8 \rightarrow r1, -128 \leq n8 \leq 127$ \\
76
  \hline
77
    mov r1, r2        & \texttt{11010000}     & $r2 \rightarrow r1$ \\
78
    mod r1, r2        & \texttt{11010001}     & $r1\ \textnormal{mod}\ r2 \rightarrow r1$ \\
79
    umod r1, r2       & \texttt{11010010}     & $r1\ \textnormal{mod}\ r2 \rightarrow r1, \textnormal{unsigned} $ \\
80
    not r1, r2        & \texttt{11010011}     & $\lnot r2 \rightarrow r1$ \\
81
    neg r1, r2        & \texttt{11010100}     & $-r1 \rightarrow r2$ \\
82
    cmp r1, r2        & \texttt{11010101}     & $r1 - r2, \textnormal{sets flags}$ \\
83
    addi r1, n4       & \texttt{11010110}     & $r1 + n4 \rightarrow r1, -8 \leq n4 \leq 7$ \\
84
    cmpi r1, n4       & \texttt{11010111}     & $r1 - n4, \textnormal{sets flags}, -8 \leq n4 \leq 7$ \\
85
    shl r1, r2        & \texttt{11011000}     & $r1 \shl r2 \rightarrow r1$ \\
86
    shr r1, r2        & \texttt{11011001}     & $r1 \shr r2 \rightarrow r1$ \\
87
    sar r1, r2        & \texttt{11011010}     & $r1 \sar r2 \rightarrow r1$ \\
88
    rolc r1, r2       & \texttt{11011011}     & $(r1 \shl r2) \vee (C \shl (r2-1)) \vee (r1 \shr (16-r2-1))$ \\
89
    rorc r1, r2       & \texttt{11011100}     & $(r1 \shr r2) \vee (C \shl (16-r2)) \vee (r1 \shl (16-r2-1))$ \\
90
    bset r1, n4       & \texttt{11011101}     & $r1 \vee (1 \shl n4) \rightarrow r1, 0 \leq n4 \leq 15$ \\
91
    bclr r1, n4       & \texttt{11011110}     & $r1 \wedge \lnot (1 \shl n4) \rightarrow r1, 0 \leq n4 \leq 15$ \\
92
    btest r1, n4      & \texttt{11011111}     & $(r1 \shr n4) \wedge 1 \rightarrow Z, 0 \leq n4 \leq 15$ \\
93
  \hline
94
    load r1, r2       & \texttt{11100000}     & $[r2] \at [r2+1] \rightarrow r1$ \\
95
    store r1, r2      & \texttt{11100001}     & $r1 \rightarrow [r2] \at [r2+1]$ \\
96
    loadl r1, r2      & \texttt{11100010}     & $(r1 \wedge \texttt{0xff00}) \vee [r2] \rightarrow r1$ \\
97
    loadh r1, r2      & \texttt{11100011}     & $(r1 \wedge \texttt{0x00ff}) \vee ([r2] \shl 8) \rightarrow r1$ \\
98
    loadb r1, r2      & \texttt{11100100}     & $[r2] \rightarrow r1, \textnormal{signed}$ \\
99
    storel r1, r2     & \texttt{11100101}     & $(r1 \wedge \texttt{0x00ff}) \rightarrow [r2]$ \\
100
    storeh r1, r2     & \texttt{11100110}     & $(r1 \shr 8) \rightarrow [r2]$ \\
101
    call r1, r2       & \texttt{11101000}     & $r1 \rightarrow pc, pc \rightarrow r2$ \\
102
  \hline
103
    br n8             & \texttt{11110000}     & $pc + n8 \rightarrow pc, -128 \leq n8 \leq 127$ \\
104
    brz n8            & \texttt{11110001}     & $Z = 1 \Rightarrow pc + n8 \rightarrow pc, -128 \leq n8 \leq 127$ \\
105
    brnz n8           & \texttt{11110010}     & $Z = 0 \Rightarrow pc + n8 \rightarrow pc, -128 \leq n8 \leq 127$ \\
106
    brle n8           & \texttt{11110011}     & $(Z = 1) \vee (N \not = V) \Rightarrow pc + n8 \rightarrow pc, -128 \leq n8 \leq 127$ \\
107
    brlt n8           & \texttt{11110100}     & $(Z = 0) \wedge (N \not = V) \Rightarrow pc + n8 \rightarrow pc, -128 \leq n8 \leq 127$ \\
108
    brge n8           & \texttt{11110101}     & $(Z = 1) \vee (N = V) \Rightarrow pc + n8 \rightarrow pc, -128 \leq n8 \leq 127$ \\
109
    brgt n8           & \texttt{11110110}     & $(Z = 0) \wedge (N = V) \Rightarrow pc + n8 \rightarrow pc, -128 \leq n8 \leq 127$ \\
110
    brule n8          & \texttt{11110111}     & $(Z = 1) \vee (C = 1) \Rightarrow pc + n8 \rightarrow pc, -128 \leq n8 \leq 127$ \\
111
    brult n8          & \texttt{11111000}     & $(Z = 0) \wedge (C = 1) \Rightarrow pc + n8 \rightarrow pc, -128 \leq n8 \leq 127$ \\
112
    bruge n8          & \texttt{11111001}     & $(Z = 1) \vee (C = 0) \Rightarrow pc + n8 \rightarrow pc, -128 \leq n8 \leq 127$ \\
113
    brugt n8          & \texttt{11111010}     & $(Z = 0) \wedge (C = 0) \Rightarrow pc + n8 \rightarrow pc, -128 \leq n8 \leq 127$ \\
114
    sext r1, r2       & \texttt{11111011}     & $(r1 \shl 8) \sar 8 \rightarrow r2$ \\
115
    ldvec r1, n4      & \texttt{11111100}     & $\textnormal{interrupt vector}\ n4 \rightarrow r1, 0 \leq n4 \leq 15$ \\
116
    stvec r1, n4      & \texttt{11111101}     & $r1 \rightarrow \textnormal{interrupt vector}\ n4, 0 \leq n4 \leq 15$ \\
117
  \hline
118
    jmp r1            & \texttt{111111100000} & $r1 \rightarrow pc$ \\
119
    jmpz r1           & \texttt{111111100001} & $Z = 1 \Rightarrow r1 \rightarrow pc$ \\
120
    jmpnz r1          & \texttt{111111100010} & $Z = 0 \Rightarrow r1 \rightarrow pc$ \\
121
    jmple r1          & \texttt{111111100011} & $(Z = 1) \vee (N \not = V) \Rightarrow r1 \rightarrow pc$ \\
122
    jmplt r1          & \texttt{111111100100} & $(Z = 0) \wedge (N \not = V) \Rightarrow r1 \rightarrow pc$ \\
123
    jmpge r1          & \texttt{111111100101} & $(Z = 1) \vee (N = V) \Rightarrow r1 \rightarrow pc$ \\
124
    jmpgt r1          & \texttt{111111100110} & $(Z = 0) \wedge (N = V) \Rightarrow r1 \rightarrow pc$ \\
125
    jmpule r1         & \texttt{111111100111} & $(Z = 1) \vee (C = 1) \Rightarrow r1 \rightarrow pc$ \\
126
    jmpult r1         & \texttt{111111101000} & $(Z = 0) \wedge (C = 1) \Rightarrow r1 \rightarrow pc$ \\
127
    jmpuge r1         & \texttt{111111101001} & $(Z = 1) \vee (C = 0) \Rightarrow r1 \rightarrow pc$ \\
128
    jmpugt r1         & \texttt{111111101010} & $(Z = 0) \wedge (C = 0) \Rightarrow r1 \rightarrow pc$ \\
129
    intr n4           & \texttt{111111101011} & $\textnormal{interrupt vector}\ n4 \rightarrow pc, pc \rightarrow ira, flags \rightarrow shflags, 0 \leq n4 \leq 15$ \\
130
    getira r1         & \texttt{111111101100} & $ira \rightarrow r1$ \\
131
    setira r1         & \texttt{111111101101} & $r1 \rightarrow ira$ \\
132
    getfl r1          & \texttt{111111101110} & $flags \rightarrow r1$ \\
133
    setfl r1          & \texttt{111111101111} & $r1 \rightarrow flags$ \\
134
    getshfl r1        & \texttt{111111110000} & $shflags \rightarrow r1$ \\
135
    setshfl r1        & \texttt{111111110001} & $r1 \rightarrow shflags$ \\
136
  \hline
137
    reti              & \texttt{1111111111110000} & $ira \rightarrow pc, shflags \rightarrow flags$ \\
138
    nop               & \texttt{1111111111110001} & $\textnormal{do nothing}$ \\
139
    sei               & \texttt{1111111111110010} & $1 \rightarrow I$ \\
140
    cli               & \texttt{1111111111110011} & $0 \rightarrow I$ \\
141
    error             & \texttt{1111111111111111} & $\textnormal{invalid operation}$ \\
142
  \end{longtable}}
143
 
144
  \subsection{NOTES}
145
  \begin{itemize}
146
  \item Apart from the standard operators, the following notation is
147
    used in the table above:
148
    \begin{itemize}
149
    \item \shl, \shr, \sar are shifting operators, with semantics as in Java
150
    \item $[x]$ means accessing memory location $x$, 8 bits wide
151
    \item $x \at y$ means concatenating $x$ and $y$, in the sense of
152
      forming a 16-bit value from two 8-bit values
153
    \end{itemize}
154
  \item Modulo does not follow the patterns for ``div'' and ``udiv'',
155
    because there was not enough room for two more 3-operand
156
    operations. The assembler accepts the mnemonic with 3 registers as
157
    operands and substitute it with the according ``mov'' and ``mod''
158
    instructions.
159
  \end{itemize}
160
 
161
  \clearpage
162
 
163
  \subsection{Instruction formats}
164
 
165
  The following formats for instructions are to be used:
166
 
167
  \begin{center}
168
    \begin{tabular}{|p{1in}|p{1in}|p{1in}|p{1in}|}
169
      \hline
170
      Bits 15 \ldots 12 & Bits 11 \ldots 8 & Bits 7 \ldots 4 & Bits 3 \ldots 0 \\
171
      \hline
172
      Opcode                & r3   & r2 & r1 \\
173
      \hline
174
      Opcode                & \multicolumn{2}{|l|}{n8} & r1 \\
175
      \hline
176
      \multicolumn{2}{|l|}{Opcode} & r2 & r1 \\
177
      \hline
178
      \multicolumn{2}{|l|}{Opcode} & n4 & r1 \\
179
      \hline
180
      \multicolumn{2}{|l|}{Opcode} & \multicolumn{2}{|l|}{n8} \\
181
      \hline
182
      \multicolumn{3}{|l|}{Opcode} & r1 \\
183
      \hline
184
      \multicolumn{3}{|l|}{Opcode} & n4 \\
185
      \hline
186
      \multicolumn{4}{|l|}{Opcode} \\
187
      \hline
188
    \end{tabular}
189
  \end{center}
190
 
191
  \section{Versions Of This Document}
192
 
193
  2006-10-04: Draft version \textbf{0.1}
194
 
195
  \noindent
196
  2006-10-05: Draft version \textbf{0.2}
197
  \begin{itemize}
198
    \item rearrangement of some ops
199
  \end{itemize}
200
 
201
  \noindent
202
  2006-10-11: Draft version \textbf{0.3}
203
  \begin{itemize}
204
    \item replaced ``ror''/``rol'' with ``mod''/``umod''
205
    \item refined considerations of direction flag
206
    \item proposal for priorities of implementation
207
  \end{itemize}
208
 
209
  \noindent
210
  2006-10-28: Draft version \textbf{0.4}
211
  \begin{itemize}
212
    \item settled to singed loads
213
    \item settled to shifts by registers
214
    \item dropped ``push''/``pop''; the secondary result would cause a
215
      considerable overhead
216
    \item specified pipelining
217
  \end{itemize}
218
 
219
  \noindent
220
  2006-10-30: Draft version \textbf{0.5}
221
  \begin{itemize}
222
    \item added shflags to ease interrupt (and stack) handling
223
    \item a few refinements
224
  \end{itemize}
225
 
226
  \noindent
227
  2006-12-02: Draft version \textbf{0.6}
228
  \begin{itemize}
229
    \item the first register is the target with ``mov'' and ``not'' now.
230
    \item now the second register is always the address when accessing memory
231
    \item reversed order with immediate loads
232
    \item ``ldvec'' and ``stvec'' use the same order now
233
    \item fixed instruction format for immediate loads
234
  \end{itemize}
235
 
236
  \noindent
237
  2006-12-14: Draft version \textbf{0.7}
238
  \begin{itemize}
239
  \item dropped ``ldpgm'' in favor of a ROM which is mapped to the
240
    ordinary memory space
241
  \item moved section about pipelinign to the implementation document
242
  \item removed note about interrupts; they are implemented already
243
  \end{itemize}
244
 
245
\end{document}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.