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

Subversion Repositories mini_aes

[/] [mini_aes/] [trunk/] [bench/] [input.vhdl] - Blame information for rev 22

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 21 arif_endro
-- ------------------------------------------------------------------------
2 16 arif_endro
-- Copyright (C) 2005 Arif Endro Nugroho
3 21 arif_endro
-- All rights reserved.
4 2 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 2 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 2 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 2 arif_endro
-- 
27 21 arif_endro
-- End Of License.
28
-- ------------------------------------------------------------------------
29 2 arif_endro
 
30
library ieee;
31
use ieee.std_logic_1164.all;
32
use ieee.std_logic_arith.all;
33
use ieee.std_logic_unsigned.all;
34
use ieee.std_logic_textio.all;
35
use std.textio.all;
36
 
37
library std_developerskit;
38
use std_developerskit.std_iopak.all;    -- Function From_HexString
39
 
40
entity input is
41
  port (
42
    clock          : out std_logic;
43 7 arif_endro
    load           : out std_logic;
44 2 arif_endro
    done           : in  std_logic;
45
    test_iteration : out integer;
46 7 arif_endro
    key_i_byte     : out std_logic_vector (007 downto 000);
47
    data_i_byte    : out std_logic_vector (007 downto 000);
48
    cipher_o_byte  : out std_logic_vector (007 downto 000)
49 2 arif_endro
    );
50
end input;
51
 
52
architecture test_bench of input is
53
 
54
--
55
  file in_file_ptr            : text open read_mode is "../data/ecb_tbl.txt";
56
--
57
  signal     clock_int        : std_logic := '0';
58 7 arif_endro
  signal     ct               : std_logic_vector (127 downto 000);
59
  signal     pt               : std_logic_vector (127 downto 000);
60
  signal     ky               : std_logic_vector (127 downto 000);
61 2 arif_endro
--
62
begin
63
--
64 7 arif_endro
  clock_int            <= not(clock_int) after 1 ns;
65
  clock                <= clock_int;
66 2 arif_endro
--
67
  process
68
--
69
    variable delay            : time      := 1 ns;
70
    variable in_line          : line;
71
    variable cipher_text      : string ( 01 to 32 );
72
    variable plain_text       : string ( 01 to 32 );
73
    variable key              : string ( 01 to 32 );
74
    variable test             : integer;
75
    variable junk_test        : string ( 01 to 02 );
76
    variable junk_plain_text  : string ( 01 to 03 );
77
    variable junk_cipher_text : string (01 to 03 );
78
    variable junk_key         : string ( 01 to 04 );
79
--
80
  begin
81
--
82
    while not (endfile(in_file_ptr)) loop
83
--
84
      readline(in_file_ptr, in_line);   -- blank lines
85
--
86
      readline(in_file_ptr, in_line);
87
      read(in_line, junk_test);
88
      read(in_line, test);
89
      readline(in_file_ptr, in_line);
90
      read(in_line, junk_key);
91
      read(in_line, key);
92
      readline(in_file_ptr, in_line);
93
      read(in_line, junk_plain_text);
94
      read(in_line, plain_text);
95
      readline(in_file_ptr, in_line);
96
      read(in_line, junk_cipher_text);
97
      read(in_line, cipher_text);
98
--
99 7 arif_endro
      ky               <= to_StdLogicVector(From_HexString(key( 01 to 32)));
100
      pt               <= to_StdLogicVector(From_HexString(plain_text( 01 to 32 )));
101
      ct               <= to_StdLogicVector(From_HexString(cipher_text( 01 to 32 )));
102
--
103
      for a in 1 to key'length/2 loop
104
        wait until rising_edge(clock_int);
105
        key_i_byte     <= to_StdLogicVector(From_HexString(key(2*a-1 to 2*a)));
106
        data_i_byte    <= to_StdLogicVector(From_HexString(plain_text(2*a-1 to 2*a)));
107
        cipher_o_byte  <= to_StdLogicVector(From_HexString(cipher_text(2*a-1 to 2*a)));
108
        load           <= '1';
109
        test_iteration <= test;
110
      end loop;
111
--
112 2 arif_endro
      wait until rising_edge(clock_int);
113 7 arif_endro
      load             <= '0';
114 2 arif_endro
--
115 7 arif_endro
      wait until falling_edge(done);
116 2 arif_endro
      wait until rising_edge(clock_int);
117
--
118
    end loop;
119
    wait;
120
  end process;
121
--
122
end test_bench;

powered by: WebSVN 2.1.0

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