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

Subversion Repositories btc_dsha256

[/] [btc_dsha256/] [trunk/] [rtl/] [vhdl/] [sha256core/] [sha_256_comp_func.vhd] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 nuxi1209
------------------------------------------------------------------- 
2
--                                                               --
3
--  Copyright (C) 2013 Author and VariStream Studio              --
4
--  Author : Yu Peng                                             --
5
--                                                               -- 
6
--  This source file may be used and distributed without         -- 
7
--  restriction provided that this copyright statement is not    -- 
8
--  removed from the file and that any derivative work contains  -- 
9
--  the original copyright notice and the associated disclaimer. -- 
10
--                                                               -- 
11
--  This source file is free software; you can redistribute it   -- 
12
--  and/or modify it under the terms of the GNU Lesser General   -- 
13
--  Public License as published by the Free Software Foundation; -- 
14
--  either version 2.1 of the License, or (at your option) any   -- 
15
--  later version.                                               -- 
16
--                                                               -- 
17
--  This source is distributed in the hope that it will be       -- 
18
--  useful, but WITHOUT ANY WARRANTY; without even the implied   -- 
19
--  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      -- 
20
--  PURPOSE.  See the GNU Lesser General Public License for more -- 
21
--  details.                                                     -- 
22
--                                                               -- 
23
--  You should have received a copy of the GNU Lesser General    -- 
24
--  Public License along with this source; if not, download it   -- 
25
--  from http://www.opencores.org/lgpl.shtml                     -- 
26
--                                                               -- 
27
-------------------------------------------------------------------
28 2 nuxi1209
-- Notes : Introduce delay of 3 clock cycle
29 3 nuxi1209
-------------------------------------------------------------------
30 2 nuxi1209
 
31
library IEEE;
32
 
33
use IEEE.STD_LOGIC_1164.ALL;
34
use ieee.std_logic_unsigned.all;
35
use work.sha_256_pkg.ALL;
36
 
37
entity sha_256_comp_func is
38
        port(
39
                iClk : in std_logic;
40
                iRst_async : in std_logic;
41
 
42
                ivA : in std_logic_vector(31 downto 0);
43
                ivB : in std_logic_vector(31 downto 0);
44
                ivC : in std_logic_vector(31 downto 0);
45
                ivD : in std_logic_vector(31 downto 0);
46
                ivE : in std_logic_vector(31 downto 0);
47
                ivF : in std_logic_vector(31 downto 0);
48
                ivG : in std_logic_vector(31 downto 0);
49
                ivH : in std_logic_vector(31 downto 0);
50
 
51
                ivK : in std_logic_vector(31 downto 0);
52
                ivW : in std_logic_vector(31 downto 0);
53
 
54
                ovA : out std_logic_vector(31 downto 0);
55
                ovB : out std_logic_vector(31 downto 0);
56
                ovC : out std_logic_vector(31 downto 0);
57
                ovD : out std_logic_vector(31 downto 0);
58
                ovE : out std_logic_vector(31 downto 0);
59
                ovF : out std_logic_vector(31 downto 0);
60
                ovG : out std_logic_vector(31 downto 0);
61
                ovH : out std_logic_vector(31 downto 0)
62
        );
63
end sha_256_comp_func;
64
 
65
architecture behavioral of sha_256_comp_func is
66
 
67
        component pipelines_without_reset IS
68
                GENERIC (gBUS_WIDTH : integer := 3; gNB_PIPELINES: integer range 1 to 255 := 2);
69
                PORT(
70
                        iClk                            : IN            STD_LOGIC;
71
                        iInput                          : IN            STD_LOGIC;
72
                        ivInput                         : IN            STD_LOGIC_VECTOR(gBUS_WIDTH-1 downto 0);
73
                        oDelayed_output         : OUT           STD_LOGIC;
74
                        ovDelayed_output        : OUT           STD_LOGIC_VECTOR(gBUS_WIDTH-1 downto 0)
75
                );
76
        end component;
77
 
78
        signal svS0, svS1 : std_logic_vector(31 downto 0);
79
        signal svMaj, svCh : std_logic_vector(31 downto 0);
80
        signal svTemp1_temp : std_logic_vector(31 downto 0);
81
        signal svTemp2, svTemp1 : std_logic_vector(31 downto 0);
82
        signal svD_2d : std_logic_vector(31 downto 0);
83
        signal svAOut : std_logic_vector(31 downto 0);
84
        signal svBOut : std_logic_vector(31 downto 0);
