forked from bogini/Pong
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dot_top.v
37 lines (32 loc) · 925 Bytes
/
dot_top.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
// Listing 13.8
module dot_top
(
input wire clk, reset,
input wire [1:0] btn,
input wire [2:0] sw,
output wire hsync, vsync,
output wire [2:0] rgb
);
// signal declaration
wire [9:0] pixel_x, pixel_y;
wire video_on, pixel_tick;
reg [2:0] rgb_reg;
wire [2:0] rgb_next;
// body
// instantiate VGA sync circuit
vga_sync vsync_unit
(.clk(clk), .reset(reset), .hsync(hsync), .vsync(vsync),
.video_on(video_on), .p_tick(pixel_tick),
.pixel_x(pixel_x), .pixel_y(pixel_y));
// instantiate graphic generator
bitmap_gen bitmap_unit
(.clk(clk), .reset(reset), .btn(btn), .sw(sw),
.video_on(video_on), .pix_x(pixel_x),
.pix_y(pixel_y), .bit_rgb(rgb_next));
// rgb buffer
always @(posedge clk)
if (pixel_tick)
rgb_reg <= rgb_next;
// output
assign rgb = rgb_reg;
endmodule