Guest User

Untitled

a guest
Sep 11th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.95 KB | None | 0 0
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date:    18:15:58 07/07/2012
  6. -- Design Name:
  7. -- Module Name:    h3 - Behavioral
  8. -- Project Name:
  9. -- Target Devices:
  10. -- Tool versions:
  11. -- Description:
  12. --
  13. -- Dependencies:
  14. --
  15. -- Revision:
  16. -- Revision 0.01 - File Created
  17. -- Additional Comments:
  18. --
  19. ----------------------------------------------------------------------------------
  20. library IEEE;
  21. use IEEE.STD_LOGIC_1164.ALL;
  22. use IEEE.std_logic_unsigned.all;
  23. use IEEE.numeric_std.all;
  24. use work.filter_pkg.all;
  25.  
  26. -- Uncomment the following library declaration if using
  27. -- arithmetic functions with Signed or Unsigned values
  28. --use IEEE.NUMERIC_STD.ALL;
  29.  
  30. -- Uncomment the following library declaration if instantiating
  31. -- any Xilinx primitives in this code.
  32. --library UNISIM;
  33. --use UNISIM.VComponents.all;
  34.  
  35. entity h3 is
  36. generic(
  37.         index : integer
  38.         --rnd_v : hash_array
  39.         );     
  40. port (
  41.       rnd_v : in hash_array;
  42.       data_in : in std_logic_vector(max_msg_bits-1 downto 0);
  43.         data_out :  out std_logic_vector(num_hash_bits-1 downto 0)
  44.         );
  45.        
  46. end h3;
  47.  
  48.  
  49.  
  50. architecture Behavioral of h3 is
  51.  
  52. signal and_value : row_array;
  53. signal digest_int : std_logic_vector(num_hash_bits-1 downto 0):=(others => '0'); -- intermediate digest
  54. --signal digest : std_logic_vector(num_hash_bits-1 downto 0):=(others => '0');  
  55.  
  56. begin
  57.  
  58. process(data_in)
  59. variable digest : std_logic_vector(num_hash_bits-1 downto 0);  
  60. begin
  61. digest := (others => '0');
  62.     for  b in 0 to  max_msg_length-1 loop  -- loop on the 8 bits of input byte
  63.         for  i in 0 to  7 loop  -- loop on the 8 bits of input byte
  64.             for  j in 0 to num_hash_bits-1 loop
  65.             and_value(b)(i)(j) <=  rnd_v(index)(b)(i)(j) and data_in(b*8+i);  -- rnd_v(index)(i)(j)
  66.             end loop;
  67.             digest := digest  xor and_value(b)(i);
  68.         end loop ;
  69.     end loop;
  70.    
  71.     data_out <= digest;
  72.  
  73. end process ;
  74.  
  75.  
  76. end Behavioral;
Add Comment
Please, Sign In to add comment