1
0
mirror of git://projects.qi-hardware.com/antorcha.git synced 2024-11-22 08:05:20 +02:00

tornado/fw/sim/alg.c: separate data processing from sample generation

This commit is contained in:
Werner Almesberger 2012-12-09 16:29:00 -03:00
parent 4d09658036
commit 07e0df0d6a

View File

@ -44,16 +44,14 @@ static uint16_t sample(double t)
#define E_SHIFT 3 /* ~ 0.1 */
#define M_SHIFT 10 /* ~ 1/S */
int main(void)
static void process(unsigned v)
{
uint16_t e = MID << E_SHIFT;
uint32_t m = MID << M_SHIFT;
int d;
int i;
bool up = 0;
for (i = 0; i != 10*S; i++) {
unsigned v = sample((double) i/S);
e = v+(e-(e >> E_SHIFT));
m = v+(m-(m >> M_SHIFT));
d = (e >> E_SHIFT)-(m >> M_SHIFT);
@ -67,5 +65,16 @@ int main(void)
printf("%d %d %d %d %d\n",
v, e >> E_SHIFT, m >> M_SHIFT, d, up);
}
int main(void)
{
int i;
for (i = 0; i != 10*S; i++) {
unsigned v = sample((double) i/S);
process(v);
}
return 0;
}