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

Subversion Repositories mini_aes

[/] [mini_aes/] [trunk/] [source/] [io_interface.vhdl] - Blame information for rev 22

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 21 arif_endro
-- ------------------------------------------------------------------------
2 15 arif_endro
-- Copyright (C) 2005 Arif Endro Nugroho
3 21 arif_endro
-- All rights reserved.
4 4 arif_endro
-- 
5 21 arif_endro
-- Redistribution and use in source and binary forms, with or without
6
-- modification, are permitted provided that the following conditions
7
-- are met:
8 4 arif_endro
-- 
9 21 arif_endro
-- 1. Redistributions of source code must retain the above copyright
10
--    notice, this list of conditions and the following disclaimer.
11
-- 2. Redistributions in binary form must reproduce the above copyright
12
--    notice, this list of conditions and the following disclaimer in the
13
--    documentation and/or other materials provided with the distribution.
14 4 arif_endro
-- 
15 21 arif_endro
-- THIS SOFTWARE IS PROVIDED BY ARIF ENDRO NUGROHO "AS IS" AND ANY EXPRESS
16
-- OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17
-- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
-- DISCLAIMED. IN NO EVENT SHALL ARIF ENDRO NUGROHO BE LIABLE FOR ANY
19
-- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20
-- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21
-- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22
-- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
23
-- STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
24
-- ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25
-- POSSIBILITY OF SUCH DAMAGE.
26 4 arif_endro
-- 
27 21 arif_endro
-- End Of License.
28
-- ------------------------------------------------------------------------
29
 
30 4 arif_endro
library ieee;
31
use ieee.std_logic_1164.all;
32
use ieee.std_logic_arith.all;
33
use ieee.std_logic_unsigned.all;
34
 
35
entity io_interface is
36
   port (
37
      clock      : in  std_logic;
38
      clear      : in  std_logic;
39
      load_i     : in  std_logic;
40
      load_i_int : out std_logic;
41
      data_i     : in  std_logic_vector (7 downto 0);
42
      key_i      : in  std_logic_vector (7 downto 0);
43
      data_o     : out std_logic_vector (7 downto 0);
44
      data_o_int : in  std_logic_vector (127 downto 000);
45
      data_i_int : out std_logic_vector (127 downto 000);
46
      key_i_int  : out std_logic_vector (127 downto 000);
47
      done_o_int : in  std_logic;
48
      done_o     : out std_logic
49
      );
50
end io_interface;
51
 
52
architecture data_flow of io_interface is
53
 
54
type fifo16x8 is array ( 0 to 15 ) of std_logic_vector (7 downto 0);
55
 
56
signal fifo_data : fifo16x8 :=
57
(
58
 B"0000_0000", B"0000_0000", B"0000_0000", B"0000_0000",
59
 B"0000_0000", B"0000_0000", B"0000_0000", B"0000_0000",
60
 B"0000_0000", B"0000_0000", B"0000_0000", B"0000_0000",
61
 B"0000_0000", B"0000_0000", B"0000_0000", B"0000_0000"
62
);
63
 
64
signal fifo_key : fifo16x8 :=
65
(
66
 B"0000_0000", B"0000_0000", B"0000_0000", B"0000_0000",
67
 B"0000_0000", B"0000_0000", B"0000_0000", B"0000_0000",
68
 B"0000_0000", B"0000_0000", B"0000_0000", B"0000_0000",
69
 B"0000_0000", B"0000_0000", B"0000_0000", B"0000_0000"
70
);
71
 
72
signal fifo_output : fifo16x8 :=
73
(
74
 B"0000_0000", B"0000_0000", B"0000_0000", B"0000_0000",
75
 B"0000_0000", B"0000_0000", B"0000_0000", B"0000_0000",
76
 B"0000_0000", B"0000_0000", B"0000_0000", B"0000_0000",
77
 B"0000_0000", B"0000_0000", B"0000_0000", B"0000_0000"
78
);
79
 
