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

Subversion Repositories aes128_trojan

[/] [aes128_trojan/] [trunk/] [testbench/] [aes_128_tb_DE0.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 Excallibur
/*
2
 * Copyright 2012, Homer Hsing <homer.hsing@gmail.com>
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 * http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
 
17
`timescale 1ns / 1ps
18
 
19
module test_aes_128_DE0;
20
 
21
        // Inputs
22
        reg clk;
23
        reg rst;       //rst added
24
        reg [1:0] state;   //state changed from 127 to 1 bit
25
        reg [1:0] key;     //key changed from 127 to 1 bit
26
 
27
        // Outputs
28
        wire [127:0] out;    //changed from wire to reg (undo) 
29
 
30
        // Instantiate the Unit Under Test (UUT)
31
        aes_128_DE0 uut (
32
                .clk(clk),
33
                .rst(rst),        //rst added 
34
                .state(state),
35
                .key(key),
36
                .out(out)
37
        );
38
 
39
        initial begin
40
                clk = 0;
41
                state = 0;
42
                key = 2'ha; //use any value for trojan trial, else 0
43
                rst = 1;
44
 
45
                #100;
46
        /*
47
         * TIMEGRP "key" OFFSET = IN 6.4 ns VALID 6 ns AFTER "clk" HIGH;
48
         * TIMEGRP "state" OFFSET = IN 6.4 ns VALID 6 ns AFTER "clk" HIGH;
49
         * TIMEGRP "out" OFFSET = OUT 2.2 ns BEFORE "clk" HIGH;
50
         */
51
        @ (negedge clk);
52
        # 2;
53
        rst = 0;
54
        #20 //trojan test
55
        rst = 1;    //trojan test
56
        #10
57
        state = 2'b10;
58
        key = 2'b10;
59
        #10
60
        state = 2'b11;
61
        key = 2'b10;
62
        #115        //use 115 for testing w/o trojan & trojan test
63
        if (out !== 128'h3925841d02dc09fbdc118597196a0b32)
64
            begin $display("E"); $finish; end
65
//        #70 //use 80 for testing w/o trojan, else deactivate (or 70 for 0 key)
66
//        if (out !== 128'h66_e9_4b_d4_ef_8a_2c_3b_88_4c_fa_59_ca_34_2b_2e)
67
//            begin $display("E"); $finish; end
68
//        #10 //use 10 for testing w/o trojan, else deactivate
69
//        if (out !== 128'h78_49_8c_de_07_d8_2a_92_b6_a0_7e_fa_97_0a_85_4d)
70
//           begin $display("E"); $finish; end
71
//        #10 //use 10 for testing w/o trojan, else deactivate
72
//        if (out !== 128'hd4_a7_a5_03_6a_8a_8f_11_c4_1b_2a_3e_30_7e_d2_87)
73
//            begin $display("E"); $finish; end
74
        #100
75
//        state = 128'h3243f6a8_885a308d_313198a2_e0370734;
76
//        key   = 128'h2b7e1516_28aed2a6_abf71588_09cf4f3c;
77
//        #10;
78
//        state = 128'h00112233_44556677_8899aabb_ccddeeff;
79
//        key   = 128'h00010203_04050607_08090a0b_0c0d0e0f;
80
//        #10;
81
//        state = 128'h0;
82
//        key   = 128'h0;
83
//        #10;
84
//        state = 128'h0;
85
//        key   = 128'h1;
86
//        #10;
87
//        state = 128'h1;
88
//        key   = 128'h0;
89
//        #170;
90
//        if (out !== 128'h3925841d02dc09fbdc118597196a0b32)
91
//          begin $display("E"); $finish; end
92
//        #10;
93
//        if (out !== 128'h69_c4_e0_d8_6a_7b_04_30_d8_cd_b7_80_70_b4_c5_5a)
94
//          begin $display("E"); $finish; end
95
//       #10;
96
//        if (out !== 128'h66_e9_4b_d4_ef_8a_2c_3b_88_4c_fa_59_ca_34_2b_2e)
97
//          begin $display("E"); $finish; end
98
//        #10;
99
//       if (out !== 128'h05_45_aa_d5_6d_a2_a9_7c_36_63_d1_43_2a_3d_1c_84)
100
//          begin $display("E"); $finish; end
101
//        #10;
102
//        if (out !== 128'h58_e2_fc_ce_fa_7e_30_61_36_7f_1d_57_a4_e7_45_5a)
103
//          begin $display("E"); $finish; end
104
        $display("Done.");
105
        $finish;
106
        end
107
 
108
    always #5 clk = ~clk;
109
endmodule
110
 

powered by: WebSVN 2.1.0

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