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/] [misc_tb/] [tb_AES_decrypt.vhd] - Blame information for rev 5

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 ghegde
library ieee;
2
use ieee.std_logic_1164.all;
3
use std.textio.all;
4
use IEEE.std_logic_textio.all;
5
 
6
entity tb_AES_decrypt is
7
end tb_AES_decrypt;
8
 
9
architecture beh_tb_AES_decrypt of tb_AES_decrypt is
10
        component AES_decrypter
11
        port (
12
                  cipher: in std_logic_vector(127 downto 0);
13
                  text_out: out std_logic_vector(127 downto 0);
14
                  key: in std_logic_vector(127 downto 0);
15
                  k_valid,c_valid: in std_logic;--Asserted when either key, cipher is valid
16
                  ready:out std_logic;--Asserted high when IP is ready to accept the data(key or Cipher)
17
                  out_valid: out std_logic;--out_valid:Asserted high when decrypted cipher is on the bus
18
                  clk,reset: in std_logic
19
                );
20
    end component;
21
 
22
   constant clk_period: time := 10 ns;
23
   signal reset,clk:std_logic;
24
   signal cipher,text_out: std_logic_vector(127 downto 0);
25
   signal key:std_logic_vector(127 downto 0);
26
   signal k_valid,c_valid,out_valid:std_logic;
27
   signal ready:std_logic;
28
 
29
 
30
begin
31
    uut:AES_decrypter
32
        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);
33
 
34
  clk_process:process
35
  begin
36
     clk<='1';
37
     wait for clk_period/2;
38
     clk<='0';
39
         wait for clk_period/2;
40
  end process;
41
 
42
        tb_process:process
43
    variable LW : line;
44
        variable error: integer:=0;
45
        begin
46
      reset<='1';
47
          k_valid<='0';
48
          c_valid<='0';
49
 
50
          wait for 5*clk_period;
51
          reset<='0';
52
 
53
          wait for clk_period;
54
 
55
          if(ready/='1') then
56
          wait until ready='1';
57
          end if;
58
          k_valid<='1';
59
          key<=x"1234567890abcdef1234567890abcdef";
60
 
61
          wait for clk_period;
62
          k_valid<='0';
63
 
64
          --Test 1
65
 
66
          wait until ready='1';
67
      --Plain text : 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA  
68
          cipher<=x"220dfcbbe717ae16ebcf69615a996adb";
69
          c_valid<='1';
70
 
71
          wait for clk_period;
72
          c_valid<='0';
73
 
74
          wait until out_valid='1';
75
          wait for 1 ns;
76
          if(x"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" /= text_out) then
77
             write(LW,string'("Decryption Error!!!"));
78
             write(LW,string'("   Expected : 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA Received : 0x"));
79
                 hwrite(LW,text_out);
80
             writeline(output,LW);
81
                 error:=1;
82
          end if;
83
 
84
          --Test 2
85
 
86
          wait until ready='1';
87
          --Plain Text : 0xBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
88
          cipher<=x"e9f386223ce53e52891c113d048145ec";
89
          c_valid<='1';
90
 
91
          wait for clk_period;
92
          c_valid<='0';
93
 
94
          wait until out_valid='1';
95
          wait for 1 ns; --Delta delay
96
          if(x"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB" /= text_out) then
97
             write(LW,string'("Decryption Error!!!"));
98
             write(LW,string'("   Expected : 0xBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB Received : 0x"));
99
                 hwrite(LW,text_out);
100
             writeline(output,LW);
101
                 error:=1;
102
          end if;
103
 
104
          --Test 3
105
 
106
          wait until ready='1';
107
          --Plain Text : 0xCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
108
          cipher<=x"5426f624ac8c7c9eea54f55103a6e3ab";
109
          c_valid<='1';
110
 
111
          wait for clk_period;
112
          c_valid<='0';
113
 
114
          wait until out_valid='1';
115
          wait for 1 ns;
116
          if(x"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC" /= text_out) then
117
             write(LW,string'("Decryption Error!!!"));
118
             write(LW,string'("   Expected : 0xCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC Received : 0x"));
119
                 hwrite(LW,text_out);
120
             writeline(output,LW);
121
                 error:=1;
122
          end if;
123
 
124
          if(error = 0) then
125
             write(LW,string'("********************************************"));
126
                 writeline(output,LW);
127
             write(LW,        string'("            All test case passed!!!         "));
128
                 writeline(output,LW);
129
             write(LW,string'("********************************************"));
130
                 writeline(output,LW);
131
          else
132
            write(LW,string'("********************************************"));
133
                writeline(output,LW);
134
        write(LW,        string'("         Some test case failed!!!!          "));
135
                writeline(output,LW);
136
            write(LW,string'("********************************************"));
137
                writeline(output,LW);
138
      end if;
139
 
140
      assert false report"This is end of simulation not test failure!!!" severity failure;      --End simulation
141
 
142
        wait;
143
        end process;
144
 
145
 
146
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.