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

Subversion Repositories sha256core

[/] [sha256core/] [trunk/] [rtl/] [msg_comp.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 entactogen
 
2
-- Copyright (c) 2013 Antonio de la Piedra
3
 
4
-- This program is free software: you can redistribute it and/or modify
5
-- it under the terms of the GNU General Public License as published by
6
-- the Free Software Foundation, either version 3 of the License, or
7
-- (at your option) any later version.
8
 
9
-- This program is distributed in the hope that it will be useful,
10
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
11
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
-- GNU General Public License for more details.
13
 
14
-- You should have received a copy of the GNU General Public License
15
-- along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
 
17
library IEEE;
18
 
19
use IEEE.STD_LOGIC_1164.ALL;
20
use IEEE.NUMERIC_STD.ALL;
21
use work.sha_fun.ALL;
22
 
23
entity msg_comp is
24
        port(clk  : in std_logic;
25
             rst : in std_logic;
26
 
27
                                 h_0 : in std_logic_vector(31 downto 0);
28
                                 h_1 : in std_logic_vector(31 downto 0);
29
                                 h_2 : in std_logic_vector(31 downto 0);
30
                                 h_3 : in std_logic_vector(31 downto 0);
31
                                 h_4 : in std_logic_vector(31 downto 0);
32
                            h_5 : in std_logic_vector(31 downto 0);
33
                            h_6 : in std_logic_vector(31 downto 0);
34
                                 h_7 : in std_logic_vector(31 downto 0);
35
 
36
                            w_i : in std_logic_vector(31 downto 0);
37
                                 k_i : in std_logic_vector(31 downto 0);
38
 
39
                                 a : out std_logic_vector(31 downto 0);
40
                                 b : out std_logic_vector(31 downto 0);
41
                                 c : out std_logic_vector(31 downto 0);
42
                                 d : out std_logic_vector(31 downto 0);
43
                                 e : out std_logic_vector(31 downto 0);
44
                                 f : out std_logic_vector(31 downto 0);
45
                                 g : out std_logic_vector(31 downto 0);
46
                                 h : out std_logic_vector(31 downto 0));
47
end msg_comp;
48
 
49
architecture structural of msg_comp is
50
 
51
        component ff_bank is
52
                        port(clk : in std_logic;
53
                                  d   : in std_logic_vector(31 downto 0);
54
              q   : out std_logic_vector(31 downto 0));
55
        end component;
56
 
57
        signal d_a_tmp : std_logic_vector(31 downto 0);
58
        signal d_b_tmp : std_logic_vector(31 downto 0);
59
        signal d_c_tmp : std_logic_vector(31 downto 0);
60
        signal d_d_tmp : std_logic_vector(31 downto 0);
61
        signal d_e_tmp : std_logic_vector(31 downto 0);
62
        signal d_f_tmp : std_logic_vector(31 downto 0);
63
        signal d_g_tmp : std_logic_vector(31 downto 0);
64
        signal d_h_tmp : std_logic_vector(31 downto 0);
65
 
66
        signal q_a_tmp : std_logic_vector(31 downto 0);
67
        signal q_b_tmp : std_logic_vector(31 downto 0);
68
        signal q_c_tmp : std_logic_vector(31 downto 0);
69
        signal q_d_tmp : std_logic_vector(31 downto 0);
70
        signal q_e_tmp : std_logic_vector(31 downto 0);
71
        signal q_f_tmp : std_logic_vector(31 downto 0);
72
        signal q_g_tmp : std_logic_vector(31 downto 0);
73
        signal q_h_tmp : std_logic_vector(31 downto 0);
74
 
75
        signal t_1, t_2 : std_logic_vector(31 downto 0);
76
 
77
begin
78
 
79
        mux_ff_a:process(rst, h_0, t_1, t_2)
80
        begin
81
                        if rst = '1' then
82
                                d_a_tmp <= h_0;
83
                        else
84
                                d_a_tmp <= std_logic_vector(unsigned(t_1) + unsigned(t_2));
85
                        end if;
86
        end process;
87
 
88
        mux_ff_b:process(rst, h_1, q_a_tmp)
89
        begin
90
                        if rst = '1' then
91
                                d_b_tmp <= h_1;
92
                        else
93
                                d_b_tmp <= q_a_tmp;
94
                        end if;
95
        end process;
96
 
97
        mux_ff_c:process(rst, h_2, q_b_tmp)
98
        begin
99
                        if rst = '1' then
100
                                d_c_tmp <= h_2;
101
                        else
102
                                d_c_tmp <= q_b_tmp;
103
                        end if;
104
        end process;
105
 
106
        mux_ff_d:process(rst, h_3, q_c_tmp)
107
        begin
108
                        if rst = '1' then
109
                                d_d_tmp <= h_3;
110
                        else
111
                                d_d_tmp <= q_c_tmp;
112
                        end if;
113
        end process;
114
 
115
        mux_ff_e:process(rst, h_4, q_d_tmp, t_1)
116
        begin
117
                        if rst = '1' then
118
                                d_e_tmp <= h_4;
119
                        else
120
                                d_e_tmp <= std_logic_vector(unsigned(q_d_tmp) + unsigned(t_1));
121
                        end if;
122
        end process;
123
 
124
        mux_ff_f:process(rst, h_5, q_e_tmp)
125
        begin
126
                        if rst = '1' then
127
                                d_f_tmp <= h_5;
128
                        else
129
                                d_f_tmp <= q_e_tmp;
130
                        end if;
131
        end process;
132
 
133
        mux_ff_g:process(rst, h_6, q_f_tmp)
134
        begin
135
                        if rst = '1' then
136
                                d_g_tmp <= h_6;
137
                        else
138
                                d_g_tmp <= q_f_tmp;
139
                        end if;
140
        end process;
141
 
142
        mux_ff_h:process(rst, h_7, q_g_tmp)
143
        begin
144
                        if rst = '1' then
145
                                d_h_tmp <= h_7;
146
                        else
147
                                d_h_tmp <= q_g_tmp;
148
                        end if;
149
        end process;
150
 
151
        ff_a : ff_bank port map (clk, d_a_tmp, q_a_tmp);
152
        ff_b : ff_bank port map (clk, d_b_tmp, q_b_tmp);
153
        ff_c : ff_bank port map (clk, d_c_tmp, q_c_tmp);
154
        ff_d : ff_bank port map (clk, d_d_tmp, q_d_tmp);
155
        ff_e : ff_bank port map (clk, d_e_tmp, q_e_tmp);
156
        ff_f : ff_bank port map (clk, d_f_tmp, q_f_tmp);
157
        ff_g : ff_bank port map (clk, d_g_tmp, q_g_tmp);
158
        ff_h : ff_bank port map (clk, d_h_tmp, q_h_tmp);
159
 
160
        a <= d_a_tmp;
161
        b <= d_b_tmp;
162
        c <= d_c_tmp;
163
        d <= d_d_tmp;
164
        e <= d_e_tmp;
165
        f <= d_f_tmp;
166
        g <= d_g_tmp;
167
        h <= d_h_tmp;
168
 
169
 
170
        t_1 <= std_logic_vector(unsigned(q_h_tmp) +
171
                         unsigned(sum_1(q_e_tmp)) +
172
                         unsigned(chi(q_e_tmp, q_f_tmp, q_g_tmp)) +
173
                         unsigned(k_i) +
174
                         unsigned(w_i));
175
 
176
        t_2 <= std_logic_vector(unsigned(sum_0(q_a_tmp)) +
177
                         unsigned(maj(q_a_tmp, q_b_tmp, q_c_tmp)));
178
 
179
end structural;

powered by: WebSVN 2.1.0

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