Removed superfluous comments. Added 2x/double_mode for A1 coefficients to filter engine.

This commit is contained in:
Niels Moseley 2017-10-21 00:38:12 +02:00
parent cf89706963
commit bdcd8a3d8f
4 changed files with 223 additions and 229 deletions

View File

@ -1,7 +1,7 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<!DOCTYPE ipe SYSTEM "ipe.dtd"> <!DOCTYPE ipe SYSTEM "ipe.dtd">
<ipe version="70206" creator="Ipe 7.2.6"> <ipe version="70206" creator="Ipe 7.2.6">
<info created="D:20171017173217" modified="D:20171017181018"/> <info created="D:20171017173217" modified="D:20171018222146"/>
<ipestyle name="basic"> <ipestyle name="basic">
<symbol name="arrow/arc(spx)"> <symbol name="arrow/arc(spx)">
<path stroke="sym-stroke" fill="sym-stroke" pen="sym-pen"> <path stroke="sym-stroke" fill="sym-stroke" pen="sym-pen">
@ -344,221 +344,19 @@ h
<use name="mark/disk(sx)" pos="352 468" size="normal" stroke="black"/> <use name="mark/disk(sx)" pos="352 468" size="normal" stroke="black"/>
<text matrix="1 0 0 1 56 -196" transformations="translations" pos="296 640" stroke="black" type="label" width="29.335" height="6.135" depth="1.93" halign="center" valign="center">output</text> <text matrix="1 0 0 1 56 -196" transformations="translations" pos="296 640" stroke="black" type="label" width="29.335" height="6.135" depth="1.93" halign="center" valign="center">output</text>
<text matrix="1 0 0 1 244 -136" transformations="translations" pos="48 672" stroke="black" type="label" width="23.246" height="6.661" depth="1.93" halign="right" valign="center">input</text> <text matrix="1 0 0 1 244 -136" transformations="translations" pos="48 672" stroke="black" type="label" width="23.246" height="6.661" depth="1.93" halign="right" valign="center">input</text>
<group matrix="1 0 0 1 0 -96"> <text matrix="1 0 0 1 56 -96" transformations="translations" pos="88 712" stroke="black" type="label" width="38.074" height="6.132" depth="1.49" halign="center" valign="center">$a_1$-states</text>
<path stroke="black" pen="heavier">
48 736 m
48 720 l
64 720 l
64 736 l
h
</path>
<path matrix="1 0 0 1 16 0" stroke="black" pen="heavier">
48 736 m
48 720 l
64 720 l
64 736 l
h
</path>
<path matrix="1 0 0 1 32 0" stroke="black" pen="heavier">
48 736 m
48 720 l
64 720 l
64 736 l
h
</path>
<path matrix="1 0 0 1 48 0" stroke="black" pen="heavier">
48 736 m
48 720 l
64 720 l
64 736 l
h
</path>
<path matrix="1 0 0 1 64 0" stroke="black" pen="heavier">
48 736 m
48 720 l
64 720 l
64 736 l
h
</path>
<path matrix="1 0 0 1 80 0" stroke="black" pen="heavier">
48 736 m
48 720 l
64 720 l
64 736 l
h
</path>
<path matrix="1 0 0 1 96 0" stroke="black" pen="heavier">
48 736 m
48 720 l
64 720 l
64 736 l
h
</path>
<path matrix="1 0 0 1 112 0" stroke="black" pen="heavier">
48 736 m
48 720 l
64 720 l
64 736 l
h
</path>
<path matrix="1 0 0 1 0 28" stroke="black" pen="heavier" arrow="normal/normal">
56 712 m
168 712 l
</path>
<text matrix="1 0 0 1 24 60" transformations="translations" pos="88 688" stroke="black" type="label" width="35.783" height="6.926" depth="1.93" halign="center" valign="center">shift reg</text>
</group>
<group matrix="1 0 0 1 160 -96">
<path stroke="black" pen="heavier">
48 736 m
48 720 l
64 720 l
64 736 l
h
</path>
<path matrix="1 0 0 1 16 0" stroke="black" pen="heavier">
48 736 m
48 720 l
64 720 l
64 736 l
h
</path>
<path matrix="1 0 0 1 32 0" stroke="black" pen="heavier">
48 736 m
48 720 l
64 720 l
64 736 l
h
</path>
<path matrix="1 0 0 1 48 0" stroke="black" pen="heavier">
48 736 m
48 720 l
64 720 l
64 736 l
h
</path>
<path matrix="1 0 0 1 64 0" stroke="black" pen="heavier">
48 736 m
48 720 l
64 720 l
64 736 l
h
</path>
<path matrix="1 0 0 1 80 0" stroke="black" pen="heavier">
48 736 m
48 720 l
64 720 l
64 736 l
h
</path>
<path matrix="1 0 0 1 96 0" stroke="black" pen="heavier">
48 736 m
48 720 l
64 720 l
64 736 l
h
</path>
<path matrix="1 0 0 1 112 0" stroke="black" pen="heavier">
48 736 m
48 720 l
64 720 l
64 736 l
h
</path>
<path matrix="1 0 0 1 0 28" stroke="black" pen="heavier" arrow="normal/normal">
56 712 m
168 712 l
</path>
<text matrix="1 0 0 1 24 60" transformations="translations" pos="88 688" stroke="black" type="label" width="35.783" height="6.926" depth="1.93" halign="center" valign="center">shift reg</text>
</group>
<text matrix="1 0 0 1 24 -96" transformations="translations" pos="88 712" stroke="black" type="label" width="38.074" height="6.132" depth="1.49" halign="center" valign="center">$a_1$-states</text>
<text matrix="1 0 0 1 184 -96" transformations="translations" pos="88 712" stroke="black" type="label" width="38.074" height="6.132" depth="1.49" halign="center" valign="center">$a_2$-states</text> <text matrix="1 0 0 1 184 -96" transformations="translations" pos="88 712" stroke="black" type="label" width="38.074" height="6.132" depth="1.49" halign="center" valign="center">$a_2$-states</text>
<path matrix="1 0 0 1 0 -96" stroke="black" pen="heavier" arrow="normal/normal"> <path matrix="1 0 0 1 0 -96" stroke="black" pen="heavier" arrow="normal/normal">
176 728 m 176 728 m
208 728 l 208 728 l
</path> </path>
<path stroke="black" pen="heavier" arrow="normal/normal"> <path stroke="black" pen="heavier" arrow="normal/normal">
328 624 m
328 608 l
296 608 l
296 584 l
312 584 l
</path>
<path stroke="black" pen="heavier" arrow="normal/normal">
192 632 m 192 632 m
192 568 l 192 568 l
312 568 l 312 568 l
</path> </path>
<use name="mark/disk(sx)" pos="192 632" size="normal" stroke="black"/> <use name="mark/disk(sx)" pos="192 632" size="normal" stroke="black"/>
<path stroke="black" pen="heavier" arrow="normal/normal">
296 468 m
32 468 l
32 632 l
48 632 l
</path>
<use name="mark/disk(sx)" pos="296 468" size="normal" stroke="black"/> <use name="mark/disk(sx)" pos="296 468" size="normal" stroke="black"/>
<group matrix="1 0 0 1 160 -16">
<path stroke="black" pen="heavier">
48 736 m
48 720 l
64 720 l
64 736 l
h
</path>
<path matrix="1 0 0 1 16 0" stroke="black" pen="heavier">
48 736 m
48 720 l
64 720 l
64 736 l
h
</path>
<path matrix="1 0 0 1 32 0" stroke="black" pen="heavier">
48 736 m
48 720 l
64 720 l
64 736 l
h
</path>
<path matrix="1 0 0 1 48 0" stroke="black" pen="heavier">
48 736 m
48 720 l
64 720 l
64 736 l
h
</path>
<path matrix="1 0 0 1 64 0" stroke="black" pen="heavier">
48 736 m
48 720 l
64 720 l
64 736 l
h
</path>
<path matrix="1 0 0 1 80 0" stroke="black" pen="heavier">
48 736 m
48 720 l
64 720 l
64 736 l
h
</path>
<path matrix="1 0 0 1 96 0" stroke="black" pen="heavier">
48 736 m
48 720 l
64 720 l
64 736 l
h
</path>
<path matrix="1 0 0 1 112 0" stroke="black" pen="heavier">
48 736 m
48 720 l
64 720 l
64 736 l
h
</path>
<path matrix="1 0 0 1 0 28" stroke="black" pen="heavier" arrow="normal/normal">
56 712 m
168 712 l
</path>
<text matrix="1 0 0 1 24 60" transformations="translations" pos="88 688" stroke="black" type="label" width="35.783" height="6.926" depth="1.93" halign="center" valign="center">shift reg</text>
</group>
<text matrix="1 0 0 1 184 -16" transformations="translations" pos="88 712" stroke="black" type="label" width="47.101" height="6.918" depth="0" halign="center" valign="center">coefficients</text> <text matrix="1 0 0 1 184 -16" transformations="translations" pos="88 712" stroke="black" type="label" width="47.101" height="6.918" depth="0" halign="center" valign="center">coefficients</text>
<path stroke="black" pen="heavier" arrow="normal/normal"> <path stroke="black" pen="heavier" arrow="normal/normal">
336 712 m 336 712 m
@ -566,31 +364,228 @@ h
376 576 l 376 576 l
360 576 l 360 576 l
</path> </path>
<path stroke="black" pen="heavier"> <path matrix="1 0 0 1 -64 0" stroke="black" pen="heavier">
176 736 m 176 736 m
192 728 l 192 728 l
192 696 l 192 696 l
176 688 l 176 688 l
h h
</path> </path>
<path stroke="black" pen="heavier" arrow="normal/normal"> <path matrix="1 0 0 1 -64 0" stroke="black" pen="heavier" arrow="normal/normal">
192 712 m 192 712 m
208 712 l 208 712 l
</path> </path>
<text matrix="1 0 0 1 -80 44" transformations="translations" pos="260 680" stroke="black" type="label" width="4.234" height="5.136" depth="0" halign="center" valign="center" size="footnote">1</text> <text matrix="1 0 0 1 -144 44" transformations="translations" pos="260 680" stroke="black" type="label" width="4.234" height="5.136" depth="0" halign="center" valign="center" size="footnote">1</text>
<path stroke="black" pen="heavier" arrow="normal/normal"> <text matrix="1 0 0 1 -144 16" transformations="translations" pos="260 680" stroke="black" type="label" width="4.234" height="5.136" depth="0" halign="center" valign="center" size="footnote">0</text>
376 672 m
160 672 l
160 696 l
176 696 l
</path>
<text matrix="1 0 0 1 -80 16" transformations="translations" pos="260 680" stroke="black" type="label" width="4.234" height="5.136" depth="0" halign="center" valign="center" size="footnote">0</text>
<use name="mark/disk(sx)" pos="376 672" size="normal" stroke="black"/> <use name="mark/disk(sx)" pos="376 672" size="normal" stroke="black"/>
<path stroke="black" pen="heavier" rarrow="normal/normal"> <path matrix="1 0 0 1 -64 0" stroke="black" pen="heavier" rarrow="normal/normal">
176 720 m 176 720 m
160 720 l 160 720 l
144 720 l 144 720 l
</path> </path>
<text matrix="1 0 0 1 28 0" transformations="translations" pos="112 720" stroke="black" type="label" width="31.814" height="6.918" depth="0" halign="right" valign="center">coeff\_in</text> <text matrix="1 0 0 1 -36 0" transformations="translations" pos="112 720" stroke="black" type="label" width="31.814" height="6.918" depth="0" halign="right" valign="center">coeff\_in</text>
<path matrix="1 0 0 1 32 -96" stroke="black" pen="heavier">
48 736 m
48 720 l
64 720 l
64 736 l
h
</path>
<path matrix="1 0 0 1 48 -96" stroke="black" pen="heavier">
48 736 m
48 720 l
64 720 l
64 736 l
h
</path>
<path matrix="1 0 0 1 64 -96" stroke="black" pen="heavier">
48 736 m
48 720 l
64 720 l
64 736 l
h
</path>
<path matrix="1 0 0 1 80 -96" stroke="black" pen="heavier">
48 736 m
48 720 l
64 720 l
64 736 l
h
</path>
<path matrix="1 0 0 1 96 -96" stroke="black" pen="heavier">
48 736 m
48 720 l
64 720 l
64 736 l
h
</path>
<path matrix="1 0 0 1 112 -96" stroke="black" pen="heavier">
48 736 m
48 720 l
64 720 l
64 736 l
h
</path>
<path matrix="0.714286 0 0 1 48 -68" stroke="black" pen="heavier" arrow="normal/normal">
56 712 m
168 712 l
</path>
<text matrix="1 0 0 1 40 -36" transformations="translations" pos="88 688" stroke="black" type="label" width="35.783" height="6.926" depth="1.93" halign="center" valign="center">shift reg</text>
<path matrix="1 0 0 1 160 -96" stroke="black" pen="heavier">
48 736 m
48 720 l
64 720 l
64 736 l
h
</path>
<path matrix="1 0 0 1 176 -96" stroke="black" pen="heavier">
48 736 m
48 720 l
64 720 l
64 736 l
h
</path>
<path matrix="1 0 0 1 192 -96" stroke="black" pen="heavier">
48 736 m
48 720 l
64 720 l
64 736 l
h
</path>
<path matrix="1 0 0 1 208 -96" stroke="black" pen="heavier">
48 736 m
48 720 l
64 720 l
64 736 l
h
</path>
<path matrix="1 0 0 1 224 -96" stroke="black" pen="heavier">
48 736 m
48 720 l
64 720 l
64 736 l
h
</path>
<path matrix="1 0 0 1 240 -96" stroke="black" pen="heavier">
48 736 m
48 720 l
64 720 l
64 736 l
h
</path>
<path matrix="0.714286 0 0 1 176 -68" stroke="black" pen="heavier" arrow="normal/normal">
56 712 m
168 712 l
</path>
<text matrix="1 0 0 1 168 -36" transformations="translations" pos="88 688" stroke="black" type="label" width="35.783" height="6.926" depth="1.93" halign="center" valign="center">shift reg</text>
<path stroke="black" arrow="normal/normal">
296 468 m
64 468 l
64 632 l
80 632 l
</path>
<path stroke="black" arrow="normal/normal">
304 632 m
320 632 l
320 608 l
296 608 l
296 584 l
312 584 l
</path>
<path matrix="1 0 0 1 160 -16" stroke="black" pen="heavier">
48 736 m
48 720 l
64 720 l
64 736 l
h
</path>
<path matrix="1 0 0 1 176 -16" stroke="black" pen="heavier">
48 736 m
48 720 l
64 720 l
64 736 l
h
</path>
<path matrix="1 0 0 1 192 -16" stroke="black" pen="heavier">
48 736 m
48 720 l
64 720 l
64 736 l
h
</path>
<path matrix="1 0 0 1 208 -16" stroke="black" pen="heavier">
48 736 m
48 720 l
64 720 l
64 736 l
h
</path>
<path matrix="1 0 0 1 224 -16" stroke="black" pen="heavier">
48 736 m
48 720 l
64 720 l
64 736 l
h
</path>
<path matrix="1 0 0 1 240 -16" stroke="black" pen="heavier">
48 736 m
48 720 l
64 720 l
64 736 l
h
</path>
<path matrix="1 0 0 1 256 -16" stroke="black" pen="heavier">
48 736 m
48 720 l
64 720 l
64 736 l
h
</path>
<path matrix="1 0 0 1 272 -16" stroke="black" pen="heavier">
48 736 m
48 720 l
64 720 l
64 736 l
h
</path>
<path matrix="1 0 0 1 160 12" stroke="black" pen="heavier" arrow="normal/normal">
56 712 m
168 712 l
</path>
<text matrix="1 0 0 1 184 44" transformations="translations" pos="88 688" stroke="black" type="label" width="35.783" height="6.926" depth="1.93" halign="center" valign="center">shift reg</text>
<path matrix="1 0 0 1 144 -16" stroke="black" pen="heavier">
48 736 m
48 720 l
64 720 l
64 736 l
h
</path>
<path matrix="1 0 0 1 128 -16" stroke="black" pen="heavier">
48 736 m
48 720 l
64 720 l
64 736 l
h
</path>
<path matrix="1 0 0 1 112 -16" stroke="black" pen="heavier">
48 736 m
48 720 l
64 720 l
64 736 l
h
</path>
<path matrix="1 0 0 1 96 -16" stroke="black" pen="heavier">
48 736 m
48 720 l
64 720 l
64 736 l
h
</path>
<path stroke="black" arrow="normal/normal">
376 672 m
96 672 l
96 696 l
112 696 l
</path>
</page> </page>
</ipe> </ipe>

