-
Notifications
You must be signed in to change notification settings - Fork 0
/
chess_state.v
71 lines (50 loc) · 2.29 KB
/
chess_state.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
module chess_state(ascii, new_ascii, RESET, ENTER, state);
input [7:0] ascii; // aktives ascii-signal
input new_ascii; // signal für neues ascii
input RESET; // Reset-Button
input ENTER; // Enter-Button
output reg [4:0] state; // state output
///////////////// statemachine /////////////////////////////////
always @ (posedge ENTER or posedge RESET)
begin
if (RESET)
state <= 4'b0101;
else
case (state)
4'b0001: //Feld 1
if (ascii == 8'h44) begin state <= 4'b0010; end
else if (ascii == 8'h53) begin state <= 4'b0100; end
4'b0010: //Feld 2
if (ascii == 8'h41) begin state <= 4'b0001; end
else if (ascii == 8'h44) begin state <= 4'b0011; end
else if (ascii == 8'h53) begin state <= 4'b0101; end
4'b0011: //Feld 3
if (ascii == 8'h41) begin state <= 4'b0010; end
else if (ascii == 8'h53) begin state <= 4'b0110; end
4'b0100: //Feld 4
if (ascii == 8'h57) begin state <= 4'b0001; end
else if (ascii == 8'h44) begin state <= 4'b0101; end
else if (ascii == 8'h53) begin state <= 4'b0111; end
4'b0101: //Feld 5
if (ascii == 8'h57) begin state <= 4'b0010; end
else if (ascii == 8'h44) begin state <= 4'b0110; end
else if (ascii == 8'h53) begin state <= 4'b1000; end
else if (ascii == 8'h41) begin state <= 4'b0100; end
4'b0110: //Feld 6
if (ascii == 8'h57) begin state <= 4'b0011; end
else if (ascii == 8'h41) begin state <= 4'b0101; end
else if (ascii == 8'h53) begin state <= 4'b1001; end
4'b0111: //Feld 7
if (ascii == 8'h57) begin state <= 4'b0100; end
else if (ascii == 8'h44) begin state <= 4'b1000; end
4'b1000: //Feld 8
if (ascii == 8'h57) begin state <= 4'b0101; end
else if (ascii == 8'h44) begin state <= 4'b1001; end
else if (ascii == 8'h41) begin state <= 4'b0111; end
4'b1001: //Feld 9
if (ascii == 8'h41) begin state <= 4'b1000; end
else if (ascii == 8'h57) begin state <= 4'b0110; end
default: begin state <= 4'b0101; end
endcase
end
endmodule