- fixed fir_stage_sys-based filters

git-svn-id: http://moon:8086/svn/vhdl/trunk@1320 cc03376c-175c-47c8-b038-4cd826a8556b
This commit is contained in:
2015-10-24 08:39:35 +00:00
parent 34ef0ebe93
commit ee627567f2
7 changed files with 199 additions and 197 deletions
+2 -3
View File
@@ -1,5 +1,3 @@
vmap ieee_proposed ../../../Common/sim/ieee_proposed
vlib work vlib work
vcom -explicit -93 "../../../lib/misc/utils_pkg.vhd" vcom -explicit -93 "../../../lib/misc/utils_pkg.vhd"
vcom -explicit -93 "../../../lib/fixed/fixed_util_pkg.vhd" vcom -explicit -93 "../../../lib/fixed/fixed_util_pkg.vhd"
@@ -7,6 +5,7 @@ vcom -explicit -93 "../../../lib/PCK_FIO-2002.7/PCK_FIO_1993.vhd"
vcom -explicit -93 "../../../lib/PCK_FIO-2002.7/PCK_FIO_1993_BODY.vhd" vcom -explicit -93 "../../../lib/PCK_FIO-2002.7/PCK_FIO_1993_BODY.vhd"
vcom -explicit -93 "../src/filter_pkg.vhd" vcom -explicit -93 "../src/filter_pkg.vhd"
vcom -explicit -93 "../src/fir_pkg.vhd" vcom -explicit -93 "../src/fir_pkg.vhd"
vcom -explicit -93 "../src/fir_stage_sys.vhd"
vcom -explicit -93 "../src/fir_stage.vhd" vcom -explicit -93 "../src/fir_stage.vhd"
vcom -explicit -93 "../src/fir_iterative.vhd" vcom -explicit -93 "../src/fir_iterative.vhd"
vcom -explicit -93 "../src/tb_fir_iterative.vhd" vcom -explicit -93 "../src/tb_fir_iterative.vhd"
@@ -15,4 +14,4 @@ do {tb_fir_iterative.wdo}
view wave view wave
view structure view structure
view signals view signals
run 20us run 6us
+6 -8
View File
@@ -56,8 +56,6 @@ add wave -noupdate -format Logic /tb_fir_iterative/uut_fir_iterative/clk
add wave -noupdate -format Literal -radix hexadecimal /tb_fir_iterative/uut_fir_iterative/inst_fir_stage/x_in add wave -noupdate -format Literal -radix hexadecimal /tb_fir_iterative/uut_fir_iterative/inst_fir_stage/x_in
add wave -noupdate -format Literal -radix hexadecimal /tb_fir_iterative/uut_fir_iterative/inst_fir_stage/h_in add wave -noupdate -format Literal -radix hexadecimal /tb_fir_iterative/uut_fir_iterative/inst_fir_stage/h_in
add wave -noupdate -format Literal -radix hexadecimal /tb_fir_iterative/uut_fir_iterative/inst_fir_stage/y_in add wave -noupdate -format Literal -radix hexadecimal /tb_fir_iterative/uut_fir_iterative/inst_fir_stage/y_in
add wave -noupdate -format Literal -radix hexadecimal /tb_fir_iterative/uut_fir_iterative/inst_fir_stage/xin
add wave -noupdate -format Literal -radix hexadecimal /tb_fir_iterative/uut_fir_iterative/inst_fir_stage/hin
add wave -noupdate -format Literal -radix hexadecimal /tb_fir_iterative/uut_fir_iterative/inst_fir_stage/yin add wave -noupdate -format Literal -radix hexadecimal /tb_fir_iterative/uut_fir_iterative/inst_fir_stage/yin
add wave -noupdate -format Literal -radix hexadecimal /tb_fir_iterative/uut_fir_iterative/inst_fir_stage/prod add wave -noupdate -format Literal -radix hexadecimal /tb_fir_iterative/uut_fir_iterative/inst_fir_stage/prod
add wave -noupdate -format Literal -radix hexadecimal /tb_fir_iterative/uut_fir_iterative/inst_fir_stage/x_out add wave -noupdate -format Literal -radix hexadecimal /tb_fir_iterative/uut_fir_iterative/inst_fir_stage/x_out
@@ -87,8 +85,10 @@ add wave -noupdate -format Literal -radix hexadecimal /tb_fir_iterative/uut_fir_
add wave -noupdate -format Logic /tb_fir_iterative/uut_fir_iterative/new_round add wave -noupdate -format Logic /tb_fir_iterative/uut_fir_iterative/new_round
add wave -noupdate -format Literal -radix hexadecimal /tb_fir_iterative/uut_fir_iterative/x_stage add wave -noupdate -format Literal -radix hexadecimal /tb_fir_iterative/uut_fir_iterative/x_stage
add wave -noupdate -format Literal -radix hexadecimal /tb_fir_iterative/uut_fir_iterative/h_din add wave -noupdate -format Literal -radix hexadecimal /tb_fir_iterative/uut_fir_iterative/h_din
add wave -noupdate -format Literal -radix hexadecimal /tb_fir_iterative/ymem add wave -noupdate -format Literal -radix hexadecimal -expand /tb_fir_iterative/ymem
add wave -noupdate -format Literal /tb_fir_iterative/uut_fir_iterative/xmem add wave -noupdate -format Literal -radix hexadecimal -expand /tb_fir_iterative/uut_fir_iterative/xmem
add wave -noupdate -format Logic /tb_fir_iterative/uut_fir_iterative/x_stage_vld
add wave -noupdate -format Logic /tb_fir_iterative/uut_fir_iterative/y_stage_vld
add wave -noupdate -divider {Xmem Dual} add wave -noupdate -divider {Xmem Dual}
add wave -noupdate -format Logic /tb_fir_iterative/uut_fir_iterative/srst add wave -noupdate -format Logic /tb_fir_iterative/uut_fir_iterative/srst
add wave -noupdate -format Logic /tb_fir_iterative/uut_fir_iterative/clk add wave -noupdate -format Logic /tb_fir_iterative/uut_fir_iterative/clk
@@ -119,15 +119,13 @@ add wave -noupdate -format Logic /tb_fir_iterative/uut_fir_iterative/clk
add wave -noupdate -format Literal -radix hexadecimal /tb_fir_iterative/uut_fir_iterative/inst_fir_stage/x_in add wave -noupdate -format Literal -radix hexadecimal /tb_fir_iterative/uut_fir_iterative/inst_fir_stage/x_in
add wave -noupdate -format Literal -radix hexadecimal /tb_fir_iterative/uut_fir_iterative/inst_fir_stage/h_in add wave -noupdate -format Literal -radix hexadecimal /tb_fir_iterative/uut_fir_iterative/inst_fir_stage/h_in
add wave -noupdate -format Literal -radix hexadecimal /tb_fir_iterative/uut_fir_iterative/inst_fir_stage/y_in add wave -noupdate -format Literal -radix hexadecimal /tb_fir_iterative/uut_fir_iterative/inst_fir_stage/y_in
add wave -noupdate -format Literal -radix hexadecimal /tb_fir_iterative/uut_fir_iterative/inst_fir_stage/xin
add wave -noupdate -format Literal -radix hexadecimal /tb_fir_iterative/uut_fir_iterative/inst_fir_stage/hin
add wave -noupdate -format Literal -radix hexadecimal /tb_fir_iterative/uut_fir_iterative/inst_fir_stage/yin add wave -noupdate -format Literal -radix hexadecimal /tb_fir_iterative/uut_fir_iterative/inst_fir_stage/yin
add wave -noupdate -format Literal -radix hexadecimal /tb_fir_iterative/uut_fir_iterative/inst_fir_stage/prod add wave -noupdate -format Literal -radix hexadecimal /tb_fir_iterative/uut_fir_iterative/inst_fir_stage/prod
add wave -noupdate -format Literal -radix hexadecimal /tb_fir_iterative/uut_fir_iterative/inst_fir_stage/x_out add wave -noupdate -format Literal -radix hexadecimal /tb_fir_iterative/uut_fir_iterative/inst_fir_stage/x_out
add wave -noupdate -format Literal -radix hexadecimal /tb_fir_iterative/uut_fir_iterative/inst_fir_stage/y_out add wave -noupdate -format Literal -radix hexadecimal /tb_fir_iterative/uut_fir_iterative/inst_fir_stage/y_out
add wave -noupdate -format Literal /tb_fir_iterative/uut_fir_iterative/s add wave -noupdate -format Literal /tb_fir_iterative/uut_fir_iterative/s
TreeUpdate [SetDefaultTree] TreeUpdate [SetDefaultTree]
WaveRestoreCursors {{Cursor 1} {5100000 ps} 0} WaveRestoreCursors {{Cursor 1} {2700000 ps} 0} {{Cursor 2} {0 ps} 0} {{Cursor 3} {148250000 ps} 0}
configure wave -namecolwidth 140 configure wave -namecolwidth 140
configure wave -valuecolwidth 100 configure wave -valuecolwidth 100
configure wave -justifyvalue left configure wave -justifyvalue left
@@ -141,4 +139,4 @@ configure wave -gridperiod 1
configure wave -griddelta 40 configure wave -griddelta 40
configure wave -timeline 0 configure wave -timeline 0
update update
WaveRestoreZoom {0 ps} {42 us} WaveRestoreZoom {0 ps} {6300 ns}
+11 -7
View File
@@ -75,7 +75,7 @@ architecture Behavioral of fir_iterative is
type state_t is (init, idle, start, proc, p1, p2, output); type state_t is (init, idle, start, proc, p1, p2, output);
signal s, sn : state_t; signal s, sn : state_t;
signal x_stage, xo, y_stage : stage_t; signal x_stage, xo, y_stage, y_stage_in : stage_t;
signal stage_en, cnt_en, new_round : std_logic; signal stage_en, cnt_en, new_round : std_logic;
subtype tap_cnt_t is natural range 0 to ntaps-1; subtype tap_cnt_t is natural range 0 to ntaps-1;
@@ -93,11 +93,15 @@ architecture Behavioral of fir_iterative is
signal y_out_reg : out_t; signal y_out_reg : out_t;
signal y_reg_valid : std_logic; signal y_reg_valid : std_logic;
signal x_stage_vld : std_logic := '1';
signal y_stage_vld : std_logic;
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
begin begin
h_addr_out <= h_addr; h_addr_out <= h_addr;
x_stage <= resize(xmem_dout, x_stage, fixed_wrap, fixed_truncate); x_stage <= resize(xmem_dout, x_stage, fixed_wrap, fixed_truncate);
y_stage_in <= to_sfixed(0, y_stage_in) when new_round = '1' else y_stage;
---------------------------------------- ----------------------------------------
process (clk) process (clk)
@@ -301,19 +305,19 @@ begin
nbits_in_frac => nbits_stages_frac, nbits_in_frac => nbits_stages_frac,
nbits_out => nbits_stages, nbits_out => nbits_stages,
nbits_out_frac => nbits_stages_frac, nbits_out_frac => nbits_stages_frac,
input_latency => 1, pipe_latency => 2
coef_latency => 1,
pipe_latency => 3
) )
PORT MAP PORT MAP
( (
rst => fir_stage_clr, rst => srst,
ce => x_stage_vld,
clk => clk, clk => clk,
x_in => x_stage, x_in => x_stage,
y_in => y_stage, y_in => y_stage_in,
h_in => h_din, h_in => h_din,
x_out => xo, x_out => xo,
y_out => y_stage y_out => y_stage,
vld_out => y_stage_vld
); );
---------------------------------------- ----------------------------------------
+3 -3
View File
@@ -40,7 +40,7 @@ Generic
( (
ntaps_per_stage : integer := 32; ntaps_per_stage : integer := 32;
nstages : integer := 2; nstages : integer := 2;
pipe_latency : integer := 4; pipe_latency : integer := 2;
nbits_in : integer := 12; nbits_in : integer := 12;
nbits_in_frac : integer := 11; nbits_in_frac : integer := 11;
nbits_stages : integer := 13; nbits_stages : integer := 13;
@@ -239,11 +239,11 @@ gen_stages:
nbits_in => nbits_stages, nbits_in => nbits_stages,
nbits_in_frac => nbits_stages_frac, nbits_in_frac => nbits_stages_frac,
nbits_out => nbits_stages, nbits_out => nbits_stages,
nbits_out_frac => nbits_stages_frac, nbits_out_frac => nbits_stages_frac
pipe_latency => pipe_latency
) )
PORT MAP PORT MAP
( (
rst => rst,
clk => clk, clk => clk,
ce => en_array(i), ce => en_array(i),
x_in => x(i+1), x_in => x(i+1),
+4 -3
View File
@@ -41,7 +41,8 @@ Generic
nbits_in : integer := 12; nbits_in : integer := 12;
nbits_in_frac : integer := 12; nbits_in_frac : integer := 12;
nbits_out : integer := 12; nbits_out : integer := 12;
nbits_out_frac : integer := 12 nbits_out_frac : integer := 12;
pipe_latency : integer := 2
); );
Port Port
( (
@@ -59,8 +60,6 @@ end fir_stage_sys;
architecture Behavioral of fir_stage_sys is architecture Behavioral of fir_stage_sys is
constant min_pipe_lat : integer := 4;
subtype in_t is sfixed(shi(nbits_in, nbits_in_frac) downto slo(nbits_in, nbits_in_frac)); subtype in_t is sfixed(shi(nbits_in, nbits_in_frac) downto slo(nbits_in, nbits_in_frac));
subtype out_t is sfixed(shi(nbits_out, nbits_out_frac) downto slo(nbits_out, nbits_out_frac)); subtype out_t is sfixed(shi(nbits_out, nbits_out_frac) downto slo(nbits_out, nbits_out_frac));
@@ -73,6 +72,8 @@ signal vld : unsigned(1 downto 0);
------------------------------------------------------------ ------------------------------------------------------------
begin begin
assert pipe_latency = 2 report "Pipe latency must be two !" severity failure;
yin <= resize(y_in, yin); yin <= resize(y_in, yin);
vld_out <= vld(vld'left); vld_out <= vld(vld'left);
y_out <= y_reg; y_out <= y_reg;
+36 -36
View File
@@ -31,11 +31,11 @@ use work.PCK_FIO.all;
ENTITY tb_fir_iterative IS ENTITY tb_fir_iterative IS
Generic ( Generic (
ntaps : integer := 11; ntaps : integer := 11;
nbits_in : integer := 15; nbits_in : integer := 16;
nbits_in_frac : integer := 15; nbits_in_frac : integer := 15;
nbits_stages : integer := 15; nbits_stages : integer := 16;
nbits_stages_frac : integer := 15; nbits_stages_frac : integer := 15;
nbits_out : integer := 15; nbits_out : integer := 16;
nbits_out_frac : integer := 15; nbits_out_frac : integer := 15;
fir_mode : fir_iterative_mode_t := symmetric; fir_mode : fir_iterative_mode_t := symmetric;
rounding : boolean := true; rounding : boolean := true;
@@ -96,43 +96,43 @@ ARCHITECTURE behavior OF tb_fir_iterative IS
SIGNAL fileout_enable : std_logic := '1'; SIGNAL fileout_enable : std_logic := '1';
-- Test coefficients -- Test coefficients
-- SIGNAL coeffs : real_array_t(0 to ntaps_addr(ntaps, fir_mode)-1) := FilterCoef_Delta(ntaps, 10, 0.999)(0 to ntaps_addr(ntaps, fir_mode)-1); SIGNAL coeffs : real_array_t(0 to ntaps_addr(ntaps, fir_mode)-1) := FilterCoef_Delta(ntaps, (ntaps-1)/2, 1.0)(0 to ntaps_addr(ntaps, fir_mode)-1);
SIGNAL coeffs : real_array_t(0 to ntaps_addr(ntaps, fir_mode)-1) := FilterCoef_Bandpass(ntaps, 0.25, 0.125, 1.0)(0 to ntaps_addr(ntaps, fir_mode)-1); -- SIGNAL coeffs : real_array_t(0 to ntaps_addr(ntaps, fir_mode)-1) := FilterCoef_Bandpass(ntaps, 0.25, 0.125, 1.0)(0 to ntaps_addr(ntaps, fir_mode)-1);
-- SIGNAL coeffs : real_array_t(0 to ntaps-1) := FilterTestCoef(ntaps); -- SIGNAL coeffs : real_array_t(0 to ntaps-1) := FilterTestCoef(ntaps);
signal x_input : real_array_t(0 to nsamples-1) := signal x_input : real_array_t(0 to nsamples-1) :=
( (
0.0, 0.01,
0.0, 0.02,
0.0, 0.03,
0.0, 0.04,
0.0, 0.05,
0.0, 0.06,
0.0, 0.07,
0.0, 0.08,
0.0, 0.09,
0.0, 0.10,
0.0, 0.11,
0.0, 0.12,
0.0, 0.13,
0.0, 0.14,
0.0, 0.15,
0.9999, 0.9999,
-0.0000, -0.9999,
0.0, -0.15,
0.0, -0.14,
0.0, -0.13,
0.0, -0.12,
0.0, -0.11,
0.0, -0.10,
0.0, -0.09,
0.0, -0.08,
0.0, -0.07,
0.0, -0.06,
0.0, -0.05,
0.0, -0.04,
0.0, -0.03,
0.0, -0.02,
0.0 -0.01
); );
type ymem_t is array (0 to nsamples-1) of sfixed(shi(nbits_out, nbits_out_frac) downto slo(nbits_out, nbits_out_frac)); type ymem_t is array (0 to nsamples-1) of sfixed(shi(nbits_out, nbits_out_frac) downto slo(nbits_out, nbits_out_frac));
+1 -1
View File
@@ -141,7 +141,7 @@ BEGIN
( (
ntaps_per_stage => ntaps_per_stage, ntaps_per_stage => ntaps_per_stage,
nstages => nstages, nstages => nstages,
pipe_latency => 5, pipe_latency => 2,
nbits_in => nbits_in, nbits_in => nbits_in,
nbits_in_frac => nbits_in_frac, nbits_in_frac => nbits_in_frac,
nbits_stages => nbits_stages, nbits_stages => nbits_stages,