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

Subversion Repositories csa

[/] [csa/] [trunk/] [bench/] [group_decrypt_tb.v] - Blame information for rev 51

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 49 simon111
 
2
 
3
// this is the test bench for decrypt module
4
 
5
 
6
`include "../bench/timescale.v"
7
 
8
module group_decrypt_tb;
9
 
10
reg clk;
11
reg rst;
12
 
13
 
14
reg     [ 8*8-1:0]    ck;
15
reg                   ks_start;
16
reg                   init;
17
reg                   last;
18
reg                   gd_en;
19
wire   [ 8*8-1:0]     dec_packet;
20
reg    [ 8*8-1:0]     enc_packet;
21
wire   [56*8-1:0]     kk;
22
wire                  valid;
23
integer               ii;
24
integer               jj;
25
integer               offset;
26
initial
27
begin
28
        $read_data(
29
                                "../test_dat/group_decrypt.in"
30
                               ,ck
31
                  );
32
 
33
 
34
        init=1'h0;
35
 
36
        // calculate kk
37
        repeat(4) @(posedge clk)
38
        ks_start=1'h1;
39
        @(posedge clk);
40
        ks_start=1'h0;
41
        repeat(14) @(posedge clk)
42
        jj=0;
43
        $display("kk=%x",kk);
44
 
45
        // input encrypt packets
46
        offset=8+(0)*8;
47
        $read_data(
48
                         "../test_dat/group_decrypt.in"
49
                       , offset
50
                       , enc_packet);
51
        init=1'h1;
52
        last=1'h0;
53
        gd_en=1'h1;
54
        @(posedge clk);
55
 
56
        for(ii=1;ii<23-1;ii=ii+1)
57
        begin
58
                init=1'h0;
59
                last=1'h0;
60
                gd_en=1'h1;
61
                offset=8+(ii)*8;
62
                $read_data(
63
                                 "../test_dat/group_decrypt.in"
64
                               , offset
65
                               , enc_packet);
66
                @(posedge clk);
67
        end
68
 
69
        offset=8+(23-1)*8;
70
        $read_data(
71
                         "../test_dat/group_decrypt.in"
72
                       , offset
73
                       , enc_packet);
74
        init=1'h0;
75
        last=1'h1;
76
        gd_en=1'h1;
77
        @(posedge clk);
78
        gd_en=1'h0;
79
 
80
        repeat(10)@(posedge clk);
81
 
82
        $stop;
83
 
84
end
85
 
86
always @(posedge clk)
87
        if(valid)
88
        begin
89
                if(jj==0)
90
                begin
91
                        $write_data(
92
                                         "../test_dat/group_decrypt.out.v"
93
                                       , dec_packet);
94
                        jj=1;
95
                end
96
                else
97
                        $write_data(
98
                                         "../test_dat/group_decrypt.out.v"
99
                                       , "a"
100
                                       , dec_packet);
101
        end
102
 
103
 
104
 
105
group_decrypt group_decrypt(
106
                          . clk     (clk)
107
                        , . rst     (rst)
108
                        , . en      (gd_en)
109
                        , . init    (init)
110
                        , . last    (last)
111
                        , . ck      (ck)
112
                        , . kk      (kk)
113
                        , . group   (enc_packet)
114
                        , . valid   (valid)
115
                        , . ogroup  (dec_packet)
116
                );
117
 
118
key_schedule key_schedule(
119
                  .clk        (clk)
120
                , .rst        (rst)
121
                , .start      (ks_start)
122
                , .ck         (ck)
123
                , .busy       ()
124
                , .done       ()
125
                , .kk         (kk)
126
                );
127
 
128
 
129
 
130
initial
131
begin
132
        clk=1'b0;
133
        forever #5 clk=~clk;
134
end
135
 
136
initial
137
begin
138
        rst=1'b1;
139
        @(posedge clk);
140
        @(posedge clk);
141
        rst=1'h0;
142
end
143
endmodule

powered by: WebSVN 2.1.0

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