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

Subversion Repositories deslcore

[/] [deslcore/] [trunk/] [rtl/] [des_loop.vhd] - Diff between revs 2 and 3

Only display areas with differences | Details | Blame | View Log

Rev 2 Rev 3
----------------------------------------------------------------------------------
 
-- Company: 
-- Copyright (c) 2013 Antonio de la Piedra
-- Engineer: 
 
-- 
-- This program is free software: you can redistribute it and/or modify
-- Create Date:    09:30:59 02/20/2013 
-- it under the terms of the GNU General Public License as published by
-- Design Name: 
-- the Free Software Foundation, either version 3 of the License, or
-- Module Name:    des - Behavioral 
-- (at your option) any later version.
-- Project Name: 
 
-- Target Devices: 
-- This program is distributed in the hope that it will be useful,
-- Tool versions: 
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- Description: 
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
--
-- GNU General Public License for more details.
-- Dependencies: 
 
--
-- You should have received a copy of the GNU General Public License
-- Revision: 
-- along with this program.  If not, see <http://www.gnu.org/licenses/>.
-- Revision 0.01 - File Created
 
-- Additional Comments: 
 
--
 
----------------------------------------------------------------------------------
 
library IEEE;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_1164.ALL;
 
 
-- Uncomment the following library declaration if using
 
-- arithmetic functions with Signed or Unsigned values
 
--use IEEE.NUMERIC_STD.ALL;
 
 
 
-- Uncomment the following library declaration if instantiating
 
-- any Xilinx primitives in this code.
 
--library UNISIM;
 
--use UNISIM.VComponents.all;
 
 
 
entity des_loop is
entity des_loop is
        port(clk :  in std_logic;
        port(clk :  in std_logic;
                  rst : in std_logic;
                  rst : in std_logic;
                  mode : in std_logic; -- 0 encrypt, 1 decrypt
                  mode : in std_logic; -- 0 encrypt, 1 decrypt
                  key_in : in std_logic_vector(55 downto 0);
                  key_in : in std_logic_vector(55 downto 0);
                  blk_in : in std_logic_vector(63 downto 0);
                  blk_in : in std_logic_vector(63 downto 0);
                  blk_out : out std_logic_vector(63 downto 0));
                  blk_out : out std_logic_vector(63 downto 0));
end des_loop;
end des_loop;
 
 
architecture Behavioral of des_loop is
architecture Behavioral of des_loop is
 
 
        signal after_ip_s : std_logic_vector(63 downto 0);
        signal after_ip_s : std_logic_vector(63 downto 0);
        signal after_ip_minus_one_s : std_logic_vector(63 downto 0);
        signal after_ip_minus_one_s : std_logic_vector(63 downto 0);
        signal after_f_s : std_logic_vector(31 downto 0);
        signal after_f_s : std_logic_vector(31 downto 0);
        signal final_s : std_logic_vector(63 downto 0);
        signal final_s : std_logic_vector(63 downto 0);
 
 
        component des_round is
        component des_round is
                port(clk : in std_logic;
                port(clk : in std_logic;
                          l_0 : in std_logic_vector(31 downto 0);
                          l_0 : in std_logic_vector(31 downto 0);
                     r_0 : in std_logic_vector(31 downto 0);
                     r_0 : in std_logic_vector(31 downto 0);
                     k_i : in std_logic_vector(47 downto 0);
                     k_i : in std_logic_vector(47 downto 0);
                     l_1 : out std_logic_vector(31 downto 0);
                     l_1 : out std_logic_vector(31 downto 0);
                     r_1 : out std_logic_vector(31 downto 0));
                     r_1 : out std_logic_vector(31 downto 0));
        end component;
        end component;
 
 
        component key_schedule is
        component key_schedule is
                port(clk : in std_logic;
                port(clk : in std_logic;
                          rst : in std_logic;
                          rst : in std_logic;
                     mode : in std_logic; -- 0 encrypt, 1 decrypt
                     mode : in std_logic; -- 0 encrypt, 1 decrypt
                key : in std_logic_vector(55 downto 0);
                key : in std_logic_vector(55 downto 0);
                     key_out : out std_logic_vector(47 downto 0));
                     key_out : out std_logic_vector(47 downto 0));
        end component;
        end component;
 
 
        signal key_s : std_logic_vector(47 downto 0);
        signal key_s : std_logic_vector(47 downto 0);
 
 
        signal l_0_s : std_logic_vector(31 downto 0);
        signal l_0_s : std_logic_vector(31 downto 0);
        signal l_1_s : std_logic_vector(31 downto 0);
        signal l_1_s : std_logic_vector(31 downto 0);
        signal r_0_s : std_logic_vector(31 downto 0);
        signal r_0_s : std_logic_vector(31 downto 0);
        signal r_1_s : std_logic_vector(31 downto 0);
        signal r_1_s : std_logic_vector(31 downto 0);
 
 
        signal rst_s : std_logic;
        signal rst_s : std_logic;
 
 
begin
begin
 
 
        pr_rst_delay : process(clk, rst)
        pr_rst_delay : process(clk, rst)
        begin
        begin
                if rising_edge(clk) then
                if rising_edge(clk) then
                        rst_s <= rst;
                        rst_s <= rst;
                end if;
                end if;
        end process;
        end process;
 
 
        pr_seq: process(clk, rst_s, blk_in)
        pr_seq: process(clk, rst_s, blk_in)
        begin
        begin
                if rst_s = '1' then
                if rst_s = '1' then
                        l_0_s <= blk_in(63 downto 32);
                        l_0_s <= blk_in(63 downto 32);
                        r_0_s <= blk_in(31 downto 0);
                        r_0_s <= blk_in(31 downto 0);
                elsif rising_edge(clk) then
                elsif rising_edge(clk) then
                        l_0_s <= l_1_s;
                        l_0_s <= l_1_s;
                        r_0_s <= r_1_s;
                        r_0_s <= r_1_s;
                end if;
                end if;
        end process;
        end process;
 
 
        DES_ROUND_0 :  des_round port map (clk, l_0_s, r_0_s, key_s, l_1_s, r_1_s);
        DES_ROUND_0 :  des_round port map (clk, l_0_s, r_0_s, key_s, l_1_s, r_1_s);
 
 
        blk_out <= r_1_s & l_1_s;
        blk_out <= r_1_s & l_1_s;
 
 
        KEY_SCHEDULE_0 : key_schedule port map (clk, rst, mode, key_in, key_s);
        KEY_SCHEDULE_0 : key_schedule port map (clk, rst, mode, key_in, key_s);
 
 
end Behavioral;
end Behavioral;
 
 
 
 

powered by: WebSVN 2.1.0

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