OpenCores
URL https://opencores.org/ocsvn/3des_vhdl/3des_vhdl/trunk

Subversion Repositories 3des_vhdl

[/] [3des_vhdl/] [trunk/] [VHDL/] [des_cipher_top.vhd] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dsocek
---------------------------------------------------------------------
2
--                              (c) Copyright 2006, CoreTex Systems, LLC                                         --
3
--                                 www.coretexsys.com                        --    
4
--                                                                       --
5
--              This source file may be used and distributed without         --
6
--              restriction provided that this copyright statement is not    --
7
--              removed from the file and that any derivative work contains  --
8
--              the original copyright notice and the associated disclaimer. --
9
--                                                                       --
10
--                  THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY      --
11
--              EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED    --
12
--              TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS    --
13
--              FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR       --
14
--              OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,          --
15
--              INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES     --
16
--              (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE    --
17
--              GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR         --
18
--              BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF   --
19
--              LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT   --
20
--              (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT   --
21
--              OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE          --
22
--              POSSIBILITY OF SUCH DAMAGE.                                  --
23
--                                                                                                                                                                               --
24
---------------------------------------------------------------------
25
 
26
----------------------------------------------------------------------
27
 
28
-- Poject structure: 
29
 
30
--  |- tdes_top.vhd
31
--  |
32
--    |- des_cipher_top.vhd
33
--    |- des_top.vhd
34
--      |- block_top.vhd
35
--        |- add_key.vhd
36
--        |
37
--        |- add_left.vhd
38
--        |
39
--                              |- e_expansion_function.vhd
40
--                              |
41
--                              |- p_box.vhd
42
--                              |
43
--                              |- s_box.vhd
44
--            |- s1_box.vhd
45
--            |- s2_box.vhd
46
--            |- s3_box.vhd
47
--            |- s4_box.vhd
48
--            |- s5_box.vhd
49
--            |- s6_box.vhd
50
--            |- s7_box.vhd
51
--            |- s8_box.vhd
52
--    |- key_schedule.vhd
53
 
54
----------------------------------------------------------------------
55
---------------------------------------------------------------------------------------------------
56
--
57
-- Title       : des_cipher_top
58
-- Company     : CoreTex Systems, LLC
59
--
60
---------------------------------------------------------------------------------------------------
61
 
62
library IEEE;
63
use IEEE.STD_LOGIC_1164.ALL;
64
use IEEE.STD_LOGIC_ARITH.ALL;
65
use IEEE.STD_LOGIC_UNSIGNED.ALL;
66
 
67
entity des_cipher_top is
68
port(
69
                --
70
                -- Core Interface 
71
                --
72
                key_in:                         in std_logic_vector(0 to 63);            -- input for key
73
                --ldkey:                                in std_logic;                                                   -- signal for loading key
74
                function_select:        in      std_logic;                                                      -- function     select: '1' = encryption, '0' = decryption
75
 
76
                data_in:                                in std_logic_vector(0 to 63);            -- input for data
77
 
78
                data_out:                       out std_logic_vector(0 to 63);   -- output for data
79
 
80
                lddata:                         in      std_logic;                                              -- data strobe (active high)
81
                core_busy:                      out     std_logic;                                              -- active high when encrypting/decryption data 
82
                des_out_rdy:            out     std_logic;                                              -- active high when encryption/decryption of data is done       
83
 
84
                reset:                          in std_logic;                                                   -- active high
85
                clock:                          in std_logic                                                    -- master clock
86
 
87
        );
88
end des_cipher_top;
89
 
90
architecture Behavioral of des_cipher_top is
91
 
92
--
93
-- 
94
--
95
component key_schedule is
96
port (
97
                -- Signals for loading key from external device
98
                key_in:                 in std_logic_vector(0 to 63);            -- input for key
99
 
100
                -- signals for communication with des top
101
                KeySelect:              in std_logic_vector(3 downto 0); -- selector for key
102
        key_out:                out std_logic_vector(0 to 47);   -- expaned key (depends on selector)
103
                key_ready:              out std_logic;                                                  -- signal for the core that key has been expanded
104
 
105
                reset: in std_logic;                                                                    -- active high
106
                clock: in std_logic                                                                     -- master clock
107
                );
108
end component;
109
 
110
component des_top is
111
port (
112
                -- Main Data
113
                key_round_in:   in      std_logic_vector(0 to 47);
114
                data_in:                        in      std_logic_vector(0 to 63);
115
                data_out:               out     std_logic_vector(0 to 63);
116
 
117
                -- Signals for communication with des 
118
                KeySelect:              inout std_logic_vector(3 downto 0);      -- selector for key
119
                key_ready:              in std_logic;                                                           -- signal for aes that key has been expanded
120
                data_ready:     in std_logic;                                                           -- signal for aes that key has been expanded
121
                func_select:    in std_logic;
122
 
123
                des_out_rdy:    out std_logic;
124
                core_busy:              out std_logic;
125
 
126
                reset:                  in std_logic;
127
                clock:                  in std_logic                                                            -- master clock
128
                );
129
end component;
130
 
131
signal key_select_internal: std_logic_vector(3 downto 0);
132
signal key_round_internal: std_logic_vector(0 to 47);
133
signal key_ready_internal: std_logic;
134
signal data_in_internal: std_logic_vector(0 to 63);
135
signal data_ready_internal: std_logic;
136
 
137
begin
138
 
139
process (clock)
140
begin
141
 
142
if rising_edge(clock) then
143
 
144
                if lddata = '1' then
145
 
146
                        -- capute data from the bus
147
                        data_in_internal                <= data_in; -- register data from the bus
148
                        data_ready_internal     <= '1';         -- data has been loaded: continue with encryptio/decryption   
149
 
150
                else
151
 
152
                        data_ready_internal     <= '0';          -- data is not loaded: wait for data 
153
 
154
                end if;
155
 
156
end if;
157
end process;
158
 
159
--
160
-- KEY EXPANDER AND DES CORE instantiation
161
--
162
KEYSCHEDULE: key_schedule
163
port map (
164
 
165
                KeySelect       => key_select_internal,
166
                key_in          => key_in,
167
 
168
                key_out                 => key_round_internal,
169
                key_ready       => key_ready_internal,
170
 
171
                reset           => reset,
172
                clock           => clock
173
);
174
 
175
DESTOP: des_top
176
port map (
177
 
178
                key_round_in    => key_round_internal,
179
 
180
                data_in                 => data_in_internal,
181
 
182
                key_ready               => key_ready_internal,
183
                data_ready              => data_ready_internal,
184
 
185
                KeySelect               => key_select_internal,
186
 
187
                func_select     => function_select,
188
 
189
                data_out                => data_out,
190
                core_busy               => core_busy,
191
                des_out_rdy     => des_out_rdy,
192
 
193
                reset                   => reset,
194
                clock                   => clock
195
);
196
 
197
end Behavioral;

powered by: WebSVN 2.1.0

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