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

Subversion Repositories avs_aes

[/] [avs_aes/] [trunk/] [rtl/] [VHDL/] [sboxM4k.vhd] - Blame information for rev 20

Details | Compare with Previous | View Log

Line No. Rev Author Line
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
-- instantiation of an Altera M4K blockram as dual port ROM
7
-- they have the nice feature of allowing an initialization file. with the
8
-- generic rominitfile it is possible to select the encryption or decryption
9
-- version sbox.hex and sbox_inv.hex
10
-- Only 8-Bit dual port was supported on CyloneII... this is why we need a lot
11
-- of blockrams in aes_core.vhd AND keyexpansionV2.vhd
12
--
13
-------------------------------------------------------------------------------
14
-- Todo:
15
--
16
-- Author(s):
17
--         Thomas Ruschival -- ruschi@opencores.org (www.ruschival.de)
18
--
19
--------------------------------------------------------------------------------
20
-- Copyright (c) 2009, Authors and opencores.org
21
-- All rights reserved.
22
--
23
-- Redistribution and use in source and binary forms, with or without modification,
24
-- are permitted provided that the following conditions are met:
25
--        * Redistributions of source code must retain the above copyright notice,
26
--        this list of conditions and the following disclaimer.
27
--        * Redistributions in binary form must reproduce the above copyright notice,
28
--        this list of conditions and the following disclaimer in the documentation
29
--        and/or other materials provided with the distribution.
30
--        * Neither the name of the organization nor the names of its contributors
31
--        may be used to endorse or promote products derived from this software without
32
--        specific prior written permission.
33
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
34
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
35
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
36
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
37
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
38
-- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
39
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
40
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
41
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
42
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
43
-- THE POSSIBILITY OF SUCH DAMAGE
44
-------------------------------------------------------------------------------
45
-- version management:
46 20 ruschi
-- $Author::                                         $
47
-- $Date::                                           $
48
-- $Revision::                                       $
49 2 ruschi
-------------------------------------------------------------------------------
50
library ieee;
51
use ieee.std_logic_1164.all;
52
 
53
library altera_mf;
54
use altera_mf.all;
55 11 ruschi
library avs_aes_lib;
56
use avs_aes_lib.avs_aes_pkg.all;
57 2 ruschi
 
58
 
59
 
60
architecture M4k of sbox is
61
        ---------------------------------------------------------------------------
62
        -- Altera Stuff
