/* Single-element delay in a single filter. The work function pushes * the item it received on the previous iteration, and then saves * the input item for the next iteration. */ float->float filter DelayOne { float last; init { last = 0.0; } work pop 1 push 1 { push(last); last = pop(); } } // this generates the delays in the lattice structure float->float splitjoin LatDel { split duplicate; add Identity(); add DelayOne(); join roundrobin; } // this is the intermediate stage of the lattice filter float->float filter LatFilt(float k_par) { work pop 2 peek 2 push 2 { float e_i = 0; float e_bar_i = 0; e_i = peek(0) - k_par*peek(1); e_bar_i = peek(1) - k_par*peek(0); push(e_i); push(e_bar_i); pop(); pop(); } } //this stage is the first stage of a lattice filter float->float splitjoin ZeroStage { split duplicate; add Identity(); add Identity(); join roundrobin; } // this class combines the delaying phase and coefficients float->float pipeline CompStage(float k_par) { add LatDel(); add LatFilt(k_par); } // this class is the last stage of a lattice filter float->void filter LastStage { work pop 2 { println(pop()); pop(); } } void->float filter Counter { float i; init { i = 1; } work push 1 { push(i); i = 0; } } void->void pipeline Lattice { add Counter(); add ZeroStage(); for (int i = 2; i < 10; i++) add CompStage(i); add LastStage(); }