Advertisement
gollub

Kaskadna veza

Jun 26th, 2018
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.18 KB | None | 0 0
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.ALL;
  3. use ieee.std_logic_unsigned.all;
  4. use IEEE.NUMERIC_STD.ALL;
  5.  
  6. entity MAC_KASKADNA is
  7.     generic(input_data_width: natural := 16);
  8.     Port ( clk_i : in STD_LOGIC;
  9.            ce_i : in STD_LOGIC;
  10.            u_i : in STD_LOGIC_VECTOR (input_data_width-1 downto 0);
  11.            b_i : in STD_LOGIC_VECTOR (input_data_width-1 downto 0);
  12.            b_j : in STD_LOGIC_VECTOR (input_data_width-1 downto 0);
  13.            b_k : in STD_LOGIC_VECTOR (input_data_width-1 downto 0);
  14.            o_i : out STD_LOGIC_VECTOR (2*input_data_width-1 downto 0));
  15. end MAC_KASKADNA;
  16.  
  17. architecture Behavioral of MAC_KASKADNA is
  18.     signal reg1, reg2 : STD_LOGIC_VECTOR (input_data_width-1 downto 0):=(others=>'0');
  19.     signal pom : STD_LOGIC_VECTOR (input_data_width-1 downto 0):=(others=>'0');
  20. begin
  21.     process(clk_i)
  22.     begin
  23.         if (clk_i'event and clk_i = '1')then
  24.             if (ce_i = '1') then
  25.                 reg1 <= u_i;
  26.                 reg2 <= reg1;
  27.             end if;
  28.         end if;
  29.     end process;
  30.     o_i <= std_logic_vector ((signed(reg1) * signed(b_j)) + (signed(u_i) * signed(b_i)) + (signed(reg2) * signed(b_k)));
  31.    
  32. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement