OpenCores
URL https://opencores.org/ocsvn/gcm-aes/gcm-aes/trunk

Subversion Repositories gcm-aes

[/] [gcm-aes/] [trunk/] [env/] [test_bench.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 tariq786
/////////////////////////////////////////////////////////////////////
2
////                                                             ////
3
////                            Test Bench for GCM-AES                       ////
4
////                                                             ////
5
////                                                             ////
6
////  Author: Tariq Bashir Ahmad and Guy Hutchison               ////
7
////          tariq.bashir@gmail.com                             ////
8
////          ghutchis@gmail.com                                 ////
9
////                                                             ////
10
////  Downloaded from: http://www.opencores.org/                                  ////
11
////                                                             ////
12
/////////////////////////////////////////////////////////////////////
13
////                                                             ////
14
//// Copyright (C) 2010          Tariq Bashir Ahmad and                          ////   
15
////                         Guy Hutchison                                               ////
16
////                         http://www.ecs.umass.edu/~tbashir   ////
17
////                                                                     ////
18
////                                                             ////
19
//// This source file may be used and distributed without        ////
20
//// restriction provided that this copyright statement is not   ////
21
//// removed from the file and that any derivative work contains ////
22
//// the original copyright notice and the associated disclaimer.////
23
////                                                             ////
24
////     THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY     ////
25
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   ////
26
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   ////
27
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      ////
28
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         ////
29
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    ////
30
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   ////
31
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        ////
32
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  ////
33
//// LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  ////
34
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  ////
35
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         ////
36
//// POSSIBILITY OF SUCH DAMAGE.                                 ////
37
////                                                             ////
38
/////////////////////////////////////////////////////////////////////
39
 
40
 
41
 
42
`timescale 1ns / 1ps
43
`define SIZE 128
44
 
45
module test_bench;
46
 
47
  // Inputs
48
  reg clk;
49
  reg rst;
50
  reg [`SIZE-1:0] dii_data;
51
  reg [3:0]       dii_data_size;
52
  reg             dii_data_vld;
53
  reg             dii_data_type;
54
  reg             dii_last_word;
55
 
56
  reg [`SIZE-1:0] cii_K;
57
  reg             cii_ctl_vld;
58
  reg             cii_IV_vld;
59
 
60
 
61
  // Outputs
62
  wire                  dii_data_not_ready;
63
  wire [`SIZE-1:0]      Out_data;
64
  wire                  Out_vld;
65
  wire                  Tag_vld;
66
  wire [3:0]            Out_data_size;
67
  wire                  Out_last_word;
68
 
69
 
70
        initial
71
          begin
72
                // Initialize Inputs
73
            clk = 0;
74
            cii_ctl_vld   = 1'b0;
75
            cii_IV_vld = 1'b0;
76
            dii_data_vld  = 1'b0;
77
            dii_last_word = 1'b0;
78
            dii_data_type = 1'b0;
79
            dii_data = 0;
80
            dii_data_size = 0;
81
            cii_K         = 0;
82
 
83
 
84
            rst = 0;
85
            repeat(1) @(posedge clk);
86
            rst =  1;
87
            repeat(10) @(posedge clk);
88
            rst =  0;
89
 
90
 
91
            @(negedge clk);
92
 
93
            cii_ctl_vld = 1'b1;
94
            cii_K       = 128'hfeffe9928665731c6d6a8f9467308308;   // {`SIZE{1'b0}};   //key
95
 
96
 
97
            @(negedge clk);
98
            cii_ctl_vld = 1'b0;
99
 
100
 
101
            cii_IV_vld = 1'b1;
102
            dii_data   = 128'hcafebabefacedbaddecaf888_00000001;    // {{(`SIZE-1){1'b0}},1'b1}; //IV (128 bits)
103
 
104
 
105
 
106
            while(dii_data_not_ready)
107
              @(negedge clk);
108
 
109
            cii_IV_vld = 1'b0;
110
            dii_data_size = 4'd15;      //SIZE IS SET HERE      
111
            dii_data_vld  = 1'b1;       // AAD
112
            dii_data      = 128'hfeedfacedeadbeeffeedfacedeadbeef; // {`SIZE{1'b1}};
113
            dii_data_type = 1'b1;       //type = AAD 
114
            dii_last_word = 1'b0;       //last word is false
115
 
