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

Subversion Repositories sd_card_controller

[/] [sd_card_controller/] [trunk/] [bench/] [verilog/] [sd_data_xfer_trig_tb.sv] - Blame information for rev 3

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

Line No. Rev Author Line
1 3 rozpruwacz
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
//// WISHBONE SD Card Controller IP Core                          ////
4
////                                                              ////
5
//// sd_data_xfer_trig_tb.sv                                      ////
6
////                                                              ////
7
//// This file is part of the WISHBONE SD Card                    ////
8
//// Controller IP Core project                                   ////
9
//// http://www.opencores.org/cores/xxx/                          ////
10
////                                                              ////
11
//// Description                                                  ////
12
//// testbench for sd_data_xfer_trig module                       ////
13
////                                                              ////
14
//// Author(s):                                                   ////
15
////     - Marek Czerski, ma.czerski@gmail.com                    ////
16
////                                                              ////
17
//////////////////////////////////////////////////////////////////////
18
////                                                              ////
19
//// Copyright (C) 2013 Authors                                   ////
20
////                                                              ////
21
//// This source file may be used and distributed without         ////
22
//// restriction provided that this copyright statement is not    ////
23
//// removed from the file and that any derivative work contains  ////
24
//// the original copyright notice and the associated disclaimer. ////
25
////                                                              ////
26
//// This source file is free software; you can redistribute it   ////
27
//// and/or modify it under the terms of the GNU Lesser General   ////
28
//// Public License as published by the Free Software Foundation; ////
29
//// either version 2.1 of the License, or (at your option) any   ////
30
//// later version.                                               ////
31
////                                                              ////
32
//// This source is distributed in the hope that it will be       ////
33
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
34
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
35
//// PURPOSE. See the GNU Lesser General Public License for more  ////
36
//// details.                                                     ////
37
////                                                              ////
38
//// You should have received a copy of the GNU Lesser General    ////
39
//// Public License along with this source; if not, download it   ////
40
//// from http://www.opencores.org/lgpl.shtml                     ////
41
////                                                              ////
42
//////////////////////////////////////////////////////////////////////
43
 
44
`include "sd_defines.h"
45
 
46
module sd_data_xfer_trig_tb();
47
 
48
parameter SD_TCLK = 20; // 50 MHz -> timescale 1ns
49
 
50
//---------------Input ports---------------
51
reg sd_clk;
52
reg rst;
53
reg cmd_with_data_start_i;
54
reg r_w_i;
55
reg [`INT_CMD_SIZE-1:0] cmd_int_status_i;
56
//---------------Output ports---------------
57
wire start_tx_o;
58
wire start_rx_o;
59
 
60
sd_data_xfer_trig sd_data_xfer_trig_dut(
61
    .sd_clk                (sd_clk),
62
    .rst                   (rst),
63
    .cmd_with_data_start_i (cmd_with_data_start_i),
64
    .r_w_i                 (r_w_i),
65
    .cmd_int_status_i      (cmd_int_status_i),
66
    .start_tx_o            (start_tx_o),
67
    .start_rx_o            (start_rx_o)
68
    );
69
 
70
// Generating SD_CLK clock
71
always
72
begin
73
    sd_clk = 0;
74
    forever #(SD_TCLK/2) sd_clk = ~sd_clk;
75
end
76
 
77
initial
78
begin
79
    rst = 1;
80
    cmd_with_data_start_i = 0;
81
    r_w_i = 0;
82
    cmd_int_status_i = 0;
83
 
84
    $display("sd_data_xfer_trig_tb start ...");
85
 
86
    #(3*SD_TCLK);
87
    rst = 0;
88
    assert(start_tx_o == 0);
89
    assert(start_rx_o == 0);
90
 
91
    #SD_TCLK;
92
    assert(start_tx_o == 0);
93
    assert(start_rx_o == 0);
94
 
95
    //succesful cmd xfer test - read
96
    cmd_with_data_start_i = 1;
97
    r_w_i = 1;
98
 
99
    #(2*SD_TCLK);
