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

Subversion Repositories deslcore

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

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 entactogen
----------------------------------------------------------------------------------
2
-- Company: 
3
-- Engineer: 
4
-- 
5
-- Create Date:    09:30:59 02/20/2013 
6
-- Design Name: 
7
-- Module Name:    des - Behavioral 
8
-- Project Name: 
9
-- Target Devices: 
10
-- Tool versions: 
11
-- Description: 
12
--
13
-- Dependencies: 
14
--
15
-- Revision: 
16
-- Revision 0.01 - File Created
17
-- Additional Comments: 
18
--
19
----------------------------------------------------------------------------------
20
library IEEE;
21
use IEEE.STD_LOGIC_1164.ALL;
22
 
23
-- Uncomment the following library declaration if using
24
-- arithmetic functions with Signed or Unsigned values
25
--use IEEE.NUMERIC_STD.ALL;
26
 
27
-- Uncomment the following library declaration if instantiating
28
-- any Xilinx primitives in this code.
29
--library UNISIM;
30
--use UNISIM.VComponents.all;
31
 
32
entity des_loop is
33
        port(clk :  in std_logic;
34
                  rst : in std_logic;
35
                  mode : in std_logic; -- 0 encrypt, 1 decrypt
36
                  key_in : in std_logic_vector(55 downto 0);
37
                  blk_in : in std_logic_vector(63 downto 0);
38
                  blk_out : out std_logic_vector(63 downto 0));
39
end des_loop;
40
 
41
architecture Behavioral of des_loop is
42
 
43
        signal after_ip_s : std_logic_vector(63 downto 0);
44
        signal after_ip_minus_one_s : std_logic_vector(63 downto 0);
45
        signal after_f_s : std_logic_vector(31 downto 0);
46
        signal final_s : std_logic_vector(63 downto 0);
47
 
48
        component des_round is
49
                port(clk : in std_logic;
50
                          l_0 : in std_logic_vector(31 downto 0);
51
                     r_0 : in std_logic_vector(31 downto 0);
52
                     k_i : in std_logic_vector(47 downto 0);
53
                     l_1 : out std_logic_vector(31 downto 0);
54
                     r_1 : out std_logic_vector(31 downto 0));
55
        end component;
56
 
57
        component key_schedule is
58
                port(clk : in std_logic;
59
                          rst : in std_logic;
60
                     mode : in std_logic; -- 0 encrypt, 1 decrypt
61
                key : in std_logic_vector(55 downto 0);
62
                     key_out : out std_logic_vector(47 downto 0));
63
        end component;
64
 
65
        signal key_s : std_logic_vector(47 downto 0);
66
 
67
        signal l_0_s : std_logic_vector(31 downto 0);
68
        signal l_1_s : std_logic_vector(31 downto 0);
69
        signal r_0_s : std_logic_vector(31 downto 0);
70
        signal r_1_s : std_logic_vector(31 downto 0);
71
 
72
        signal rst_s : std_logic;
73
 
74
begin
75
 
76
        pr_rst_delay : process(clk, rst)
77
        begin
78
                if rising_edge(clk) then
79
                        rst_s <= rst;
80
                end if;
81
        end process;
82
 
83
        pr_seq: process(clk, rst_s, blk_in)
84
        begin
85
                if rst_s = '1' then
86
                        l_0_s <= blk_in(63 downto 32);
87
                        r_0_s <= blk_in(31 downto 0);
88
                elsif rising_edge(clk) then
89
                        l_0_s <= l_1_s;
90
                        r_0_s <= r_1_s;
91
                end if;
92
        end process;
93
 
94
        DES_ROUND_0 :  des_round port map (clk, l_0_s, r_0_s, key_s, l_1_s, r_1_s);
95
 
96
        blk_out <= r_1_s & l_1_s;
97
 
98
        KEY_SCHEDULE_0 : key_schedule port map (clk, rst, mode, key_in, key_s);
99
 
100
end Behavioral;
101
 

powered by: WebSVN 2.1.0

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