This repository has been archived by the owner on Dec 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tic_tac_toe_tb.v
101 lines (87 loc) · 2.2 KB
/
tic_tac_toe_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
`timescale 1ns / 1ns
module tic_tac_toe_tb ;
parameter A = 2'b01 ;
parameter B = 2'b10 ;
parameter PLAY = 2'b00 ;
parameter Awin = 2'b01 ;
parameter Bwin = 2'b10 ;
parameter DRAW = 2'b11 ;
reg [8:0] A_move ;
reg [8:0] B_move ;
reg OK_btn ;
reg reset ;
wire [8:0] A_state ;
wire [8:0] B_state ;
wire [160:0] result ;
tic_tac_toe #(A , B , PLAY , Awin , Bwin , DRAW )
DUT (
.B_move (B_move ) ,
.A_state (A_state ) ,
.OK_btn (OK_btn ) ,
.B_state (B_state ) ,
.result (result ) ,
.reset (reset ) ,
.A_move (A_move ) );
// "Constant Pattern"
// Start Time = 870 ns, End Time = 1 us, Period = 0 ns
initial
begin
A_move = 9'b000000000 ;
# 70 A_move = 9'b000000001 ;
# 200 A_move = 9'b000001001 ;
# 100 A_move = 9'b010001001 ;
# 100 A_move = 9'b110001001 ;
# 150 A_move = 9'b000000000 ;
# 50 A_move = 9'b000000010 ;
# 200 A_move = 9'b000000000 ;
# 130 ;
// dumped values till 1 us
end
// "Constant Pattern"
// Start Time = 870 ns, End Time = 1 us, Period = 0 ns
initial
begin
B_move = 9'b000000000 ;
# 20 B_move = 9'b000000001 ;
# 100 B_move = 9'b000000000 ;
# 50 B_move = 9'b000000001 ;
# 50 B_move = 9'b000000010 ;
# 100 B_move = 9'b000010010 ;
# 100 B_move = 9'b001010010 ;
# 100 B_move = 9'b001010110 ;
# 100 B_move = 9'b000000000 ;
# 100 B_move = 9'b000000100 ;
# 150 B_move = 9'b000000000 ;
# 130 ;
// dumped values till 1 us
end
// "Clock Pattern" : dutyCycle = 20
// Start Time = 0 ns, End Time = 1 us, Period = 50 ns
initial
begin
OK_btn = 1'b0 ;
# 40 ;
repeat(19)
begin
OK_btn = 1'b1 ;
#10 OK_btn = 1'b0 ;
#40 ;
// 990 ns, repeat pattern in loop.
end
OK_btn = 1'b1 ;
# 10 ;
// dumped values till 1 us
end
// "Constant Pattern"
// Start Time = 815 ns, End Time = 1 us, Period = 0 ns
initial
begin
reset = 1'b0 ;
# 815 reset = 1'b1 ;
# 10 reset = 1'b0 ;
# 175 ;
// dumped values till 1 us
end
initial
#2000 $stop;
endmodule