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

Subversion Repositories sd_card_controller

[/] [sd_card_controller/] [trunk/] [bench/] [verilog/] [monostable_domain_cross_tb.sv] - Blame information for rev 8

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 rozpruwacz
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
//// WISHBONE SD Card Controller IP Core                          ////
4
////                                                              ////
5
//// monostable_domain_cross_tb.sv                                ////
6
////                                                              ////
7
//// This file is part of the WISHBONE SD Card                    ////
8
//// Controller IP Core project                                   ////
9 8 rozpruwacz
//// http://opencores.org/project,sd_card_controller              ////
10 3 rozpruwacz
////                                                              ////
11
//// Description                                                  ////
12
//// testbench for monostable_domain_cross 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
module monostable_domain_cross_tb();
45
 
46
parameter TCLK_A = 20; // 50 MHz -> timescale 1ns
47
parameter TCLK_B = 203; // 4.98 MHz -> timescale 1ns
48
 
49
reg rst0;
50
reg rst1;
51
reg clk_a;
52
reg in;
53
reg clk_b;
54
wire out0;
55
wire out1;
56
integer i;
57
 
58
monostable_domain_cross monostable_domain_cross_dut0(
59
    .rst(rst0),
60
    .clk_a(clk_a),
61
    .in(in),
62
    .clk_b(clk_b),
63
    .out(out0)
64
);
65
 
66
monostable_domain_cross monostable_domain_cross_dut1(
67
    .rst(rst1),
68
    .clk_a(clk_b),
69
    .in(in),
70
    .clk_b(clk_a),
71
    .out(out1)
72
);
73
 
74
// Generating clk_a clock
75
always
76
begin
77
    clk_a=0;
78
    forever #(TCLK_A/2) clk_a = ~clk_a;
79
end
80
 
81
// Generating clk_b clock
82
always
83
begin
84
    clk_b=0;
85
    forever #(TCLK_B/2) clk_b = ~clk_b;
86
end
87
 
88
initial
89
begin
90
    rst0 = 1;
91
    rst1 = 1;
92
    in = 0;
93
 
94
    #(3.2*TCLK_B);
95
    rst0 = 0;
96
 
97
    $display("monostable_domain_cross_tb start ...");
98
 
99
    for (i = 0; i < 2; i = i + 1) begin
100
        wait(clk_a == 0);
101
        wait(clk_a == 1);
102
        in = 1;
103
        #(1.5*TCLK_A);
104
        in = 0;
105
 
106
        wait(out0 == 1);
107
        #(1.5*TCLK_B);
108
        assert(out0 == 0);
109
    end
110
 
111
    rst0 = 1;
112
    ///////////////////////////////////////////////////////////////////////
113
    rst1 = 0;
114
 
115
    for (i = 0; i < 2; i = i + 1) begin
116
        wait(clk_b == 0);
117
        wait(clk_b == 1);
118
        fork
119
            begin
120
                in = 1;
121
                #(1.5*TCLK_B);
122
                in = 0;
123
            end
124
            begin
125
                wait(out1 == 1);
126
                #(1.5*TCLK_A);
127
                assert(out1 == 0);
128
            end
129
        join
130
    end
131
 
132
 
133
    #(10*TCLK_B) $display("monostable_domain_cross_tb finish ...");
134
    $finish;
135
 
136
end
137
 
138
endmodule

powered by: WebSVN 2.1.0

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