1 |
2 |
dsocek |
---------------------------------------------------------------------
|
2 |
|
|
-- (c) Copyright 2006, CoreTex Systems, LLC --
|
3 |
|
|
-- www.coretexsys.com --
|
4 |
|
|
-- --
|
5 |
|
|
-- This source file may be used and distributed without --
|
6 |
|
|
-- restriction provided that this copyright statement is not --
|
7 |
|
|
-- removed from the file and that any derivative work contains --
|
8 |
|
|
-- the original copyright notice and the associated disclaimer. --
|
9 |
|
|
-- --
|
10 |
|
|
-- THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY --
|
11 |
|
|
-- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED --
|
12 |
|
|
-- TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS --
|
13 |
|
|
-- FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR --
|
14 |
|
|
-- OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, --
|
15 |
|
|
-- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES --
|
16 |
|
|
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE --
|
17 |
|
|
-- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR --
|
18 |
|
|
-- BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
|
19 |
|
|
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
|
20 |
|
|
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT --
|
21 |
|
|
-- OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE --
|
22 |
|
|
-- POSSIBILITY OF SUCH DAMAGE. --
|
23 |
|
|
-- --
|
24 |
|
|
---------------------------------------------------------------------
|
25 |
|
|
|
26 |
|
|
----------------------------------------------------------------------
|
27 |
|
|
|
28 |
|
|
-- Poject structure:
|
29 |
|
|
|
30 |
|
|
-- |- tdes_top.vhd
|
31 |
|
|
-- |
|
32 |
|
|
-- |- des_cipher_top.vhd
|
33 |
|
|
-- |- des_top.vhd
|
34 |
|
|
-- |- block_top.vhd
|
35 |
|
|
-- |- add_key.vhd
|
36 |
|
|
-- |
|
37 |
|
|
-- |- add_left.vhd
|
38 |
|
|
-- |
|
39 |
|
|
-- |- e_expansion_function.vhd
|
40 |
|
|
-- |
|
41 |
|
|
-- |- p_box.vhd
|
42 |
|
|
-- |
|
43 |
|
|
-- |- s_box.vhd
|
44 |
|
|
-- |- s1_box.vhd
|
45 |
|
|
-- |- s2_box.vhd
|
46 |
|
|
-- |- s3_box.vhd
|
47 |
|
|
-- |- s4_box.vhd
|
48 |
|
|
-- |- s5_box.vhd
|
49 |
|
|
-- |- s6_box.vhd
|
50 |
|
|
-- |- s7_box.vhd
|
51 |
|
|
-- |- s8_box.vhd
|
52 |
|
|
-- |- key_schedule.vhd
|
53 |
|
|
|
54 |
|
|
----------------------------------------------------------------------
|
55 |
|
|
|
56 |
|
|
---------------------------------------------------------------------------------------------------
|
57 |
|
|
--
|
58 |
|
|
-- Title : s1_box
|
59 |
|
|
-- Company : CoreTex Systems, LLC
|
60 |
|
|
--
|
61 |
|
|
---------------------------------------------------------------------------------------------------
|
62 |
|
|
|
63 |
|
|
library IEEE;
|
64 |
|
|
use IEEE.STD_LOGIC_1164.ALL;
|
65 |
|
|
use IEEE.STD_LOGIC_ARITH.ALL;
|
66 |
|
|
use IEEE.STD_LOGIC_UNSIGNED.ALL;
|
67 |
|
|
|
68 |
|
|
ENTITY s1_box IS
|
69 |
|
|
port (
|
70 |
|
|
A: IN std_logic_VECTOR(5 downto 0);
|
71 |
|
|
SPO: OUT std_logic_VECTOR(3 downto 0));
|
72 |
|
|
END s1_box;
|
73 |
|
|
|
74 |
|
|
architecture Behavioral of s1_box is
|
75 |
|
|
|
76 |
|
|
begin
|
77 |
|
|
|
78 |
|
|
SPO <= "1110" when A = x"0" else
|
79 |
|
|
"0000" when A = x"1" else
|
80 |
|
|
"0100" when A = x"2" else
|
81 |
|
|
"1111" when A = x"3" else
|
82 |
|
|
"1101" when A = x"4" else
|
83 |
|
|
"0111" when A = x"5" else
|
84 |
|
|
"0001" when A = x"6" else
|
85 |
|
|
"0100" when A = x"7" else
|
86 |
|
|
"0010" when A = x"8" else
|
87 |
|
|
"1110" when A = x"9" else
|
88 |
|
|
"1111" when A = x"A" else
|
89 |
|
|
"0010" when A = x"B" else
|
90 |
|
|
"1011" when A = x"C" else
|
91 |
|
|
"1101" when A = x"D" else
|
92 |
|
|
"1000" when A = x"E" else
|
93 |
|
|
"0001" when A = x"F" else
|
94 |
|
|
"0011" when A = x"10" else
|
95 |
|
|
"1010" when A = x"11" else
|
96 |
|
|
"1010" when A = x"12" else
|
97 |
|
|
"0110" when A = x"13" else
|
98 |
|
|
"0110" when A = x"14" else
|
99 |
|
|
"1100" when A = x"15" else
|
100 |
|
|
"1100" when A = x"16" else
|
101 |
|
|
"1011" when A = x"17" else
|
102 |
|
|
"0101" when A = x"18" else
|
103 |
|
|
"1001" when A = x"19" else
|
104 |
|
|
"1001" when A = x"1A" else
|
105 |
|
|
"0101" when A = x"1B" else
|
106 |
|
|
"0000" when A = x"1C" else
|
107 |
|
|
"0011" when A = x"1D" else
|
108 |
|
|
"0111" when A = x"1E" else
|
109 |
|
|
"1000" when A = x"1F" else
|
110 |
|
|
"0100" when A = x"20" else
|
111 |
|
|
"1111" when A = x"21" else
|
112 |
|
|
"0001" when A = x"22" else
|
113 |
|
|
"1100" when A = x"23" else
|
114 |
|
|
"1110" when A = x"24" else
|
115 |
|
|
"1000" when A = x"25" else
|
116 |
|
|
"1000" when A = x"26" else
|
117 |
|
|
"0010" when A = x"27" else
|
118 |
|
|
"1101" when A = x"28" else
|
119 |
|
|
"0100" when A = x"29" else
|
120 |
|
|
"0110" when A = x"2A" else
|
121 |
|
|
"1001" when A = x"2B" else
|
122 |
|
|
"0010" when A = x"2C" else
|
123 |
|
|
"0001" when A = x"2D" else
|
124 |
|
|
"1011" when A = x"2E" else
|
125 |
|
|
"0111" when A = x"2F" else
|
126 |
|
|
"1111" when A = x"30" else
|
127 |
|
|
"0101" when A = x"31" else
|
128 |
|
|
"1100" when A = x"32" else
|
129 |
|
|
"1011" when A = x"33" else
|
130 |
|
|
"1001" when A = x"34" else
|
131 |
|
|
"0011" when A = x"35" else
|
132 |
|
|
"0111" when A = x"36" else
|
133 |
|
|
"1110" when A = x"37" else
|
134 |
|
|
"0011" when A = x"38" else
|
135 |
|
|
"1010" when A = x"39" else
|
136 |
|
|
"1010" when A = x"3A" else
|
137 |
|
|
"0000" when A = x"3B" else
|
138 |
|
|
"0101" when A = x"3C" else
|
139 |
|
|
"0110" when A = x"3D" else
|
140 |
|
|
"0000" when A = x"3E" else
|
141 |
|
|
"1101" when A = x"3F" else
|
142 |
|
|
"1101";
|
143 |
|
|
|
144 |
|
|
END Behavioral;
|