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 16

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 7 arif_endro
-- $Id: input.vhdl,v 1.2 2005-12-23 04:27:00 arif_endro Exp $
2 2 arif_endro
-------------------------------------------------------------------------------
3
-- Title       : Input
4
-- Project     : Mini AES 128 
5
-------------------------------------------------------------------------------
6
-- File        : input.vhdl
7
-- Author      : "Arif E. Nugroho" <arif_endro@yahoo.com>
8
-- Created     : 2005/12/03
9
-- Last update : 
10
-- Simulators  : ModelSim SE PLUS 6.0
11
-- Synthesizers: ISE Xilinx 6.3i
12
-- Target      : 
13
-------------------------------------------------------------------------------
14
-- Description : Input stimuli file for test bench.
15
-------------------------------------------------------------------------------
16 16 arif_endro
-- Copyright (C) 2005 Arif Endro Nugroho
17 2 arif_endro
-------------------------------------------------------------------------------
18
-- 
19
--         THIS SOURCE FILE MAY BE USED AND DISTRIBUTED WITHOUT RESTRICTION
20
-- PROVIDED THAT THIS COPYRIGHT STATEMENT IS NOT REMOVED FROM THE FILE AND THAT
21
-- ANY DERIVATIVE WORK CONTAINS THE ORIGINAL COPYRIGHT NOTICE AND THE
22
-- ASSOCIATED DISCLAIMER.
23
-- 
24
-------------------------------------------------------------------------------
25
-- 
26
--         THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
27
-- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
28
-- MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
29
-- EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31
-- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
32
-- OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
33
-- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
34
-- OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
35
-- ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36
-- 
37
-------------------------------------------------------------------------------
38
 
39
library ieee;
40
use ieee.std_logic_1164.all;
41
use ieee.std_logic_arith.all;
42
use ieee.std_logic_unsigned.all;
43
use ieee.std_logic_textio.all;
44
use std.textio.all;
45
 
46
library std_developerskit;
47
use std_developerskit.std_iopak.all;    -- Function From_HexString
48
 
49
entity input is
50
  port (
51
    clock          : out std_logic;
52 7 arif_endro
    load           : out std_logic;
53 2 arif_endro
    done           : in  std_logic;
54
    test_iteration : out integer;
55 7 arif_endro
    key_i_byte     : out std_logic_vector (007 downto 000);
56
    data_i_byte    : out std_logic_vector (007 downto 000);
57
    cipher_o_byte  : out std_logic_vector (007 downto 000)
58 2 arif_endro
    );
59
end input;
60
 
61
architecture test_bench of input is
62
 
63
--
64
  file in_file_ptr            : text open read_mode is "../data/ecb_tbl.txt";
65
--
66
  signal     clock_int        : std_logic := '0';
67 7 arif_endro
  signal     ct               : std_logic_vector (127 downto 000);
68
  signal     pt               : std_logic_vector (127 downto 000);
69
  signal     ky               : std_logic_vector (127 downto 000);
70 2 arif_endro
--
71
begin
72
--
73 7 arif_endro
  clock_int            <= not(clock_int) after 1 ns;
74
  clock                <= clock_int;
75 2 arif_endro
--
76
  process
77
--
78
    variable delay            : time      := 1 ns;
79
    variable in_line          : line;
80
    variable cipher_text      : string ( 01 to 32 );
81
    variable plain_text       : string ( 01 to 32 );
82
    variable key              : string ( 01 to 32 );
83
    variable test             : integer;
84
    variable junk_test        : string ( 01 to 02 );
85
    variable junk_plain_text  : string ( 01 to 03 );
86
    variable junk_cipher_text : string (01 to 03 );
87
    variable junk_key         : string ( 01 to 04 );
88
--
89
  begin
90
--
91
    while not (endfile(in_file_ptr)) loop
92
--
93
      readline(in_file_ptr, in_line);   -- blank lines
94
--
95
      readline(in_file_ptr, in_line);
96
      read(in_line, junk_test);
97
      read(in_line, test);
98
      readline(in_file_ptr, in_line);
99
      read(in_line, junk_key);
100
      read(in_line, key);
101
      readline(in_file_ptr, in_line);
102
      read(in_line, junk_plain_text);
103
      read(in_line, plain_text);
104
      readline(in_file_ptr, in_line);
105
      read(in_line, junk_cipher_text);
106
      read(in_line, cipher_text);
107
--
108 7 arif_endro
      ky               <= to_StdLogicVector(From_HexString(key( 01 to 32)));
109
      pt               <= to_StdLogicVector(From_HexString(plain_text( 01 to 32 )));
110
      ct               <= to_StdLogicVector(From_HexString(cipher_text( 01 to 32 )));
111
--
112
      for a in 1 to key'length/2 loop
113
        wait until rising_edge(clock_int);
114
        key_i_byte     <= to_StdLogicVector(From_HexString(key(2*a-1 to 2*a)));
115
        data_i_byte    <= to_StdLogicVector(From_HexString(plain_text(2*a-1 to 2*a)));
116
        cipher_o_byte  <= to_StdLogicVector(From_HexString(cipher_text(2*a-1 to 2*a)));
117
        load           <= '1';
118
        test_iteration <= test;
119
      end loop;
120
--
121 2 arif_endro
      wait until rising_edge(clock_int);
122 7 arif_endro
      load             <= '0';
123 2 arif_endro
--
124 7 arif_endro
      wait until falling_edge(done);
125 2 arif_endro
      wait until rising_edge(clock_int);
126
--
127
    end loop;
128
    wait;
129
  end process;
130
--
131
end test_bench;

powered by: WebSVN 2.1.0

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