OpenCores
URL https://opencores.org/ocsvn/securehash256bits/securehash256bits/trunk

Subversion Repositories securehash256bits

[/] [securehash256bits/] [trunk/] [sha256compressionCore.vhd] - Blame information for rev 5

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 feketebv
--(Maximum Frequency: 301.051MHz)
2 4 feketebv
 
3
LIBRARY IEEE;
4
use IEEE.std_logic_1164.all;
5
use IEEE.std_logic_unsigned.all;
6
 
7
ENTITY sha256compressionCore is
8
    Port ( clock        : in  STD_LOGIC;
9
           --data input signals
10
           data         : in  STD_LOGIC_VECTOR (255 downto 0);
11
           load   : in  STD_LOGIC;
12
           w, k         : in  STD_LOGIC_VECTOR (31 downto 0);
13
           enable : in  STD_LOGIC;
14
           --hash output signals
15
           digest       : out STD_LOGIC_VECTOR (255 downto 0));
16
end sha256compressionCore;
17
 
18
ARCHITECTURE Behavioral of sha256compressionCore is
19
 
20
   signal b,c,d,f,g,h,su0,su1,maj,ch,temp1,temp2,a1,a2,e1,sum : STD_LOGIC_VECTOR(31 downto 0);
21
 
22
BEGIN
23
 
24
   compression: process(clock)
25
   begin
26
      if rising_edge(clock) then
27
         if load = '1' then
28
                                a1 <= data(255 downto 224);
29
                                b <= data(223 downto 192);
30
                                c <= data(191 downto 160);
31
                                d <= data(159 downto 128);
32
                                e1 <= data(127 downto 96);
33
                                f <= data(95 downto 64);
34
                                g <= data(63 downto 32);
35
                                h <= data(31 downto 0);
36
                                a2 <= (others => '0');
37
                                temp1 <= (others => '0');
38
         elsif enable = '1' then
39
            a1 <= su0;
40
                                a2 <= maj;
41
                                temp1 <= h + su1 + ch;
42
                                b <= temp2;
43
                                c <= b;
44
                                d <= c;
45
                                e1 <= d;
46
                                f <= sum;
47
                                g <= f;
48
                                h <= g + w + k;
49
                        end if;
50
                end if;
51
   end process;
52
   --main_loop_pipe asynchron circuitry
53 5 feketebv
   su1 <= (sum(5 downto 0) & sum(31 downto 6)) xor (sum(10 downto 0) & sum(31 downto 11)) xor (sum(24 downto 0) & sum(31 downto 25));
54 4 feketebv
   ch <= (sum and f) xor ((not sum) and g);
55
   su0 <= (temp2(1 downto 0) & temp2(31 downto 2)) xor (temp2(12 downto 0) & temp2(31 downto 13)) xor (temp2(21 downto 0) & temp2(31 downto 22));
56
   maj <= (temp2 and (b xor c)) xor (b and c);
57
   sum <= e1 + temp1;
58
   temp2 <= temp1 + a1 + a2;
59
   --end of main_loop_pipe asynchron circuitry
60
   digest <= temp2 & b & c & d & sum & f & g & h;
61
 
62
END Behavioral;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.