85
        signal svCOut : std_logic_vector(31 downto 0);
86
        signal svDOut : std_logic_vector(31 downto 0);
87
        signal svEOut : std_logic_vector(31 downto 0);
88
        signal svFOut : std_logic_vector(31 downto 0);
89
        signal svGOut : std_logic_vector(31 downto 0);
90
        signal svHOut : std_logic_vector(31 downto 0);
91
 
92
begin
93
 
94
        proc_delay1: process(iClk)
95
        begin
96
                if rising_edge(iClk) then
97
                        svS0 <= sum_0(ivA);
98
                        svMaj <= maj(ivA, ivB, ivC);
99
                        svS1 <= sum_1(ivE);
100
                        svCh <= chi(ivE, ivF, ivG);
101
                        svTemp1_temp <= ivH + ivK + ivW;
102
                end if;
103
        end process;
104
 
105
        proc_delay2: process(iClk)
106
        begin
107
                if rising_edge(iClk) then
108
                        svTemp2 <= svS0 + svMaj;
109
                        svTemp1 <= svTemp1_temp + svS1 + svCh;
110
                end if;
111
        end process;
112
 
113
        pipelines_without_reset_for_D_2d : pipelines_without_reset
114
        generic map (
115
                gBUS_WIDTH => 32,
116
                gNB_PIPELINES => 2)
117
        port map (
118
                iClk => iClk,
119
                iInput => '0',
120
                oDelayed_output => open,
121
                ivInput => ivD,
122
                ovDelayed_output => svD_2d);
123
 
124
        proc_delay3: process(iClk)
125
        begin
126
                if rising_edge(iClk) then
127
                        svAOut <= svTemp2 + svTemp1;
128
                        svEOut <= svD_2d + svTemp1;
129
                end if;
130
        end process;
131
 
132
        pipelines_without_reset_for_B : pipelines_without_reset
133
        generic map (
134
                gBUS_WIDTH => 32,
135
                gNB_PIPELINES => 3)
136
        port map (
137
                iClk => iClk,
138
                iInput => '0',
139
                oDelayed_output => open,
140
                ivInput => ivA,
141
                ovDelayed_output => svBOut);
142
 
143
        pipelines_without_reset_for_C : pipelines_without_reset
144
        generic map (
145
                gBUS_WIDTH => 32,
146
                gNB_PIPELINES => 3)
147
        port map (
148
                iClk => iClk,
149
                iInput => '0',
150
                oDelayed_output => open,
151
                ivInput => ivB,
152
                ovDelayed_output => svCOut);
153
 
154
        pipelines_without_reset_for_D : pipelines_without_reset
155
        generic map (
156
                gBUS_WIDTH => 32,
157
                gNB_PIPELINES => 3)
158
        port map (
159
                iClk => iClk,
160
                iInput => '0',
161
                oDelayed_output => open,
162
                ivInput => ivC,
163
                ovDelayed_output => svDOut);
164
 
165
        pipelines_without_reset_for_F : pipelines_without_reset
166
        generic map (
167
                gBUS_WIDTH => 32,
168
                gNB_PIPELINES => 3)
169
        port map (
170
                iClk => iClk,
171
                iInput => '0',
172
                oDelayed_output => open,
173
                ivInput => ivE,
174
                ovDelayed_output => svFOut);
175
 
176
        pipelines_without_reset_for_G : pipelines_without_reset
177
        generic map (
178
                gBUS_WIDTH => 32,
179
                gNB_PIPELINES => 3)
180
        port map (
181
                iClk => iClk,
182
                iInput => '0',
183
                oDelayed_output => open,
184
                ivInput => ivF,
185
                ovDelayed_output => svGOut);
186
 
187
        pipelines_without_reset_for_H : pipelines_without_reset
188
        generic map (
189
                gBUS_WIDTH => 32,
190
                gNB_PIPELINES => 3)
191
        port map (
192
                iClk => iClk,
193
                iInput => '0',
194
                oDelayed_output => open,
195
                ivInput => ivG,
196
                ovDelayed_output => svHOut);
197
 
198
        ovA <= svAOut;
199
        ovB <= svBOut;
200
        ovC <= svCOut;
201
        ovD <= svDOut;
202
        ovE <= svEOut;
203
        ovF <= svFOut;
204
        ovG <= svGOut;
205
        ovH <= svHOut;
206
 
207
end behavioral;

powered by: WebSVN 2.1.0

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