-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmoveGenerator.v
137 lines (131 loc) · 4.16 KB
/
moveGenerator.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 04/20/2022 07:03:48 PM
// Design Name:
// Module Name: moveGenerator
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module moveGenerator(
input get_move,
input reset,
output [1:0] move,
output end_move
);
// Create local parameters for what the direction of the current move is
localparam [1:0] UP = 2'd0,
DOWN = 2'd1,
LEFT = 2'd2,
RIGHT = 2'd3;
reg [3:0] pattern, next_pattern; // Stores which step of the pattern
reg [1:0] next_move; // UP/DOWN/LEFT/RIGHT current output
reg end_move_reg; // set to high when end of pattern reached, signals no more moves remaining
assign move = next_move;
assign end_move = end_move_reg;
always @(posedge get_move or posedge reset)
begin
if (reset) begin
pattern <= 0;
next_pattern <= 0;
next_move <= 0;
end_move_reg <= 0;
end
else begin
pattern <= next_pattern;
case (pattern)
0 : begin
next_move = UP;
next_pattern = pattern + 1;
end_move_reg = 0;
end
1 : begin
next_move = DOWN;
next_pattern = pattern + 1;
end_move_reg = 0;
end
2 : begin
next_move = UP;
next_pattern = pattern + 1;
end_move_reg = 0;
end
3 : begin
next_move = RIGHT;
next_pattern = pattern + 1;
end_move_reg = 0;
end
4 : begin
next_move = DOWN;
next_pattern = pattern + 1;
end_move_reg = 0;
end
5 : begin
next_move = UP;
next_pattern = pattern + 1;
end_move_reg = 0;
end
6 : begin
next_move = LEFT;
next_pattern = pattern + 1;
end_move_reg = 0;
end
7 : begin
next_move = RIGHT;
next_pattern = pattern + 1;
end_move_reg = 0;
end
8 : begin
next_move = DOWN;
next_pattern = pattern + 1;
end_move_reg = 0;
end
9 : begin
next_move = LEFT;
next_pattern = pattern + 1;
end_move_reg = 0;
end
10 : begin
next_move = UP;
next_pattern = pattern + 1;
end_move_reg = 0;
end
11 : begin
next_move = RIGHT;
next_pattern = pattern + 1;
end_move_reg = 0;
end
12 : begin
next_move = LEFT;
next_pattern = pattern + 1;
end_move_reg = 0;
end
13 : begin
next_move = DOWN;
next_pattern = pattern + 1;
end_move_reg = 0;
end
14 : begin
next_move = RIGHT;
next_pattern = pattern + 1;
end_move_reg = 0;
end
15 : begin
next_move = LEFT;
next_pattern = pattern;
end_move_reg = 1;
end
endcase
end
end
endmodule