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 |
|
|
-- Notes : Introduce delay of 1 clock cycle
|
29 |
|
|
-------------------------------------------------------------------
|
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_1c 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_1c;
|
64 |
|
|
|
65 |
|
|
architecture behavioral of sha_256_comp_func_1c 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 svAOut : std_logic_vector(31 downto 0);
|
79 |
|
|
signal svEOut : std_logic_vector(31 downto 0);
|
80 |
|
|
|
81 |
|
|
begin
|
82 |
|
|
process(iClk)
|
83 |
|
|
begin
|
84 |
|
|
if rising_edge(iClk) then
|
85 |
|
|
svAOut <= ivH + sum_1(ivE) + chi(ivE, ivF, ivG) + ivK + ivW + sum_0(ivA) + maj(ivA, ivB, ivC);
|
86 |
|
|
svEOut <= ivH + sum_1(ivE) + chi(ivE, ivF, ivG) + ivK + ivW + ivD;
|
87 |
|
|
end if;
|
88 |
|
|
end process;
|
89 |
|
|
|
90 |
|
|
ovA <= svAOut;
|
91 |
|
|
ovE <= svEOut;
|
92 |
|
|
|
93 |
|
|
process(iClk)
|
94 |
|
|
begin
|
95 |
|
|
if rising_edge(iClk) then
|
96 |
|
|
ovB <= ivA;
|
97 |
|
|
ovC <= ivB;
|
98 |
|
|
ovD <= ivC;
|
99 |
|
|
ovF <= ivE;
|
100 |
|
|
ovG <= ivF;
|
101 |
|
|
ovH <= ivG;
|
102 |
|
|
end if;
|
103 |
|
|
end process;
|
104 |
|
|
|
105 |
|
|
end behavioral;
|