5bbc85798a663d0e34a4bc122ac514fca3bd3537
[mw/milkymist.git] / boards / xilinx-ml401 / rtl / vga.v
1 /*
2  * Milkymist VJ SoC
3  * Copyright (C) 2007, 2008, 2009 Sebastien Bourdeauducq
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, version 3 of the License.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17
18 `include "setup.v"
19
20 module vga #(
21         parameter csr_addr = 4'h0,
22         parameter fml_depth = 26
23 ) (
24         input sys_clk,
25         input sys_rst,
26         
27         /* Configuration interface */
28         input [13:0] csr_a,
29         input csr_we,
30         input [31:0] csr_di,
31         output [31:0] csr_do,
32         
33         /* Framebuffer FML 4x64 interface */
34         output [fml_depth-1:0] fml_adr,
35         output fml_stb,
36         input fml_ack,
37         input [63:0] fml_di,
38
39         /* Direct Cache Bus */
40         output dcb_stb,
41         output [fml_depth-1:0] dcb_adr,
42         input [63:0] dcb_dat,
43         input dcb_hit,
44         
45         /* VGA pads */
46         output vga_psave_n,
47         output vga_hsync_n,
48         output vga_vsync_n,
49         output vga_sync_n,
50         output vga_blank_n,
51         output [7:0] vga_r,
52         output [7:0] vga_g,
53         output [7:0] vga_b,
54         output vga_clkout
55 );
56
57 wire vga_clk;
58
59 reg [1:0] fcounter;
60 always @(posedge sys_clk) fcounter <= fcounter + 2'd1;
61 assign vga_clk = fcounter[1];
62
63 assign vga_clkout = vga_clk;
64
65 vgafb #(
66         .csr_addr(csr_addr),
67         .fml_depth(fml_depth)
68 ) vgafb (
69         .sys_clk(sys_clk),
70         .sys_rst(sys_rst),
71         
72         .csr_a(csr_a),
73         .csr_we(csr_we),
74         .csr_di(csr_di),
75         .csr_do(csr_do),
76         
77         .fml_adr(fml_adr),
78         .fml_stb(fml_stb),
79         .fml_ack(fml_ack),
80         .fml_di(fml_di),
81         
82         .dcb_stb(dcb_stb),
83         .dcb_adr(dcb_adr),
84         .dcb_dat(dcb_dat),
85         .dcb_hit(dcb_hit),
86         
87         .vga_clk(vga_clk),
88         .vga_psave_n(vga_psave_n),
89         .vga_hsync_n(vga_hsync_n),
90         .vga_vsync_n(vga_vsync_n),
91         .vga_sync_n(vga_sync_n),
92         .vga_blank_n(vga_blank_n),
93         .vga_r(vga_r),
94         .vga_g(vga_g),
95         .vga_b(vga_b)
96 );
97
98 endmodule