-
Notifications
You must be signed in to change notification settings - Fork 0
/
chess.v
79 lines (47 loc) · 1.82 KB
/
chess.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
module chess (LED_R, CLOCK_50, CLOCK_27, KEY, PS2_CLK, PS2_DAT, HEX0, HEX1, HEX2, HEX3, HEX4, HEX5, HEX6, HEX7, VGA_HS, VGA_VS, VGA_R, VGA_G, VGA_B, VGA_BLANK, VGA_CLK);
input CLOCK_50;
input CLOCK_27;
input [3:0] KEY;
input PS2_CLK, PS2_DAT;
output [6:0] HEX0, HEX1, HEX2, HEX3, HEX4, HEX5, HEX6, HEX7;
output VGA_HS, VGA_VS, VGA_BLANK, VGA_CLK;
output [9:0] VGA_R, VGA_G, VGA_B;
output [17:0] LED_R;
/////////////////////// RESET //////////////////////////////////////
wire RESET;
wire ENTER;
assign RESET = ~KEY[0];
assign ENTER = ~KEY[3];
/////////////////////// pixel clock 65 MHz /////////////////////////
wire CLOCK_65;
pll65 pll0 (CLOCK_50, CLOCK_65);
/////////////////////// XVGA video signals /////////////////////////
wire [10:0] hcount;
wire [9:0] vcount;
wire hsync, vsync, blank;
xvga xvga0 (CLOCK_65, hcount, vcount, hsync, vsync, blank);
assign VGA_HS = hsync;
assign VGA_VS = vsync;
assign VGA_BLANK = ~blank;
assign VGA_CLK = CLOCK_65;
///////////////////////// keyboard input ///////////////////////////
wire ready;
wire [7:0] ascii_char;
ps2decoder (CLOCK_27, RESET, PS2_CLK, PS2_DAT, ascii_char, ready);
wire [3:0] hex_char;
asciidecoder (ascii_char, hex_char);
hexdisplay h1(hex_char, HEX4); //für debug
hexdisplay h2(hex_char, HEX5); //für debug
assign LED_R[0] = ready;
//////////////////// chess state machine ////////////////////////
wire [4:0] state;
wire [7:0] tmp = {1'b0,1'b0,1'b0,state[4],state[3],state[2],state[1],state[0]};
chess_state c0(ascii_char, ready, RESET, ENTER, state);
bcddisplay h3(tmp, HEX3, HEX2, HEX1, HEX0); //für debug
////////////////////////// display //////////////////////////////
wire [9:0] R,G,B;
chess_display d1 (state, CLOCK_65, hcount, vcount, R, G, B);
assign VGA_R = R;
assign VGA_G = G;
assign VGA_B = B;
endmodule