-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy path28_Auto_drink_machine_tb.v
101 lines (84 loc) · 1.47 KB
/
28_Auto_drink_machine_tb.v
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
//Testbench of auto drink machine
//author:WangFW
//date:2020-6-9
`timescale 10ns/1ns
module Auto_drink_machine_tb();
reg clk;
reg rst_n;
reg [1:0] select;
reg [1:0] coin;
wire [1:0] drink;
wire [1:0] back;
initial
begin
clk=0;
rst_n=1;
select=2'b00;
coin=2'b00;
#10 rst_n=0;
#10 rst_n=1;
//a1--a2--a3
@(posedge clk)
select=2'b01;
@(posedge clk)
select=2'b00;
@(posedge clk)
coin=2'b01;
@(posedge clk)
coin=2'b00;
@(posedge clk)
coin=2'b01;
@(posedge clk)
coin=2'b00;
//a1--a2--a4
@(posedge clk)
select=2'b00;
@(posedge clk)
select=2'b01;
@(posedge clk)
select=2'b00;
@(posedge clk)
coin=2'b01;
@(posedge clk)
coin=2'b00;
@(posedge clk)
coin=2'b10;
@(posedge clk)
coin=2'b00;
//a1--a5
@(posedge clk)
select=2'b00;
@(posedge clk)
select=2'b01;
@(posedge clk)
select=2'b00;
@(posedge clk)
coin=2'b10;
@(posedge clk)
coin=2'b00;
//b1---b2
@(posedge clk)
select=2'b00;
@(posedge clk)
select=2'b10;
@(posedge clk)
select=2'b00;
@(posedge clk)
coin=2'b01;
@(posedge clk)
coin=2'b00;
//b1---b3
@(posedge clk)
select=2'b00;
@(posedge clk)
select=2'b10;
@(posedge clk)
select=2'b00;
@(posedge clk)
coin=2'b10;
@(posedge clk)
coin=2'b00;
end
always #1 clk<=~clk;
Auto_drink_machine dut(.clk(clk),.rst_n(rst_n),.coin(coin),.select(select),.drink(drink),.back(back));
endmodule