63 11 ruschi
        -- ( I don't want this in avs_aes_pkg because it is vendor specific)
64 2 ruschi
        ---------------------------------------------------------------------------
65
        component altsyncram
66
                generic (
67
                        ADDRESS_REG_B                     : STRING;
68
                        CLOCK_ENABLE_INPUT_A      : STRING;
69
                        CLOCK_ENABLE_INPUT_B      : STRING;
70
                        CLOCK_ENABLE_OUTPUT_A     : STRING;
71
                        CLOCK_ENABLE_OUTPUT_B     : STRING;
72
                        INDATA_REG_B                      : STRING;
73
                        INIT_FILE                                 : STRING;
74
                        INTENDED_DEVICE_FAMILY    : STRING;
75
                        LPM_TYPE                                  : STRING;
76
                        NUMWORDS_A                                : NATURAL;
77
                        NUMWORDS_B                                : NATURAL;
78
                        OPERATION_MODE                    : STRING;
79
                        OUTDATA_ACLR_A                    : STRING;
80
                        OUTDATA_ACLR_B                    : STRING;
81
                        OUTDATA_REG_A                     : STRING;
82
                        OUTDATA_REG_B                     : STRING;
83
                        POWER_UP_UNINITIALIZED    : STRING;
84
                        WIDTHAD_A                                 : NATURAL;
85
                        WIDTHAD_B                                 : NATURAL;
86
                        WIDTH_A                                   : NATURAL;
87
                        WIDTH_B                                   : NATURAL;
88
                        WIDTH_BYTEENA_A                   : NATURAL;
89
                        WIDTH_BYTEENA_B                   : NATURAL;
90
                        WRCONTROL_WRADDRESS_REG_B : STRING
91
                        );
92
                port (
93
                        wren_a    : in  STD_LOGIC;
94
                        wren_b    : in  STD_LOGIC;
95
                        clock0    : in  STD_LOGIC;
96
                        address_a : in  STD_LOGIC_VECTOR (7 downto 0);
97
                        address_b : in  STD_LOGIC_VECTOR (7 downto 0);
98
                        q_a               : out STD_LOGIC_VECTOR (7 downto 0);
99
                        q_b               : out STD_LOGIC_VECTOR (7 downto 0);
100
                        data_a    : in  STD_LOGIC_VECTOR (7 downto 0);
101
                        data_b    : in  STD_LOGIC_VECTOR (7 downto 0)
102
                        );
103
        end component;
104
 
105
begin
106
 
107
        assign_inverse : if INVERSE generate
108
                m4kblock_inv : altsyncram
109
                        generic map (
110
                                address_reg_b                     => "CLOCK0",
111
                                clock_enable_input_a      => "BYPASS",
112
                                clock_enable_input_b      => "BYPASS",
113
                                clock_enable_output_a     => "BYPASS",
114
                                clock_enable_output_b     => "BYPASS",
115
                                indata_reg_b                      => "CLOCK0",
116
                                init_file                                 => "sbox_inv.hex",
117
                                intended_device_family    => "Cyclone II",
118
                                lpm_type                                  => "altsyncram",
119
                                numwords_a                                => 256,
120
                                numwords_b                                => 256,
121
                                operation_mode                    => "BIDIR_DUAL_PORT",
122
                                outdata_aclr_a                    => "NONE",
123
                                outdata_aclr_b                    => "NONE",
124
                                outdata_reg_a                     => "UNREGISTERED",  -- IMPORTANT not CLOCK0!!!
125
                                outdata_reg_b                     => "UNREGISTERED",  -- IMPORTANT not CLOCK0!!!
126
                                power_up_uninitialized    => "FALSE",
127
                                widthad_a                                 => 8,
128
                                widthad_b                                 => 8,
129
                                width_a                                   => 8,
130
                                width_b                                   => 8,
131
                                width_byteena_a                   => 1,
132
                                width_byteena_b                   => 1,
133
                                wrcontrol_wraddress_reg_b => "CLOCK0"
134
                                )
135
                        port map (
136
                                wren_a    => '0',                -- we don't write to ROM
137
                                wren_b    => '0',                -- we don't write to ROM
138
                                clock0    => clk,
139
                                data_a    => (others => '0'),  -- dumb compiler wants it anyway
140
                                data_b    => (others => '0'),  -- dumb compiler wants it anyway
141
                                address_a => address_a,
142
                                address_b => address_b,
143
                                q_a               => q_a,
144
                                q_b               => q_b
145
                                );
146
        end generate assign_inverse;
147
 
148
        assign_encrypt : if not INVERSE generate
149
                m4kblock_fwd : altsyncram
150
                        generic map (
151
                                address_reg_b                     => "CLOCK0",
152
                                clock_enable_input_a      => "BYPASS",
153
                                clock_enable_input_b      => "BYPASS",
154
                                clock_enable_output_a     => "BYPASS",
155
                                clock_enable_output_b     => "BYPASS",
156
                                indata_reg_b                      => "CLOCK0",
157
                                init_file                                 => "sbox.hex",
158
                                intended_device_family    => "Cyclone II",
159
                                lpm_type                                  => "altsyncram",
160
                                numwords_a                                => 256,
161
                                numwords_b                                => 256,
162
                                operation_mode                    => "BIDIR_DUAL_PORT",
163
                                outdata_aclr_a                    => "NONE",
164
                                outdata_aclr_b                    => "NONE",
165
                                outdata_reg_a                     => "UNREGISTERED",  -- IMPORTANT not CLOCK0!!!
166
                                outdata_reg_b                     => "UNREGISTERED",  -- IMPORTANT not CLOCK0!!!
167
                                power_up_uninitialized    => "FALSE",
168
                                widthad_a                                 => 8,
169
                                widthad_b                                 => 8,
170
                                width_a                                   => 8,
171
                                width_b                                   => 8,
172
                                width_byteena_a                   => 1,
173
                                width_byteena_b                   => 1,
174
                                wrcontrol_wraddress_reg_b => "CLOCK0"
175
                                )
176
                        port map (
177
                                wren_a    => '0',                -- we don't write to ROM
178
                                wren_b    => '0',                -- we don't write to ROM
179
                                clock0    => clk,
180
                                data_a    => (others => '0'),  -- dumb compiler wants it anyway
181
                                data_b    => (others => '0'),  -- dumb compiler wants it anyway
182
                                address_a => address_a,
183
                                address_b => address_b,
184
                                q_a               => q_a,
185
                                q_b               => q_b
186
                                );
187
        end generate assign_encrypt;
188
end M4k;

powered by: WebSVN 2.1.0

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