View File

@ -6,11 +6,6 @@
// http://www.moseleyinstruments.com // http://www.moseleyinstruments.com
// //
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, ..
// this is all arse-backwards as fuck ..
// we should use a shift register for states + coefficients!!
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
module FILTER ( module FILTER (
clk, clk,
@ -52,6 +47,7 @@ module FILTER (
reg state_sel; reg state_sel;
reg accu_sel; reg accu_sel;
reg do_accu; reg do_accu;
reg double_mode;
reg update_states; reg update_states;
reg update_coeffs; reg update_coeffs;
reg [3:0] cur_state; reg [3:0] cur_state;
@ -80,6 +76,7 @@ module FILTER (
assign mul_coeff = coefmem[11]; assign mul_coeff = coefmem[11];
assign sig_out = accu; assign sig_out = accu;
// clocked stuff..
always @(posedge clk, negedge rst_an) always @(posedge clk, negedge rst_an)
begin begin
if (rst_an == 0) if (rst_an == 0)
@ -102,6 +99,7 @@ module FILTER (
accu_sel <= 0; accu_sel <= 0;
state_sel <= 0; state_sel <= 0;
do_accu <= 0; do_accu <= 0;
double_mode <= 0;
update_states <= 0; update_states <= 0;
update_coeffs <= 0; update_coeffs <= 0;
@ -149,7 +147,10 @@ module FILTER (
// update the accumulator if necessary // update the accumulator if necessary
if (do_accu) if (do_accu)
begin begin
accu <= accu_in + mul_result; if (double_mode)
accu <= accu_in +{mul_result[14:0], 1'b0};
else
accu <= accu_in + mul_result;
end end
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@ -162,6 +163,7 @@ module FILTER (
mul_start <= 0; mul_start <= 0;
state_sel <= 0; state_sel <= 0;
accu_sel <= 0; accu_sel <= 0;
double_mode <= 0;
update_states <= 0; update_states <= 0;
update_coeffs <= 0; update_coeffs <= 0;
case(cur_state) case(cur_state)
@ -181,11 +183,6 @@ module FILTER (
// to reach a valid state // to reach a valid state
begin begin
cur_state <= 4'b0010; cur_state <= 4'b0010;
//for(i=0; i<6; i=i+1)
//begin
// $display("s1[%d] = %x", i, state1[i]);
// $display("s2[%d] = %x", i, state2[i]);
//end
end end
4'b0010: // wait for multiplier to complete 4'b0010: // wait for multiplier to complete
begin begin
@ -194,6 +191,7 @@ module FILTER (
cur_state <= 4'b0011; cur_state <= 4'b0011;
accu_sel <= 0; // accu = sig_in + mul_result accu_sel <= 0; // accu = sig_in + mul_result
do_accu <= 1; do_accu <= 1;
double_mode <= 1; // a1 coefficient has double the weight
end end
end end
4'b0011: // update accu, 1st section only! 4'b0011: // update accu, 1st section only!
@ -252,6 +250,7 @@ module FILTER (
cur_state <= 4'b1011; cur_state <= 4'b1011;
accu_sel <= 1; // accu = accu + mul_result accu_sel <= 1; // accu = accu + mul_result
do_accu <= 1; do_accu <= 1;
double_mode <= 1; // a1 coefficient has double the weight
end end
end end
4'b1011: // update accu, 2nd..5th section only! 4'b1011: // update accu, 2nd..5th section only!

View File

@ -46,7 +46,7 @@ module FILTER_TB;
#10 #10
coef_load = 1; coef_load = 1;
// section 1 // section 1
coef_in = {1'b0, 9'd128}; // sign-magnitude a1 = -0.25 coef_in = {1'b0, 9'd64}; // sign-magnitude a1 = -0.25
#10 #10
coef_in = {1'b1, 9'd256}; // sign-magnitude a2 = 0.5 coef_in = {1'b1, 9'd256}; // sign-magnitude a2 = 0.5
#10 #10

View File

@ -31,4 +31,4 @@ The testbench should approximately give the following step response results:
- 205 - 205
- 205 - 205
Note that there might be a few +/- 1 round-off errors. Note that may be a few +/- 1 round-off errors.