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

Subversion Repositories aes_decry_ip_128bit

[/] [aes_decry_ip_128bit/] [trunk/] [testbench/] [tb_AES_decrypt.vhd] - Blame information for rev 5

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 ghegde
--************************************************************
2
--Copyright 2015, Ganesh Hegde < ghegde@opencores.org >      
3
--                                                           
4
--This source file may be used and distributed without  
5
--restriction provided that this copyright statement is not 
6
--removed from the file and that any derivative work contains
7
--the original copyright notice and the associated disclaimer.
8
--
9
--This source is distributed in the hope that it will be
10
--useful, but WITHOUT ANY WARRANTY; without even the implied
11
--warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12
--PURPOSE.  See the GNU Lesser General Public License for more
13
--details.
14
--
15
--You should have received a copy of the GNU Lesser General
16
--Public License along with this source; if not, download it
17
--from http://www.opencores.org/lgpl.shtml
18
--
19
--*************************************************************
20
--This file is a test bench for AES decryption IP.
21
--*************************************************************
22
 
23
library ieee;
24
use ieee.std_logic_1164.all;
25
use std.textio.all;
26
use IEEE.std_logic_textio.all;
27
 
28
entity tb_AES_decrypt is
29
end tb_AES_decrypt;
30
 
31
architecture beh_tb_AES_decrypt of tb_AES_decrypt is
32
        component AES_decrypter
33
        port (
34
                  cipher: in std_logic_vector(127 downto 0);
35
                  text_out: out std_logic_vector(127 downto 0);
36
                  key: in std_logic_vector(127 downto 0);
37
                  k_valid,c_valid: in std_logic;--Asserted when either key, cipher is valid
38
                  ready:out std_logic;--Asserted high when IP is ready to accept the data(key or Cipher)
39
                  out_valid: out std_logic;--out_valid:Asserted high when decrypted cipher is on the bus
40
                  clk,reset: in std_logic
41
                );
42
    end component;
43
 
44
   constant clk_period: time := 10 ns;
45
   signal reset,clk:std_logic;
46
   signal cipher,text_out: std_logic_vector(127 downto 0);
47
   signal key:std_logic_vector(127 downto 0);
48
   signal k_valid,c_valid,out_valid:std_logic;
49
   signal ready:std_logic;
50
 
51
 
52
begin
53
    uut:AES_decrypter
54
        port map(cipher=>cipher,text_out=>text_out,key=>key,k_valid=>k_valid,c_valid=>c_valid,out_valid=>out_valid,clk=>clk,reset=>reset,ready=>ready);
55
 
56
  clk_process:process
57
  begin
58
     clk<='1';
59
     wait for clk_period/2;
60
     clk<='0';
61
         wait for clk_period/2;
62
  end process;
63
 
64
        tb_process:process
65
    variable LW : line;
66
        variable error: integer:=0;
67
        begin
68
      reset<='1';
69
          k_valid<='0';
70
          c_valid<='0';
71
 
72
          wait for 5*clk_period;
73
          reset<='0';
74
 
75
          wait for clk_period;
76
 
77
          if(ready/='1') then
78
          wait until ready='1';
79
          end if;
80
          k_valid<='1';
81
          key<=x"1234567890abcdef1234567890abcdef";
82
 
83
          wait for clk_period;
84
          k_valid<='0';
85
 
86
          --Test 1
87
 
88
          wait until ready='1';
89
      --Plain text : 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA  
90
          cipher<=x"220dfcbbe717ae16ebcf69615a996adb";
91
          c_valid<='1';
92
 
93
          wait for clk_period;
94
          c_valid<='0';
95
 
96
          wait until out_valid='1';
97
          wait for 1 ns;
98
          if(x"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" /= text_out) then
99
             write(LW,string'("Decryption Error!!!"));
100
             write(LW,string'("   Expected : 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA Received : 0x"));
101
                 hwrite(LW,text_out);
102
             writeline(output,LW);
103
                 error:=1;
104
          end if;
105
 
106
          --Test 2
107
 
108
          wait until ready='1';
109
          --Plain Text : 0xBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
110
          cipher<=x"e9f386223ce53e52891c113d048145ec";
111
          c_valid<='1';
112
 
113
          wait for clk_period;
114
          c_valid<='0';
115
 
116
          wait until out_valid='1';
117
          wait for 1 ns; --Delta delay
118
          if(x"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB" /= text_out) then
119
             write(LW,string'("Decryption Error!!!"));
120
             write(LW,string'("   Expected : 0xBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB Received : 0x"));
121
                 hwrite(LW,text_out);
122
             writeline(output,LW);
123
                 error:=1;
124
          end if;
125
 
126
          --Test 3
127
 
128
          wait until ready='1';
129
          --Plain Text : 0xCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
130
          cipher<=x"5426f624ac8c7c9eea54f55103a6e3ab";
131
          c_valid<='1';
132
 
133
          wait for clk_period;
134
          c_valid<='0';
135
 
136
          wait until out_valid='1';
137
          wait for 1 ns;
138
          if(x"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC" /= text_out) then
139
             write(LW,string'("Decryption Error!!!"));
140
             write(LW,string'("   Expected : 0xCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC Received : 0x"));
141
                 hwrite(LW,text_out);
142
             writeline(output,LW);
143
                 error:=1;
144
          end if;
145
 
146
          if(error = 0) then
147
             write(LW,string'("********************************************"));
148
                 writeline(output,LW);
149
             write(LW,        string'("            All test case passed!!!         "));
150
                 writeline(output,LW);
151
             write(LW,string'("********************************************"));
152
                 writeline(output,LW);
153
          else
154
            write(LW,string'("********************************************"));
155
                writeline(output,LW);
156
        write(LW,        string'("         Some test case failed!!!!          "));
157
                writeline(output,LW);
158
            write(LW,string'("********************************************"));
159
                writeline(output,LW);
160
      end if;
161
 
162
      assert false report"This is end of simulation not test failure!!!" severity failure;      --End simulation
163
 
164
        wait;
165
        end process;
166
 
167
 
168
end beh_tb_AES_decrypt;

powered by: WebSVN 2.1.0

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