Advertisement
gollub

TOP_LEVEL kaskadna direktna FIR NE RADI!!!

Jun 26th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 2.96 KB | None | 0 0
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.ALL;
  3. use IEEE.NUMERIC_STD.ALL;
  4. use work.util_pkg.all;
  5.  
  6. entity TOP_LEVEL is
  7.     generic(fir_ord : natural := 10;
  8.             input_data_width : natural := 12;
  9.             output_data_width : natural := 12);
  10.     Port ( clk_i : in STD_LOGIC;
  11.            ce_i : in STD_LOGIC;
  12.            coef_addr_i1 : in STD_LOGIC_VECTOR (log2c(fir_ord+1)-1 downto 0);
  13.            coef_addr_i2 : in STD_LOGIC_VECTOR (log2c(fir_ord+1)-1 downto 0);
  14.            coef_addr_i3 : in STD_LOGIC_VECTOR (log2c(fir_ord+1)-1 downto 0);
  15.            coef_i1 : in STD_LOGIC_VECTOR (input_data_width-1 downto 0);
  16.            coef_i2 : in STD_LOGIC_VECTOR (input_data_width-1 downto 0);
  17.            coef_i3 : in STD_LOGIC_VECTOR (input_data_width-1 downto 0);
  18.            we_i : in STD_LOGIC;
  19.            data_i : in STD_LOGIC_VECTOR (input_data_width-1 downto 0);
  20.            data_o : out STD_LOGIC_VECTOR (output_data_width-1 downto 0));
  21. end TOP_LEVEL;
  22.  
  23. architecture Behavioral of TOP_LEVEL is
  24.     type std_2d is array (fir_ord downto 0) of
  25.         std_logic_vector(2*input_data_width-1 downto 0);
  26.     signal mac_inter : std_2d:=(others=>(others=>'0'));
  27.    
  28.     type coef_t is array (fir_ord downto 0) of
  29.             std_logic_vector(input_data_width-1 downto 0);
  30.     signal b_s1 : coef_t := (others=>(others=>'0'));  
  31.     signal b_s2 : coef_t := (others=>(others=>'0'));
  32.     signal b_s3 : coef_t := (others=>(others=>'0'));
  33. begin
  34.     process(clk_i)
  35.     begin
  36.         if(clk_i'event and clk_i = '1')then
  37.             if (ce_i = '1' and we_i = '1') then
  38.                 b_s1(to_integer(unsigned(coef_addr_i1))) <= coef_i1;
  39.                 b_s2(to_integer(unsigned(coef_addr_i2))) <= coef_i2;
  40.                 b_s3(to_integer(unsigned(coef_addr_i3))) <= coef_i3;
  41.             end if;
  42.         end if;
  43.     end process;
  44.     first_section:
  45.         entity work.ASK(behavioral)
  46.         generic map(input_data_width=>input_data_width)
  47.         port map(clk_i=>clk_i,
  48.                  ce_i=>ce_i,
  49.                  u_i=>data_i,
  50.                  b_i=>b_s1(0),
  51.                  b_j=>b_s2(0),
  52.                  b_k=>b_s3(0),
  53.                  o_i=>mac_inter(0));
  54.      other_sections:
  55.         for i in 1 to fir_ord generate
  56.         fir_section:
  57.         entity work.ASK(behavioral)
  58.         generic map(input_data_width=>input_data_width)
  59.         port map(clk_i=>clk_i,
  60.                  ce_i=>ce_i,
  61.                  u_i=>mac_inter(i-1),
  62.                  b_i=>b_s1(i),
  63.                  b_j=>b_s2(i),
  64.                  b_k=>b_s3(i),
  65.                  o_i=>mac_inter(i));
  66.         end generate;
  67.      
  68.        process(clk_i)
  69.             begin
  70.                if(clk_i'event and clk_i='1')then
  71.                    if (ce_i = '1') then
  72.                        data_o <= mac_inter(fir_ord)
  73.                            (2*input_data_width-2 downto 2*input_data_width-output_data_width-1);
  74.                    end if;
  75.                end if;
  76.            end process;  
  77.            
  78. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement