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

Subversion Repositories present

[/] [present/] [trunk/] [DecodeTesting/] [rtl/] [vhdl/] [PresentFullDecoder.vhd] - Blame information for rev 16

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

Line No. Rev Author Line
1 4 gajos
-----------------------------------------------------------------------
2
----                                                               ----
3
---- Present - a lightweight block cipher project                  ----
4
----                                                               ----
5
---- This file is part of the Present - a lightweight block        ----
6
---- cipher project                                                ----
7
---- http://www.http://opencores.org/project,present               ----
8
----                                                               ----
9
---- Description:                                                  ----
10
----     Present decoder with suitable key generator for decoding  ----
11
---- (basing on given encode key).                                 ----
12
---- To Do:                                                        ----
13
----                                                               ----
14
---- Author(s):                                                    ----
15
---- - Krzysztof Gajewski, gajos@opencores.org                     ----
16
----                       k.gajewski@gmail.com                    ----
17
----                                                               ----
18
-----------------------------------------------------------------------
19
----                                                               ----
20
---- Copyright (C) 2013 Authors and OPENCORES.ORG                  ----
21
----                                                               ----
22
---- This source file may be used and distributed without          ----
23
---- restriction provided that this copyright statement is not     ----
24
---- removed from the file and that any derivative work contains   ----
25
---- the original copyright notice and the associated disclaimer.  ----
26
----                                                               ----
27
---- This source file is free software; you can redistribute it    ----
28
---- and-or modify it under the terms of the GNU Lesser General    ----
29
---- Public License as published by the Free Software Foundation;  ----
30
---- either version 2.1 of the License, or (at your option) any    ----
31
---- later version.                                                ----
32
----                                                               ----
33
---- This source is distributed in the hope that it will be        ----
34
---- useful, but WITHOUT ANY WARRANTY; without even the implied    ----
35
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR       ----
36
---- PURPOSE. See the GNU Lesser General Public License for more   ----
37
---- details.                                                      ----
38
----                                                               ----
39
---- You should have received a copy of the GNU Lesser General     ----
40
---- Public License along with this source; if not, download it    ----
41
---- from http://www.opencores.org/lgpl.shtml                      ----
42
----                                                               ----
43
-----------------------------------------------------------------------
44 3 gajos
library IEEE;
45
use IEEE.STD_LOGIC_1164.ALL;
46
 
47
-- Uncomment the following library declaration if using
48
-- arithmetic functions with Signed or Unsigned values
49
--use IEEE.NUMERIC_STD.ALL;
50
 
51
-- Uncomment the following library declaration if instantiating
52
-- any Xilinx primitives in this code.
53
--library UNISIM;
54
--use UNISIM.VComponents.all;
55
 
56
entity PresentFullDecoder is
57
        generic (
58
                        w_2: integer := 2;
59
                        w_4: integer := 4;
60
                        w_5: integer := 5;
61
                        w_32: integer := 32;
62
                        w_64: integer := 64;
63
                        w_80: integer := 80
64
        );
65
        port(
66
                ciphertext : in std_logic_vector(w_64 - 1 downto 0);
67
                key               : in std_logic_vector(w_80 - 1 downto 0);
68
                plaintext  : out std_logic_vector(w_64 - 1 downto 0);
69
                start, clk, reset : in std_logic;
70
                ready : out std_logic
71
        );
72
end PresentFullDecoder;
73
 
74
architecture Behavioral of PresentFullDecoder is
75
 
76 4 gajos
-- Key generator component
77 3 gajos
component PresentEncKeyGen is
78
        generic (
79
                        w_2: integer := 2;
80
                        w_4: integer := 4;
81
                        w_5: integer := 5;
82
                        w_80: integer := 80
83
        );
84
        port(
85
                key             : in std_logic_vector(w_80 - 1 downto 0);
86
                key_end : out std_logic_vector(w_80 - 1 downto 0);
87
                start, clk, reset : in std_logic;
88
                ready : out std_logic
89
        );
90
end component PresentEncKeyGen;
91
 
92 4 gajos
-- 'pure' Present decoder
93 3 gajos
component PresentDec is
94
        generic (
95
                        w_2: integer := 2;
96
                        w_4: integer := 4;
97
                        w_5: integer := 5;
98
                        w_32: integer := 32;
99
                        w_64: integer := 64;
100
                        w_80: integer := 80
101
        );
102
        port(
103
                plaintext  : in std_logic_vector(w_64 - 1 downto 0);
104
                key               : in std_logic_vector(w_80 - 1 downto 0);
105
                ciphertext : out std_logic_vector(w_64 - 1 downto 0);
106
                start, clk, reset : in std_logic;
107
                ready : out std_logic
108
        );
109
end component PresentDec;
110
 
111
component FullDecoderSM is
112
        port(
113
                key_gen_start : out std_logic;
114
                key_gen_ready : in std_logic;
115
                decode_start  : out std_logic;
116
                decode_ready  : in std_logic;
117
                full_decoder_start :in std_logic;
118
                full_decoder_ready : out std_logic;
119
                clk, reset  :in std_logic
120
        );
121
end component FullDecoderSM;
122
 
123 4 gajos
-- signals
124
 
125 3 gajos
signal key_gen_output : std_logic_vector(w_80 - 1 downto 0);
126
 
127
signal key_gen_start : std_logic;
128
signal key_gen_ready : std_logic;
129
 
130
signal decode_start  : std_logic;
131
signal decode_ready  : std_logic;
132
 
133
begin
134
 
135 4 gajos
    -- connections
136
 
137 3 gajos
        keyGen : PresentEncKeyGen
138
                port map(
139
                        key             => key,
140
                        key_end => key_gen_output,
141
                        start           => key_gen_start,
142
                        clk             => clk,
143
                        reset           => reset,
144
                        ready           => key_gen_ready
145
        );
146
 
147
        decoder : PresentDec
148
                port map(
149
                        plaintext       => ciphertext,
150
                        key                     => key_gen_output,
151
                        ciphertext      => plaintext,
152
                        start                   => decode_start,
153
                        clk                     => clk,
154
                        reset                   => reset,
155
                        ready           => decode_ready
156
        );
157
 
158
        SM : FullDecoderSM
159
                port map(
160
                        key_gen_start => key_gen_start,
161
                        key_gen_ready => key_gen_ready,
162
                        decode_start  => decode_start,
163
                        decode_ready  => decode_ready,
164
                        full_decoder_start => start,
165
                        full_decoder_ready => ready,
166
                        clk => clk,
167
                        reset => reset
168
        );
169
 
170
end Behavioral;

powered by: WebSVN 2.1.0

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