File tree Expand file tree Collapse file tree 5 files changed +444
-4
lines changed
TUTORIALS/FROM_BLINKER_TO_RISCV Expand file tree Collapse file tree 5 files changed +444
-4
lines changed Original file line number Diff line number Diff line change
1
+
2
+ // donut.c by Andy Sloane (@a1k0n)
3
+ // https://gist.github.com/a1k0n/8ea6516b4946ab36348fb61703dc3194
4
+
1
5
#include <stdint.h>
2
6
#include <stdio.h>
3
7
#include <string.h>
Original file line number Diff line number Diff line change
1
+ // donut.c by Andy Sloane (@a1k0n)
2
+ // https://gist.github.com/a1k0n/8ea6516b4946ab36348fb61703dc3194
3
+
1
4
#include <stdint.h>
2
5
#include <stdio.h>
3
6
#include <string.h>
4
7
#include <unistd.h>
5
8
#include <math.h>
6
9
10
+ #define WITH_RV32M
11
+
7
12
#define debug (...)
8
13
//#define debug printf
9
14
@@ -120,13 +125,17 @@ void main() {
120
125
}
121
126
// todo: shift and add version of this
122
127
128
+
123
129
/*
124
130
if (d < dmin) dmin = d;
125
131
if (d > dmax) dmax = d;
132
+ */
133
+
134
+ #ifdef WITH_RV32M
126
135
px += d * vxi14 >> 14 ;
127
136
py += d * vyi14 >> 14 ;
128
137
pz += d * vzi14 >> 14 ;
129
- */
138
+ #else
130
139
{
131
140
// 11x1.14 fixed point 3x parallel multiply
132
141
// only 16 bit registers needed; starts from highest bit to lowest
@@ -149,7 +158,7 @@ void main() {
149
158
py += dy >> 4 ;
150
159
pz += dz >> 4 ;
151
160
}
152
-
161
+ #endif
153
162
niters ++ ;
154
163
}
155
164
}
You can’t perform that action at this time.
0 commit comments