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

Subversion Repositories deslcore

[/] [deslcore/] [trunk/] [rtl/] [des_loop.vhd] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 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 2 entactogen
library IEEE;
18
use IEEE.STD_LOGIC_1164.ALL;
19
 
20
entity des_loop is
21
        port(clk :  in std_logic;
22
                  rst : in std_logic;
23
                  mode : in std_logic; -- 0 encrypt, 1 decrypt
24
                  key_in : in std_logic_vector(55 downto 0);
25
                  blk_in : in std_logic_vector(63 downto 0);
26
                  blk_out : out std_logic_vector(63 downto 0));
27
end des_loop;
28
 
29
architecture Behavioral of des_loop is
30
 
31
        signal after_ip_s : std_logic_vector(63 downto 0);
32
        signal after_ip_minus_one_s : std_logic_vector(63 downto 0);
33
        signal after_f_s : std_logic_vector(31 downto 0);
34
        signal final_s : std_logic_vector(63 downto 0);
35
 
36
        component des_round is
37
                port(clk : in std_logic;
38
                          l_0 : in std_logic_vector(31 downto 0);
39
                     r_0 : in std_logic_vector(31 downto 0);
40
                     k_i : in std_logic_vector(47 downto 0);
41
                     l_1 : out std_logic_vector(31 downto 0);
42
                     r_1 : out std_logic_vector(31 downto 0));
43
        end component;
44
 
45
        component key_schedule is
46
                port(clk : in std_logic;
47
                          rst : in std_logic;
48
                     mode : in std_logic; -- 0 encrypt, 1 decrypt
49
                key : in std_logic_vector(55 downto 0);
50
                     key_out : out std_logic_vector(47 downto 0));
51
        end component;
52
 
53
        signal key_s : std_logic_vector(47 downto 0);
54
 
55
        signal l_0_s : std_logic_vector(31 downto 0);
56
        signal l_1_s : std_logic_vector(31 downto 0);
57
        signal r_0_s : std_logic_vector(31 downto 0);
58
        signal r_1_s : std_logic_vector(31 downto 0);
59
 
60
        signal rst_s : std_logic;
61
 
62
begin
63
 
64
        pr_rst_delay : process(clk, rst)
65
        begin
66
                if rising_edge(clk) then
67
                        rst_s <= rst;
68
                end if;
69
        end process;
70
 
71
        pr_seq: process(clk, rst_s, blk_in)
72
        begin
73
                if rst_s = '1' then
74
                        l_0_s <= blk_in(63 downto 32);
75
                        r_0_s <= blk_in(31 downto 0);
76
                elsif rising_edge(clk) then
77
                        l_0_s <= l_1_s;
78
                        r_0_s <= r_1_s;
79
                end if;
80
        end process;
81
 
82
        DES_ROUND_0 :  des_round port map (clk, l_0_s, r_0_s, key_s, l_1_s, r_1_s);
83
 
84
        blk_out <= r_1_s & l_1_s;
85
 
86
        KEY_SCHEDULE_0 : key_schedule port map (clk, rst, mode, key_in, key_s);
87
 
88
end Behavioral;
89
 

powered by: WebSVN 2.1.0

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