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

Subversion Repositories s80186

[/] [s80186/] [trunk/] [fpga/] [VGA/] [FrameBuffer.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 FrameBuffer(input logic clk,
19
                   input logic sys_clk,
20
                   input logic is_border,
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
                   input logic [2:0] glyph_row,
32
                   input logic is_blank,
33
                   input logic cursor_enabled,
34
                   input logic [14:0] cursor_pos,
35
                   input logic [2:0] cursor_scan_start,
36
                   input logic [2:0] cursor_scan_end,
37
                   input logic [10:0] address,
38
                   output logic [7:0] glyph,
39
                   output logic [3:0] background,
40
                   output logic [3:0] foreground,
41
                   output logic render_cursor);
42
 
43
wire [15:0] cpu_q;
44
wire cpu_wr_en = data_m_access & cs & data_m_wr_en;
45
assign data_m_data_out = data_m_ack ? cpu_q : 16'b0;
46
 
47
logic vga_valid;
48
wire [15:0] vga_q;
49
assign {background, foreground, glyph} = is_border || !vga_valid ? 16'b0 : vga_q;
50
 
51
always_ff @(posedge clk)
52
    render_cursor <= ~is_blank && cursor_enabled && address == cursor_pos[10:0] &&
53
        glyph_row >= cursor_scan_start && glyph_row <= cursor_scan_end;
54
 
55
FrameBufferRAM FrameBufferRAM(.clock_a(sys_clk),
56
                              // CPU
57
                              .address_a(data_m_addr[11:1]),
58
                              .byteena_a(data_m_bytesel),
59
                              .data_a(data_m_data_in),
60
                              .q_a(cpu_q),
61
                              .wren_a(cpu_wr_en),
62
                              // VGA
63
                              .clock_b(clk),
64
                              .address_b(address),
65
                              .data_b(16'b0),
66
                              .q_b(vga_q),
67
                              .wren_b(1'b0));
68
 
69
always_ff @(posedge sys_clk)
70
    data_m_ack <= data_m_access & cs;
71
 
72
always_ff @(posedge clk)
73
    vga_valid <= ~is_blank;
74
 
75
endmodule

powered by: WebSVN 2.1.0

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