Line 48... |
Line 48... |
-- x : mean(-3 -2 -1 0 1 2 3) = 0
|
-- x : mean(-3 -2 -1 0 1 2 3) = 0
|
-- . round(x/2) : mean(-2 -1 -1 0 1 1 2) = 0
|
-- . round(x/2) : mean(-2 -1 -1 0 1 1 2) = 0
|
-- . floor(x/2) : mean(-2 -1 -1 0 0 1 1) = -2/8 = -0.25 = -2^(N-1)/2 / 2^N
|
-- . floor(x/2) : mean(-2 -1 -1 0 0 1 1) = -2/8 = -0.25 = -2^(N-1)/2 / 2^N
|
-- So the DC offset due to truncation is -0.25 LSbit, independent of N.
|
-- So the DC offset due to truncation is -0.25 LSbit, independent of N.
|
|
|
library IEEE, common_pkg_lib, common_add_sub_lib, common_requantize_lib;
|
library IEEE, common_pkg_lib, astron_adder_lib, astron_requantize_lib;
|
use IEEE.std_logic_1164.ALL;
|
use IEEE.std_logic_1164.ALL;
|
use IEEE.numeric_std.ALL;
|
use IEEE.numeric_std.ALL;
|
use common_pkg_lib.common_pkg.ALL;
|
use common_pkg_lib.common_pkg.ALL;
|
|
|
entity fft_sepa is
|
entity fft_sepa is
|
Line 97... |
Line 97... |
begin
|
begin
|
|
|
---------------------------------------------------------------
|
---------------------------------------------------------------
|
-- ADDER AND SUBTRACTOR
|
-- ADDER AND SUBTRACTOR
|
---------------------------------------------------------------
|
---------------------------------------------------------------
|
adder : entity common_add_sub_lib.common_add_sub
|
adder : entity astron_adder_lib.common_add_sub
|
generic map (
|
generic map (
|
g_direction => "ADD",
|
g_direction => "ADD",
|
g_representation => "SIGNED",
|
g_representation => "SIGNED",
|
g_pipeline_input => 0,
|
g_pipeline_input => 0,
|
g_pipeline_output => 1,
|
g_pipeline_output => 1,
|
Line 113... |
Line 113... |
in_a => r.add_reg_a,
|
in_a => r.add_reg_a,
|
in_b => r.add_reg_b,
|
in_b => r.add_reg_b,
|
result => add_result
|
result => add_result
|
);
|
);
|
|
|
subtractor : entity common_add_sub_lib.common_add_sub
|
subtractor : entity astron_adder_lib.common_add_sub
|
generic map (
|
generic map (
|
g_direction => "SUB",
|
g_direction => "SUB",
|
g_representation => "SIGNED",
|
g_representation => "SIGNED",
|
g_pipeline_input => 0,
|
g_pipeline_input => 0,
|
g_pipeline_output => 1,
|
g_pipeline_output => 1,
|
Line 137... |
Line 137... |
sub_result_q <= sub_result(c_data_w downto 1);
|
sub_result_q <= sub_result(c_data_w downto 1);
|
end generate;
|
end generate;
|
|
|
gen_sepa_round : IF c_sepa_round=TRUE GENERATE
|
gen_sepa_round : IF c_sepa_round=TRUE GENERATE
|
-- round the one LSbit
|
-- round the one LSbit
|
round_add : ENTITY common_requantize_lib.common_round
|
round_add : ENTITY astron_requantize_lib.common_round
|
GENERIC MAP (
|
GENERIC MAP (
|
g_representation => "SIGNED", -- SIGNED (round +-0.5 away from zero to +- infinity) or UNSIGNED rounding (round 0.5 up to + inifinity)
|
g_representation => "SIGNED", -- SIGNED (round +-0.5 away from zero to +- infinity) or UNSIGNED rounding (round 0.5 up to + inifinity)
|
g_round => TRUE, -- when TRUE round the input, else truncate the input
|
g_round => TRUE, -- when TRUE round the input, else truncate the input
|
g_round_clip => FALSE, -- when TRUE clip rounded input >= +max to avoid wrapping to output -min (signed) or 0 (unsigned)
|
g_round_clip => FALSE, -- when TRUE clip rounded input >= +max to avoid wrapping to output -min (signed) or 0 (unsigned)
|
g_pipeline_input => 0, -- >= 0
|
g_pipeline_input => 0, -- >= 0
|
Line 153... |
Line 153... |
clk => clk,
|
clk => clk,
|
in_dat => add_result,
|
in_dat => add_result,
|
out_dat => add_result_q
|
out_dat => add_result_q
|
);
|
);
|
|
|
round_sub : ENTITY common_requantize_lib.common_round
|
round_sub : ENTITY astron_requantize_lib.common_round
|
GENERIC MAP (
|
GENERIC MAP (
|
g_representation => "SIGNED", -- SIGNED (round +-0.5 away from zero to +- infinity) or UNSIGNED rounding (round 0.5 up to + inifinity)
|
g_representation => "SIGNED", -- SIGNED (round +-0.5 away from zero to +- infinity) or UNSIGNED rounding (round 0.5 up to + inifinity)
|
g_round => TRUE, -- when TRUE round the input, else truncate the input
|
g_round => TRUE, -- when TRUE round the input, else truncate the input
|
g_round_clip => FALSE, -- when TRUE clip rounded input >= +max to avoid wrapping to output -min (signed) or 0 (unsigned)
|
g_round_clip => FALSE, -- when TRUE clip rounded input >= +max to avoid wrapping to output -min (signed) or 0 (unsigned)
|
g_pipeline_input => 0, -- >= 0
|
g_pipeline_input => 0, -- >= 0
|