aboutsummaryrefslogtreecommitdiff
path: root/README.adoc
blob: 694dcad9c0b17fb469dd194f1355c249e90165e6 (plain) (blame)
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
Montreal
========
:revnumber: 0.1.0-draft

A RISC-V RV32E processor designed for TinyTapeout.

RV32E
-----

https://docs.riscv.org/reference/isa/unpriv/unpriv-index.html[ISA Reference]

Reduces number of integer registers to 16 general-purpose registers
(x0-x15). Upper 16 registers consume around one quarter of the total
area of the core excluding memories, thus their removal saves around 25%
core area with a corresponding core power reduction.

Each register is 32 bits wide.

[cols="1,2,4", options="header"]
|===

| Register
| Description
| Purpose

| x0
| dedicated zero
| Source operand for value 0.

| x1
| return address
| Written by JAL/JALR. Holds address to be returned to once a function returns.
Must be saved to stack before calling another function.

| x2
| stack pointer
| Always points to top of the stack in RAM. Decremented to allocate space,
incremented to free it. CALLEE must restore it BEFORE returning.

| x3
| global pointer
|

| x4
| thread pointer
|

| x5
| alternate link reg
| Second link register for nested JAL sequences. Caller must save
if needed across a call.

| x6
| general scratch reg
|

| x7
| general scratch reg
|

| x8
| frame pointer
|

| x9
| saved register
|

| x10
| first function argument
| Also used to return integer results from function.

| x11
| second function argument
|

| x12
| third function argument
|

| x13
| fourth function argument
|

| x14
| fifth function argument
|

| x15
| sixth function argument
|

| pc
| program counter
| Address of current instruction

|===

Instruction Set
---------------

.Relevant opcodes for the IP. `inst[1:0] = 11`.
[cols="2*^1m,8*^2m", hrows=2]
|===

|
|
8+^| inst[4:2]

|
|
| 000
| 001
| 010
| 011
| 100
| 101
| 110
| 111

1.4+.^| inst[6:5]
| 00
| LOAD
|
|
| MISC-MEM
| OP-IMM
| AUIPC
|
|

| 01
| STORE
|
|
|
| OP
| LUI
|
|

| 10
|
|
|
|
|
|
|
|

| 11
| BRANCH
| JALR
|
| JAL
| SYSTEM
|
|
|
|===

=== Immediate Types

The labels `[7]`, `[20]`, and `[31]` represent the bits `inst[7]`, `inst[20]`, and `inst[31]`, respectively.

image::docs/images/i-immediate.svg[width=100%]
image::docs/images/s-immediate.svg[width=100%]
image::docs/images/b-immediate.svg[width=100%]
image::docs/images/u-immediate.svg[width=100%]
image::docs/images/j-immediate.svg[width=100%]

=== LUI

image::docs/images/lui.svg[width=100%]

=== AUIPC

image::docs/images/auipc.svg[width=100%]

=== OP-IMM

image::docs/images/addi.svg[width=100%]
image::docs/images/slti.svg[width=100%]
image::docs/images/sltiu.svg[width=100%]
image::docs/images/xori.svg[width=100%]
image::docs/images/ori.svg[width=100%]
image::docs/images/andi.svg[width=100%]
image::docs/images/slli.svg[width=100%]
image::docs/images/srli.svg[width=100%]
image::docs/images/srai.svg[width=100%]

=== OP

image::docs/images/add.svg[width=100%]
image::docs/images/sub.svg[width=100%]
image::docs/images/slt.svg[width=100%]
image::docs/images/sltu.svg[width=100%]
image::docs/images/xor.svg[width=100%]
image::docs/images/or.svg[width=100%]
image::docs/images/and.svg[width=100%]
image::docs/images/sll.svg[width=100%]
image::docs/images/srl.svg[width=100%]
image::docs/images/sra.svg[width=100%]
image::docs/images/czero.eqz.svg[width=100%]
image::docs/images/czero.nez.svg[width=100%]

=== JAL

image::docs/images/jal.svg[width=100%]

=== JALR

image::docs/images/jalr.svg[width=100%]

=== BRANCH

The labels `[11]` and `[12]` represent the bits `imm[11]` and `imm[12]` respectively.

image::docs/images/beq.svg[width=100%]
image::docs/images/bne.svg[width=100%]
image::docs/images/blt.svg[width=100%]
image::docs/images/bge.svg[width=100%]
image::docs/images/bltu.svg[width=100%]
image::docs/images/bgeu.svg[width=100%]

=== LOAD

image::docs/images/lb.svg[width=100%]
image::docs/images/lh.svg[width=100%]
image::docs/images/lw.svg[width=100%]
image::docs/images/lbu.svg[width=100%]
image::docs/images/lhu.svg[width=100%]

=== STORE

image::docs/images/sb.svg[width=100%]
image::docs/images/sh.svg[width=100%]
image::docs/images/sw.svg[width=100%]

=== MISC-MEM

image::docs/images/fence.svg[width=100%]

=== SYSTEM

image::docs/images/ecall.svg[width=100%]
image::docs/images/ebreak.svg[width=100%]