| 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 |
|
|
---- Substitution layer of Present cipher. Simple logic. ----
|
| 11 |
|
|
---- For more information see ----
|
| 12 |
|
|
---- http://homes.esat.kuleuven.be/~abogdano/papers/ ----
|
| 13 |
|
|
---- present_ches07.pdf ----
|
| 14 |
|
|
---- To Do: ----
|
| 15 |
|
|
---- ----
|
| 16 |
|
|
---- Author(s): ----
|
| 17 |
|
|
---- - Krzysztof Gajewski, gajos@opencores.org ----
|
| 18 |
|
|
---- k.gajewski@gmail.com ----
|
| 19 |
|
|
---- ----
|
| 20 |
|
|
-----------------------------------------------------------------------
|
| 21 |
|
|
---- ----
|
| 22 |
|
|
---- Copyright (C) 2013 Authors and OPENCORES.ORG ----
|
| 23 |
|
|
---- ----
|
| 24 |
|
|
---- This source file may be used and distributed without ----
|
| 25 |
|
|
---- restriction provided that this copyright statement is not ----
|
| 26 |
|
|
---- removed from the file and that any derivative work contains ----
|
| 27 |
|
|
---- the original copyright notice and the associated disclaimer. ----
|
| 28 |
|
|
---- ----
|
| 29 |
|
|
---- This source file is free software; you can redistribute it ----
|
| 30 |
|
|
---- and-or modify it under the terms of the GNU Lesser General ----
|
| 31 |
|
|
---- Public License as published by the Free Software Foundation; ----
|
| 32 |
|
|
---- either version 2.1 of the License, or (at your option) any ----
|
| 33 |
|
|
---- later version. ----
|
| 34 |
|
|
---- ----
|
| 35 |
|
|
---- This source is distributed in the hope that it will be ----
|
| 36 |
|
|
---- useful, but WITHOUT ANY WARRANTY; without even the implied ----
|
| 37 |
|
|
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ----
|
| 38 |
|
|
---- PURPOSE. See the GNU Lesser General Public License for more ----
|
| 39 |
|
|
---- details. ----
|
| 40 |
|
|
---- ----
|
| 41 |
|
|
---- You should have received a copy of the GNU Lesser General ----
|
| 42 |
|
|
---- Public License along with this source; if not, download it ----
|
| 43 |
|
|
---- from http://www.opencores.org/lgpl.shtml ----
|
| 44 |
|
|
---- ----
|
| 45 |
|
|
-----------------------------------------------------------------------
|
| 46 |
3 |
gajos |
library IEEE;
|
| 47 |
|
|
use IEEE.STD_LOGIC_1164.ALL;
|
| 48 |
|
|
use IEEE.STD_LOGIC_ARITH.ALL;
|
| 49 |
|
|
use IEEE.STD_LOGIC_UNSIGNED.ALL;
|
| 50 |
|
|
|
| 51 |
|
|
entity slayer is
|
| 52 |
|
|
generic (
|
| 53 |
|
|
w_4 : integer := 4
|
| 54 |
|
|
);
|
| 55 |
|
|
port (
|
| 56 |
|
|
input : in std_logic_vector(w_4-1 downto 0);
|
| 57 |
|
|
output : out std_logic_vector(w_4-1 downto 0)
|
| 58 |
|
|
);
|
| 59 |
|
|
end slayer;
|
| 60 |
|
|
|
| 61 |
|
|
architecture Behavioral of slayer is
|
| 62 |
|
|
|
| 63 |
|
|
begin
|
| 64 |
|
|
output <= x"C" when input = x"0" else
|
| 65 |
|
|
x"5" when input = x"1" else
|
| 66 |
|
|
x"6" when input = x"2" else
|
| 67 |
|
|
x"B" when input = x"3" else
|
| 68 |
|
|
x"9" when input = x"4" else
|
| 69 |
|
|
x"0" when input = x"5" else
|
| 70 |
|
|
x"A" when input = x"6" else
|
| 71 |
|
|
x"D" when input = x"7" else
|
| 72 |
|
|
x"3" when input = x"8" else
|
| 73 |
|
|
x"E" when input = x"9" else
|
| 74 |
|
|
x"F" when input = x"A" else
|
| 75 |
|
|
x"8" when input = x"B" else
|
| 76 |
|
|
x"4" when input = x"C" else
|
| 77 |
|
|
x"7" when input = x"D" else
|
| 78 |
|
|
x"1" when input = x"E" else
|
| 79 |
|
|
x"2" when input = x"F" else
|
| 80 |
|
|
"ZZZZ";
|
| 81 |
|
|
end Behavioral;
|