OpenCores
URL https://opencores.org/ocsvn/s80186/s80186/trunk

Subversion Repositories s80186

[/] [s80186/] [trunk/] [fpga/] [VGA/] [VGAController.sv] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 jamieiles
// Copyright Jamie Iles, 2017
2
//
3
// This file is part of s80x86.
4
//
5
// s80x86 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, either version 3 of the License, or
8
// (at your option) any later version.
9
//
10
// s80x86 is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
// GNU General Public License for more details.
14
//
15
// You should have received a copy of the GNU General Public License
16
// along with s80x86.  If not, see .
17
 
18
module VGAController(input logic clk,
19
                     input logic sys_clk,
20
                     input logic reset,
21
                     // CPU port
22
                     input logic cs,
23
                     input logic data_m_access,
24
                     output logic data_m_ack,
25
                     input logic [19:1] data_m_addr,
26
                     input logic data_m_wr_en,
27
                     input logic [15:0] data_m_data_in,
28
                     output logic [15:0] data_m_data_out,
29
                     input logic [1:0] data_m_bytesel,
30
                     // VGA signals
31
                     output logic vga_hsync,
32
                     output logic vga_vsync,
33
                     output logic [3:0] vga_r,
34
                     output logic [3:0] vga_g,
35
                     output logic [3:0] vga_b,
36
                     input logic cursor_enabled,
37
                     input logic [14:0] cursor_pos,
38
                     input logic [2:0] cursor_scan_start,
39
                     input logic [2:0] cursor_scan_end);
40
 
41
wire hsync;
42
wire vsync;
43
wire is_blank;
44
wire [9:0] row;
45
wire [9:0] col;
46
logic fdata;
47
 
48
// Putting a 640x400 display into a 640x480 screen.  Black bars of 40 pixels
49
// at the top and bottom.
50
wire [9:0] shifted_row = row - 10'd40;
51
wire is_border = row < 10'd40 || row >= 10'd440;
52
 
53
wire [3:0] fb_background;
54
wire [3:0] fb_foreground;
55
wire [7:0] fb_glyph;
56
logic [2:0] fb_fcl_col;
57
logic [2:0] fb_fcl_row;
58
wire render_cursor;
59
 
60
logic [2:0] vsync_pipe;
61
assign vga_vsync = vsync_pipe[0];
62
logic [2:0] hsync_pipe;
63
assign vga_hsync = hsync_pipe[0];
64
 
65
// 2 vertical pixels per horizontal pixel to scale out.
66
wire [10:0] frame_buffer_address = ({1'b0, shifted_row} / 11'd16) * 11'd80 + ({1'b0, col} / 11'd8);
67
 
68
VGASync VGASync(.*);
69
 
70
FrameBuffer FrameBuffer(.address(frame_buffer_address),
71
                        .glyph(fb_glyph),
72
                        .background(fb_background),
73
                        .foreground(fb_foreground),
74
                        .glyph_row(shifted_row[3:1]),
75
                        .*);
76
 
77
FontColorLUT FontColorLUT(.glyph(fb_glyph),
78
                          .glyph_row(fb_fcl_row),
79
                          .glyph_col(fb_fcl_col),
80
                          .foreground(fb_foreground),
81
                          .background(fb_background),
82
                          .r(vga_r),
83
                          .g(vga_g),
84
                          .b(vga_b),
85
                          .*);
86
 
87
always_ff @(posedge clk) begin
88
    fb_fcl_col <= col[2:0];
89
    fb_fcl_row <= shifted_row[3:1];
90
end
91
 
92
always_ff @(posedge clk) begin
93
    vsync_pipe <= {vsync, vsync_pipe[2:1]};
94
    hsync_pipe <= {hsync, hsync_pipe[2:1]};
95
end
96
 
97
endmodule

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.