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

Subversion Repositories fully_pipelined_128_aes_algorithm

[/] [fully_pipelined_128_aes_algorithm/] [trunk/] [bench/] [tb_AES_Encrypt.vhd] - Blame information for rev 8

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 8 muhammedko
----------------------------------------------------------------------------------
2
-- Company: 
3
-- Engineer: 
4
-- 
5
-- Create Date: 12/29/2021 12:29:20 AM
6
-- Design Name: 
7
-- Module Name: tb_AES_Encrypt - Behavioral
8
-- Project Name: 
9
-- Target Devices: 
10
-- Tool Versions: 
11
-- Description: 
12
-- 
13
-- Dependencies: 
14
-- 
15
-- Revision:
16
-- Revision 0.01 - File Created
17
-- Additional Comments:
18
-- 
19
----------------------------------------------------------------------------------
20
LIBRARY IEEE;
21
USE IEEE.STD_LOGIC_1164.ALL;
22
USE IEEE.STD_LOGIC_ARITH.ALL;
23
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
24
USE std.textio.ALL;
25
USE IEEE.STD_LOGIC_TEXTIO.ALL;
26
 
27
-- Uncomment the following library declaration if using
28
-- arithmetic functions with Signed or Unsigned values
29
--use IEEE.NUMERIC_STD.ALL;
30
 
31
-- Uncomment the following library declaration if instantiating
32
-- any Xilinx leaf cells in this code.
33
--library UNISIM;
34
--use UNISIM.VComponents.all;
35
 
36
ENTITY tb_AES_Encrypt IS
37
    --  Port ( );
38
END tb_AES_Encrypt;
39
 
40
ARCHITECTURE Behavioral OF tb_AES_Encrypt IS
41
 
42
    COMPONENT AES_Encrypt IS
43
        PORT (
44
            CLK         : IN STD_LOGIC;
45
            aes_enable  : IN STD_LOGIC;
46
            aes_stop    : IN STD_LOGIC;
47
            aes_message : IN STD_LOGIC_VECTOR(16 * 8 - 1 DOWNTO 0);
48
            aes_key     : IN STD_LOGIC_VECTOR(16 * 8 - 1 DOWNTO 0);
49
            aes_out     : OUT STD_LOGIC_VECTOR(16 * 8 - 1 DOWNTO 0);
50
            aes_done    : OUT STD_LOGIC;
51
            aes_valid   : OUT STD_LOGIC
52
        );
53
    END COMPONENT;
54
    SIGNAL aes_enable  : STD_LOGIC                      := '0';
55
    SIGNAL aes_stop    : STD_LOGIC                      := '0';
56
    SIGNAL aes_valid   : STD_LOGIC                      := '0';
57
    SIGNAL aes_done    : STD_LOGIC                      := '0';
58
    SIGNAL CLK         : STD_LOGIC                      := '1';
59
    SIGNAL aes_message : STD_LOGIC_VECTOR(127 DOWNTO 0) := (OTHERS => '0');
60
    SIGNAL aes_key     : STD_LOGIC_VECTOR(127 DOWNTO 0) := (OTHERS => '0');
61
    SIGNAL aes_out     : STD_LOGIC_VECTOR(127 DOWNTO 0) := (OTHERS => '0');
62
 
63
    SIGNAL doutGolden : STD_LOGIC_VECTOR(127 DOWNTO 0) := (OTHERS => '0');
64
BEGIN
65
    CLK <= NOT CLK AFTER 5 ns;
66
 
67
    dut : PROCESS
68
    BEGIN
69
        WAIT FOR 50 ns;
70
        WAIT UNTIL falling_edge(CLK);
71
        aes_enable <= '1';
72
        FOR i IN 0 TO 10000 LOOP
73
            aes_key     <= x"2b7e151628aed2a6abf7158809cf4f3c";
74
            aes_message <= conv_std_logic_vector(i * 45154, aes_message'length);
75
            WAIT UNTIL falling_edge(CLK);
76
            aes_enable <= '0';
77
        END LOOP;
78
        aes_stop <= '1';
79
        WAIT UNTIL falling_edge(CLK);
80
        aes_stop <= '0';
81
        WAIT UNTIL aes_done = '1';
82
        WAIT FOR 100 ns;
83
        REPORT "Verification has been completed successffully!!!";
84
        std.env.finish;
85
    END PROCESS;
86
 
87
    dut_verify : PROCESS IS
88
        VARIABLE cntr                           : INTEGER := 0;
89
        FILE GoldenResult_file                  : text OPEN read_mode IS "GoldenData.txt"; -- give path
90
        VARIABLE GoldenResult_file_current_line : line;
91
        VARIABLE GoldenData_current_field       : STD_LOGIC_VECTOR(127 DOWNTO 0) := (OTHERS => '0');
92
 
93
    BEGIN
94
        WAIT UNTIL rising_edge(aes_valid);
95
        WHILE (cntr < 10000) LOOP
96
            REPORT "Entity: aes_out = " & to_hstring(aes_out) & "h";
97
            readline(GoldenResult_file, GoldenResult_file_current_line);
98
            hread(GoldenResult_file_current_line, GoldenData_current_field);
99
            doutGolden <= GoldenData_current_field;
100
 
101
            WAIT UNTIL rising_edge(CLK);
102
 
103
            ASSERT GoldenData_current_field = aes_out
104
            REPORT "The encryipted data is not correct"
105
                SEVERITY failure;
106
 
107
            cntr := cntr + 1;
108
        END LOOP;
109
    END PROCESS;
110
    AES_Encrypt_Inst : AES_Encrypt
111
    PORT MAP(
112
        CLK         => CLK,
113
        aes_enable  => aes_enable,
114
        aes_stop    => aes_stop,
115
        aes_message => aes_message,
116
        aes_key     => aes_key,
117
        aes_out     => aes_out,
118
        aes_done    => aes_done,
119
        aes_valid   => aes_valid
120
    );
121
END Behavioral;

powered by: WebSVN 2.1.0

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