-
Notifications
You must be signed in to change notification settings - Fork 1
/
Sudoku.v
94 lines (74 loc) · 2.14 KB
/
Sudoku.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
//=======================================================
// This code is generated by Terasic System Builder
//=======================================================
module Sudoku(
//////////// CLOCK //////////
input MAX10_CLK1_50,
//////////// KEY //////////
input [1:0] KEY,
//////////// SW //////////
input [9:0] SW,
//////////// VGA //////////
output [3:0] VGA_B,
output [3:0] VGA_G,
output VGA_HS,
output [3:0] VGA_R,
output VGA_VS,
output [0:9] LEDR,
//////////// SEG7: 3.3-V LVTTL //////////
output [7:0] HEX0,
output [7:0] HEX1,
output [7:0] HEX2,
output [7:0] HEX3,
output [7:0] HEX4,
output [7:0] HEX5
);
// signal declaration
wire clk, async_rstn, sync_rstn, video_on, pixel_tick, keyEnter, keyReset;
wire [9:0] pixel_x, pixel_y;
reg [11:0] rgb_reg;
wire [11:0] rgb_next;
assign clk = MAX10_CLK1_50;
EdgeDetector EnterKey (.clk(clk),
.rstn(1),
.trigger(~KEY[1]),
.pulse(keyEnter));
EdgeDetector ResetKey (.clk(clk),
.rstn(1),
.trigger(~KEY[0]),
.pulse(keyReset));
// instantiate vga sync circuit
VGASync vsync_unit (.clk(clk),
.rstn(1),
.hsync(VGA_HS),
.vsync(VGA_VS),
.video_on(video_on),
.p_tick(pixel_tick),
.pixel_x(pixel_x),
.pixel_y(pixel_y));
PixelGen px_gen (.clk(clk),
.rstn(1),
.video_on(video_on),
.p_tick(pixel_tick),
.keyEnter(keyEnter),
.keyReset(keyReset),
.pixel_x(pixel_x),
.pixel_y(pixel_y),
.sw(SW[9:0]),
.leds(LEDR),
.r(rgb_next[11:8]),
.g(rgb_next[7:4]),
.b(rgb_next[3:0]),
.h5(HEX5),
.h4(HEX4),
.h3(HEX3),
.h2(HEX2),
.h1(HEX1),
.h0(HEX0));
// rgb buffer
always@(posedge clk)
if(pixel_tick)
rgb_reg <= rgb_next;
// output
assign {VGA_R, VGA_G, VGA_B} = rgb_reg;
endmodule