80
signal load_core   : std_logic := '0';
81
signal done_int    : std_logic := '0';
82
signal up_counter  : integer range 0 to 15 := 0;
83
-- signal data_o_int : std_logic_vector (127 downto 000) :=
84
--   ( X"3925841D_02DC09FB_DC118597_196A0B32" );  -- CT 0
85
 
86
begin
87
 
88
load_i_int <= load_core;
89
 
90
process(clock, clear)
91
begin
92
if (clear = '1') then
93
   done_o <= '0';
94
elsif (clock = '1' and clock'event) then
95
   done_o <= done_int;
96
end if;
97
end process;
98
 
99
process(clock, clear)
100
begin
101
if (clear = '1') then
102
   up_counter <= 0;
103
elsif (clock = '1' and clock'event) then
104
   if (done_o_int = '1') then
105
      up_counter <= 0;
106
-- elsif ((up_counter = 0) and (done_o_int = '1')) then
107
-- elsif (done_o_int = '0' and done_o_int'event) then
108
-- 20051219 FIXME 
109
      done_int   <= '1';
110
   elsif (up_counter < 15 ) then
111
      up_counter <= up_counter + 1;
112
   else
113
--    up_counter <= 0;
114
      done_int   <= '0';
115
   end if;
116
end if;
117
end process;
118
 
119
process(clock, clear)
120
begin
121
if (clear = '1') then
122
   fifo_output <= (others => (others => '0'));
123
elsif (clock = '1' and clock'event) then
124
   if (done_o_int = '1') then
125
      fifo_output <= ( data_o_int (127 downto 120), data_o_int (119 downto 112), data_o_int (111 downto 104),
126
                       data_o_int (103 downto 096), data_o_int (095 downto 088), data_o_int (087 downto 080),
127
                       data_o_int (079 downto 072), data_o_int (071 downto 064), data_o_int (063 downto 056),
128
                       data_o_int (055 downto 048), data_o_int (047 downto 040), data_o_int (039 downto 032),
129
                       data_o_int (031 downto 024), data_o_int (023 downto 016), data_o_int (015 downto 008),
130
                       data_o_int (007 downto 000));
131
   end if;
132
end if;
133
end process;
134
 
135
process(clock, clear)
136
begin
137
if (clear = '1') then
138
data_o <= (others => '0');
139
elsif (clock = '1' and clock'event) then
140
data_o <= fifo_output(up_counter);
141
end if;
142
end process;
143
 
144
process(clock, clear)
145
begin
146
   if (clear = '1') then
147
      fifo_key     <= (others => (others => '0'));
148
      fifo_data    <= (others => (others => '0'));
149
      load_core    <= '1';
150
   elsif (clock = '1' and clock'event) then
151
      if (load_i  = '1') then
152
         fifo_key     <= (fifo_key (1 to 15) & key_i);
153
         fifo_data    <= (fifo_data (1 to 15) & data_i);
154
      end if;
155
         load_core    <= load_i;
156
   end if;
157
end process;
158
 
159
key_i_int<= ( fifo_key (00) & fifo_key (01) & fifo_key (02) & fifo_key (03) &
160
              fifo_key (04) & fifo_key (05) & fifo_key (06) & fifo_key (07) &
161
              fifo_key (08) & fifo_key (09) & fifo_key (10) & fifo_key (11) &
162
              fifo_key (12) & fifo_key (13) & fifo_key (14) & fifo_key (15) );
163
 
164
data_i_int<= ( fifo_data (00) & fifo_data (01) & fifo_data (02) & fifo_data (03) &
165
               fifo_data (04) & fifo_data (05) & fifo_data (06) & fifo_data (07) &
166
               fifo_data (08) & fifo_data (09) & fifo_data (10) & fifo_data (11) &
167
               fifo_data (12) & fifo_data (13) & fifo_data (14) & fifo_data (15) );
168
 
169
end data_flow;

powered by: WebSVN 2.1.0

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