100
    assert(start_tx_o == 0);
101
    assert(start_rx_o == 1);
102
    cmd_with_data_start_i = 0;
103
    r_w_i = 0;
104
 
105
    #SD_TCLK;
106
    assert(start_tx_o == 0);
107
    assert(start_rx_o == 0);
108
 
109
    cmd_int_status_i[`INT_CMD_CC] = 1;
110
    #(2*SD_TCLK);
111
    assert(start_tx_o == 0);
112
    assert(start_rx_o == 0);
113
    cmd_int_status_i[`INT_CMD_CC] = 0;
114
    #SD_TCLK;
115
    assert(start_tx_o == 0);
116
    assert(start_rx_o == 0);
117
 
118
    //reset
119
    rst = 1;
120
    #(3*SD_TCLK);
121
    rst = 0;
122
    assert(start_tx_o == 0);
123
    assert(start_rx_o == 0);
124
 
125
    //succesful cmd xfer test - write
126
    cmd_with_data_start_i = 1;
127
 
128
    #SD_TCLK;
129
    assert(start_tx_o == 0);
130
    assert(start_rx_o == 0);
131
    cmd_with_data_start_i = 0;
132
 
133
    #(3*SD_TCLK);
134
    assert(start_tx_o == 0);
135
    assert(start_rx_o == 0);
136
 
137
    cmd_int_status_i[`INT_CMD_CC] = 1;
138
    #(2*SD_TCLK);
139
    assert(start_tx_o == 1);
140
    assert(start_rx_o == 0);
141
    cmd_int_status_i[`INT_CMD_CC] = 0;
142
    #SD_TCLK;
143
    assert(start_tx_o == 0);
144
    assert(start_rx_o == 0);
145
 
146
    //reset
147
    rst = 1;
148
    #(3*SD_TCLK);
149
    rst = 0;
150
    assert(start_tx_o == 0);
151
    assert(start_rx_o == 0);
152
 
153
    //unsuccesful cmd xfer test - read
154
    cmd_with_data_start_i = 1;
155
    r_w_i = 1;
156
 
157
    #(2*SD_TCLK);
158
    assert(start_tx_o == 0);
159
    assert(start_rx_o == 1);
160
    cmd_with_data_start_i = 0;
161
    r_w_i = 0;
162
 
163
    #SD_TCLK;
164
    assert(start_tx_o == 0);
165
    assert(start_rx_o == 0);
166
 
167
    cmd_int_status_i[`INT_CMD_EI] = 1;
168
    #(2*SD_TCLK);
169
    assert(start_tx_o == 0);
170
    assert(start_rx_o == 0);
171
    cmd_int_status_i[`INT_CMD_EI] = 0;
172
    #SD_TCLK;
173
    assert(start_tx_o == 0);
174
    assert(start_rx_o == 0);
175
 
176
    //reset
177
    rst = 1;
178
    #(3*SD_TCLK);
179
    rst = 0;
180
    assert(start_tx_o == 0);
181
    assert(start_rx_o == 0);
182
 
183
    //unsuccesful cmd xfer test - write
184
    cmd_with_data_start_i = 1;
185
 
186
    #SD_TCLK;
187
    assert(start_tx_o == 0);
188
    assert(start_rx_o == 0);
189
    cmd_with_data_start_i = 0;
190
 
191
    #(3*SD_TCLK);
192
    assert(start_tx_o == 0);
193
    assert(start_rx_o == 0);
194
 
195
    cmd_int_status_i[`INT_CMD_EI] = 1;
196
    #(2*SD_TCLK);
197
    assert(start_tx_o == 0);
198
    assert(start_rx_o == 0);
199
    cmd_int_status_i[`INT_CMD_EI] = 0;
200
    #SD_TCLK;
201
    assert(start_tx_o == 0);
202
    assert(start_rx_o == 0);
203
 
204
    #(10*SD_TCLK) $display("sd_data_xfer_trig_tb finish ...");
205
    $finish;
206
 
207
end
208
 
209
endmodule

powered by: WebSVN 2.1.0

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