| 1 |
3 |
olivier.gi |
//----------------------------------------------------------------------------
|
| 2 |
|
|
// Copyright (C) 2015 Authors
|
| 3 |
|
|
//
|
| 4 |
|
|
// This source file may be used and distributed without restriction provided
|
| 5 |
|
|
// that this copyright statement is not removed from the file and that any
|
| 6 |
|
|
// derivative work contains the original copyright notice and the associated
|
| 7 |
|
|
// disclaimer.
|
| 8 |
|
|
//
|
| 9 |
|
|
// This source file is free software; you can redistribute it and/or modify
|
| 10 |
|
|
// it under the terms of the GNU Lesser General Public License as published
|
| 11 |
|
|
// by the Free Software Foundation; either version 2.1 of the License, or
|
| 12 |
|
|
// (at your option) any later version.
|
| 13 |
|
|
//
|
| 14 |
|
|
// This source is distributed in the hope that it will be useful, but WITHOUT
|
| 15 |
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
| 16 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
| 17 |
|
|
// License for more details.
|
| 18 |
|
|
//
|
| 19 |
|
|
// You should have received a copy of the GNU Lesser General Public License
|
| 20 |
|
|
// along with this source; if not, write to the Free Software Foundation,
|
| 21 |
|
|
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
| 22 |
|
|
//
|
| 23 |
|
|
//----------------------------------------------------------------------------
|
| 24 |
|
|
//
|
| 25 |
|
|
// *File Name: ogfx_backend.v
|
| 26 |
|
|
//
|
| 27 |
|
|
// *Module Description:
|
| 28 |
|
|
// Backend module of the graphic controller.
|
| 29 |
|
|
// The purpose of this block is to:
|
| 30 |
|
|
//
|
| 31 |
|
|
// - fetch the data from the specified frame buffer
|
| 32 |
|
|
// - convert data depending on selected video mode
|
| 33 |
|
|
//
|
| 34 |
|
|
// *Author(s):
|
| 35 |
|
|
// - Olivier Girard, olgirard@gmail.com
|
| 36 |
|
|
//
|
| 37 |
|
|
//----------------------------------------------------------------------------
|
| 38 |
|
|
// $Rev$
|
| 39 |
|
|
// $LastChangedBy$
|
| 40 |
|
|
// $LastChangedDate$
|
| 41 |
|
|
//----------------------------------------------------------------------------
|
| 42 |
|
|
`ifdef OGFX_NO_INCLUDE
|
| 43 |
|
|
`else
|
| 44 |
|
|
`include "openGFX430_defines.v"
|
| 45 |
|
|
`endif
|
| 46 |
|
|
|
| 47 |
|
|
module ogfx_backend (
|
| 48 |
|
|
|
| 49 |
|
|
// OUTPUTs
|
| 50 |
|
|
refresh_data_o, // Display refresh data
|
| 51 |
|
|
refresh_data_ready_o, // Display refresh new data is ready
|
| 52 |
|
|
|
| 53 |
|
|
vid_ram_addr_o, // Video-RAM refresh address
|
| 54 |
|
|
vid_ram_cen_o, // Video-RAM refresh enable (active low)
|
| 55 |
|
|
|
| 56 |
|
|
`ifdef WITH_PROGRAMMABLE_LUT
|
| 57 |
|
|
lut_ram_addr_o, // LUT-RAM refresh address
|
| 58 |
|
|
lut_ram_cen_o, // LUT-RAM refresh enable (active low)
|
| 59 |
|
|
`endif
|
| 60 |
|
|
|
| 61 |
|
|
// INPUTs
|
| 62 |
|
|
mclk, // Main system clock
|
| 63 |
|
|
puc_rst, // Main system reset
|
| 64 |
|
|
|
| 65 |
|
|
display_width_i, // Display width
|
| 66 |
|
|
display_height_i, // Display height
|
| 67 |
|
|
display_size_i, // Display size (number of pixels)
|
| 68 |
|
|
display_y_swap_i, // Display configuration: swap Y axis (horizontal symmetry)
|
| 69 |
|
|
display_x_swap_i, // Display configuration: swap X axis (vertical symmetry)
|
| 70 |
|
|
display_cl_swap_i, // Display configuration: swap column/lines
|
| 71 |
|
|
|
| 72 |
|
|
gfx_mode_i, // Video mode (1xx:16bpp / 011:8bpp / 010:4bpp / 001:2bpp / 000:1bpp)
|
| 73 |
|
|
|
| 74 |
|
|
`ifdef WITH_PROGRAMMABLE_LUT
|
| 75 |
|
|
lut_ram_dout_i, // LUT-RAM data output
|
| 76 |
|
|
lut_ram_dout_rdy_nxt_i, // LUT-RAM data output ready during next cycle
|
| 77 |
|
|
`endif
|
| 78 |
|
|
|
| 79 |
|
|
vid_ram_dout_i, // Video-RAM data output
|
| 80 |
|
|
vid_ram_dout_rdy_nxt_i, // Video-RAM data output ready during next cycle
|
| 81 |
|
|
|
| 82 |
|
|
refresh_active_i, // Display refresh on going
|
| 83 |
|
|
refresh_data_request_i, // Display refresh new data request
|
| 84 |
|
|
refresh_frame_base_addr_i, // Refresh frame base address
|
| 85 |
11 |
olivier.gi |
|
| 86 |
|
|
hw_lut_palette_sel_i, // Hardware LUT palette configuration
|
| 87 |
|
|
hw_lut_bgcolor_i, // Hardware LUT background-color selection
|
| 88 |
|
|
hw_lut_fgcolor_i, // Hardware LUT foreground-color selection
|
| 89 |
|
|
sw_lut_enable_i, // Refresh LUT-RAM enable
|
| 90 |
|
|
sw_lut_bank_select_i // Refresh LUT-RAM bank selection
|
| 91 |
3 |
olivier.gi |
);
|
| 92 |
|
|
|
| 93 |
|
|
// OUTPUTs
|
| 94 |
|
|
//=========
|
| 95 |
|
|
output [15:0] refresh_data_o; // Display refresh data
|
| 96 |
|
|
output refresh_data_ready_o; // Display refresh new data is ready
|
| 97 |
|
|
|
| 98 |
|
|
output [`VRAM_MSB:0] vid_ram_addr_o; // Video-RAM refresh address
|
| 99 |
|
|
output vid_ram_cen_o; // Video-RAM refresh enable (active low)
|
| 100 |
|
|
|
| 101 |
|
|
`ifdef WITH_PROGRAMMABLE_LUT
|
| 102 |
|
|
output [`LRAM_MSB:0] lut_ram_addr_o; // LUT-RAM refresh address
|
| 103 |
|
|
output lut_ram_cen_o; // LUT-RAM refresh enable (active low)
|
| 104 |
|
|
`endif
|
| 105 |
|
|
|
| 106 |
|
|
// INPUTs
|
| 107 |
|
|
//=========
|
| 108 |
|
|
input mclk; // Main system clock
|
| 109 |
|
|
input puc_rst; // Main system reset
|
| 110 |
|
|
|
| 111 |
|
|
input [`LPIX_MSB:0] display_width_i; // Display width
|
| 112 |
|
|
input [`LPIX_MSB:0] display_height_i; // Display height
|
| 113 |
|
|
input [`SPIX_MSB:0] display_size_i; // Display size (number of pixels)
|
| 114 |
|
|
input display_y_swap_i; // Display configuration: swap Y axis (horizontal symmetry)
|
| 115 |
|
|
input display_x_swap_i; // Display configuration: swap X axis (vertical symmetry)
|
| 116 |
|
|
input display_cl_swap_i; // Display configuration: swap column/lines
|
| 117 |
|
|
|
| 118 |
|
|
input [2:0] gfx_mode_i; // Video mode (1xx:16bpp / 011:8bpp / 010:4bpp / 001:2bpp / 000:1bpp)
|
| 119 |
|
|
|
| 120 |
|
|
`ifdef WITH_PROGRAMMABLE_LUT
|
| 121 |
|
|
input [15:0] lut_ram_dout_i; // LUT-RAM data output
|
| 122 |
|
|
input lut_ram_dout_rdy_nxt_i; // LUT-RAM data output ready during next cycle
|
| 123 |
|
|
`endif
|
| 124 |
|
|
|
| 125 |
|
|
input [15:0] vid_ram_dout_i; // Video-RAM data output
|
| 126 |
|
|
input vid_ram_dout_rdy_nxt_i; // Video-RAM data output ready during next cycle
|
| 127 |
|
|
|
| 128 |
|
|
input refresh_active_i; // Display refresh on going
|
| 129 |
|
|
input refresh_data_request_i; // Display refresh new data request
|
| 130 |
|
|
input [`APIX_MSB:0] refresh_frame_base_addr_i; // Refresh frame base address
|
| 131 |
|
|
|
| 132 |
11 |
olivier.gi |
input [2:0] hw_lut_palette_sel_i; // Hardware LUT palette configuration
|
| 133 |
|
|
input [3:0] hw_lut_bgcolor_i; // Hardware LUT background-color selection
|
| 134 |
|
|
input [3:0] hw_lut_fgcolor_i; // Hardware LUT foreground-color selection
|
| 135 |
|
|
input sw_lut_enable_i; // Refresh LUT-RAM enable
|
| 136 |
|
|
input sw_lut_bank_select_i; // Refresh LUT-RAM bank selection
|
| 137 |
3 |
olivier.gi |
|
| 138 |
11 |
olivier.gi |
|
| 139 |
3 |
olivier.gi |
//=============================================================================
|
| 140 |
|
|
// 1) WIRE, REGISTERS AND PARAMETER DECLARATION
|
| 141 |
|
|
//=============================================================================
|
| 142 |
|
|
|
| 143 |
|
|
// Wires
|
| 144 |
|
|
wire [15:0] frame_data;
|
| 145 |
|
|
wire frame_data_ready;
|
| 146 |
|
|
wire frame_data_request;
|
| 147 |
|
|
|
| 148 |
|
|
|
| 149 |
|
|
//============================================================================
|
| 150 |
|
|
// 2) FRAME MEMORY ACCESS
|
| 151 |
|
|
//============================================================================
|
| 152 |
|
|
|
| 153 |
|
|
ogfx_backend_frame_fifo ogfx_backend_frame_fifo_inst (
|
| 154 |
|
|
|
| 155 |
|
|
// OUTPUTs
|
| 156 |
|
|
.frame_data_o ( frame_data ), // Frame data
|
| 157 |
|
|
.frame_data_ready_o ( frame_data_ready ), // Frame data ready
|
| 158 |
|
|
|
| 159 |
|
|
.vid_ram_addr_o ( vid_ram_addr_o ), // Video-RAM address
|
| 160 |
|
|
.vid_ram_cen_o ( vid_ram_cen_o ), // Video-RAM enable (active low)
|
| 161 |
|
|
|
| 162 |
|
|
// INPUTs
|
| 163 |
|
|
.mclk ( mclk ), // Main system clock
|
| 164 |
|
|
.puc_rst ( puc_rst ), // Main system reset
|
| 165 |
|
|
|
| 166 |
|
|
.display_width_i ( display_width_i ), // Display width
|
| 167 |
|
|
.display_height_i ( display_height_i ), // Display height
|
| 168 |
|
|
.display_size_i ( display_size_i ), // Display size (number of pixels)
|
| 169 |
|
|
.display_y_swap_i ( display_y_swap_i ), // Display configuration: swap Y axis (horizontal symmetry)
|
| 170 |
|
|
.display_x_swap_i ( display_x_swap_i ), // Display configuration: swap X axis (vertical symmetry)
|
| 171 |
|
|
.display_cl_swap_i ( display_cl_swap_i ), // Display configuration: swap column/lines
|
| 172 |
|
|
|
| 173 |
|
|
.frame_data_request_i ( frame_data_request ), // Request for next frame data
|
| 174 |
|
|
|
| 175 |
|
|
.gfx_mode_i ( gfx_mode_i ), // Video mode (1xx:16bpp / 011:8bpp / 010:4bpp / 001:2bpp / 000:1bpp)
|
| 176 |
|
|
|
| 177 |
|
|
.vid_ram_dout_i ( vid_ram_dout_i ), // Video-RAM data output
|
| 178 |
|
|
.vid_ram_dout_rdy_nxt_i ( vid_ram_dout_rdy_nxt_i ), // Video-RAM data output ready during next cycle
|
| 179 |
|
|
|
| 180 |
|
|
.refresh_active_i ( refresh_active_i ), // Display refresh on going
|
| 181 |
|
|
.refresh_frame_base_addr_i ( refresh_frame_base_addr_i ) // Refresh frame base address
|
| 182 |
|
|
);
|
| 183 |
|
|
|
| 184 |
|
|
|
| 185 |
|
|
//============================================================================
|
| 186 |
|
|
// 3) LUT MEMORY ACCESS
|
| 187 |
|
|
//============================================================================
|
| 188 |
|
|
|
| 189 |
|
|
ogfx_backend_lut_fifo ogfx_backend_lut_fifo_inst (
|
| 190 |
|
|
|
| 191 |
|
|
// OUTPUTs
|
| 192 |
|
|
.frame_data_request_o ( frame_data_request ), // Request for next frame data
|
| 193 |
|
|
|
| 194 |
|
|
.refresh_data_o ( refresh_data_o ), // Display Refresh data
|
| 195 |
|
|
.refresh_data_ready_o ( refresh_data_ready_o ), // Display Refresh data ready
|
| 196 |
|
|
|
| 197 |
|
|
`ifdef WITH_PROGRAMMABLE_LUT
|
| 198 |
|
|
.lut_ram_addr_o ( lut_ram_addr_o ), // LUT-RAM address
|
| 199 |
|
|
.lut_ram_cen_o ( lut_ram_cen_o ), // LUT-RAM enable (active low)
|
| 200 |
|
|
`endif
|
| 201 |
|
|
|
| 202 |
|
|
// INPUTs
|
| 203 |
|
|
.mclk ( mclk ), // Main system clock
|
| 204 |
|
|
.puc_rst ( puc_rst ), // Main system reset
|
| 205 |
|
|
|
| 206 |
|
|
.frame_data_i ( frame_data ), // Frame data
|
| 207 |
|
|
.frame_data_ready_i ( frame_data_ready ), // Frame data ready
|
| 208 |
|
|
|
| 209 |
|
|
.gfx_mode_i ( gfx_mode_i ), // Video mode (1xx:16bpp / 011:8bpp / 010:4bpp / 001:2bpp / 000:1bpp)
|
| 210 |
|
|
|
| 211 |
|
|
`ifdef WITH_PROGRAMMABLE_LUT
|
| 212 |
|
|
.lut_ram_dout_i ( lut_ram_dout_i ), // LUT-RAM data output
|
| 213 |
|
|
.lut_ram_dout_rdy_nxt_i ( lut_ram_dout_rdy_nxt_i ), // LUT-RAM data output ready during next cycle
|
| 214 |
|
|
`endif
|
| 215 |
|
|
|
| 216 |
|
|
.refresh_active_i ( refresh_active_i ), // Display refresh on going
|
| 217 |
|
|
.refresh_data_request_i ( refresh_data_request_i ), // Request for next refresh data
|
| 218 |
11 |
olivier.gi |
|
| 219 |
|
|
.hw_lut_palette_sel_i ( hw_lut_palette_sel_i ), // Hardware LUT palette configuration
|
| 220 |
|
|
.hw_lut_bgcolor_i ( hw_lut_bgcolor_i ), // Hardware LUT background-color selection
|
| 221 |
|
|
.hw_lut_fgcolor_i ( hw_lut_fgcolor_i ), // Hardware LUT foreground-color selection
|
| 222 |
|
|
.sw_lut_enable_i ( sw_lut_enable_i ), // Refresh LUT-RAM enable
|
| 223 |
|
|
.sw_lut_bank_select_i ( sw_lut_bank_select_i ) // Refresh LUT-RAM bank selection
|
| 224 |
3 |
olivier.gi |
);
|
| 225 |
|
|
|
| 226 |
|
|
|
| 227 |
|
|
endmodule // ogfx_backend
|
| 228 |
|
|
|
| 229 |
|
|
`ifdef OGFX_NO_INCLUDE
|
| 230 |
|
|
`else
|
| 231 |
|
|
`include "openGFX430_undefines.v"
|
| 232 |
|
|
`endif
|