116
            @(negedge clk);
117
            dii_data_vld  = 1'b0;
118
 
119
 
120
            while(dii_data_not_ready)
121
              @(negedge clk);
122
 
123
            dii_data_vld  = 1'b1;
124
            dii_data_size = 4'd3;           //SIZE IS SET HERE  
125
            dii_data      = 32'habaddad2;//{`SIZE{1'b1}};
126
            dii_data_type = 1'b1;         //type = AAD
127
            dii_last_word = 1'b0;        //last word is false
128
 
129
            @(negedge clk);
130
            dii_data_vld  = 1'b0;
131
 
132
 
133
        while(dii_data_not_ready)
134
              @(negedge clk);
135
 
136
            dii_data_vld  = 1'b1;
137
            dii_data_size = 4'd15;           //SIZE IS SET HERE  
138
            dii_data      = 128'hd9313225f88406e5a55909c5aff5269a;//{`SIZE{1'b1}};
139
            dii_data_type = 1'b0;         //type = PT
140
            dii_last_word = 1'b0;        //last word is true
141
 
142
            @(negedge clk);
143
            dii_data_vld  = 1'b0;
144
 
145
 
146
           while(dii_data_not_ready)
147
              @(negedge clk);
148
 
149
            dii_data_vld  = 1'b1;
150
            dii_data_size = 4'd15;           //SIZE IS SET HERE  
151
            dii_data      = 128'h86a7a9531534f7da2e4c303d8a318a72;//{`SIZE{1'b1}};
152
            dii_data_type = 1'b0;         //type = PT
153
            dii_last_word = 1'b0;        //last word is true
154
 
155
            @(negedge clk);
156
            dii_data_vld  = 1'b0;
157
 
158
            while(dii_data_not_ready)
159
              @(negedge clk);
160
 
161
            dii_data_vld  = 1'b1;
162
            dii_data_size = 4'd15;           //SIZE IS SET HERE  
163
            dii_data      = 128'h1c3c0c95956809532fcf0e2449a6b525;//{`SIZE{1'b1}};
164
            dii_data_type = 1'b0;         //type = PT
165
            dii_last_word = 1'b0;        //last word is true
166
 
167
            @(negedge clk);
168
            dii_data_vld  = 1'b0;
169
 
170
 
171
            while(dii_data_not_ready)
172
              @(negedge clk);
173
 
174
            dii_data_vld  = 1'b1;
175
            dii_data_size = 4'd11;           //SIZE IS SET HERE  
176
            dii_data      = 128'hb16aedf5aa0de657ba637b39;//{`SIZE{1'b1}};
177
            dii_data_type = 1'b0;         //type = PT
178
            dii_last_word = 1'b1;        //last word is true
179
 
180
            @(negedge clk);
181
            dii_data_vld  = 1'b0;
182
 
183
          end
184
 
185
 
186
 
187
        always
188
                #7 clk = ~clk;
189
 
190
 
191
 
192
 
193
        gcm_aes_v0 uut (
194
                  .clk(clk),
195
                  .rst(rst),
196
                  .dii_data(dii_data),
197
                  .dii_data_size(dii_data_size),
198
                  .dii_data_vld(dii_data_vld),
199
                  .dii_data_type(dii_data_type),
200
                  .dii_data_not_ready(dii_data_not_ready),
201
                  .dii_last_word(dii_last_word),
202
                  .cii_K(cii_K),
203
                  .cii_ctl_vld(cii_ctl_vld),
204
                  .cii_IV_vld(cii_IV_vld),
205
                  .Out_data(Out_data),
206
                  .Out_vld(Out_vld),
207
                  .Tag_vld(Tag_vld),
208
                  .Out_data_size(Out_data_size),
209
                  .Out_last_word(Out_last_word)
210
                  );
211
 
212
 
213
 
214
        initial
215
          begin
216
           // $vcdpluson;
217
                                #5000;
218
            $stop;
219
          end
220
 
221
        initial
222
   $monitor($time,":DNR = %b, Out_data = %h, Out_vld = %b, Tag_vld = %b, Out_data_size=%d, Out_last_word=%d\n",dii_data_not_ready,Out_data,Out_vld,Tag_vld,Out_data_size,Out_last_word);
223
 
224
 
225
endmodule
226
 
227
 

powered by: WebSVN 2.1.0

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