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

Subversion Repositories boundaries

[/] [boundaries/] [tags/] [TAG000/] [bench/] [verilog/] [debouncer_tb.v] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 esquehill
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
//// debouncer_tb.v                                               ////
4
////                                                              ////
5
//// This file is part of the boundaries opencores effort.        ////
6
//// <http://www.opencores.org/cores/boundaries/>                 ////
7
////                                                              ////
8
//// Module Description:                                          ////
9
//// debouncer testbench.                                         ////
10
////                                                              ////
11
//// To Do:                                                       ////
12
//// Done.                                                        ////
13
////                                                              ////
14
//// Author(s):                                                   ////
15
//// - Shannon Hill                                               ////
16
////                                                              ////
17
//////////////////////////////////////////////////////////////////////
18
////                                                              ////
19
//// Copyright (C) 2004 Shannon Hill and OPENCORES.ORG            ////
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
// $Id: debouncer_tb.v,v 1.1 2004-07-07 12:39:14 esquehill Exp $
45
//
46
// CVS Revision History
47
//
48
// $Log: not supported by cvs2svn $
49
//
50
//
51
 
52
`timescale 1ns/1ps
53
 
54
module debouncer_tb();
55
 
56
reg    clk_i;
57
reg    rst_i;
58
reg    button_i;
59
wire   button_o;
60
 
61
integer count;
62
 
63
initial
64
begin
65
clk_i <= 0;
66
rst_i <= 1;
67
#10;
68
rst_i <= 0;
69
end
70
 
71
always @( button_o ) count = count + 1;
72
 
73
always #500 clk_i <= ~clk_i;  // 1000 ns clock
74
 
75
debouncer #(8) u_db ( /*AUTOINST*/
76
                     // Outputs
77
                     .button_o          (button_o),
78
                     // Inputs
79
                     .rst_i             (rst_i),
80
                     .clk_i             (clk_i),
81
                     .button_i          (button_i));
82
real    period;
83
integer i;
84
 
85
initial
86
begin
87
 button_i <= 0;
88
 period    = 250000.0;
89
 count     = 0;
90
 forever
91
 begin
92
 
93
   for( i = 0 ; i < 8 ; i = i + 1 )
94
   begin
95
    #(period);
96
     button_i <= ~button_i;  // 8 bounces 
97
   end
98
 
99
       period = period + 1000.0;
100
 
101
   if( period > 400000.0 )
102
     begin
103
 
104
     if( count == 1160 ) $display("OK");
105
                    else $display("%d: wrong number of output transitions, expect=1160, actual=%d",$time,count);
106
 
107
     $finish;
108
     end
109
 
110
 end
111
end
112
 
113
endmodule

powered by: WebSVN 2.1.0

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