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

Subversion Repositories deslxcore

[/] [deslxcore/] [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
                  key_pre_w_in : in std_logic_vector(63 downto 0);
38
                  key_pos_w_in : in std_logic_vector(63 downto 0);
39
                  blk_in : in std_logic_vector(63 downto 0);
40
                  blk_out : out std_logic_vector(63 downto 0));
41
end des_loop;
42
 
43
architecture Behavioral of des_loop is
44
 
45
        signal after_ip_s : std_logic_vector(63 downto 0);
46
        signal after_ip_minus_one_s : std_logic_vector(63 downto 0);
47
        signal after_f_s : std_logic_vector(31 downto 0);
48
        signal final_s : std_logic_vector(63 downto 0);
49
 
50
        component des_round is
51
                port(clk : in std_logic;
52
                          l_0 : in std_logic_vector(31 downto 0);
53
                     r_0 : in std_logic_vector(31 downto 0);
54
                     k_i : in std_logic_vector(47 downto 0);
55
                     l_1 : out std_logic_vector(31 downto 0);
56
                     r_1 : out std_logic_vector(31 downto 0));
57
        end component;
58
 
59
        component key_schedule is
60
                port(clk : in std_logic;
61
                          rst : in std_logic;
62
                     mode : in std_logic; -- 0 encrypt, 1 decrypt
63
                key : in std_logic_vector(55 downto 0);
64
                     key_out : out std_logic_vector(47 downto 0));
65
        end component;
66
 
67
        signal key_s : std_logic_vector(47 downto 0);
68
 
69
        signal l_0_s : std_logic_vector(31 downto 0);
70
        signal l_1_s : std_logic_vector(31 downto 0);
71
        signal r_0_s : std_logic_vector(31 downto 0);
72
        signal r_1_s : std_logic_vector(31 downto 0);
73
 
74
        signal rst_s : std_logic;
75
 
76
        signal blk_in_s  : std_logic_vector(63 downto 0);
77
        signal blk_out_s : std_logic_vector(63 downto 0);
78
 
79
begin
80
 
81
        pr_rst_delay : process(clk, rst)
82
        begin
83
                if rising_edge(clk) then
84
                        rst_s <= rst;
85
                end if;
86
        end process;
87
 
88
        blk_in_s <= (blk_in xor key_pre_w_in) when mode = '0' else (blk_in xor key_pos_w_in);
89
 
90
        pr_seq: process(clk, rst_s, blk_in)
91
        begin
92
                if rst_s = '1' then
93
                        l_0_s <= blk_in_s(63 downto 32);
94
                        r_0_s <= blk_in_s(31 downto 0);
95
                elsif rising_edge(clk) then
96
                        l_0_s <= l_1_s;
97
                        r_0_s <= r_1_s;
98
                end if;
99
        end process;
100
 
101
        DES_ROUND_0 :  des_round port map (clk, l_0_s, r_0_s, key_s, l_1_s, r_1_s);
102
 
103
        blk_out_s <= r_1_s & l_1_s;
104
 
105
        blk_out <= (blk_out_s xor key_pre_w_in) when mode = '1' else (blk_out_s xor key_pos_w_in);
106
 
107
        KEY_SCHEDULE_0 : key_schedule port map (clk, rst, mode, key_in, key_s);
108
 
109
end Behavioral;
110
 

powered by: WebSVN 2.1.0

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