[<<][meta][>>][..]
Mon Jan 28 16:04:11 CET 2013

Accumulators

Interesting problem: the accumulator nodes need to be generated before
the number of outputs is actually known.  At the point when the nb of
inputs are known, the SSA sequence is already written to the dictionary.

Looks like we need to call ai-arity here.

It's neat that this is possible, but I don't want to introduce that
dependency.  It makes more sense to fork off the bindings using
`parameterize' and insert them manually.

EDIT: This was a bit of a shuffle, but it seems to work now.  It's not
the most elegant code due to the presence of accumulator registers,
though it is quite general: fold a function over a fixed static type
(vector), using an arbitrary accumulation operation, and automatically
lift all operations over the structure.

(display
 (ai-c (stream
        (lambda (freq)
          (fold B
                +
                0
                (phasor freq 0 1))))
       #:nsi 0
       #:tc '((B . 10))))


#ifndef PROC
#define PROC(x) proc_##x
#endif
#define proc_nb_state 10
#define proc_nb_in_stream 0
#define proc_nb_in_param 10
#define proc_nb_out 1
#define proc_in_list(m) \
m(0, freq) \

INLINE void proc_loop(aa_ s, aa_ i, aa_ o, int n) {
	for (int t = 0, p = 0; t < n; t++, p ^= 1) {
		_ v3 = 0;
		for(int i0 = 0; i0 < 10; i0++) {
			_ v1; p_add(&v1, s[p][0+i0], i[0][0+i0]);
			p_wrap(&s[p^1][0+i0], v1, 0, 1);
			_ v4; p_add(&v4, v3, s[p][0+i0]);
			p_set(&v3, v4);
		}
		o[0][t] = v3;
	}
}
box> 



[Reply][About]
[<<][meta][>>][..]