1 |
2 |
ruschi |
------------------------------------------------------------------------------
|
2 |
10 |
ruschi |
-- This file is part of the project avs_aes
|
3 |
|
|
-- see: http://opencores.org/project,avs_aes
|
4 |
2 |
ruschi |
--
|
5 |
|
|
-- description:
|
6 |
|
|
-- Sbox implements a lookup ROM for nonlinear substitution of a Bytearray.
|
7 |
|
|
-- This is only the entity for either arch1 (which is pure VHDL) or M4K which
|
8 |
|
|
-- is an Altera M4K-Blockram implementation.
|
9 |
|
|
--
|
10 |
|
|
-------------------------------------------------------------------------------!
|
11 |
|
|
--
|
12 |
|
|
-- Author(s):
|
13 |
|
|
-- Thomas Ruschival -- ruschi@opencores.org (www.ruschival.de)
|
14 |
|
|
--
|
15 |
|
|
--------------------------------------------------------------------------------
|
16 |
|
|
-- Copyright (c) 2009, Authors and opencores.org
|
17 |
|
|
-- All rights reserved.
|
18 |
|
|
--
|
19 |
|
|
-- Redistribution and use in source and binary forms, with or without modification,
|
20 |
|
|
-- are permitted provided that the following conditions are met:
|
21 |
|
|
-- * Redistributions of source code must retain the above copyright notice,
|
22 |
|
|
-- this list of conditions and the following disclaimer.
|
23 |
|
|
-- * Redistributions in binary form must reproduce the above copyright notice,
|
24 |
|
|
-- this list of conditions and the following disclaimer in the documentation
|
25 |
|
|
-- and/or other materials provided with the distribution.
|
26 |
|
|
-- * Neither the name of the organization nor the names of its contributors
|
27 |
|
|
-- may be used to endorse or promote products derived from this software without
|
28 |
|
|
-- specific prior written permission.
|
29 |
|
|
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
30 |
|
|
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
31 |
|
|
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
32 |
|
|
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
33 |
|
|
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
34 |
|
|
-- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
35 |
|
|
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
36 |
|
|
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
37 |
|
|
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
38 |
|
|
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
39 |
|
|
-- THE POSSIBILITY OF SUCH DAMAGE
|
40 |
|
|
-------------------------------------------------------------------------------
|
41 |
|
|
-- version management:
|
42 |
|
|
-- $Author$
|
43 |
|
|
-- $Date$
|
44 |
|
|
-- $Revision$
|
45 |
|
|
-------------------------------------------------------------------------------
|
46 |
|
|
library ieee;
|
47 |
|
|
use ieee.std_logic_1164.all;
|
48 |
|
|
|
49 |
|
|
-------------------------------------------------------------------------------
|
50 |
|
|
-- The interface is 2x8Bit because Altera megafunction is supposed to be at max
|
51 |
|
|
-- 8Bit dual port ROM (and I relied on a altera quartus generated component
|
52 |
|
|
-- before) see architecture m4k
|
53 |
|
|
-------------------------------------------------------------------------------
|
54 |
|
|
entity sbox is
|
55 |
|
|
generic (
|
56 |
|
|
INVERSE : BOOLEAN := false -- is this the inverse or the forward
|
57 |
|
|
-- lookup table.
|
58 |
|
|
-- TRUE -> inverse sbox
|
59 |
|
|
-- FALSE -> forward sbox
|
60 |
|
|
);
|
61 |
|
|
port(
|
62 |
|
|
clk : in STD_LOGIC; -- system clock
|
63 |
|
|
address_a : in STD_LOGIC_VECTOR (7 downto 0); -- 1st byte
|
64 |
|
|
address_b : in STD_LOGIC_VECTOR (7 downto 0); -- 2nd byte
|
65 |
|
|
q_a : out STD_LOGIC_VECTOR (7 downto 0); -- substituted 1st byte
|
66 |
|
|
q_b : out STD_LOGIC_VECTOR (7 downto 0) -- substituted 2nd byte
|
67 |
|
|
);
|
68 |
|
|
end sbox;
|
69 |
|
|
|