User manual
Example .mif sine table generator
/
*
*
main.c
*
*
slapdash quick and dirty sine table .. not
*
checked for symmetry, etc.
*
*
initial version .. 02 Oct 2011 .. K.Metzger
*
*
/
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#define N 256
#define pi 3.14159265
void main(void) {
unsigned ctr;
int v;
FILE
*
out;
out = fopen("sine_rom.mif", "wa");
if (out == NULL) {
printf("cannot open output file\n");
exit(1);
}
printf("starting\n");
for(ctr=0; ctr<N; ctr++) {
v = 32767
*
sin(2
*
pi
*
ctr/(float)N);
fprintf(out, "%d : %04X;\n", ctr, v);
}
fclose(out);
printf("done\n");
}
EECS 452 – Fall 2014 Lecture 5 – Page 92/143 Tuesday – September 16, 2014