Skip to content

Commit 0bac913

Browse files
committed
Added provenance info for donut.c
New version of donut with nice "rendering" and stats
1 parent 9b663f7 commit 0bac913

File tree

5 files changed

+444
-4
lines changed

5 files changed

+444
-4
lines changed

FemtoRV/FIRMWARE/EXAMPLES/donut.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2+
// donut.c by Andy Sloane (@a1k0n)
3+
// https://gist.github.com/a1k0n/8ea6516b4946ab36348fb61703dc3194
4+
15
#include <stdint.h>
26
#include <stdio.h>
37
#include <string.h>

FemtoRV/TUTORIALS/FROM_BLINKER_TO_RISCV/FIRMWARE/donut.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1+
// donut.c by Andy Sloane (@a1k0n)
2+
// https://gist.github.com/a1k0n/8ea6516b4946ab36348fb61703dc3194
3+
14
#include <stdint.h>
25
#include <stdio.h>
36
#include <string.h>
47
#include <unistd.h>
58
#include <math.h>
69

10+
#define WITH_RV32M
11+
712
#define debug(...)
813
//#define debug printf
914

@@ -120,13 +125,17 @@ void main() {
120125
}
121126
// todo: shift and add version of this
122127

128+
123129
/*
124130
if (d < dmin) dmin = d;
125131
if (d > dmax) dmax = d;
132+
*/
133+
134+
#ifdef WITH_RV32M
126135
px += d*vxi14 >> 14;
127136
py += d*vyi14 >> 14;
128137
pz += d*vzi14 >> 14;
129-
*/
138+
#else
130139
{
131140
// 11x1.14 fixed point 3x parallel multiply
132141
// only 16 bit registers needed; starts from highest bit to lowest
@@ -149,7 +158,7 @@ void main() {
149158
py += dy >> 4;
150159
pz += dz >> 4;
151160
}
152-
161+
#endif
153162
niters++;
154163
}
155164
}

0 commit comments

Comments
 (0)