Date:2012-12-09 20:29:00 (6 years 9 months ago)
Author:Werner Almesberger
Commit:07e0df0d6a3e1c18ff666d993bf38ee0a3c72e66
Message:tornado/fw/sim/alg.c: separate data processing from sample generation

Files: tornado/fw/sim/alg.c (1 diff)

Change Details

tornado/fw/sim/alg.c
4444#define E_SHIFT 3 /* ~ 0.1 */
4545#define M_SHIFT 10 /* ~ 1/S */
4646
47int main(void)
47
48static void process(unsigned v)
4849{
4950    uint16_t e = MID << E_SHIFT;
5051    uint32_t m = MID << M_SHIFT;
5152    int d;
52    int i;
5353    bool up = 0;
5454
55    e = v+(e-(e >> E_SHIFT));
56    m = v+(m-(m >> M_SHIFT));
57    d = (e >> E_SHIFT)-(m >> M_SHIFT);
58    if (up) {
59        if (d < -H)
60            up = 0;
61    } else {
62        if (d > H)
63            up = 1;
64    }
65    printf("%d %d %d %d %d\n",
66        v, e >> E_SHIFT, m >> M_SHIFT, d, up);
67}
68
69
70int main(void)
71{
72    int i;
73
5574    for (i = 0; i != 10*S; i++) {
5675        unsigned v = sample((double) i/S);
57        e = v+(e-(e >> E_SHIFT));
58        m = v+(m-(m >> M_SHIFT));
59        d = (e >> E_SHIFT)-(m >> M_SHIFT);
60        if (up) {
61            if (d < -H)
62                up = 0;
63        } else {
64            if (d > H)
65                up = 1;
66        }
67        printf("%d %d %d %d %d\n",
68            v, e >> E_SHIFT, m >> M_SHIFT, d, up);
76
77        process(v);
6978    }
7079    return 0;
7180}

Archive Download the corresponding diff file

Branches:
master
tornado-v1



interactive