This repository was archived by the owner on Aug 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathinputconditioner.t.v
More file actions
64 lines (55 loc) · 1.51 KB
/
inputconditioner.t.v
File metadata and controls
64 lines (55 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//------------------------------------------------------------------------
// Input Conditioner test bench
//------------------------------------------------------------------------
`timescale 1 ns / 1 ps
`include "inputconditioner.v"
module testConditioner();
reg clk;
reg pin;
wire conditioned;
wire rising;
wire falling;
inputconditioner dut(.clk(clk),
.noisysignal(pin),
.conditioned(conditioned),
.positiveedge(rising),
.negativeedge(falling));
// Generate clock (50MHz)
initial clk = 0;
always #10 clk=!clk; // 50MHz Clock
initial begin
// Your Test Code
// Be sure to test each of the three conditioner functions:
// Synchronization, Debouncing, Edge Detection
$dumpfile("inputconditioner.vcd");
$dumpvars();
//Testing Synchronization and edge detection
pin = 0; #150
pin = 1; #133
pin = 0; #231
pin = 1; #52
pin = 0; #100
//Testing debouncing when input bounces but remains zero
pin = 0; #5
pin = 1; #5
pin = 0; #5
pin = 1; #5
pin = 0; #100
//Check that conditioned = 0 the whole time
//Testing debouncing when input bounces and switches to one
pin = 0; #5
pin = 1; #5
pin = 0; #5
pin = 1; #2
pin = 0; #3
pin = 1; #1
pin = 0; #5
pin = 1; #160
//Check that conditioned = 0 and then switches to 1 after pin has settled
//Check delay for even clock cycle changes
pin = 0; #120
pin = 1; #120
pin = 0; #120
$finish;
end
endmodule