CRLF
git-svn-id: http://moon:8086/svn/vhdl/trunk@1050 cc03376c-175c-47c8-b038-4cd826a8556b
This commit is contained in:
@@ -1,104 +1,104 @@
|
|||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
-- Company:
|
-- Company:
|
||||||
-- Engineer:
|
-- Engineer:
|
||||||
--
|
--
|
||||||
-- Create Date: 12:16:14 10/02/05
|
-- Create Date: 12:16:14 10/02/05
|
||||||
-- Design Name:
|
-- Design Name:
|
||||||
-- Module Name: cordic_stage_pre - Behavioral
|
-- Module Name: cordic_stage_pre - Behavioral
|
||||||
-- Project Name:
|
-- Project Name:
|
||||||
-- Target Device:
|
-- Target Device:
|
||||||
-- Tool versions:
|
-- Tool versions:
|
||||||
-- Description:
|
-- Description:
|
||||||
--
|
--
|
||||||
-- Dependencies:
|
-- Dependencies:
|
||||||
--
|
--
|
||||||
-- Revision:
|
-- Revision:
|
||||||
-- Revision 0.01 - File Created
|
-- Revision 0.01 - File Created
|
||||||
-- Additional Comments:
|
-- Additional Comments:
|
||||||
--
|
--
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
LIBRARY IEEE;
|
LIBRARY IEEE;
|
||||||
USE IEEE.STD_LOGIC_1164.ALL;
|
USE IEEE.STD_LOGIC_1164.ALL;
|
||||||
USE IEEE.NUMERIC_STD.ALL;
|
USE IEEE.NUMERIC_STD.ALL;
|
||||||
|
|
||||||
library ieee_proposed;
|
library ieee_proposed;
|
||||||
use ieee_proposed.math_utility_pkg.all;
|
use ieee_proposed.math_utility_pkg.all;
|
||||||
use ieee_proposed.fixed_pkg.all;
|
use ieee_proposed.fixed_pkg.all;
|
||||||
|
|
||||||
library work;
|
library work;
|
||||||
use work.fixed_util_pkg.all;
|
use work.fixed_util_pkg.all;
|
||||||
|
|
||||||
---- Uncomment the following library declaration if instantiating
|
---- Uncomment the following library declaration if instantiating
|
||||||
---- any Xilinx primitives in this code.
|
---- any Xilinx primitives in this code.
|
||||||
--library UNISIM;
|
--library UNISIM;
|
||||||
--use UNISIM.VComponents.all;
|
--use UNISIM.VComponents.all;
|
||||||
|
|
||||||
entity cic_c_pipe is
|
entity cic_c_pipe is
|
||||||
Generic
|
Generic
|
||||||
(
|
(
|
||||||
max_diff_delay : integer := 1;
|
max_diff_delay : integer := 1;
|
||||||
max_width : integer := 32;
|
max_width : integer := 32;
|
||||||
max_width_frac : integer := 20
|
max_width_frac : integer := 20
|
||||||
);
|
);
|
||||||
Port
|
Port
|
||||||
(
|
(
|
||||||
clk : in std_logic;
|
clk : in std_logic;
|
||||||
rst : in std_logic;
|
rst : in std_logic;
|
||||||
vld_in : in std_logic;
|
vld_in : in std_logic;
|
||||||
diff_delay : in natural range 1 to max_diff_delay;
|
diff_delay : in natural range 1 to max_diff_delay;
|
||||||
din : in sfixed;
|
din : in sfixed;
|
||||||
dout : out sfixed;
|
dout : out sfixed;
|
||||||
vld_out : out std_logic
|
vld_out : out std_logic
|
||||||
);
|
);
|
||||||
end cic_c_pipe;
|
end cic_c_pipe;
|
||||||
|
|
||||||
architecture Behavioral of cic_c_pipe is
|
architecture Behavioral of cic_c_pipe is
|
||||||
|
|
||||||
subtype word_t is sfixed(shi(max_width, max_width_frac) downto slo(max_width, max_width_frac));
|
subtype word_t is sfixed(shi(max_width, max_width_frac) downto slo(max_width, max_width_frac));
|
||||||
type word_pipe_t is array (1 to max_diff_delay) of word_t;
|
type word_pipe_t is array (1 to max_diff_delay) of word_t;
|
||||||
|
|
||||||
signal word_pipe : word_pipe_t;
|
signal word_pipe : word_pipe_t;
|
||||||
|
|
||||||
------------------------------------------------------------
|
------------------------------------------------------------
|
||||||
begin
|
begin
|
||||||
|
|
||||||
------------------------------------------------------------
|
------------------------------------------------------------
|
||||||
delay_pipe_proc:
|
delay_pipe_proc:
|
||||||
process(clk)
|
process(clk)
|
||||||
begin
|
begin
|
||||||
if rising_edge(clk) then
|
if rising_edge(clk) then
|
||||||
if rst = '1' then
|
if rst = '1' then
|
||||||
-- for i in 1 to max_diff_delay loop
|
-- for i in 1 to max_diff_delay loop
|
||||||
-- word_pipe(i) <= (shi(max_width, max_width_frac) downto slo(max_width, max_width_frac) => '0');
|
-- word_pipe(i) <= (shi(max_width, max_width_frac) downto slo(max_width, max_width_frac) => '0');
|
||||||
-- end loop;
|
-- end loop;
|
||||||
elsif vld_in = '1' then
|
elsif vld_in = '1' then
|
||||||
word_pipe(1) <= resize(din, word_pipe(1));
|
word_pipe(1) <= resize(din, word_pipe(1));
|
||||||
for i in 2 to max_diff_delay loop
|
for i in 2 to max_diff_delay loop
|
||||||
word_pipe(i) <= word_pipe(i-1);
|
word_pipe(i) <= word_pipe(i-1);
|
||||||
end loop;
|
end loop;
|
||||||
end if;
|
end if;
|
||||||
end if;
|
end if;
|
||||||
end process;
|
end process;
|
||||||
|
|
||||||
------------------------------------------------------------
|
------------------------------------------------------------
|
||||||
comb_proc:
|
comb_proc:
|
||||||
process(clk)
|
process(clk)
|
||||||
variable x0, x1 : sfixed(shi(max_width, max_width_frac) downto slo(max_width, max_width_frac));
|
variable x0, x1 : sfixed(shi(max_width, max_width_frac) downto slo(max_width, max_width_frac));
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if rising_edge(clk) then
|
if rising_edge(clk) then
|
||||||
vld_out <= '0';
|
vld_out <= '0';
|
||||||
x0 := resize(din, x0);
|
x0 := resize(din, x0);
|
||||||
x1 := word_pipe(diff_delay);
|
x1 := word_pipe(diff_delay);
|
||||||
if rst = '1' then
|
if rst = '1' then
|
||||||
dout <= (shi(max_width, max_width_frac) downto slo(max_width, max_width_frac) => '0');
|
dout <= (shi(max_width, max_width_frac) downto slo(max_width, max_width_frac) => '0');
|
||||||
elsif vld_in = '1' then
|
elsif vld_in = '1' then
|
||||||
vld_out <= '1';
|
vld_out <= '1';
|
||||||
dout <= resize(x0 - x1, shi(max_width, max_width_frac), slo(max_width, max_width_frac));
|
dout <= resize(x0 - x1, shi(max_width, max_width_frac), slo(max_width, max_width_frac));
|
||||||
end if;
|
end if;
|
||||||
end if;
|
end if;
|
||||||
end process;
|
end process;
|
||||||
|
|
||||||
------------------------------------------------------------
|
------------------------------------------------------------
|
||||||
end Behavioral;
|
end Behavioral;
|
||||||
|
|
||||||
|
|||||||
@@ -1,203 +1,203 @@
|
|||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
-- Company:
|
-- Company:
|
||||||
-- Engineer:
|
-- Engineer:
|
||||||
--
|
--
|
||||||
-- Create Date: 17:16:42 13.05.2007
|
-- Create Date: 17:16:42 13.05.2007
|
||||||
-- Design Name: tb_mix_cpx
|
-- Design Name: tb_mix_cpx
|
||||||
-- Module Name: tb_mix_cpx.vhd
|
-- Module Name: tb_mix_cpx.vhd
|
||||||
-- Project Name: mix_cpx
|
-- Project Name: mix_cpx
|
||||||
-- Target Device:
|
-- Target Device:
|
||||||
-- Tool versions:
|
-- Tool versions:
|
||||||
-- Description:
|
-- Description:
|
||||||
--
|
--
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
LIBRARY ieee;
|
LIBRARY ieee;
|
||||||
use IEEE.STD_LOGIC_1164.ALL;
|
use IEEE.STD_LOGIC_1164.ALL;
|
||||||
use IEEE.MATH_REAL.ALL;
|
use IEEE.MATH_REAL.ALL;
|
||||||
USE ieee.numeric_std.ALL;
|
USE ieee.numeric_std.ALL;
|
||||||
|
|
||||||
library ieee_proposed;
|
library ieee_proposed;
|
||||||
use ieee_proposed.math_utility_pkg.all;
|
use ieee_proposed.math_utility_pkg.all;
|
||||||
use ieee_proposed.fixed_pkg.all;
|
use ieee_proposed.fixed_pkg.all;
|
||||||
|
|
||||||
library work;
|
library work;
|
||||||
use work.fixed_util_pkg.all;
|
use work.fixed_util_pkg.all;
|
||||||
use work.utils_pkg.all;
|
use work.utils_pkg.all;
|
||||||
|
|
||||||
ENTITY cic_decim_pipe IS
|
ENTITY cic_decim_pipe IS
|
||||||
Generic
|
Generic
|
||||||
(
|
(
|
||||||
nstages : integer := 3;
|
nstages : integer := 3;
|
||||||
diff_delay : integer := 1;
|
diff_delay : integer := 1;
|
||||||
ratio : integer := 64;
|
ratio : integer := 64;
|
||||||
scale_nbits : integer := 9;
|
scale_nbits : integer := 9;
|
||||||
in_width : integer := 32;
|
in_width : integer := 32;
|
||||||
in_width_frac : integer := 20;
|
in_width_frac : integer := 20;
|
||||||
out_width : integer := 32;
|
out_width : integer := 32;
|
||||||
out_width_frac : integer := 20
|
out_width_frac : integer := 20
|
||||||
);
|
);
|
||||||
Port
|
Port
|
||||||
(
|
(
|
||||||
clk : in std_logic;
|
clk : in std_logic;
|
||||||
rst : in std_logic;
|
rst : in std_logic;
|
||||||
vld_in : in std_logic;
|
vld_in : in std_logic;
|
||||||
din : in sfixed;
|
din : in sfixed;
|
||||||
dout : out sfixed;
|
dout : out sfixed;
|
||||||
vld_out : out std_logic
|
vld_out : out std_logic
|
||||||
);
|
);
|
||||||
END cic_decim_pipe;
|
END cic_decim_pipe;
|
||||||
|
|
||||||
ARCHITECTURE behavior OF cic_decim_pipe IS
|
ARCHITECTURE behavior OF cic_decim_pipe IS
|
||||||
|
|
||||||
COMPONENT cic_i_pipe
|
COMPONENT cic_i_pipe
|
||||||
GENERIC
|
GENERIC
|
||||||
(
|
(
|
||||||
max_width : integer;
|
max_width : integer;
|
||||||
max_width_frac : integer
|
max_width_frac : integer
|
||||||
);
|
);
|
||||||
PORT
|
PORT
|
||||||
(
|
(
|
||||||
clk : in std_logic;
|
clk : in std_logic;
|
||||||
rst : in std_logic;
|
rst : in std_logic;
|
||||||
vld_in : in std_logic;
|
vld_in : in std_logic;
|
||||||
din : in sfixed;
|
din : in sfixed;
|
||||||
dout : out sfixed;
|
dout : out sfixed;
|
||||||
vld_out : out std_logic
|
vld_out : out std_logic
|
||||||
);
|
);
|
||||||
END COMPONENT;
|
END COMPONENT;
|
||||||
|
|
||||||
COMPONENT cic_c_pipe
|
COMPONENT cic_c_pipe
|
||||||
GENERIC
|
GENERIC
|
||||||
(
|
(
|
||||||
max_diff_delay : integer;
|
max_diff_delay : integer;
|
||||||
max_width : integer;
|
max_width : integer;
|
||||||
max_width_frac : integer
|
max_width_frac : integer
|
||||||
);
|
);
|
||||||
PORT
|
PORT
|
||||||
(
|
(
|
||||||
clk : in std_logic;
|
clk : in std_logic;
|
||||||
rst : in std_logic;
|
rst : in std_logic;
|
||||||
vld_in : in std_logic;
|
vld_in : in std_logic;
|
||||||
diff_delay : in natural range 1 to max_diff_delay;
|
diff_delay : in natural range 1 to max_diff_delay;
|
||||||
din : in sfixed;
|
din : in sfixed;
|
||||||
dout : out sfixed;
|
dout : out sfixed;
|
||||||
vld_out : out std_logic
|
vld_out : out std_logic
|
||||||
);
|
);
|
||||||
END COMPONENT;
|
END COMPONENT;
|
||||||
|
|
||||||
constant max_gain_bits : natural := natural(NextExpBaseTwo(real(ratio)**real(nstages)));
|
constant max_gain_bits : natural := natural(NextExpBaseTwo(real(ratio)**real(nstages)));
|
||||||
|
|
||||||
constant integ_nbits : natural := in_width + max_gain_bits;
|
constant integ_nbits : natural := in_width + max_gain_bits;
|
||||||
constant integ_nbits_frac : natural := integ_nbits - (in_width - in_width_frac);
|
constant integ_nbits_frac : natural := integ_nbits - (in_width - in_width_frac);
|
||||||
|
|
||||||
constant comb_nbits : natural := out_width+1;
|
constant comb_nbits : natural := out_width+1;
|
||||||
constant comb_nbits_frac : natural := out_width_frac+1;
|
constant comb_nbits_frac : natural := out_width_frac+1;
|
||||||
|
|
||||||
subtype word_i_t is sfixed(shi(integ_nbits, integ_nbits_frac) downto slo(integ_nbits, integ_nbits_frac));
|
subtype word_i_t is sfixed(shi(integ_nbits, integ_nbits_frac) downto slo(integ_nbits, integ_nbits_frac));
|
||||||
type word_i_pipe_t is array (0 to nstages) of word_i_t;
|
type word_i_pipe_t is array (0 to nstages) of word_i_t;
|
||||||
|
|
||||||
signal word_i_pipe : word_i_pipe_t;
|
signal word_i_pipe : word_i_pipe_t;
|
||||||
signal vld_i_pipe : unsigned (0 to nstages);
|
signal vld_i_pipe : unsigned (0 to nstages);
|
||||||
signal vld_i : std_logic;
|
signal vld_i : std_logic;
|
||||||
|
|
||||||
subtype word_c_t is sfixed(shi(comb_nbits, comb_nbits_frac) downto slo(comb_nbits, comb_nbits_frac));
|
subtype word_c_t is sfixed(shi(comb_nbits, comb_nbits_frac) downto slo(comb_nbits, comb_nbits_frac));
|
||||||
type word_c_pipe_t is array (0 to nstages) of word_c_t;
|
type word_c_pipe_t is array (0 to nstages) of word_c_t;
|
||||||
|
|
||||||
signal word_c_pipe : word_c_pipe_t;
|
signal word_c_pipe : word_c_pipe_t;
|
||||||
signal vld_c_pipe : unsigned (0 to nstages);
|
signal vld_c_pipe : unsigned (0 to nstages);
|
||||||
signal vld_c : std_logic;
|
signal vld_c : std_logic;
|
||||||
|
|
||||||
signal resample_cnt : natural range 1 to ratio;
|
signal resample_cnt : natural range 1 to ratio;
|
||||||
signal resample_vld : std_logic;
|
signal resample_vld : std_logic;
|
||||||
|
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
||||||
assert false report "max_gain_bits = " & natural'image(max_gain_bits) & "." severity note;
|
assert false report "max_gain_bits = " & natural'image(max_gain_bits) & "." severity note;
|
||||||
assert false report "integ. prec. = " & natural'image(integ_nbits) & ":" & natural'image(integ_nbits_frac) & "." severity note;
|
assert false report "integ. prec. = " & natural'image(integ_nbits) & ":" & natural'image(integ_nbits_frac) & "." severity note;
|
||||||
assert false report "comb prec. = " & natural'image(comb_nbits) & ":" & natural'image(comb_nbits_frac) & "." severity note;
|
assert false report "comb prec. = " & natural'image(comb_nbits) & ":" & natural'image(comb_nbits_frac) & "." severity note;
|
||||||
|
|
||||||
vld_i <= vld_i_pipe(nstages);
|
vld_i <= vld_i_pipe(nstages);
|
||||||
|
|
||||||
input_scale:
|
input_scale:
|
||||||
process(clk)
|
process(clk)
|
||||||
variable x : sfixed(shi(integ_nbits, integ_nbits_frac) downto slo(integ_nbits, integ_nbits_frac));
|
variable x : sfixed(shi(integ_nbits, integ_nbits_frac) downto slo(integ_nbits, integ_nbits_frac));
|
||||||
variable xs : sfixed(shi(integ_nbits, integ_nbits_frac) downto slo(integ_nbits, integ_nbits_frac));
|
variable xs : sfixed(shi(integ_nbits, integ_nbits_frac) downto slo(integ_nbits, integ_nbits_frac));
|
||||||
variable xsi : sfixed(shi(integ_nbits, integ_nbits_frac) downto slo(integ_nbits, integ_nbits_frac));
|
variable xsi : sfixed(shi(integ_nbits, integ_nbits_frac) downto slo(integ_nbits, integ_nbits_frac));
|
||||||
begin
|
begin
|
||||||
if rising_edge(clk) then
|
if rising_edge(clk) then
|
||||||
x := resize(din, x);
|
x := resize(din, x);
|
||||||
xs := x sra scale_nbits;
|
xs := x sra scale_nbits;
|
||||||
word_i_pipe(0) <= xs;
|
word_i_pipe(0) <= xs;
|
||||||
vld_i_pipe(0) <= vld_in;
|
vld_i_pipe(0) <= vld_in;
|
||||||
end if;
|
end if;
|
||||||
end process;
|
end process;
|
||||||
|
|
||||||
gen_i_stages:
|
gen_i_stages:
|
||||||
for i in 1 to nstages generate
|
for i in 1 to nstages generate
|
||||||
begin
|
begin
|
||||||
inst_cic_i_pipe: cic_i_pipe
|
inst_cic_i_pipe: cic_i_pipe
|
||||||
GENERIC MAP
|
GENERIC MAP
|
||||||
(
|
(
|
||||||
max_width => integ_nbits,
|
max_width => integ_nbits,
|
||||||
max_width_frac => integ_nbits_frac
|
max_width_frac => integ_nbits_frac
|
||||||
)
|
)
|
||||||
PORT MAP
|
PORT MAP
|
||||||
(
|
(
|
||||||
clk => clk,
|
clk => clk,
|
||||||
rst => rst,
|
rst => rst,
|
||||||
vld_in => vld_i_pipe(i-1),
|
vld_in => vld_i_pipe(i-1),
|
||||||
din => word_i_pipe(i-1),
|
din => word_i_pipe(i-1),
|
||||||
dout => word_i_pipe(i),
|
dout => word_i_pipe(i),
|
||||||
vld_out => vld_i_pipe(i)
|
vld_out => vld_i_pipe(i)
|
||||||
);
|
);
|
||||||
end generate;
|
end generate;
|
||||||
|
|
||||||
word_c_pipe(0) <= resize(word_i_pipe(nstages), word_c_pipe(0), fixed_wrap, fixed_truncate);
|
word_c_pipe(0) <= resize(word_i_pipe(nstages), word_c_pipe(0), fixed_wrap, fixed_truncate);
|
||||||
vld_c_pipe(0) <= resample_vld;
|
vld_c_pipe(0) <= resample_vld;
|
||||||
vld_c <= vld_c_pipe(nstages);
|
vld_c <= vld_c_pipe(nstages);
|
||||||
|
|
||||||
vld_out <= vld_c;
|
vld_out <= vld_c;
|
||||||
|
|
||||||
gen_c_stages:
|
gen_c_stages:
|
||||||
for i in 1 to nstages generate
|
for i in 1 to nstages generate
|
||||||
begin
|
begin
|
||||||
inst_cic_c_pipe: cic_c_pipe
|
inst_cic_c_pipe: cic_c_pipe
|
||||||
GENERIC MAP
|
GENERIC MAP
|
||||||
(
|
(
|
||||||
max_diff_delay => diff_delay,
|
max_diff_delay => diff_delay,
|
||||||
max_width => comb_nbits,
|
max_width => comb_nbits,
|
||||||
max_width_frac => comb_nbits_frac
|
max_width_frac => comb_nbits_frac
|
||||||
)
|
)
|
||||||
PORT MAP
|
PORT MAP
|
||||||
(
|
(
|
||||||
clk => clk,
|
clk => clk,
|
||||||
rst => rst,
|
rst => rst,
|
||||||
vld_in => vld_c_pipe(i-1),
|
vld_in => vld_c_pipe(i-1),
|
||||||
diff_delay => diff_delay,
|
diff_delay => diff_delay,
|
||||||
din => word_c_pipe(i-1),
|
din => word_c_pipe(i-1),
|
||||||
dout => word_c_pipe(i),
|
dout => word_c_pipe(i),
|
||||||
vld_out => vld_c_pipe(i)
|
vld_out => vld_c_pipe(i)
|
||||||
);
|
);
|
||||||
end generate;
|
end generate;
|
||||||
|
|
||||||
resampler_proc:
|
resampler_proc:
|
||||||
process(clk)
|
process(clk)
|
||||||
begin
|
begin
|
||||||
if rising_edge(clk) then
|
if rising_edge(clk) then
|
||||||
resample_vld <= '0';
|
resample_vld <= '0';
|
||||||
if rst = '1' then
|
if rst = '1' then
|
||||||
resample_cnt <= 1;
|
resample_cnt <= 1;
|
||||||
elsif vld_i = '1' then
|
elsif vld_i = '1' then
|
||||||
if resample_cnt = ratio then
|
if resample_cnt = ratio then
|
||||||
resample_vld <= '1';
|
resample_vld <= '1';
|
||||||
resample_cnt <= 1;
|
resample_cnt <= 1;
|
||||||
else
|
else
|
||||||
resample_cnt <= resample_cnt + 1;
|
resample_cnt <= resample_cnt + 1;
|
||||||
end if ;
|
end if ;
|
||||||
end if;
|
end if;
|
||||||
end if;
|
end if;
|
||||||
end process;
|
end process;
|
||||||
|
|
||||||
dout <= resize(word_c_pipe(nstages), shi(out_width, out_width_frac), slo(out_width, out_width_frac));
|
dout <= resize(word_c_pipe(nstages), shi(out_width, out_width_frac), slo(out_width, out_width_frac));
|
||||||
|
|
||||||
END;
|
END;
|
||||||
|
|||||||
@@ -1,81 +1,81 @@
|
|||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
-- Company:
|
-- Company:
|
||||||
-- Engineer:
|
-- Engineer:
|
||||||
--
|
--
|
||||||
-- Create Date: 12:16:14 10/02/05
|
-- Create Date: 12:16:14 10/02/05
|
||||||
-- Design Name:
|
-- Design Name:
|
||||||
-- Module Name: cordic_stage_pre - Behavioral
|
-- Module Name: cordic_stage_pre - Behavioral
|
||||||
-- Project Name:
|
-- Project Name:
|
||||||
-- Target Device:
|
-- Target Device:
|
||||||
-- Tool versions:
|
-- Tool versions:
|
||||||
-- Description:
|
-- Description:
|
||||||
--
|
--
|
||||||
-- Dependencies:
|
-- Dependencies:
|
||||||
--
|
--
|
||||||
-- Revision:
|
-- Revision:
|
||||||
-- Revision 0.01 - File Created
|
-- Revision 0.01 - File Created
|
||||||
-- Additional Comments:
|
-- Additional Comments:
|
||||||
--
|
--
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
LIBRARY IEEE;
|
LIBRARY IEEE;
|
||||||
USE IEEE.STD_LOGIC_1164.ALL;
|
USE IEEE.STD_LOGIC_1164.ALL;
|
||||||
USE IEEE.NUMERIC_STD.ALL;
|
USE IEEE.NUMERIC_STD.ALL;
|
||||||
|
|
||||||
library ieee_proposed;
|
library ieee_proposed;
|
||||||
use ieee_proposed.math_utility_pkg.all;
|
use ieee_proposed.math_utility_pkg.all;
|
||||||
use ieee_proposed.fixed_pkg.all;
|
use ieee_proposed.fixed_pkg.all;
|
||||||
|
|
||||||
library work;
|
library work;
|
||||||
use work.fixed_util_pkg.all;
|
use work.fixed_util_pkg.all;
|
||||||
|
|
||||||
---- Uncomment the following library declaration if instantiating
|
---- Uncomment the following library declaration if instantiating
|
||||||
---- any Xilinx primitives in this code.
|
---- any Xilinx primitives in this code.
|
||||||
--library UNISIM;
|
--library UNISIM;
|
||||||
--use UNISIM.VComponents.all;
|
--use UNISIM.VComponents.all;
|
||||||
|
|
||||||
entity cic_i_pipe is
|
entity cic_i_pipe is
|
||||||
Generic
|
Generic
|
||||||
(
|
(
|
||||||
max_width : integer := 32;
|
max_width : integer := 32;
|
||||||
max_width_frac : integer := 20
|
max_width_frac : integer := 20
|
||||||
);
|
);
|
||||||
Port
|
Port
|
||||||
(
|
(
|
||||||
clk : in std_logic;
|
clk : in std_logic;
|
||||||
rst : in std_logic;
|
rst : in std_logic;
|
||||||
vld_in : in std_logic;
|
vld_in : in std_logic;
|
||||||
din : in sfixed;
|
din : in sfixed;
|
||||||
dout : out sfixed;
|
dout : out sfixed;
|
||||||
vld_out : out std_logic
|
vld_out : out std_logic
|
||||||
);
|
);
|
||||||
end cic_i_pipe;
|
end cic_i_pipe;
|
||||||
|
|
||||||
architecture Behavioral of cic_i_pipe is
|
architecture Behavioral of cic_i_pipe is
|
||||||
|
|
||||||
signal accu : sfixed(shi(max_width, max_width_frac) downto slo(max_width, max_width_frac));
|
signal accu : sfixed(shi(max_width, max_width_frac) downto slo(max_width, max_width_frac));
|
||||||
|
|
||||||
------------------------------------------------------------
|
------------------------------------------------------------
|
||||||
begin
|
begin
|
||||||
|
|
||||||
dout <= resize(accu, shi(max_width, max_width_frac), slo(max_width, max_width_frac));
|
dout <= resize(accu, shi(max_width, max_width_frac), slo(max_width, max_width_frac));
|
||||||
|
|
||||||
------------------------------------------------------------
|
------------------------------------------------------------
|
||||||
integ_proc:
|
integ_proc:
|
||||||
process(clk)
|
process(clk)
|
||||||
variable x : sfixed(shi(max_width, max_width_frac) downto slo(max_width, max_width_frac));
|
variable x : sfixed(shi(max_width, max_width_frac) downto slo(max_width, max_width_frac));
|
||||||
begin
|
begin
|
||||||
if rising_edge(clk) then
|
if rising_edge(clk) then
|
||||||
vld_out <= '0';
|
vld_out <= '0';
|
||||||
if rst = '1' then
|
if rst = '1' then
|
||||||
accu <= (shi(max_width, max_width_frac) downto slo(max_width, max_width_frac) => '0');
|
accu <= (shi(max_width, max_width_frac) downto slo(max_width, max_width_frac) => '0');
|
||||||
elsif vld_in = '1' then
|
elsif vld_in = '1' then
|
||||||
vld_out <= '1';
|
vld_out <= '1';
|
||||||
x := resize(din, x);
|
x := resize(din, x);
|
||||||
accu <= resize(x + accu, accu);
|
accu <= resize(x + accu, accu);
|
||||||
end if;
|
end if;
|
||||||
end if;
|
end if;
|
||||||
end process;
|
end process;
|
||||||
|
|
||||||
------------------------------------------------------------
|
------------------------------------------------------------
|
||||||
end Behavioral;
|
end Behavioral;
|
||||||
|
|
||||||
|
|||||||
@@ -1,98 +1,98 @@
|
|||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
-- Company:
|
-- Company:
|
||||||
-- Engineer:
|
-- Engineer:
|
||||||
--
|
--
|
||||||
-- Create Date: 17:16:42 13.05.2007
|
-- Create Date: 17:16:42 13.05.2007
|
||||||
-- Design Name: tb_mix_cpx
|
-- Design Name: tb_mix_cpx
|
||||||
-- Module Name: tb_mix_cpx.vhd
|
-- Module Name: tb_mix_cpx.vhd
|
||||||
-- Project Name: mix_cpx
|
-- Project Name: mix_cpx
|
||||||
-- Target Device:
|
-- Target Device:
|
||||||
-- Tool versions:
|
-- Tool versions:
|
||||||
-- Description:
|
-- Description:
|
||||||
--
|
--
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
LIBRARY ieee;
|
LIBRARY ieee;
|
||||||
use IEEE.STD_LOGIC_1164.ALL;
|
use IEEE.STD_LOGIC_1164.ALL;
|
||||||
use IEEE.MATH_REAL.ALL;
|
use IEEE.MATH_REAL.ALL;
|
||||||
USE ieee.numeric_std.ALL;
|
USE ieee.numeric_std.ALL;
|
||||||
use std.textio.all; -- Imports the standard textio package.
|
use std.textio.all; -- Imports the standard textio package.
|
||||||
|
|
||||||
library ieee_proposed;
|
library ieee_proposed;
|
||||||
use ieee_proposed.math_utility_pkg.all;
|
use ieee_proposed.math_utility_pkg.all;
|
||||||
use ieee_proposed.fixed_pkg.all;
|
use ieee_proposed.fixed_pkg.all;
|
||||||
|
|
||||||
library work;
|
library work;
|
||||||
use work.fixed_util_pkg.all;
|
use work.fixed_util_pkg.all;
|
||||||
|
|
||||||
entity syn_cic_c_pipe is
|
entity syn_cic_c_pipe is
|
||||||
Generic
|
Generic
|
||||||
(
|
(
|
||||||
max_diff_delay : integer := 2;
|
max_diff_delay : integer := 2;
|
||||||
max_width : integer := 32;
|
max_width : integer := 32;
|
||||||
max_width_frac : integer := 20
|
max_width_frac : integer := 20
|
||||||
);
|
);
|
||||||
Port
|
Port
|
||||||
(
|
(
|
||||||
clk : in std_logic;
|
clk : in std_logic;
|
||||||
rst : in std_logic;
|
rst : in std_logic;
|
||||||
vld_in : in std_logic;
|
vld_in : in std_logic;
|
||||||
diff_delay : in natural range 1 to max_diff_delay;
|
diff_delay : in natural range 1 to max_diff_delay;
|
||||||
din : in signed(max_width-1 downto 0);
|
din : in signed(max_width-1 downto 0);
|
||||||
dout : out signed(max_width-1 downto 0);
|
dout : out signed(max_width-1 downto 0);
|
||||||
vld_out : out std_logic
|
vld_out : out std_logic
|
||||||
);
|
);
|
||||||
end syn_cic_c_pipe;
|
end syn_cic_c_pipe;
|
||||||
|
|
||||||
ARCHITECTURE behavior OF syn_cic_c_pipe IS
|
ARCHITECTURE behavior OF syn_cic_c_pipe IS
|
||||||
|
|
||||||
-- Component Declaration for the Unit Under Test (UUT)
|
-- Component Declaration for the Unit Under Test (UUT)
|
||||||
COMPONENT cic_c_pipe
|
COMPONENT cic_c_pipe
|
||||||
GENERIC
|
GENERIC
|
||||||
(
|
(
|
||||||
max_diff_delay : integer;
|
max_diff_delay : integer;
|
||||||
max_width : integer;
|
max_width : integer;
|
||||||
max_width_frac : integer
|
max_width_frac : integer
|
||||||
);
|
);
|
||||||
PORT
|
PORT
|
||||||
(
|
(
|
||||||
clk : in std_logic;
|
clk : in std_logic;
|
||||||
rst : in std_logic;
|
rst : in std_logic;
|
||||||
vld_in : in std_logic;
|
vld_in : in std_logic;
|
||||||
diff_delay : in natural range 1 to max_diff_delay;
|
diff_delay : in natural range 1 to max_diff_delay;
|
||||||
din : in sfixed;
|
din : in sfixed;
|
||||||
dout : out sfixed;
|
dout : out sfixed;
|
||||||
vld_out : out std_logic
|
vld_out : out std_logic
|
||||||
);
|
);
|
||||||
END COMPONENT;
|
END COMPONENT;
|
||||||
|
|
||||||
--Inputs
|
--Inputs
|
||||||
SIGNAL sdin : sfixed(shi(max_width, max_width_frac) downto slo(max_width, max_width_frac));
|
SIGNAL sdin : sfixed(shi(max_width, max_width_frac) downto slo(max_width, max_width_frac));
|
||||||
|
|
||||||
--Outputs
|
--Outputs
|
||||||
SIGNAL sdout : sfixed(shi(max_width, max_width_frac) downto slo(max_width, max_width_frac));
|
SIGNAL sdout : sfixed(shi(max_width, max_width_frac) downto slo(max_width, max_width_frac));
|
||||||
|
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
||||||
-- Instantiate the Unit Under Test (UUT)
|
-- Instantiate the Unit Under Test (UUT)
|
||||||
uut: cic_c_pipe
|
uut: cic_c_pipe
|
||||||
GENERIC MAP
|
GENERIC MAP
|
||||||
(
|
(
|
||||||
max_diff_delay => max_diff_delay,
|
max_diff_delay => max_diff_delay,
|
||||||
max_width => max_width,
|
max_width => max_width,
|
||||||
max_width_frac => max_width_frac
|
max_width_frac => max_width_frac
|
||||||
)
|
)
|
||||||
PORT MAP
|
PORT MAP
|
||||||
(
|
(
|
||||||
clk => clk,
|
clk => clk,
|
||||||
rst => rst,
|
rst => rst,
|
||||||
vld_in => vld_in,
|
vld_in => vld_in,
|
||||||
diff_delay => diff_delay,
|
diff_delay => diff_delay,
|
||||||
din => sdin,
|
din => sdin,
|
||||||
dout => sdout,
|
dout => sdout,
|
||||||
vld_out => vld_out
|
vld_out => vld_out
|
||||||
);
|
);
|
||||||
|
|
||||||
sdin <= to_sfixed(din, shi(max_width, max_width_frac), slo(max_width, max_width_frac));
|
sdin <= to_sfixed(din, shi(max_width, max_width_frac), slo(max_width, max_width_frac));
|
||||||
dout <= signed(sdout);
|
dout <= signed(sdout);
|
||||||
|
|
||||||
END;
|
END;
|
||||||
|
|||||||
@@ -1,92 +1,92 @@
|
|||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
-- Company:
|
-- Company:
|
||||||
-- Engineer:
|
-- Engineer:
|
||||||
--
|
--
|
||||||
-- Create Date: 17:16:42 13.05.2007
|
-- Create Date: 17:16:42 13.05.2007
|
||||||
-- Design Name: tb_mix_cpx
|
-- Design Name: tb_mix_cpx
|
||||||
-- Module Name: tb_mix_cpx.vhd
|
-- Module Name: tb_mix_cpx.vhd
|
||||||
-- Project Name: mix_cpx
|
-- Project Name: mix_cpx
|
||||||
-- Target Device:
|
-- Target Device:
|
||||||
-- Tool versions:
|
-- Tool versions:
|
||||||
-- Description:
|
-- Description:
|
||||||
--
|
--
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
LIBRARY ieee;
|
LIBRARY ieee;
|
||||||
use IEEE.STD_LOGIC_1164.ALL;
|
use IEEE.STD_LOGIC_1164.ALL;
|
||||||
use IEEE.MATH_REAL.ALL;
|
use IEEE.MATH_REAL.ALL;
|
||||||
USE ieee.numeric_std.ALL;
|
USE ieee.numeric_std.ALL;
|
||||||
use std.textio.all; -- Imports the standard textio package.
|
use std.textio.all; -- Imports the standard textio package.
|
||||||
|
|
||||||
library ieee_proposed;
|
library ieee_proposed;
|
||||||
use ieee_proposed.math_utility_pkg.all;
|
use ieee_proposed.math_utility_pkg.all;
|
||||||
use ieee_proposed.fixed_pkg.all;
|
use ieee_proposed.fixed_pkg.all;
|
||||||
|
|
||||||
library work;
|
library work;
|
||||||
use work.fixed_util_pkg.all;
|
use work.fixed_util_pkg.all;
|
||||||
|
|
||||||
entity syn_cic_i_pipe is
|
entity syn_cic_i_pipe is
|
||||||
Generic
|
Generic
|
||||||
(
|
(
|
||||||
max_width : integer := 32;
|
max_width : integer := 32;
|
||||||
max_width_frac : integer := 20
|
max_width_frac : integer := 20
|
||||||
);
|
);
|
||||||
Port
|
Port
|
||||||
(
|
(
|
||||||
clk : in std_logic;
|
clk : in std_logic;
|
||||||
rst : in std_logic;
|
rst : in std_logic;
|
||||||
vld_in : in std_logic;
|
vld_in : in std_logic;
|
||||||
din : in signed(max_width-1 downto 0);
|
din : in signed(max_width-1 downto 0);
|
||||||
dout : out signed(max_width-1 downto 0);
|
dout : out signed(max_width-1 downto 0);
|
||||||
vld_out : out std_logic
|
vld_out : out std_logic
|
||||||
);
|
);
|
||||||
end syn_cic_i_pipe;
|
end syn_cic_i_pipe;
|
||||||
|
|
||||||
ARCHITECTURE behavior OF syn_cic_i_pipe IS
|
ARCHITECTURE behavior OF syn_cic_i_pipe IS
|
||||||
|
|
||||||
-- Component Declaration for the Unit Under Test (UUT)
|
-- Component Declaration for the Unit Under Test (UUT)
|
||||||
COMPONENT cic_i_pipe
|
COMPONENT cic_i_pipe
|
||||||
GENERIC
|
GENERIC
|
||||||
(
|
(
|
||||||
max_width : integer;
|
max_width : integer;
|
||||||
max_width_frac : integer
|
max_width_frac : integer
|
||||||
);
|
);
|
||||||
PORT
|
PORT
|
||||||
(
|
(
|
||||||
clk : in std_logic;
|
clk : in std_logic;
|
||||||
rst : in std_logic;
|
rst : in std_logic;
|
||||||
vld_in : in std_logic;
|
vld_in : in std_logic;
|
||||||
din : in sfixed;
|
din : in sfixed;
|
||||||
dout : out sfixed;
|
dout : out sfixed;
|
||||||
vld_out : out std_logic
|
vld_out : out std_logic
|
||||||
);
|
);
|
||||||
END COMPONENT;
|
END COMPONENT;
|
||||||
|
|
||||||
--Inputs
|
--Inputs
|
||||||
SIGNAL sdin : sfixed(shi(max_width, max_width_frac) downto slo(max_width, max_width_frac));
|
SIGNAL sdin : sfixed(shi(max_width, max_width_frac) downto slo(max_width, max_width_frac));
|
||||||
|
|
||||||
--Outputs
|
--Outputs
|
||||||
SIGNAL sdout : sfixed(shi(max_width, max_width_frac) downto slo(max_width, max_width_frac));
|
SIGNAL sdout : sfixed(shi(max_width, max_width_frac) downto slo(max_width, max_width_frac));
|
||||||
|
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
||||||
-- Instantiate the Unit Under Test (UUT)
|
-- Instantiate the Unit Under Test (UUT)
|
||||||
uut: cic_i_pipe
|
uut: cic_i_pipe
|
||||||
GENERIC MAP
|
GENERIC MAP
|
||||||
(
|
(
|
||||||
max_width => max_width,
|
max_width => max_width,
|
||||||
max_width_frac => max_width_frac
|
max_width_frac => max_width_frac
|
||||||
)
|
)
|
||||||
PORT MAP
|
PORT MAP
|
||||||
(
|
(
|
||||||
clk => clk,
|
clk => clk,
|
||||||
rst => rst,
|
rst => rst,
|
||||||
vld_in => vld_in,
|
vld_in => vld_in,
|
||||||
din => sdin,
|
din => sdin,
|
||||||
dout => sdout,
|
dout => sdout,
|
||||||
vld_out => vld_out
|
vld_out => vld_out
|
||||||
);
|
);
|
||||||
|
|
||||||
sdin <= to_sfixed(din, shi(max_width, max_width_frac), slo(max_width, max_width_frac));
|
sdin <= to_sfixed(din, shi(max_width, max_width_frac), slo(max_width, max_width_frac));
|
||||||
dout <= signed(sdout);
|
dout <= signed(sdout);
|
||||||
|
|
||||||
END;
|
END;
|
||||||
|
|||||||
@@ -1,136 +1,136 @@
|
|||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
-- Company:
|
-- Company:
|
||||||
-- Engineer:
|
-- Engineer:
|
||||||
--
|
--
|
||||||
-- Create Date: 17:16:42 13.05.2007
|
-- Create Date: 17:16:42 13.05.2007
|
||||||
-- Design Name: tb_mix_cpx
|
-- Design Name: tb_mix_cpx
|
||||||
-- Module Name: tb_mix_cpx.vhd
|
-- Module Name: tb_mix_cpx.vhd
|
||||||
-- Project Name: mix_cpx
|
-- Project Name: mix_cpx
|
||||||
-- Target Device:
|
-- Target Device:
|
||||||
-- Tool versions:
|
-- Tool versions:
|
||||||
-- Description:
|
-- Description:
|
||||||
--
|
--
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
LIBRARY ieee;
|
LIBRARY ieee;
|
||||||
use IEEE.STD_LOGIC_1164.ALL;
|
use IEEE.STD_LOGIC_1164.ALL;
|
||||||
use IEEE.MATH_REAL.ALL;
|
use IEEE.MATH_REAL.ALL;
|
||||||
USE ieee.numeric_std.ALL;
|
USE ieee.numeric_std.ALL;
|
||||||
use std.textio.all; -- Imports the standard textio package.
|
use std.textio.all; -- Imports the standard textio package.
|
||||||
|
|
||||||
library ieee_proposed;
|
library ieee_proposed;
|
||||||
use ieee_proposed.math_utility_pkg.all;
|
use ieee_proposed.math_utility_pkg.all;
|
||||||
use ieee_proposed.fixed_pkg.all;
|
use ieee_proposed.fixed_pkg.all;
|
||||||
|
|
||||||
library work;
|
library work;
|
||||||
use work.PCK_FIO.all;
|
use work.PCK_FIO.all;
|
||||||
use work.fixed_util_pkg.all;
|
use work.fixed_util_pkg.all;
|
||||||
|
|
||||||
ENTITY tb_cic_c_pipe IS
|
ENTITY tb_cic_c_pipe IS
|
||||||
Generic
|
Generic
|
||||||
(
|
(
|
||||||
max_width : integer := 32;
|
max_width : integer := 32;
|
||||||
max_width_frac : integer := 20
|
max_width_frac : integer := 20
|
||||||
);
|
);
|
||||||
END tb_cic_c_pipe;
|
END tb_cic_c_pipe;
|
||||||
|
|
||||||
ARCHITECTURE behavior OF tb_cic_c_pipe IS
|
ARCHITECTURE behavior OF tb_cic_c_pipe IS
|
||||||
|
|
||||||
-- Component Declaration for the Unit Under Test (UUT)
|
-- Component Declaration for the Unit Under Test (UUT)
|
||||||
COMPONENT cic_c_pipe
|
COMPONENT cic_c_pipe
|
||||||
GENERIC
|
GENERIC
|
||||||
(
|
(
|
||||||
max_diff_delay : integer;
|
max_diff_delay : integer;
|
||||||
max_width : integer;
|
max_width : integer;
|
||||||
max_width_frac : integer
|
max_width_frac : integer
|
||||||
);
|
);
|
||||||
PORT
|
PORT
|
||||||
(
|
(
|
||||||
clk : in std_logic;
|
clk : in std_logic;
|
||||||
rst : in std_logic;
|
rst : in std_logic;
|
||||||
vld_in : in std_logic;
|
vld_in : in std_logic;
|
||||||
diff_delay : in natural range 1 to max_diff_delay;
|
diff_delay : in natural range 1 to max_diff_delay;
|
||||||
din : in sfixed;
|
din : in sfixed;
|
||||||
dout : out sfixed;
|
dout : out sfixed;
|
||||||
vld_out : out std_logic
|
vld_out : out std_logic
|
||||||
);
|
);
|
||||||
END COMPONENT;
|
END COMPONENT;
|
||||||
|
|
||||||
--Constants
|
--Constants
|
||||||
constant PERIOD : time := 10 ns;
|
constant PERIOD : time := 10 ns;
|
||||||
|
|
||||||
|
|
||||||
--Inputs
|
--Inputs
|
||||||
SIGNAL clk : std_logic := '0';
|
SIGNAL clk : std_logic := '0';
|
||||||
SIGNAL srst : std_logic := '1';
|
SIGNAL srst : std_logic := '1';
|
||||||
SIGNAL vld_in : std_logic := '0';
|
SIGNAL vld_in : std_logic := '0';
|
||||||
SIGNAL din : sfixed(shi(max_width, max_width_frac) downto slo(max_width, max_width_frac));
|
SIGNAL din : sfixed(shi(max_width, max_width_frac) downto slo(max_width, max_width_frac));
|
||||||
SIGNAL diff_delay : natural := 1;
|
SIGNAL diff_delay : natural := 1;
|
||||||
|
|
||||||
--Outputs
|
--Outputs
|
||||||
SIGNAL dout : sfixed(shi(max_width, max_width_frac) downto slo(max_width, max_width_frac));
|
SIGNAL dout : sfixed(shi(max_width, max_width_frac) downto slo(max_width, max_width_frac));
|
||||||
SIGNAL vld_out : std_logic;
|
SIGNAL vld_out : std_logic;
|
||||||
|
|
||||||
SIGNAL fileout_enable : std_logic := '0';
|
SIGNAL fileout_enable : std_logic := '0';
|
||||||
|
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
||||||
-- Instantiate the Unit Under Test (UUT)
|
-- Instantiate the Unit Under Test (UUT)
|
||||||
uut: cic_c_pipe
|
uut: cic_c_pipe
|
||||||
GENERIC MAP
|
GENERIC MAP
|
||||||
(
|
(
|
||||||
max_diff_delay => 2,
|
max_diff_delay => 2,
|
||||||
max_width => max_width,
|
max_width => max_width,
|
||||||
max_width_frac => max_width_frac
|
max_width_frac => max_width_frac
|
||||||
)
|
)
|
||||||
PORT MAP
|
PORT MAP
|
||||||
(
|
(
|
||||||
clk => clk,
|
clk => clk,
|
||||||
rst => srst,
|
rst => srst,
|
||||||
vld_in => vld_in,
|
vld_in => vld_in,
|
||||||
diff_delay => diff_delay,
|
diff_delay => diff_delay,
|
||||||
din => din,
|
din => din,
|
||||||
dout => dout,
|
dout => dout,
|
||||||
vld_out => vld_out
|
vld_out => vld_out
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
tb_clk : PROCESS
|
tb_clk : PROCESS
|
||||||
BEGIN
|
BEGIN
|
||||||
clk <= not clk;
|
clk <= not clk;
|
||||||
wait for PERIOD/2;
|
wait for PERIOD/2;
|
||||||
END PROCESS;
|
END PROCESS;
|
||||||
|
|
||||||
tb : PROCESS
|
tb : PROCESS
|
||||||
|
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
||||||
-- Wait 100 ns for global reset to finish
|
-- Wait 100 ns for global reset to finish
|
||||||
wait for 4*PERIOD;
|
wait for 4*PERIOD;
|
||||||
srst <= '0';
|
srst <= '0';
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
wait for 2*PERIOD;
|
wait for 2*PERIOD;
|
||||||
wait until rising_edge(clk);
|
wait until rising_edge(clk);
|
||||||
din <= to_sfixed(0.0, din);
|
din <= to_sfixed(0.0, din);
|
||||||
vld_in <= '1';
|
vld_in <= '1';
|
||||||
|
|
||||||
wait for 9*PERIOD;
|
wait for 9*PERIOD;
|
||||||
wait until rising_edge(clk);
|
wait until rising_edge(clk);
|
||||||
|
|
||||||
din <= to_sfixed(0.5, din);
|
din <= to_sfixed(0.5, din);
|
||||||
|
|
||||||
wait for 9*PERIOD;
|
wait for 9*PERIOD;
|
||||||
wait until rising_edge(clk);
|
wait until rising_edge(clk);
|
||||||
|
|
||||||
din <= to_sfixed(0.0, din);
|
din <= to_sfixed(0.0, din);
|
||||||
|
|
||||||
wait for 9*PERIOD;
|
wait for 9*PERIOD;
|
||||||
wait until rising_edge(clk);
|
wait until rising_edge(clk);
|
||||||
vld_in <= '0';
|
vld_in <= '0';
|
||||||
|
|
||||||
wait for 20*PERIOD;
|
wait for 20*PERIOD;
|
||||||
|
|
||||||
assert false report "Test finished" severity error;
|
assert false report "Test finished" severity error;
|
||||||
wait;
|
wait;
|
||||||
END PROCESS;
|
END PROCESS;
|
||||||
|
|
||||||
END;
|
END;
|
||||||
|
|||||||
@@ -1,153 +1,153 @@
|
|||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
-- Company:
|
-- Company:
|
||||||
-- Engineer:
|
-- Engineer:
|
||||||
--
|
--
|
||||||
-- Create Date: 17:16:42 13.05.2007
|
-- Create Date: 17:16:42 13.05.2007
|
||||||
-- Design Name: tb_mix_cpx
|
-- Design Name: tb_mix_cpx
|
||||||
-- Module Name: tb_mix_cpx.vhd
|
-- Module Name: tb_mix_cpx.vhd
|
||||||
-- Project Name: mix_cpx
|
-- Project Name: mix_cpx
|
||||||
-- Target Device:
|
-- Target Device:
|
||||||
-- Tool versions:
|
-- Tool versions:
|
||||||
-- Description:
|
-- Description:
|
||||||
--
|
--
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
LIBRARY ieee;
|
LIBRARY ieee;
|
||||||
use IEEE.STD_LOGIC_1164.ALL;
|
use IEEE.STD_LOGIC_1164.ALL;
|
||||||
use IEEE.MATH_REAL.ALL;
|
use IEEE.MATH_REAL.ALL;
|
||||||
USE ieee.numeric_std.ALL;
|
USE ieee.numeric_std.ALL;
|
||||||
use std.textio.all; -- Imports the standard textio package.
|
use std.textio.all; -- Imports the standard textio package.
|
||||||
|
|
||||||
library ieee_proposed;
|
library ieee_proposed;
|
||||||
use ieee_proposed.math_utility_pkg.all;
|
use ieee_proposed.math_utility_pkg.all;
|
||||||
use ieee_proposed.fixed_pkg.all;
|
use ieee_proposed.fixed_pkg.all;
|
||||||
|
|
||||||
library work;
|
library work;
|
||||||
use work.PCK_FIO.all;
|
use work.PCK_FIO.all;
|
||||||
use work.fixed_util_pkg.all;
|
use work.fixed_util_pkg.all;
|
||||||
|
|
||||||
ENTITY tb_cic_decim_pipe IS
|
ENTITY tb_cic_decim_pipe IS
|
||||||
Generic
|
Generic
|
||||||
(
|
(
|
||||||
nstages : integer := 3;
|
nstages : integer := 3;
|
||||||
ratio : integer := 64;
|
ratio : integer := 64;
|
||||||
scale_nbits : integer := 18;
|
scale_nbits : integer := 18;
|
||||||
in_width : integer := 18;
|
in_width : integer := 18;
|
||||||
in_width_frac : integer := 16;
|
in_width_frac : integer := 16;
|
||||||
out_width : integer := 18;
|
out_width : integer := 18;
|
||||||
out_width_frac : integer := 16
|
out_width_frac : integer := 16
|
||||||
);
|
);
|
||||||
END tb_cic_decim_pipe;
|
END tb_cic_decim_pipe;
|
||||||
|
|
||||||
ARCHITECTURE behavior OF tb_cic_decim_pipe IS
|
ARCHITECTURE behavior OF tb_cic_decim_pipe IS
|
||||||
|
|
||||||
-- Component Declaration for the Unit Under Test (UUT)
|
-- Component Declaration for the Unit Under Test (UUT)
|
||||||
COMPONENT cic_decim_pipe
|
COMPONENT cic_decim_pipe
|
||||||
GENERIC
|
GENERIC
|
||||||
(
|
(
|
||||||
nstages : integer;
|
nstages : integer;
|
||||||
ratio : integer;
|
ratio : integer;
|
||||||
scale_nbits : integer;
|
scale_nbits : integer;
|
||||||
in_width : integer;
|
in_width : integer;
|
||||||
in_width_frac : integer;
|
in_width_frac : integer;
|
||||||
out_width : integer;
|
out_width : integer;
|
||||||
out_width_frac : integer
|
out_width_frac : integer
|
||||||
);
|
);
|
||||||
PORT
|
PORT
|
||||||
(
|
(
|
||||||
clk : in std_logic;
|
clk : in std_logic;
|
||||||
rst : in std_logic;
|
rst : in std_logic;
|
||||||
vld_in : in std_logic;
|
vld_in : in std_logic;
|
||||||
din : in sfixed;
|
din : in sfixed;
|
||||||
dout : out sfixed;
|
dout : out sfixed;
|
||||||
vld_out : out std_logic
|
vld_out : out std_logic
|
||||||
);
|
);
|
||||||
END COMPONENT;
|
END COMPONENT;
|
||||||
|
|
||||||
--Constants
|
--Constants
|
||||||
constant PERIOD : time := 10 ns;
|
constant PERIOD : time := 10 ns;
|
||||||
|
|
||||||
|
|
||||||
--Inputs
|
--Inputs
|
||||||
SIGNAL clk : std_logic := '0';
|
SIGNAL clk : std_logic := '0';
|
||||||
SIGNAL srst : std_logic := '1';
|
SIGNAL srst : std_logic := '1';
|
||||||
SIGNAL vld_in : std_logic := '0';
|
SIGNAL vld_in : std_logic := '0';
|
||||||
SIGNAL din : sfixed(shi(in_width, in_width_frac) downto slo(in_width, in_width_frac));
|
SIGNAL din : sfixed(shi(in_width, in_width_frac) downto slo(in_width, in_width_frac));
|
||||||
|
|
||||||
--Outputs
|
--Outputs
|
||||||
SIGNAL dout : sfixed(shi(out_width, out_width_frac) downto slo(out_width, out_width_frac));
|
SIGNAL dout : sfixed(shi(out_width, out_width_frac) downto slo(out_width, out_width_frac));
|
||||||
SIGNAL vld_out : std_logic;
|
SIGNAL vld_out : std_logic;
|
||||||
|
|
||||||
SIGNAL fileout_enable : std_logic := '0';
|
SIGNAL fileout_enable : std_logic := '0';
|
||||||
|
|
||||||
signal XR, YR : real;
|
signal XR, YR : real;
|
||||||
|
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
||||||
XR <= to_real(din);
|
XR <= to_real(din);
|
||||||
YR <= to_real(dout);
|
YR <= to_real(dout);
|
||||||
|
|
||||||
-- Instantiate the Unit Under Test (UUT)
|
-- Instantiate the Unit Under Test (UUT)
|
||||||
uut : cic_decim_pipe
|
uut : cic_decim_pipe
|
||||||
GENERIC MAP
|
GENERIC MAP
|
||||||
(
|
(
|
||||||
nstages => nstages,
|
nstages => nstages,
|
||||||
ratio => ratio,
|
ratio => ratio,
|
||||||
scale_nbits => scale_nbits,
|
scale_nbits => scale_nbits,
|
||||||
in_width => in_width,
|
in_width => in_width,
|
||||||
in_width_frac => in_width_frac,
|
in_width_frac => in_width_frac,
|
||||||
out_width => out_width,
|
out_width => out_width,
|
||||||
out_width_frac => out_width_frac
|
out_width_frac => out_width_frac
|
||||||
)
|
)
|
||||||
PORT MAP
|
PORT MAP
|
||||||
(
|
(
|
||||||
clk => clk,
|
clk => clk,
|
||||||
rst => srst,
|
rst => srst,
|
||||||
vld_in => vld_in,
|
vld_in => vld_in,
|
||||||
din => din,
|
din => din,
|
||||||
dout => dout,
|
dout => dout,
|
||||||
vld_out => vld_out
|
vld_out => vld_out
|
||||||
);
|
);
|
||||||
|
|
||||||
tb_clk : PROCESS
|
tb_clk : PROCESS
|
||||||
BEGIN
|
BEGIN
|
||||||
clk <= not clk;
|
clk <= not clk;
|
||||||
wait for PERIOD/2;
|
wait for PERIOD/2;
|
||||||
END PROCESS;
|
END PROCESS;
|
||||||
|
|
||||||
tb : PROCESS
|
tb : PROCESS
|
||||||
|
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
||||||
-- Wait 100 ns for global reset to finish
|
-- Wait 100 ns for global reset to finish
|
||||||
wait for 4*PERIOD;
|
wait for 4*PERIOD;
|
||||||
srst <= '0';
|
srst <= '0';
|
||||||
|
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
wait for 2*PERIOD;
|
wait for 2*PERIOD;
|
||||||
wait until rising_edge(clk);
|
wait until rising_edge(clk);
|
||||||
din <= to_sfixed(0.0, din);
|
din <= to_sfixed(0.0, din);
|
||||||
vld_in <= '1';
|
vld_in <= '1';
|
||||||
|
|
||||||
wait for 49*PERIOD;
|
wait for 49*PERIOD;
|
||||||
wait until rising_edge(clk);
|
wait until rising_edge(clk);
|
||||||
|
|
||||||
din <= to_sfixed(0.5, din);
|
din <= to_sfixed(0.5, din);
|
||||||
|
|
||||||
wait for 4999*PERIOD;
|
wait for 4999*PERIOD;
|
||||||
wait until rising_edge(clk);
|
wait until rising_edge(clk);
|
||||||
|
|
||||||
din <= to_sfixed(-0.5, din);
|
din <= to_sfixed(-0.5, din);
|
||||||
|
|
||||||
wait for 99*PERIOD;
|
wait for 99*PERIOD;
|
||||||
wait until rising_edge(clk);
|
wait until rising_edge(clk);
|
||||||
|
|
||||||
din <= to_sfixed(0.0, din);
|
din <= to_sfixed(0.0, din);
|
||||||
|
|
||||||
wait for 499*PERIOD;
|
wait for 499*PERIOD;
|
||||||
wait until rising_edge(clk);
|
wait until rising_edge(clk);
|
||||||
vld_in <= '0';
|
vld_in <= '0';
|
||||||
|
|
||||||
wait;
|
wait;
|
||||||
END PROCESS;
|
END PROCESS;
|
||||||
|
|
||||||
END;
|
END;
|
||||||
|
|||||||
@@ -1,126 +1,126 @@
|
|||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
-- Company:
|
-- Company:
|
||||||
-- Engineer:
|
-- Engineer:
|
||||||
--
|
--
|
||||||
-- Create Date: 17:16:42 13.05.2007
|
-- Create Date: 17:16:42 13.05.2007
|
||||||
-- Design Name: tb_mix_cpx
|
-- Design Name: tb_mix_cpx
|
||||||
-- Module Name: tb_mix_cpx.vhd
|
-- Module Name: tb_mix_cpx.vhd
|
||||||
-- Project Name: mix_cpx
|
-- Project Name: mix_cpx
|
||||||
-- Target Device:
|
-- Target Device:
|
||||||
-- Tool versions:
|
-- Tool versions:
|
||||||
-- Description:
|
-- Description:
|
||||||
--
|
--
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
LIBRARY ieee;
|
LIBRARY ieee;
|
||||||
use IEEE.STD_LOGIC_1164.ALL;
|
use IEEE.STD_LOGIC_1164.ALL;
|
||||||
use IEEE.MATH_REAL.ALL;
|
use IEEE.MATH_REAL.ALL;
|
||||||
USE ieee.numeric_std.ALL;
|
USE ieee.numeric_std.ALL;
|
||||||
use std.textio.all; -- Imports the standard textio package.
|
use std.textio.all; -- Imports the standard textio package.
|
||||||
|
|
||||||
library ieee_proposed;
|
library ieee_proposed;
|
||||||
use ieee_proposed.math_utility_pkg.all;
|
use ieee_proposed.math_utility_pkg.all;
|
||||||
use ieee_proposed.fixed_pkg.all;
|
use ieee_proposed.fixed_pkg.all;
|
||||||
|
|
||||||
library work;
|
library work;
|
||||||
use work.PCK_FIO.all;
|
use work.PCK_FIO.all;
|
||||||
use work.fixed_util_pkg.all;
|
use work.fixed_util_pkg.all;
|
||||||
|
|
||||||
ENTITY tb_cic_i_pipe IS
|
ENTITY tb_cic_i_pipe IS
|
||||||
Generic
|
Generic
|
||||||
(
|
(
|
||||||
max_width : integer := 32;
|
max_width : integer := 32;
|
||||||
max_width_frac : integer := 20
|
max_width_frac : integer := 20
|
||||||
);
|
);
|
||||||
END tb_cic_i_pipe;
|
END tb_cic_i_pipe;
|
||||||
|
|
||||||
ARCHITECTURE behavior OF tb_cic_i_pipe IS
|
ARCHITECTURE behavior OF tb_cic_i_pipe IS
|
||||||
|
|
||||||
-- Component Declaration for the Unit Under Test (UUT)
|
-- Component Declaration for the Unit Under Test (UUT)
|
||||||
COMPONENT cic_i_pipe
|
COMPONENT cic_i_pipe
|
||||||
GENERIC
|
GENERIC
|
||||||
(
|
(
|
||||||
max_width : integer;
|
max_width : integer;
|
||||||
max_width_frac : integer
|
max_width_frac : integer
|
||||||
);
|
);
|
||||||
PORT
|
PORT
|
||||||
(
|
(
|
||||||
clk : in std_logic;
|
clk : in std_logic;
|
||||||
rst : in std_logic;
|
rst : in std_logic;
|
||||||
vld_in : in std_logic;
|
vld_in : in std_logic;
|
||||||
din : in sfixed;
|
din : in sfixed;
|
||||||
dout : out sfixed;
|
dout : out sfixed;
|
||||||
vld_out : out std_logic
|
vld_out : out std_logic
|
||||||
);
|
);
|
||||||
END COMPONENT;
|
END COMPONENT;
|
||||||
|
|
||||||
--Constants
|
--Constants
|
||||||
constant PERIOD : time := 10 ns;
|
constant PERIOD : time := 10 ns;
|
||||||
|
|
||||||
|
|
||||||
--Inputs
|
--Inputs
|
||||||
SIGNAL clk : std_logic := '0';
|
SIGNAL clk : std_logic := '0';
|
||||||
SIGNAL srst : std_logic := '1';
|
SIGNAL srst : std_logic := '1';
|
||||||
SIGNAL vld_in : std_logic := '0';
|
SIGNAL vld_in : std_logic := '0';
|
||||||
SIGNAL din : sfixed(shi(max_width, max_width_frac) downto slo(max_width, max_width_frac));
|
SIGNAL din : sfixed(shi(max_width, max_width_frac) downto slo(max_width, max_width_frac));
|
||||||
|
|
||||||
--Outputs
|
--Outputs
|
||||||
SIGNAL dout : sfixed(shi(max_width, max_width_frac) downto slo(max_width, max_width_frac));
|
SIGNAL dout : sfixed(shi(max_width, max_width_frac) downto slo(max_width, max_width_frac));
|
||||||
SIGNAL vld_out : std_logic;
|
SIGNAL vld_out : std_logic;
|
||||||
|
|
||||||
SIGNAL fileout_enable : std_logic := '0';
|
SIGNAL fileout_enable : std_logic := '0';
|
||||||
|
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
||||||
-- Instantiate the Unit Under Test (UUT)
|
-- Instantiate the Unit Under Test (UUT)
|
||||||
uut: cic_i_pipe
|
uut: cic_i_pipe
|
||||||
GENERIC MAP
|
GENERIC MAP
|
||||||
(
|
(
|
||||||
max_width => max_width,
|
max_width => max_width,
|
||||||
max_width_frac => max_width_frac
|
max_width_frac => max_width_frac
|
||||||
)
|
)
|
||||||
PORT MAP
|
PORT MAP
|
||||||
(
|
(
|
||||||
clk => clk,
|
clk => clk,
|
||||||
rst => srst,
|
rst => srst,
|
||||||
vld_in => vld_in,
|
vld_in => vld_in,
|
||||||
din => din,
|
din => din,
|
||||||
dout => dout,
|
dout => dout,
|
||||||
vld_out => vld_out
|
vld_out => vld_out
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
tb_clk : PROCESS
|
tb_clk : PROCESS
|
||||||
BEGIN
|
BEGIN
|
||||||
clk <= not clk;
|
clk <= not clk;
|
||||||
wait for PERIOD/2;
|
wait for PERIOD/2;
|
||||||
END PROCESS;
|
END PROCESS;
|
||||||
|
|
||||||
tb : PROCESS
|
tb : PROCESS
|
||||||
|
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
||||||
-- Wait 100 ns for global reset to finish
|
-- Wait 100 ns for global reset to finish
|
||||||
wait for 4*PERIOD;
|
wait for 4*PERIOD;
|
||||||
srst <= '0';
|
srst <= '0';
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
wait for 2*PERIOD;
|
wait for 2*PERIOD;
|
||||||
wait until rising_edge(clk);
|
wait until rising_edge(clk);
|
||||||
din <= to_sfixed(0.0, din);
|
din <= to_sfixed(0.0, din);
|
||||||
vld_in <= '1';
|
vld_in <= '1';
|
||||||
|
|
||||||
wait for 9*PERIOD;
|
wait for 9*PERIOD;
|
||||||
wait until rising_edge(clk);
|
wait until rising_edge(clk);
|
||||||
|
|
||||||
din <= to_sfixed(0.5, din);
|
din <= to_sfixed(0.5, din);
|
||||||
|
|
||||||
wait for 9*PERIOD;
|
wait for 9*PERIOD;
|
||||||
wait until rising_edge(clk);
|
wait until rising_edge(clk);
|
||||||
vld_in <= '0';
|
vld_in <= '0';
|
||||||
|
|
||||||
wait for 20*PERIOD;
|
wait for 20*PERIOD;
|
||||||
|
|
||||||
assert false report "Test finished" severity error;
|
assert false report "Test finished" severity error;
|
||||||
wait;
|
wait;
|
||||||
END PROCESS;
|
END PROCESS;
|
||||||
|
|
||||||
END;
|
END;
|
||||||
|
|||||||
Reference in New Issue
Block a user