| 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_reg.v
|
| 26 |
|
|
//
|
| 27 |
|
|
// *Module Description:
|
| 28 |
|
|
// Registers for oMSP programming.
|
| 29 |
|
|
//
|
| 30 |
|
|
// *Author(s):
|
| 31 |
|
|
// - Olivier Girard, olgirard@gmail.com
|
| 32 |
|
|
//
|
| 33 |
|
|
//----------------------------------------------------------------------------
|
| 34 |
|
|
// $Rev$
|
| 35 |
|
|
// $LastChangedBy$
|
| 36 |
|
|
// $LastChangedDate$
|
| 37 |
|
|
//----------------------------------------------------------------------------
|
| 38 |
|
|
`ifdef OGFX_NO_INCLUDE
|
| 39 |
|
|
`else
|
| 40 |
|
|
`include "openGFX430_defines.v"
|
| 41 |
|
|
`endif
|
| 42 |
|
|
|
| 43 |
|
|
module ogfx_reg (
|
| 44 |
|
|
|
| 45 |
|
|
// OUTPUTs
|
| 46 |
|
|
irq_gfx_o, // Graphic Controller interrupt
|
| 47 |
|
|
|
| 48 |
|
|
gpu_data_o, // GPU data
|
| 49 |
|
|
gpu_data_avail_o, // GPU data available
|
| 50 |
|
|
gpu_enable_o, // GPU enable
|
| 51 |
|
|
|
| 52 |
|
|
lt24_reset_n_o, // LT24 Reset (Active Low)
|
| 53 |
|
|
lt24_on_o, // LT24 on/off
|
| 54 |
|
|
lt24_cfg_clk_o, // LT24 Interface clock configuration
|
| 55 |
|
|
lt24_cfg_refr_o, // LT24 Interface refresh configuration
|
| 56 |
|
|
lt24_cfg_refr_sync_en_o, // LT24 Interface refresh sync enable configuration
|
| 57 |
|
|
lt24_cfg_refr_sync_val_o, // LT24 Interface refresh sync value configuration
|
| 58 |
|
|
lt24_cmd_refr_o, // LT24 Interface refresh command
|
| 59 |
|
|
lt24_cmd_val_o, // LT24 Generic command value
|
| 60 |
|
|
lt24_cmd_has_param_o, // LT24 Generic command has parameters
|
| 61 |
|
|
lt24_cmd_param_o, // LT24 Generic command parameter value
|
| 62 |
|
|
lt24_cmd_param_rdy_o, // LT24 Generic command trigger
|
| 63 |
|
|
lt24_cmd_dfill_o, // LT24 Data fill value
|
| 64 |
|
|
lt24_cmd_dfill_wr_o, // LT24 Data fill trigger
|
| 65 |
|
|
|
| 66 |
|
|
display_width_o, // Display width
|
| 67 |
|
|
display_height_o, // Display height
|
| 68 |
|
|
display_size_o, // Display size (number of pixels)
|
| 69 |
|
|
display_y_swap_o, // Display configuration: swap Y axis (horizontal symmetry)
|
| 70 |
|
|
display_x_swap_o, // Display configuration: swap X axis (vertical symmetry)
|
| 71 |
|
|
display_cl_swap_o, // Display configuration: swap column/lines
|
| 72 |
|
|
gfx_mode_o, // Video mode (1xx:16bpp / 011:8bpp / 010:4bpp / 001:2bpp / 000:1bpp)
|
| 73 |
|
|
|
| 74 |
|
|
per_dout_o, // Peripheral data output
|
| 75 |
|
|
|
| 76 |
|
|
refresh_frame_addr_o, // Refresh frame base address
|
| 77 |
|
|
refresh_lut_select_o, // Refresh LUT bank selection
|
| 78 |
|
|
|
| 79 |
|
|
`ifdef WITH_PROGRAMMABLE_LUT
|
| 80 |
|
|
lut_ram_addr_o, // LUT-RAM address
|
| 81 |
|
|
lut_ram_din_o, // LUT-RAM data
|
| 82 |
|
|
lut_ram_wen_o, // LUT-RAM write strobe (active low)
|
| 83 |
|
|
lut_ram_cen_o, // LUT-RAM chip enable (active low)
|
| 84 |
|
|
`endif
|
| 85 |
|
|
|
| 86 |
|
|
vid_ram_addr_o, // Video-RAM address
|
| 87 |
|
|
vid_ram_din_o, // Video-RAM data
|
| 88 |
|
|
vid_ram_wen_o, // Video-RAM write strobe (active low)
|
| 89 |
|
|
vid_ram_cen_o, // Video-RAM chip enable (active low)
|
| 90 |
|
|
|
| 91 |
|
|
// INPUTs
|
| 92 |
|
|
dbg_freeze_i, // Freeze address auto-incr on read
|
| 93 |
|
|
gpu_cmd_done_evt_i, // GPU command done event
|
| 94 |
|
|
gpu_cmd_error_evt_i, // GPU command error event
|
| 95 |
|
|
gpu_get_data_i, // GPU get next data
|
| 96 |
|
|
lt24_status_i, // LT24 FSM Status
|
| 97 |
|
|
lt24_start_evt_i, // LT24 FSM is starting
|
| 98 |
|
|
lt24_done_evt_i, // LT24 FSM is done
|
| 99 |
|
|
mclk, // Main system clock
|
| 100 |
|
|
per_addr_i, // Peripheral address
|
| 101 |
|
|
per_din_i, // Peripheral data input
|
| 102 |
|
|
per_en_i, // Peripheral enable (high active)
|
| 103 |
|
|
per_we_i, // Peripheral write enable (high active)
|
| 104 |
|
|
puc_rst, // Main system reset
|
| 105 |
|
|
`ifdef WITH_PROGRAMMABLE_LUT
|
| 106 |
|
|
lut_ram_dout_i, // LUT-RAM data input
|
| 107 |
|
|
`endif
|
| 108 |
|
|
vid_ram_dout_i // Video-RAM data input
|
| 109 |
|
|
);
|
| 110 |
|
|
|
| 111 |
|
|
// OUTPUTs
|
| 112 |
|
|
//=========
|
| 113 |
|
|
output irq_gfx_o; // Graphic Controller interrupt
|
| 114 |
|
|
|
| 115 |
|
|
output [15:0] gpu_data_o; // GPU data
|
| 116 |
|
|
output gpu_data_avail_o; // GPU data available
|
| 117 |
|
|
output gpu_enable_o; // GPU enable
|
| 118 |
|
|
|
| 119 |
|
|
output lt24_reset_n_o; // LT24 Reset (Active Low)
|
| 120 |
|
|
output lt24_on_o; // LT24 on/off
|
| 121 |
|
|
output [2:0] lt24_cfg_clk_o; // LT24 Interface clock configuration
|
| 122 |
|
|
output [11:0] lt24_cfg_refr_o; // LT24 Interface refresh configuration
|
| 123 |
|
|
output lt24_cfg_refr_sync_en_o; // LT24 Interface refresh sync configuration
|
| 124 |
|
|
output [9:0] lt24_cfg_refr_sync_val_o; // LT24 Interface refresh sync value configuration
|
| 125 |
|
|
output lt24_cmd_refr_o; // LT24 Interface refresh command
|
| 126 |
|
|
output [7:0] lt24_cmd_val_o; // LT24 Generic command value
|
| 127 |
|
|
output lt24_cmd_has_param_o; // LT24 Generic command has parameters
|
| 128 |
|
|
output [15:0] lt24_cmd_param_o; // LT24 Generic command parameter value
|
| 129 |
|
|
output lt24_cmd_param_rdy_o; // LT24 Generic command trigger
|
| 130 |
|
|
output [15:0] lt24_cmd_dfill_o; // LT24 Data fill value
|
| 131 |
|
|
output lt24_cmd_dfill_wr_o; // LT24 Data fill trigger
|
| 132 |
|
|
|
| 133 |
|
|
output [`LPIX_MSB:0] display_width_o; // Display width
|
| 134 |
|
|
output [`LPIX_MSB:0] display_height_o; // Display height
|
| 135 |
|
|
output [`SPIX_MSB:0] display_size_o; // Display size (number of pixels)
|
| 136 |
|
|
output display_y_swap_o; // Display configuration: swap Y axis (horizontal symmetry)
|
| 137 |
|
|
output display_x_swap_o; // Display configuration: swap X axis (vertical symmetry)
|
| 138 |
|
|
output display_cl_swap_o; // Display configuration: swap column/lines
|
| 139 |
|
|
output [2:0] gfx_mode_o; // Video mode (1xx:16bpp / 011:8bpp / 010:4bpp / 001:2bpp / 000:1bpp)
|
| 140 |
|
|
|
| 141 |
|
|
output [15:0] per_dout_o; // Peripheral data output
|
| 142 |
|
|
|
| 143 |
|
|
output [`APIX_MSB:0] refresh_frame_addr_o; // Refresh frame base address
|
| 144 |
|
|
output [1:0] refresh_lut_select_o; // Refresh LUT bank selection
|
| 145 |
|
|
|
| 146 |
|
|
`ifdef WITH_PROGRAMMABLE_LUT
|
| 147 |
|
|
output [`LRAM_MSB:0] lut_ram_addr_o; // LUT-RAM address
|
| 148 |
|
|
output [15:0] lut_ram_din_o; // LUT-RAM data
|
| 149 |
|
|
output lut_ram_wen_o; // LUT-RAM write strobe (active low)
|
| 150 |
|
|
output lut_ram_cen_o; // LUT-RAM chip enable (active low)
|
| 151 |
|
|
`endif
|
| 152 |
|
|
|
| 153 |
|
|
output [`VRAM_MSB:0] vid_ram_addr_o; // Video-RAM address
|
| 154 |
|
|
output [15:0] vid_ram_din_o; // Video-RAM data
|
| 155 |
|
|
output vid_ram_wen_o; // Video-RAM write strobe (active low)
|
| 156 |
|
|
output vid_ram_cen_o; // Video-RAM chip enable (active low)
|
| 157 |
|
|
|
| 158 |
|
|
// INPUTs
|
| 159 |
|
|
//=========
|
| 160 |
|
|
input dbg_freeze_i; // Freeze address auto-incr on read
|
| 161 |
|
|
input gpu_cmd_done_evt_i; // GPU command done event
|
| 162 |
|
|
input gpu_cmd_error_evt_i; // GPU command error event
|
| 163 |
|
|
input gpu_get_data_i; // GPU get next data
|
| 164 |
|
|
input [4:0] lt24_status_i; // LT24 FSM Status
|
| 165 |
|
|
input lt24_start_evt_i; // LT24 FSM is starting
|
| 166 |
|
|
input lt24_done_evt_i; // LT24 FSM is done
|
| 167 |
|
|
input mclk; // Main system clock
|
| 168 |
|
|
input [13:0] per_addr_i; // Peripheral address
|
| 169 |
|
|
input [15:0] per_din_i; // Peripheral data input
|
| 170 |
|
|
input per_en_i; // Peripheral enable (high active)
|
| 171 |
|
|
input [1:0] per_we_i; // Peripheral write enable (high active)
|
| 172 |
|
|
input puc_rst; // Main system reset
|
| 173 |
|
|
`ifdef WITH_PROGRAMMABLE_LUT
|
| 174 |
|
|
input [15:0] lut_ram_dout_i; // LUT-RAM data input
|
| 175 |
|
|
`endif
|
| 176 |
|
|
input [15:0] vid_ram_dout_i; // Video-RAM data input
|
| 177 |
|
|
|
| 178 |
|
|
|
| 179 |
|
|
//=============================================================================
|
| 180 |
|
|
// 1) PARAMETER DECLARATION
|
| 181 |
|
|
//=============================================================================
|
| 182 |
|
|
|
| 183 |
|
|
// Register base address (must be aligned to decoder bit width)
|
| 184 |
|
|
parameter [14:0] BASE_ADDR = 15'h0200;
|
| 185 |
|
|
|
| 186 |
|
|
// Decoder bit width (defines how many bits are considered for address decoding)
|
| 187 |
|
|
parameter DEC_WD = 7;
|
| 188 |
|
|
|
| 189 |
|
|
// Register addresses offset
|
| 190 |
|
|
parameter [DEC_WD-1:0] GFX_CTRL = 'h00, // General control/status/irq
|
| 191 |
|
|
GFX_STATUS = 'h08,
|
| 192 |
|
|
GFX_IRQ = 'h0A,
|
| 193 |
|
|
|
| 194 |
|
|
DISPLAY_WIDTH = 'h10, // Display configuration
|
| 195 |
|
|
DISPLAY_HEIGHT = 'h12,
|
| 196 |
|
|
DISPLAY_SIZE_HI = 'h14,
|
| 197 |
|
|
DISPLAY_SIZE_LO = 'h16,
|
| 198 |
|
|
DISPLAY_CFG = 'h18,
|
| 199 |
|
|
|
| 200 |
|
|
LT24_CFG = 'h20, // LT24 configuration and Generic command sending
|
| 201 |
|
|
LT24_REFRESH = 'h22,
|
| 202 |
|
|
LT24_REFRESH_SYNC = 'h24,
|
| 203 |
|
|
LT24_CMD = 'h26,
|
| 204 |
|
|
LT24_CMD_PARAM = 'h28,
|
| 205 |
|
|
LT24_CMD_DFILL = 'h2A,
|
| 206 |
|
|
LT24_STATUS = 'h2C,
|
| 207 |
|
|
|
| 208 |
|
|
LUT_RAM_ADDR = 'h30, // LUT Memory Access Gate
|
| 209 |
|
|
LUT_RAM_DATA = 'h32,
|
| 210 |
|
|
|
| 211 |
|
|
FRAME_SELECT = 'h3E, // Frame pointers and selection
|
| 212 |
|
|
FRAME0_PTR_HI = 'h40,
|
| 213 |
|
|
FRAME0_PTR_LO = 'h42,
|
| 214 |
|
|
FRAME1_PTR_HI = 'h44,
|
| 215 |
|
|
FRAME1_PTR_LO = 'h46,
|
| 216 |
|
|
FRAME2_PTR_HI = 'h48,
|
| 217 |
|
|
FRAME2_PTR_LO = 'h4A,
|
| 218 |
|
|
FRAME3_PTR_HI = 'h4C,
|
| 219 |
|
|
FRAME3_PTR_LO = 'h4E,
|
| 220 |
|
|
|
| 221 |
|
|
VID_RAM0_CFG = 'h50, // First Video Memory Access Gate
|
| 222 |
|
|
VID_RAM0_WIDTH = 'h52,
|
| 223 |
|
|
VID_RAM0_ADDR_HI = 'h54,
|
| 224 |
|
|
VID_RAM0_ADDR_LO = 'h56,
|
| 225 |
|
|
VID_RAM0_DATA = 'h58,
|
| 226 |
|
|
|
| 227 |
|
|
VID_RAM1_CFG = 'h60, // Second Video Memory Access Gate
|
| 228 |
|
|
VID_RAM1_WIDTH = 'h62,
|
| 229 |
|
|
VID_RAM1_ADDR_HI = 'h64,
|
| 230 |
|
|
VID_RAM1_ADDR_LO = 'h66,
|
| 231 |
|
|
VID_RAM1_DATA = 'h68,
|
| 232 |
|
|
|
| 233 |
|
|
GPU_CMD = 'h70, // Graphic Processing Unit
|
| 234 |
|
|
GPU_STAT = 'h72;
|
| 235 |
|
|
|
| 236 |
|
|
|
| 237 |
|
|
// Register one-hot decoder utilities
|
| 238 |
|
|
parameter DEC_SZ = (1 << DEC_WD);
|
| 239 |
|
|
parameter [DEC_SZ-1:0] BASE_REG = {{DEC_SZ-1{1'b0}}, 1'b1};
|
| 240 |
|
|
|
| 241 |
|
|
// Register one-hot decoder
|
| 242 |
|
|
parameter [DEC_SZ-1:0] GFX_CTRL_D = (BASE_REG << GFX_CTRL ),
|
| 243 |
|
|
GFX_STATUS_D = (BASE_REG << GFX_STATUS ),
|
| 244 |
|
|
GFX_IRQ_D = (BASE_REG << GFX_IRQ ),
|
| 245 |
|
|
|
| 246 |
|
|
DISPLAY_WIDTH_D = (BASE_REG << DISPLAY_WIDTH ),
|
| 247 |
|
|
DISPLAY_HEIGHT_D = (BASE_REG << DISPLAY_HEIGHT ),
|
| 248 |
|
|
DISPLAY_SIZE_HI_D = (BASE_REG << DISPLAY_SIZE_HI ),
|
| 249 |
|
|
DISPLAY_SIZE_LO_D = (BASE_REG << DISPLAY_SIZE_LO ),
|
| 250 |
|
|
DISPLAY_CFG_D = (BASE_REG << DISPLAY_CFG ),
|
| 251 |
|
|
|
| 252 |
|
|
LT24_CFG_D = (BASE_REG << LT24_CFG ),
|
| 253 |
|
|
LT24_REFRESH_D = (BASE_REG << LT24_REFRESH ),
|
| 254 |
|
|
LT24_REFRESH_SYNC_D = (BASE_REG << LT24_REFRESH_SYNC ),
|
| 255 |
|
|
LT24_CMD_D = (BASE_REG << LT24_CMD ),
|
| 256 |
|
|
LT24_CMD_PARAM_D = (BASE_REG << LT24_CMD_PARAM ),
|
| 257 |
|
|
LT24_CMD_DFILL_D = (BASE_REG << LT24_CMD_DFILL ),
|
| 258 |
|
|
LT24_STATUS_D = (BASE_REG << LT24_STATUS ),
|
| 259 |
|
|
|
| 260 |
|
|
LUT_RAM_ADDR_D = (BASE_REG << LUT_RAM_ADDR ),
|
| 261 |
|
|
LUT_RAM_DATA_D = (BASE_REG << LUT_RAM_DATA ),
|
| 262 |
|
|
|
| 263 |
|
|
FRAME_SELECT_D = (BASE_REG << FRAME_SELECT ),
|
| 264 |
|
|
FRAME0_PTR_HI_D = (BASE_REG << FRAME0_PTR_HI ),
|
| 265 |
|
|
FRAME0_PTR_LO_D = (BASE_REG << FRAME0_PTR_LO ),
|
| 266 |
|
|
FRAME1_PTR_HI_D = (BASE_REG << FRAME1_PTR_HI ),
|
| 267 |
|
|
FRAME1_PTR_LO_D = (BASE_REG << FRAME1_PTR_LO ),
|
| 268 |
|
|
FRAME2_PTR_HI_D = (BASE_REG << FRAME2_PTR_HI ),
|
| 269 |
|
|
FRAME2_PTR_LO_D = (BASE_REG << FRAME2_PTR_LO ),
|
| 270 |
|
|
FRAME3_PTR_HI_D = (BASE_REG << FRAME3_PTR_HI ),
|
| 271 |
|
|
FRAME3_PTR_LO_D = (BASE_REG << FRAME3_PTR_LO ),
|
| 272 |
|
|
|
| 273 |
|
|
VID_RAM0_CFG_D = (BASE_REG << VID_RAM0_CFG ),
|
| 274 |
|
|
VID_RAM0_WIDTH_D = (BASE_REG << VID_RAM0_WIDTH ),
|
| 275 |
|
|
VID_RAM0_ADDR_HI_D = (BASE_REG << VID_RAM0_ADDR_HI ),
|
| 276 |
|
|
VID_RAM0_ADDR_LO_D = (BASE_REG << VID_RAM0_ADDR_LO ),
|
| 277 |
|
|
VID_RAM0_DATA_D = (BASE_REG << VID_RAM0_DATA ),
|
| 278 |
|
|
|
| 279 |
|
|
VID_RAM1_CFG_D = (BASE_REG << VID_RAM1_CFG ),
|
| 280 |
|
|
VID_RAM1_WIDTH_D = (BASE_REG << VID_RAM1_WIDTH ),
|
| 281 |
|
|
VID_RAM1_ADDR_HI_D = (BASE_REG << VID_RAM1_ADDR_HI ),
|
| 282 |
|
|
VID_RAM1_ADDR_LO_D = (BASE_REG << VID_RAM1_ADDR_LO ),
|
| 283 |
|
|
VID_RAM1_DATA_D = (BASE_REG << VID_RAM1_DATA ),
|
| 284 |
|
|
|
| 285 |
|
|
GPU_CMD_D = (BASE_REG << GPU_CMD ),
|
| 286 |
|
|
GPU_STAT_D = (BASE_REG << GPU_STAT );
|
| 287 |
|
|
|
| 288 |
|
|
|
| 289 |
|
|
//============================================================================
|
| 290 |
|
|
// 2) REGISTER DECODER
|
| 291 |
|
|
//============================================================================
|
| 292 |
|
|
|
| 293 |
|
|
// Local register selection
|
| 294 |
|
|
wire reg_sel = per_en_i & (per_addr_i[13:DEC_WD-1]==BASE_ADDR[14:DEC_WD]);
|
| 295 |
|
|
|
| 296 |
|
|
// Register local address
|
| 297 |
|
|
wire [DEC_WD-1:0] reg_addr = {per_addr_i[DEC_WD-2:0], 1'b0};
|
| 298 |
|
|
|
| 299 |
|
|
// Register address decode
|
| 300 |
|
|
wire [DEC_SZ-1:0] reg_dec = (GFX_CTRL_D & {DEC_SZ{(reg_addr == GFX_CTRL )}}) |
|
| 301 |
|
|
(GFX_STATUS_D & {DEC_SZ{(reg_addr == GFX_STATUS )}}) |
|
| 302 |
|
|
(GFX_IRQ_D & {DEC_SZ{(reg_addr == GFX_IRQ )}}) |
|
| 303 |
|
|
|
| 304 |
|
|
(DISPLAY_WIDTH_D & {DEC_SZ{(reg_addr == DISPLAY_WIDTH )}}) |
|
| 305 |
|
|
(DISPLAY_HEIGHT_D & {DEC_SZ{(reg_addr == DISPLAY_HEIGHT )}}) |
|
| 306 |
|
|
(DISPLAY_SIZE_HI_D & {DEC_SZ{(reg_addr == DISPLAY_SIZE_HI )}}) |
|
| 307 |
|
|
(DISPLAY_SIZE_LO_D & {DEC_SZ{(reg_addr == DISPLAY_SIZE_LO )}}) |
|
| 308 |
|
|
(DISPLAY_CFG_D & {DEC_SZ{(reg_addr == DISPLAY_CFG )}}) |
|
| 309 |
|
|
|
| 310 |
|
|
(LT24_CFG_D & {DEC_SZ{(reg_addr == LT24_CFG )}}) |
|
| 311 |
|
|
(LT24_REFRESH_D & {DEC_SZ{(reg_addr == LT24_REFRESH )}}) |
|
| 312 |
|
|
(LT24_REFRESH_SYNC_D & {DEC_SZ{(reg_addr == LT24_REFRESH_SYNC )}}) |
|
| 313 |
|
|
(LT24_CMD_D & {DEC_SZ{(reg_addr == LT24_CMD )}}) |
|
| 314 |
|
|
(LT24_CMD_PARAM_D & {DEC_SZ{(reg_addr == LT24_CMD_PARAM )}}) |
|
| 315 |
|
|
(LT24_CMD_DFILL_D & {DEC_SZ{(reg_addr == LT24_CMD_DFILL )}}) |
|
| 316 |
|
|
(LT24_STATUS_D & {DEC_SZ{(reg_addr == LT24_STATUS )}}) |
|
| 317 |
|
|
|
| 318 |
|
|
(LUT_RAM_ADDR_D & {DEC_SZ{(reg_addr == LUT_RAM_ADDR )}}) |
|
| 319 |
|
|
(LUT_RAM_DATA_D & {DEC_SZ{(reg_addr == LUT_RAM_DATA )}}) |
|
| 320 |
|
|
|
| 321 |
|
|
(FRAME_SELECT_D & {DEC_SZ{(reg_addr == FRAME_SELECT )}}) |
|
| 322 |
|
|
(FRAME0_PTR_HI_D & {DEC_SZ{(reg_addr == FRAME0_PTR_HI )}}) |
|
| 323 |
|
|
(FRAME0_PTR_LO_D & {DEC_SZ{(reg_addr == FRAME0_PTR_LO )}}) |
|
| 324 |
|
|
(FRAME1_PTR_HI_D & {DEC_SZ{(reg_addr == FRAME1_PTR_HI )}}) |
|
| 325 |
|
|
(FRAME1_PTR_LO_D & {DEC_SZ{(reg_addr == FRAME1_PTR_LO )}}) |
|
| 326 |
|
|
(FRAME2_PTR_HI_D & {DEC_SZ{(reg_addr == FRAME2_PTR_HI )}}) |
|
| 327 |
|
|
(FRAME2_PTR_LO_D & {DEC_SZ{(reg_addr == FRAME2_PTR_LO )}}) |
|
| 328 |
|
|
(FRAME3_PTR_HI_D & {DEC_SZ{(reg_addr == FRAME3_PTR_HI )}}) |
|
| 329 |
|
|
(FRAME3_PTR_LO_D & {DEC_SZ{(reg_addr == FRAME3_PTR_LO )}}) |
|
| 330 |
|
|
|
| 331 |
|
|
(VID_RAM0_CFG_D & {DEC_SZ{(reg_addr == VID_RAM0_CFG )}}) |
|
| 332 |
|
|
(VID_RAM0_WIDTH_D & {DEC_SZ{(reg_addr == VID_RAM0_WIDTH )}}) |
|
| 333 |
|
|
(VID_RAM0_ADDR_HI_D & {DEC_SZ{(reg_addr == VID_RAM0_ADDR_HI )}}) |
|
| 334 |
|
|
(VID_RAM0_ADDR_LO_D & {DEC_SZ{(reg_addr == VID_RAM0_ADDR_LO )}}) |
|
| 335 |
|
|
(VID_RAM0_DATA_D & {DEC_SZ{(reg_addr == VID_RAM0_DATA )}}) |
|
| 336 |
|
|
|
| 337 |
|
|
(VID_RAM1_CFG_D & {DEC_SZ{(reg_addr == VID_RAM1_CFG )}}) |
|
| 338 |
|
|
(VID_RAM1_WIDTH_D & {DEC_SZ{(reg_addr == VID_RAM1_WIDTH )}}) |
|
| 339 |
|
|
(VID_RAM1_ADDR_HI_D & {DEC_SZ{(reg_addr == VID_RAM1_ADDR_HI )}}) |
|
| 340 |
|
|
(VID_RAM1_ADDR_LO_D & {DEC_SZ{(reg_addr == VID_RAM1_ADDR_LO )}}) |
|
| 341 |
|
|
(VID_RAM1_DATA_D & {DEC_SZ{(reg_addr == VID_RAM1_DATA )}}) |
|
| 342 |
|
|
|
| 343 |
|
|
(GPU_CMD_D & {DEC_SZ{(reg_addr == GPU_CMD )}}) |
|
| 344 |
|
|
(GPU_STAT_D & {DEC_SZ{(reg_addr == GPU_STAT )}});
|
| 345 |
|
|
|
| 346 |
|
|
// Read/Write probes
|
| 347 |
|
|
wire reg_write = |per_we_i & reg_sel;
|
| 348 |
|
|
wire reg_read = ~|per_we_i & reg_sel;
|
| 349 |
|
|
|
| 350 |
|
|
// Read/Write vectors
|
| 351 |
|
|
wire [DEC_SZ-1:0] reg_wr = reg_dec & {DEC_SZ{reg_write}};
|
| 352 |
|
|
wire [DEC_SZ-1:0] reg_rd = reg_dec & {DEC_SZ{reg_read}};
|
| 353 |
|
|
|
| 354 |
|
|
// Other wire declarations
|
| 355 |
|
|
wire [`APIX_MSB:0] frame0_ptr;
|
| 356 |
|
|
`ifdef WITH_FRAME1_POINTER
|
| 357 |
|
|
wire [`APIX_MSB:0] frame1_ptr;
|
| 358 |
|
|
`endif
|
| 359 |
|
|
`ifdef WITH_FRAME2_POINTER
|
| 360 |
|
|
wire [`APIX_MSB:0] frame2_ptr;
|
| 361 |
|
|
`endif
|
| 362 |
|
|
`ifdef WITH_FRAME3_POINTER
|
| 363 |
|
|
wire [`APIX_MSB:0] frame3_ptr;
|
| 364 |
|
|
`endif
|
| 365 |
|
|
wire [`APIX_MSB:0] vid_ram0_base_addr;
|
| 366 |
|
|
wire [`APIX_MSB:0] vid_ram1_base_addr;
|
| 367 |
|
|
`ifdef WITH_EXTRA_LUT_BANK
|
| 368 |
|
|
reg lut_bank_select;
|
| 369 |
|
|
`endif
|
| 370 |
|
|
reg vid_ram0_addr_lo_wr_dly;
|
| 371 |
|
|
reg vid_ram1_addr_lo_wr_dly;
|
| 372 |
|
|
wire gpu_fifo_done_evt;
|
| 373 |
|
|
wire gpu_fifo_ovfl_evt;
|
| 374 |
|
|
|
| 375 |
|
|
|
| 376 |
|
|
//============================================================================
|
| 377 |
|
|
// 3) REGISTERS
|
| 378 |
|
|
//============================================================================
|
| 379 |
|
|
|
| 380 |
|
|
//------------------------------------------------
|
| 381 |
|
|
// GFX_CTRL Register
|
| 382 |
|
|
//------------------------------------------------
|
| 383 |
|
|
reg [15:0] gfx_ctrl;
|
| 384 |
|
|
|
| 385 |
|
|
wire gfx_ctrl_wr = reg_wr[GFX_CTRL];
|
| 386 |
|
|
|
| 387 |
|
|
always @ (posedge mclk or posedge puc_rst)
|
| 388 |
|
|
if (puc_rst) gfx_ctrl <= 16'h0000;
|
| 389 |
|
|
else if (gfx_ctrl_wr) gfx_ctrl <= per_din_i;
|
| 390 |
|
|
|
| 391 |
|
|
// Bitfield assignments
|
| 392 |
|
|
wire gfx_irq_refr_done_en = gfx_ctrl[0];
|
| 393 |
|
|
wire gfx_irq_refr_start_en = gfx_ctrl[1];
|
| 394 |
|
|
wire gfx_irq_gpu_fifo_done_en = gfx_ctrl[4];
|
| 395 |
|
|
wire gfx_irq_gpu_fifo_ovfl_en = gfx_ctrl[5];
|
| 396 |
|
|
wire gfx_irq_gpu_cmd_done_en = gfx_ctrl[6];
|
| 397 |
|
|
wire gfx_irq_gpu_cmd_error_en = gfx_ctrl[7];
|
| 398 |
|
|
assign gfx_mode_o = gfx_ctrl[10:8]; // 1xx: 16 bits-per-pixel
|
| 399 |
|
|
// 011: 8 bits-per-pixel
|
| 400 |
|
|
// 010: 4 bits-per-pixel
|
| 401 |
|
|
// 001: 2 bits-per-pixel
|
| 402 |
|
|
// 000: 1 bits-per-pixel
|
| 403 |
|
|
wire gpu_enable_o = gfx_ctrl[12];
|
| 404 |
|
|
|
| 405 |
|
|
// Video modes decoding
|
| 406 |
|
|
wire gfx_mode_1_bpp = (gfx_mode_o == 3'b000);
|
| 407 |
|
|
wire gfx_mode_2_bpp = (gfx_mode_o == 3'b001);
|
| 408 |
|
|
wire gfx_mode_4_bpp = (gfx_mode_o == 3'b010);
|
| 409 |
|
|
wire gfx_mode_8_bpp = (gfx_mode_o == 3'b011);
|
| 410 |
|
|
wire gfx_mode_16_bpp = ~(gfx_mode_8_bpp | gfx_mode_4_bpp | gfx_mode_2_bpp | gfx_mode_1_bpp);
|
| 411 |
|
|
|
| 412 |
|
|
//------------------------------------------------
|
| 413 |
|
|
// GFX_STATUS Register
|
| 414 |
|
|
//------------------------------------------------
|
| 415 |
|
|
wire [15:0] gfx_status;
|
| 416 |
|
|
|
| 417 |
|
|
assign gfx_status[0] = lt24_status_i[2]; // Screen Refresh is busy
|
| 418 |
|
|
assign gfx_status[15:1] = 15'h0000;
|
| 419 |
|
|
|
| 420 |
|
|
//------------------------------------------------
|
| 421 |
|
|
// GFX_IRQ Register
|
| 422 |
|
|
//------------------------------------------------
|
| 423 |
|
|
wire [15:0] gfx_irq;
|
| 424 |
|
|
|
| 425 |
|
|
// Clear IRQ when 1 is written. Set IRQ when FSM is done
|
| 426 |
|
|
wire gfx_irq_refr_done_clr = per_din_i[0] & reg_wr[GFX_IRQ];
|
| 427 |
|
|
wire gfx_irq_refr_done_set = lt24_done_evt_i;
|
| 428 |
|
|
|
| 429 |
|
|
wire gfx_irq_refr_start_clr = per_din_i[1] & reg_wr[GFX_IRQ];
|
| 430 |
|
|
wire gfx_irq_refr_start_set = lt24_start_evt_i;
|
| 431 |
|
|
|
| 432 |
|
|
wire gfx_irq_gpu_fifo_done_clr = per_din_i[4] & reg_wr[GFX_IRQ];
|
| 433 |
|
|
wire gfx_irq_gpu_fifo_done_set = gpu_fifo_done_evt;
|
| 434 |
|
|
|
| 435 |
|
|
wire gfx_irq_gpu_fifo_ovfl_clr = per_din_i[5] & reg_wr[GFX_IRQ];
|
| 436 |
|
|
wire gfx_irq_gpu_fifo_ovfl_set = gpu_fifo_ovfl_evt;
|
| 437 |
|
|
|
| 438 |
|
|
wire gfx_irq_gpu_cmd_done_clr = per_din_i[6] & reg_wr[GFX_IRQ];
|
| 439 |
|
|
wire gfx_irq_gpu_cmd_done_set = gpu_cmd_done_evt_i;
|
| 440 |
|
|
|
| 441 |
|
|
wire gfx_irq_gpu_cmd_error_clr = per_din_i[7] & reg_wr[GFX_IRQ];
|
| 442 |
|
|
wire gfx_irq_gpu_cmd_error_set = gpu_cmd_error_evt_i;
|
| 443 |
|
|
|
| 444 |
|
|
reg gfx_irq_refr_done;
|
| 445 |
|
|
reg gfx_irq_refr_start;
|
| 446 |
|
|
reg gfx_irq_gpu_fifo_done;
|
| 447 |
|
|
reg gfx_irq_gpu_fifo_ovfl;
|
| 448 |
|
|
reg gfx_irq_gpu_cmd_done;
|
| 449 |
|
|
reg gfx_irq_gpu_cmd_error;
|
| 450 |
|
|
always @ (posedge mclk or posedge puc_rst)
|
| 451 |
|
|
if (puc_rst)
|
| 452 |
|
|
begin
|
| 453 |
|
|
gfx_irq_refr_done <= 1'b0;
|
| 454 |
|
|
gfx_irq_refr_start <= 1'b0;
|
| 455 |
|
|
gfx_irq_gpu_fifo_done <= 1'b0;
|
| 456 |
|
|
gfx_irq_gpu_fifo_ovfl <= 1'b0;
|
| 457 |
|
|
gfx_irq_gpu_cmd_done <= 1'b0;
|
| 458 |
|
|
gfx_irq_gpu_cmd_error <= 1'b0;
|
| 459 |
|
|
end
|
| 460 |
|
|
else
|
| 461 |
|
|
begin
|
| 462 |
|
|
gfx_irq_refr_done <= (gfx_irq_refr_done_set | (~gfx_irq_refr_done_clr & gfx_irq_refr_done )); // IRQ set has priority over clear
|
| 463 |
|
|
gfx_irq_refr_start <= (gfx_irq_refr_start_set | (~gfx_irq_refr_start_clr & gfx_irq_refr_start )); // IRQ set has priority over clear
|
| 464 |
|
|
gfx_irq_gpu_fifo_done <= (gfx_irq_gpu_fifo_done_set | (~gfx_irq_gpu_fifo_done_clr & gfx_irq_gpu_fifo_done)); // IRQ set has priority over clear
|
| 465 |
|
|
gfx_irq_gpu_fifo_ovfl <= (gfx_irq_gpu_fifo_ovfl_set | (~gfx_irq_gpu_fifo_ovfl_clr & gfx_irq_gpu_fifo_ovfl)); // IRQ set has priority over clear
|
| 466 |
|
|
gfx_irq_gpu_cmd_done <= (gfx_irq_gpu_cmd_done_set | (~gfx_irq_gpu_cmd_done_clr & gfx_irq_gpu_cmd_done )); // IRQ set has priority over clear
|
| 467 |
|
|
gfx_irq_gpu_cmd_error <= (gfx_irq_gpu_cmd_error_set | (~gfx_irq_gpu_cmd_error_clr & gfx_irq_gpu_cmd_error)); // IRQ set has priority over clear
|
| 468 |
|
|
end
|
| 469 |
|
|
|
| 470 |
|
|
assign gfx_irq = {8'h00,
|
| 471 |
|
|
gfx_irq_gpu_cmd_error, gfx_irq_gpu_cmd_done, gfx_irq_gpu_fifo_ovfl, gfx_irq_gpu_fifo_done,
|
| 472 |
|
|
2'h0, gfx_irq_refr_start, gfx_irq_refr_done};
|
| 473 |
|
|
|
| 474 |
|
|
assign irq_gfx_o = (gfx_irq_refr_done & gfx_irq_refr_done_en) |
|
| 475 |
|
|
(gfx_irq_refr_start & gfx_irq_refr_start_en) |
|
| 476 |
|
|
(gfx_irq_gpu_cmd_error & gfx_irq_gpu_cmd_error_en) |
|
| 477 |
|
|
(gfx_irq_gpu_cmd_done & gfx_irq_gpu_cmd_done_en) |
|
| 478 |
|
|
(gfx_irq_gpu_fifo_ovfl & gfx_irq_gpu_fifo_ovfl_en) |
|
| 479 |
|
|
(gfx_irq_gpu_fifo_done & gfx_irq_gpu_fifo_done_en); // Graphic Controller interrupt
|
| 480 |
|
|
|
| 481 |
|
|
//------------------------------------------------
|
| 482 |
|
|
// DISPLAY_WIDTH Register
|
| 483 |
|
|
//------------------------------------------------
|
| 484 |
|
|
reg [`LPIX_MSB:0] display_width_o;
|
| 485 |
|
|
|
| 486 |
|
|
wire display_width_wr = reg_wr[DISPLAY_WIDTH];
|
| 487 |
|
|
wire [`LPIX_MSB:0] display_w_h_nxt = (|per_din_i[`LPIX_MSB:0]) ? per_din_i[`LPIX_MSB:0] :
|
| 488 |
|
|
{{`LPIX_MSB{1'b0}}, 1'b1};
|
| 489 |
|
|
|
| 490 |
|
|
always @ (posedge mclk or posedge puc_rst)
|
| 491 |
|
|
if (puc_rst) display_width_o <= {{`LPIX_MSB{1'b0}}, 1'b1};
|
| 492 |
|
|
else if (display_width_wr) display_width_o <= display_w_h_nxt;
|
| 493 |
|
|
|
| 494 |
|
|
wire [16:0] display_width_tmp = {{16-`LPIX_MSB{1'b0}}, display_width_o};
|
| 495 |
|
|
wire [15:0] display_width_rd = display_width_tmp[15:0];
|
| 496 |
|
|
|
| 497 |
|
|
//------------------------------------------------
|
| 498 |
|
|
// DISPLAY_HEIGHT Register
|
| 499 |
|
|
//------------------------------------------------
|
| 500 |
|
|
reg [`LPIX_MSB:0] display_height_o;
|
| 501 |
|
|
|
| 502 |
|
|
wire display_height_wr = reg_wr[DISPLAY_HEIGHT];
|
| 503 |
|
|
|
| 504 |
|
|
always @ (posedge mclk or posedge puc_rst)
|
| 505 |
|
|
if (puc_rst) display_height_o <= {{`LPIX_MSB{1'b0}}, 1'b1};
|
| 506 |
|
|
else if (display_height_wr) display_height_o <= display_w_h_nxt;
|
| 507 |
|
|
|
| 508 |
|
|
wire [16:0] display_height_tmp = {{16-`LPIX_MSB{1'b0}}, display_height_o};
|
| 509 |
|
|
wire [15:0] display_height_rd = display_height_tmp[15:0];
|
| 510 |
|
|
|
| 511 |
|
|
//------------------------------------------------
|
| 512 |
|
|
// DISPLAY_SIZE_HI Register
|
| 513 |
|
|
//------------------------------------------------
|
| 514 |
|
|
`ifdef WITH_DISPLAY_SIZE_HI
|
| 515 |
|
|
reg [`SPIX_HI_MSB:0] display_size_hi;
|
| 516 |
|
|
|
| 517 |
|
|
wire display_size_hi_wr = reg_wr[DISPLAY_SIZE_HI];
|
| 518 |
|
|
|
| 519 |
|
|
always @ (posedge mclk or posedge puc_rst)
|
| 520 |
|
|
if (puc_rst) display_size_hi <= {`SPIX_HI_MSB+1{1'h0}};
|
| 521 |
|
|
else if (display_size_hi_wr) display_size_hi <= per_din_i[`SPIX_HI_MSB:0];
|
| 522 |
|
|
|
| 523 |
|
|
wire [16:0] display_size_hi_tmp = {{16-`SPIX_HI_MSB{1'h0}}, display_size_hi};
|
| 524 |
|
|
wire [15:0] display_size_hi_rd = display_size_hi_tmp[15:0];
|
| 525 |
|
|
`endif
|
| 526 |
|
|
|
| 527 |
|
|
//------------------------------------------------
|
| 528 |
|
|
// DISPLAY_SIZE_LO Register
|
| 529 |
|
|
//------------------------------------------------
|
| 530 |
|
|
reg [`SPIX_LO_MSB:0] display_size_lo;
|
| 531 |
|
|
|
| 532 |
|
|
wire display_size_lo_wr = reg_wr[DISPLAY_SIZE_LO];
|
| 533 |
|
|
|
| 534 |
|
|
always @ (posedge mclk or posedge puc_rst)
|
| 535 |
|
|
if (puc_rst) display_size_lo <= {{`SPIX_LO_MSB{1'h0}}, 1'b1};
|
| 536 |
|
|
else if (display_size_lo_wr) display_size_lo <= per_din_i[`SPIX_LO_MSB:0];
|
| 537 |
|
|
|
| 538 |
|
|
wire [16:0] display_size_lo_tmp = {{16-`SPIX_LO_MSB{1'h0}}, display_size_lo};
|
| 539 |
|
|
wire [15:0] display_size_lo_rd = display_size_lo_tmp[15:0];
|
| 540 |
|
|
|
| 541 |
|
|
`ifdef WITH_DISPLAY_SIZE_HI
|
| 542 |
|
|
assign display_size_o = {display_size_hi, display_size_lo};
|
| 543 |
|
|
`else
|
| 544 |
|
|
assign display_size_o = display_size_lo;
|
| 545 |
|
|
`endif
|
| 546 |
|
|
|
| 547 |
|
|
//------------------------------------------------
|
| 548 |
|
|
// DISPLAY_CFG Register
|
| 549 |
|
|
//------------------------------------------------
|
| 550 |
|
|
reg display_x_swap_o;
|
| 551 |
|
|
reg display_y_swap_o;
|
| 552 |
|
|
reg display_cl_swap_o;
|
| 553 |
|
|
|
| 554 |
|
|
wire display_cfg_wr = reg_wr[DISPLAY_CFG];
|
| 555 |
|
|
|
| 556 |
|
|
always @ (posedge mclk or posedge puc_rst)
|
| 557 |
|
|
if (puc_rst)
|
| 558 |
|
|
begin
|
| 559 |
|
|
display_cl_swap_o <= 1'b0;
|
| 560 |
|
|
display_y_swap_o <= 1'b0;
|
| 561 |
|
|
display_x_swap_o <= 1'b0;
|
| 562 |
|
|
end
|
| 563 |
|
|
else if (display_cfg_wr)
|
| 564 |
|
|
begin
|
| 565 |
|
|
display_cl_swap_o <= per_din_i[0];
|
| 566 |
|
|
display_y_swap_o <= per_din_i[1];
|
| 567 |
|
|
display_x_swap_o <= per_din_i[2];
|
| 568 |
|
|
end
|
| 569 |
|
|
|
| 570 |
|
|
wire [15:0] display_cfg = {13'h0000,
|
| 571 |
|
|
display_x_swap_o,
|
| 572 |
|
|
display_y_swap_o,
|
| 573 |
|
|
display_cl_swap_o};
|
| 574 |
|
|
|
| 575 |
|
|
//------------------------------------------------
|
| 576 |
|
|
// LT24_CFG Register
|
| 577 |
|
|
//------------------------------------------------
|
| 578 |
|
|
reg [15:0] lt24_cfg;
|
| 579 |
|
|
|
| 580 |
|
|
wire lt24_cfg_wr = reg_wr[LT24_CFG];
|
| 581 |
|
|
|
| 582 |
|
|
always @ (posedge mclk or posedge puc_rst)
|
| 583 |
|
|
if (puc_rst) lt24_cfg <= 16'h0000;
|
| 584 |
|
|
else if (lt24_cfg_wr) lt24_cfg <= per_din_i;
|
| 585 |
|
|
|
| 586 |
|
|
// Bitfield assignments
|
| 587 |
|
|
assign lt24_cfg_clk_o = lt24_cfg[6:4];
|
| 588 |
|
|
assign lt24_reset_n_o = ~lt24_cfg[1];
|
| 589 |
|
|
assign lt24_on_o = lt24_cfg[0];
|
| 590 |
|
|
|
| 591 |
|
|
//------------------------------------------------
|
| 592 |
|
|
// LT24_REFRESH Register
|
| 593 |
|
|
//------------------------------------------------
|
| 594 |
|
|
reg lt24_cmd_refr_o;
|
| 595 |
|
|
reg [11:0] lt24_cfg_refr_o;
|
| 596 |
|
|
|
| 597 |
|
|
wire lt24_refresh_wr = reg_wr[LT24_REFRESH];
|
| 598 |
|
|
wire lt24_cmd_refr_clr = lt24_done_evt_i & lt24_status_i[2] & (lt24_cfg_refr_o==8'h00); // Auto-clear in manual refresh mode when done
|
| 599 |
|
|
|
| 600 |
|
|
always @ (posedge mclk or posedge puc_rst)
|
| 601 |
|
|
if (puc_rst) lt24_cmd_refr_o <= 1'h0;
|
| 602 |
|
|
else if (lt24_refresh_wr) lt24_cmd_refr_o <= per_din_i[0];
|
| 603 |
|
|
else if (lt24_cmd_refr_clr) lt24_cmd_refr_o <= 1'h0;
|
| 604 |
|
|
|
| 605 |
|
|
always @ (posedge mclk or posedge puc_rst)
|
| 606 |
|
|
if (puc_rst) lt24_cfg_refr_o <= 12'h000;
|
| 607 |
|
|
else if (lt24_refresh_wr) lt24_cfg_refr_o <= per_din_i[15:4];
|
| 608 |
|
|
|
| 609 |
|
|
wire [15:0] lt24_refresh = {lt24_cfg_refr_o, 3'h0, lt24_cmd_refr_o};
|
| 610 |
|
|
|
| 611 |
|
|
//------------------------------------------------
|
| 612 |
|
|
// LT24_REFRESH Register
|
| 613 |
|
|
//------------------------------------------------
|
| 614 |
|
|
reg lt24_cfg_refr_sync_en_o;
|
| 615 |
|
|
reg [9:0] lt24_cfg_refr_sync_val_o;
|
| 616 |
|
|
|
| 617 |
|
|
wire lt24_refresh_sync_wr = reg_wr[LT24_REFRESH_SYNC];
|
| 618 |
|
|
|
| 619 |
|
|
always @ (posedge mclk or posedge puc_rst)
|
| 620 |
|
|
if (puc_rst) lt24_cfg_refr_sync_en_o <= 1'h0;
|
| 621 |
|
|
else if (lt24_refresh_sync_wr) lt24_cfg_refr_sync_en_o <= per_din_i[15];
|
| 622 |
|
|
|
| 623 |
|
|
always @ (posedge mclk or posedge puc_rst)
|
| 624 |
|
|
if (puc_rst) lt24_cfg_refr_sync_val_o <= 10'h000;
|
| 625 |
|
|
else if (lt24_refresh_sync_wr) lt24_cfg_refr_sync_val_o <= per_din_i[9:0];
|
| 626 |
|
|
|
| 627 |
|
|
wire [15:0] lt24_refresh_sync = {lt24_cfg_refr_sync_en_o, 5'h00, lt24_cfg_refr_sync_val_o};
|
| 628 |
|
|
|
| 629 |
|
|
|
| 630 |
|
|
//------------------------------------------------
|
| 631 |
|
|
// LT24_CMD Register
|
| 632 |
|
|
//------------------------------------------------
|
| 633 |
|
|
reg [15:0] lt24_cmd;
|
| 634 |
|
|
|
| 635 |
|
|
wire lt24_cmd_wr = reg_wr[LT24_CMD];
|
| 636 |
|
|
|
| 637 |
|
|
always @ (posedge mclk or posedge puc_rst)
|
| 638 |
|
|
if (puc_rst) lt24_cmd <= 16'h0000;
|
| 639 |
|
|
else if (lt24_cmd_wr) lt24_cmd <= per_din_i;
|
| 640 |
|
|
|
| 641 |
|
|
assign lt24_cmd_val_o = lt24_cmd[7:0];
|
| 642 |
|
|
assign lt24_cmd_has_param_o = lt24_cmd[8];
|
| 643 |
|
|
|
| 644 |
|
|
//------------------------------------------------
|
| 645 |
|
|
// LT24_CMD_PARAM Register
|
| 646 |
|
|
//------------------------------------------------
|
| 647 |
|
|
reg [15:0] lt24_cmd_param_o;
|
| 648 |
|
|
|
| 649 |
|
|
wire lt24_cmd_param_wr = reg_wr[LT24_CMD_PARAM];
|
| 650 |
|
|
|
| 651 |
|
|
always @ (posedge mclk or posedge puc_rst)
|
| 652 |
|
|
if (puc_rst) lt24_cmd_param_o <= 16'h0000;
|
| 653 |
|
|
else if (lt24_cmd_param_wr) lt24_cmd_param_o <= per_din_i;
|
| 654 |
|
|
|
| 655 |
|
|
reg lt24_cmd_param_rdy_o;
|
| 656 |
|
|
always @ (posedge mclk or posedge puc_rst)
|
| 657 |
|
|
if (puc_rst) lt24_cmd_param_rdy_o <= 1'b0;
|
| 658 |
|
|
else lt24_cmd_param_rdy_o <= lt24_cmd_param_wr;
|
| 659 |
|
|
|
| 660 |
|
|
//------------------------------------------------
|
| 661 |
|
|
// LT24_CMD_DFILL Register
|
| 662 |
|
|
//------------------------------------------------
|
| 663 |
|
|
reg [15:0] lt24_cmd_dfill_o;
|
| 664 |
|
|
|
| 665 |
|
|
assign lt24_cmd_dfill_wr_o = reg_wr[LT24_CMD_DFILL];
|
| 666 |
|
|
|
| 667 |
|
|
always @ (posedge mclk or posedge puc_rst)
|
| 668 |
|
|
if (puc_rst) lt24_cmd_dfill_o <= 16'h0000;
|
| 669 |
|
|
else if (lt24_cmd_dfill_wr_o) lt24_cmd_dfill_o <= per_din_i;
|
| 670 |
|
|
|
| 671 |
|
|
//------------------------------------------------
|
| 672 |
|
|
// LT24_STATUS Register
|
| 673 |
|
|
//------------------------------------------------
|
| 674 |
|
|
wire [15:0] lt24_status;
|
| 675 |
|
|
|
| 676 |
|
|
assign lt24_status[0] = lt24_status_i[0]; // FSM_BUSY
|
| 677 |
|
|
assign lt24_status[1] = lt24_status_i[1]; // WAIT_PARAM
|
| 678 |
|
|
assign lt24_status[2] = lt24_status_i[2]; // REFRESH_BUSY
|
| 679 |
|
|
assign lt24_status[3] = lt24_status_i[3]; // WAIT_FOR_SCANLINE
|
| 680 |
|
|
assign lt24_status[4] = lt24_status_i[4]; // DATA_FILL_BUSY
|
| 681 |
|
|
assign lt24_status[15:5] = 11'h000;
|
| 682 |
|
|
|
| 683 |
|
|
|
| 684 |
|
|
//------------------------------------------------
|
| 685 |
|
|
// LUT_RAM_ADDR Register
|
| 686 |
|
|
//------------------------------------------------
|
| 687 |
|
|
`ifdef WITH_PROGRAMMABLE_LUT
|
| 688 |
|
|
|
| 689 |
|
|
reg [7:0] lut_ram_addr;
|
| 690 |
|
|
wire [7:0] lut_ram_addr_inc;
|
| 691 |
|
|
wire lut_ram_addr_inc_wr;
|
| 692 |
|
|
|
| 693 |
|
|
wire lut_ram_addr_wr = reg_wr[LUT_RAM_ADDR];
|
| 694 |
|
|
|
| 695 |
|
|
always @ (posedge mclk or posedge puc_rst)
|
| 696 |
|
|
if (puc_rst) lut_ram_addr <= 8'h00;
|
| 697 |
|
|
else if (lut_ram_addr_wr) lut_ram_addr <= per_din_i[7:0];
|
| 698 |
|
|
else if (lut_ram_addr_inc_wr) lut_ram_addr <= lut_ram_addr_inc;
|
| 699 |
|
|
|
| 700 |
|
|
assign lut_ram_addr_inc = lut_ram_addr + 8'h01;
|
| 701 |
|
|
wire [15:0] lut_ram_addr_rd = {8'h00, lut_ram_addr};
|
| 702 |
|
|
|
| 703 |
|
|
`ifdef WITH_EXTRA_LUT_BANK
|
| 704 |
|
|
assign lut_ram_addr_o = {lut_bank_select, lut_ram_addr};
|
| 705 |
|
|
`else
|
| 706 |
|
|
assign lut_ram_addr_o = lut_ram_addr;
|
| 707 |
|
|
`endif
|
| 708 |
|
|
|
| 709 |
|
|
`else
|
| 710 |
|
|
wire [15:0] lut_ram_addr_rd = 16'h0000;
|
| 711 |
|
|
`endif
|
| 712 |
|
|
|
| 713 |
|
|
//------------------------------------------------
|
| 714 |
|
|
// LUT_RAM_DATA Register
|
| 715 |
|
|
//------------------------------------------------
|
| 716 |
|
|
`ifdef WITH_PROGRAMMABLE_LUT
|
| 717 |
|
|
|
| 718 |
|
|
// Update the LUT_RAM_DATA register with regular register write access
|
| 719 |
|
|
wire lut_ram_data_wr = reg_wr[LUT_RAM_DATA];
|
| 720 |
|
|
wire lut_ram_data_rd = reg_rd[LUT_RAM_DATA];
|
| 721 |
|
|
reg lut_ram_dout_rdy;
|
| 722 |
|
|
|
| 723 |
|
|
// LUT-RAM data Register
|
| 724 |
|
|
reg [15:0] lut_ram_data;
|
| 725 |
|
|
always @ (posedge mclk or posedge puc_rst)
|
| 726 |
|
|
if (puc_rst) lut_ram_data <= 16'h0000;
|
| 727 |
|
|
else if (lut_ram_data_wr) lut_ram_data <= per_din_i;
|
| 728 |
|
|
else if (lut_ram_dout_rdy) lut_ram_data <= lut_ram_dout_i;
|
| 729 |
|
|
|
| 730 |
|
|
// Increment the address after a write or read access to the LUT_RAM_DATA register
|
| 731 |
|
|
assign lut_ram_addr_inc_wr = lut_ram_data_wr | lut_ram_data_rd;
|
| 732 |
|
|
|
| 733 |
|
|
// Apply peripheral data bus % write strobe during VID_RAMx_DATA write access
|
| 734 |
|
|
assign lut_ram_din_o = per_din_i & {16{lut_ram_data_wr}};
|
| 735 |
|
|
assign lut_ram_wen_o = ~(|per_we_i & lut_ram_data_wr);
|
| 736 |
|
|
|
| 737 |
|
|
// Trigger a LUT-RAM read access immediately after:
|
| 738 |
|
|
// - a LUT-RAM_ADDR register write access
|
| 739 |
|
|
// - a LUT-RAM_DATA register read access
|
| 740 |
|
|
reg lut_ram_addr_wr_dly;
|
| 741 |
|
|
always @ (posedge mclk or posedge puc_rst)
|
| 742 |
|
|
if (puc_rst) lut_ram_addr_wr_dly <= 1'b0;
|
| 743 |
|
|
else lut_ram_addr_wr_dly <= lut_ram_addr_wr;
|
| 744 |
|
|
|
| 745 |
|
|
reg lut_ram_data_rd_dly;
|
| 746 |
|
|
always @ (posedge mclk or posedge puc_rst)
|
| 747 |
|
|
if (puc_rst) lut_ram_data_rd_dly <= 1'b0;
|
| 748 |
|
|
else lut_ram_data_rd_dly <= lut_ram_data_rd;
|
| 749 |
|
|
|
| 750 |
|
|
// Chip enable.
|
| 751 |
|
|
// Note: we perform a data read access:
|
| 752 |
|
|
// - one cycle after a VID_RAM_DATA register read access (so that the address has been incremented)
|
| 753 |
|
|
// - one cycle after a VID_RAM_ADDR register write
|
| 754 |
|
|
assign lut_ram_cen_o = ~(lut_ram_addr_wr_dly | lut_ram_data_rd_dly | // Read access
|
| 755 |
|
|
lut_ram_data_wr); // Write access
|
| 756 |
|
|
|
| 757 |
|
|
// Update the VRAM_DATA register one cycle after each memory access
|
| 758 |
|
|
always @ (posedge mclk or posedge puc_rst)
|
| 759 |
|
|
if (puc_rst) lut_ram_dout_rdy <= 1'b0;
|
| 760 |
|
|
else lut_ram_dout_rdy <= ~lut_ram_cen_o;
|
| 761 |
|
|
|
| 762 |
|
|
`else
|
| 763 |
|
|
wire [15:0] lut_ram_data = 16'h0000;
|
| 764 |
|
|
`endif
|
| 765 |
|
|
|
| 766 |
|
|
//------------------------------------------------
|
| 767 |
|
|
// FRAME_SELECT Register
|
| 768 |
|
|
//------------------------------------------------
|
| 769 |
|
|
|
| 770 |
|
|
wire frame_select_wr = reg_wr[FRAME_SELECT];
|
| 771 |
|
|
|
| 772 |
|
|
`ifdef WITH_PROGRAMMABLE_LUT
|
| 773 |
|
|
reg refresh_sw_lut_enable;
|
| 774 |
|
|
|
| 775 |
|
|
always @ (posedge mclk or posedge puc_rst)
|
| 776 |
|
|
if (puc_rst) refresh_sw_lut_enable <= 1'b0;
|
| 777 |
|
|
else if (frame_select_wr) refresh_sw_lut_enable <= per_din_i[2];
|
| 778 |
|
|
`else
|
| 779 |
|
|
wire refresh_sw_lut_enable = 1'b0;
|
| 780 |
|
|
`endif
|
| 781 |
|
|
|
| 782 |
|
|
`ifdef WITH_EXTRA_LUT_BANK
|
| 783 |
|
|
reg refresh_sw_lut_select;
|
| 784 |
|
|
|
| 785 |
|
|
always @ (posedge mclk or posedge puc_rst)
|
| 786 |
|
|
if (puc_rst)
|
| 787 |
|
|
begin
|
| 788 |
|
|
refresh_sw_lut_select <= 1'b0;
|
| 789 |
|
|
lut_bank_select <= 1'b0;
|
| 790 |
|
|
end
|
| 791 |
|
|
else if (frame_select_wr)
|
| 792 |
|
|
begin
|
| 793 |
|
|
refresh_sw_lut_select <= per_din_i[3];
|
| 794 |
|
|
lut_bank_select <= per_din_i[15];
|
| 795 |
|
|
end
|
| 796 |
|
|
`else
|
| 797 |
|
|
assign refresh_sw_lut_select = 1'b0;
|
| 798 |
|
|
wire lut_bank_select = 1'b0;
|
| 799 |
|
|
`endif
|
| 800 |
|
|
wire [1:0] refresh_lut_select_o = {refresh_sw_lut_select, refresh_sw_lut_enable};
|
| 801 |
|
|
|
| 802 |
|
|
`ifdef WITH_FRAME1_POINTER
|
| 803 |
|
|
`ifdef WITH_FRAME2_POINTER
|
| 804 |
|
|
reg [1:0] refresh_frame_select;
|
| 805 |
|
|
reg [1:0] vid_ram0_frame_select;
|
| 806 |
|
|
reg [1:0] vid_ram1_frame_select;
|
| 807 |
|
|
|
| 808 |
|
|
always @ (posedge mclk or posedge puc_rst)
|
| 809 |
|
|
if (puc_rst)
|
| 810 |
|
|
begin
|
| 811 |
|
|
refresh_frame_select <= 2'h0;
|
| 812 |
|
|
vid_ram0_frame_select <= 2'h0;
|
| 813 |
|
|
vid_ram1_frame_select <= 2'h0;
|
| 814 |
|
|
end
|
| 815 |
|
|
else if (frame_select_wr)
|
| 816 |
|
|
begin
|
| 817 |
|
|
refresh_frame_select <= per_din_i[1:0];
|
| 818 |
|
|
vid_ram0_frame_select <= per_din_i[5:4];
|
| 819 |
|
|
vid_ram1_frame_select <= per_din_i[7:6];
|
| 820 |
|
|
end
|
| 821 |
|
|
|
| 822 |
|
|
wire [15:0] frame_select = {lut_bank_select, 7'h00, vid_ram1_frame_select, vid_ram0_frame_select, refresh_lut_select_o, refresh_frame_select};
|
| 823 |
|
|
`else
|
| 824 |
|
|
reg refresh_frame_select;
|
| 825 |
|
|
reg vid_ram0_frame_select;
|
| 826 |
|
|
reg vid_ram1_frame_select;
|
| 827 |
|
|
|
| 828 |
|
|
always @ (posedge mclk or posedge puc_rst)
|
| 829 |
|
|
if (puc_rst)
|
| 830 |
|
|
begin
|
| 831 |
|
|
refresh_frame_select <= 1'h0;
|
| 832 |
|
|
vid_ram0_frame_select <= 1'h0;
|
| 833 |
|
|
vid_ram1_frame_select <= 1'h0;
|
| 834 |
|
|
end
|
| 835 |
|
|
else if (frame_select_wr)
|
| 836 |
|
|
begin
|
| 837 |
|
|
refresh_frame_select <= per_din_i[0];
|
| 838 |
|
|
vid_ram0_frame_select <= per_din_i[4];
|
| 839 |
|
|
vid_ram1_frame_select <= per_din_i[6];
|
| 840 |
|
|
end
|
| 841 |
|
|
|
| 842 |
|
|
wire [15:0] frame_select = {lut_bank_select, 7'h00, 1'h0, vid_ram1_frame_select, 1'h0, vid_ram0_frame_select, refresh_lut_select_o, 1'h0, refresh_frame_select};
|
| 843 |
|
|
`endif
|
| 844 |
|
|
`else
|
| 845 |
|
|
wire [15:0] frame_select = {lut_bank_select, 11'h000, refresh_lut_select_o, 2'h0};
|
| 846 |
|
|
`endif
|
| 847 |
|
|
|
| 848 |
|
|
// Frame pointer selections
|
| 849 |
|
|
`ifdef WITH_FRAME1_POINTER
|
| 850 |
|
|
assign refresh_frame_addr_o = (refresh_frame_select==0) ? frame0_ptr :
|
| 851 |
|
|
`ifdef WITH_FRAME2_POINTER
|
| 852 |
|
|
(refresh_frame_select==1) ? frame1_ptr :
|
| 853 |
|
|
`ifdef WITH_FRAME3_POINTER
|
| 854 |
|
|
(refresh_frame_select==2) ? frame2_ptr :
|
| 855 |
|
|
frame3_ptr ;
|
| 856 |
|
|
`else
|
| 857 |
|
|
frame2_ptr ;
|
| 858 |
|
|
`endif
|
| 859 |
|
|
`else
|
| 860 |
|
|
frame1_ptr ;
|
| 861 |
|
|
`endif
|
| 862 |
|
|
|
| 863 |
|
|
assign vid_ram0_base_addr = (vid_ram0_frame_select==0) ? frame0_ptr :
|
| 864 |
|
|
`ifdef WITH_FRAME2_POINTER
|
| 865 |
|
|
(vid_ram0_frame_select==1) ? frame1_ptr :
|
| 866 |
|
|
`ifdef WITH_FRAME3_POINTER
|
| 867 |
|
|
(vid_ram0_frame_select==2) ? frame2_ptr :
|
| 868 |
|
|
frame3_ptr ;
|
| 869 |
|
|
`else
|
| 870 |
|
|
frame2_ptr ;
|
| 871 |
|
|
`endif
|
| 872 |
|
|
`else
|
| 873 |
|
|
frame1_ptr ;
|
| 874 |
|
|
`endif
|
| 875 |
|
|
|
| 876 |
|
|
assign vid_ram1_base_addr = (vid_ram1_frame_select==0) ? frame0_ptr :
|
| 877 |
|
|
`ifdef WITH_FRAME2_POINTER
|
| 878 |
|
|
(vid_ram1_frame_select==1) ? frame1_ptr :
|
| 879 |
|
|
`ifdef WITH_FRAME3_POINTER
|
| 880 |
|
|
(vid_ram1_frame_select==2) ? frame2_ptr :
|
| 881 |
|
|
frame3_ptr ;
|
| 882 |
|
|
`else
|
| 883 |
|
|
frame2_ptr ;
|
| 884 |
|
|
`endif
|
| 885 |
|
|
`else
|
| 886 |
|
|
frame1_ptr ;
|
| 887 |
|
|
`endif
|
| 888 |
|
|
|
| 889 |
|
|
`else
|
| 890 |
|
|
assign refresh_frame_addr_o = frame0_ptr;
|
| 891 |
|
|
assign vid_ram0_base_addr = frame0_ptr;
|
| 892 |
|
|
assign vid_ram1_base_addr = frame0_ptr;
|
| 893 |
|
|
`endif
|
| 894 |
|
|
|
| 895 |
|
|
//------------------------------------------------
|
| 896 |
|
|
// FRAME0_PTR_HI Register
|
| 897 |
|
|
//------------------------------------------------
|
| 898 |
|
|
`ifdef VRAM_BIGGER_4_KW
|
| 899 |
|
|
reg [`APIX_HI_MSB:0] frame0_ptr_hi;
|
| 900 |
|
|
|
| 901 |
|
|
wire frame0_ptr_hi_wr = reg_wr[FRAME0_PTR_HI];
|
| 902 |
|
|
|
| 903 |
|
|
always @ (posedge mclk or posedge puc_rst)
|
| 904 |
|
|
if (puc_rst) frame0_ptr_hi <= {`APIX_HI_MSB+1{1'b0}};
|
| 905 |
|
|
else if (frame0_ptr_hi_wr) frame0_ptr_hi <= per_din_i[`APIX_HI_MSB:0];
|
| 906 |
|
|
|
| 907 |
|
|
wire [16:0] frame0_ptr_hi_tmp = {{16-`APIX_HI_MSB{1'b0}}, frame0_ptr_hi};
|
| 908 |
|
|
wire [15:0] frame0_ptr_hi_rd = frame0_ptr_hi_tmp[15:0];
|
| 909 |
|
|
`endif
|
| 910 |
|
|
|
| 911 |
|
|
//------------------------------------------------
|
| 912 |
|
|
// FRAME0_PTR_LO Register
|
| 913 |
|
|
//------------------------------------------------
|
| 914 |
|
|
reg [`APIX_LO_MSB:0] frame0_ptr_lo;
|
| 915 |
|
|
|
| 916 |
|
|
wire frame0_ptr_lo_wr = reg_wr[FRAME0_PTR_LO];
|
| 917 |
|
|
|
| 918 |
|
|
always @ (posedge mclk or posedge puc_rst)
|
| 919 |
|
|
if (puc_rst) frame0_ptr_lo <= {`APIX_LO_MSB+1{1'b0}};
|
| 920 |
|
|
else if (frame0_ptr_lo_wr) frame0_ptr_lo <= per_din_i[`APIX_LO_MSB:0];
|
| 921 |
|
|
|
| 922 |
|
|
`ifdef VRAM_BIGGER_4_KW
|
| 923 |
|
|
assign frame0_ptr = {frame0_ptr_hi[`APIX_HI_MSB:0], frame0_ptr_lo};
|
| 924 |
|
|
wire [15:0] frame0_ptr_lo_rd = frame0_ptr_lo;
|
| 925 |
|
|
`else
|
| 926 |
|
|
assign frame0_ptr = {frame0_ptr_lo[`APIX_LO_MSB:0]};
|
| 927 |
|
|
wire [16:0] frame0_ptr_lo_tmp = {{16-`APIX_LO_MSB{1'b0}}, frame0_ptr_lo};
|
| 928 |
|
|
wire [15:0] frame0_ptr_lo_rd = frame0_ptr_lo_tmp[15:0];
|
| 929 |
|
|
`endif
|
| 930 |
|
|
|
| 931 |
|
|
//------------------------------------------------
|
| 932 |
|
|
// FRAME1_PTR_HI Register
|
| 933 |
|
|
//------------------------------------------------
|
| 934 |
|
|
`ifdef WITH_FRAME1_POINTER
|
| 935 |
|
|
`ifdef VRAM_BIGGER_4_KW
|
| 936 |
|
|
reg [`APIX_HI_MSB:0] frame1_ptr_hi;
|
| 937 |
|
|
|
| 938 |
|
|
wire frame1_ptr_hi_wr = reg_wr[FRAME1_PTR_HI];
|
| 939 |
|
|
|
| 940 |
|
|
always @ (posedge mclk or posedge puc_rst)
|
| 941 |
|
|
if (puc_rst) frame1_ptr_hi <= {`APIX_HI_MSB+1{1'b0}};
|
| 942 |
|
|
else if (frame1_ptr_hi_wr) frame1_ptr_hi <= per_din_i[`APIX_HI_MSB:0];
|
| 943 |
|
|
|
| 944 |
|
|
wire [16:0] frame1_ptr_hi_tmp = {{16-`APIX_HI_MSB{1'b0}}, frame1_ptr_hi};
|
| 945 |
|
|
wire [15:0] frame1_ptr_hi_rd = frame1_ptr_hi_tmp[15:0];
|
| 946 |
|
|
`endif
|
| 947 |
|
|
`endif
|
| 948 |
|
|
|
| 949 |
|
|
//------------------------------------------------
|
| 950 |
|
|
// FRAME1_PTR_LO Register
|
| 951 |
|
|
//------------------------------------------------
|
| 952 |
|
|
`ifdef WITH_FRAME1_POINTER
|
| 953 |
|
|
reg [`APIX_LO_MSB:0] frame1_ptr_lo;
|
| 954 |
|
|
|
| 955 |
|
|
wire frame1_ptr_lo_wr = reg_wr[FRAME1_PTR_LO];
|
| 956 |
|
|
|
| 957 |
|
|
always @ (posedge mclk or posedge puc_rst)
|
| 958 |
|
|
if (puc_rst) frame1_ptr_lo <= {`APIX_LO_MSB+1{1'b0}};
|
| 959 |
|
|
else if (frame1_ptr_lo_wr) frame1_ptr_lo <= per_din_i[`APIX_LO_MSB:0];
|
| 960 |
|
|
|
| 961 |
|
|
`ifdef VRAM_BIGGER_4_KW
|
| 962 |
|
|
assign frame1_ptr = {frame1_ptr_hi[`APIX_HI_MSB:0], frame1_ptr_lo};
|
| 963 |
|
|
wire [15:0] frame1_ptr_lo_rd = frame1_ptr_lo;
|
| 964 |
|
|
`else
|
| 965 |
|
|
assign frame1_ptr = {frame1_ptr_lo[`APIX_LO_MSB:0]};
|
| 966 |
|
|
wire [16:0] frame1_ptr_lo_tmp = {{16-`APIX_LO_MSB{1'b0}}, frame1_ptr_lo};
|
| 967 |
|
|
wire [15:0] frame1_ptr_lo_rd = frame1_ptr_lo_tmp[15:0];
|
| 968 |
|
|
`endif
|
| 969 |
|
|
`endif
|
| 970 |
|
|
|
| 971 |
|
|
//------------------------------------------------
|
| 972 |
|
|
// FRAME2_PTR_HI Register
|
| 973 |
|
|
//------------------------------------------------
|
| 974 |
|
|
`ifdef WITH_FRAME2_POINTER
|
| 975 |
|
|
`ifdef VRAM_BIGGER_4_KW
|
| 976 |
|
|
reg [`APIX_HI_MSB:0] frame2_ptr_hi;
|
| 977 |
|
|
|
| 978 |
|
|
wire frame2_ptr_hi_wr = reg_wr[FRAME2_PTR_HI];
|
| 979 |
|
|
|
| 980 |
|
|
always @ (posedge mclk or posedge puc_rst)
|
| 981 |
|
|
if (puc_rst) frame2_ptr_hi <= {`APIX_HI_MSB+1{1'b0}};
|
| 982 |
|
|
else if (frame2_ptr_hi_wr) frame2_ptr_hi <= per_din_i[`APIX_HI_MSB:0];
|
| 983 |
|
|
|
| 984 |
|
|
wire [16:0] frame2_ptr_hi_tmp = {{16-`APIX_HI_MSB{1'b0}}, frame2_ptr_hi};
|
| 985 |
|
|
wire [15:0] frame2_ptr_hi_rd = frame2_ptr_hi_tmp[15:0];
|
| 986 |
|
|
`endif
|
| 987 |
|
|
`endif
|
| 988 |
|
|
|
| 989 |
|
|
//------------------------------------------------
|
| 990 |
|
|
// FRAME2_PTR_LO Register
|
| 991 |
|
|
//------------------------------------------------
|
| 992 |
|
|
`ifdef WITH_FRAME2_POINTER
|
| 993 |
|
|
reg [`APIX_LO_MSB:0] frame2_ptr_lo;
|
| 994 |
|
|
|
| 995 |
|
|
wire frame2_ptr_lo_wr = reg_wr[FRAME2_PTR_LO];
|
| 996 |
|
|
|
| 997 |
|
|
always @ (posedge mclk or posedge puc_rst)
|
| 998 |
|
|
if (puc_rst) frame2_ptr_lo <= {`APIX_LO_MSB+1{1'b0}};
|
| 999 |
|
|
else if (frame2_ptr_lo_wr) frame2_ptr_lo <= per_din_i[`APIX_LO_MSB:0];
|
| 1000 |
|
|
|
| 1001 |
|
|
`ifdef VRAM_BIGGER_4_KW
|
| 1002 |
|
|
assign frame2_ptr = {frame2_ptr_hi[`APIX_HI_MSB:0], frame2_ptr_lo};
|
| 1003 |
|
|
wire [15:0] frame2_ptr_lo_rd = frame2_ptr_lo;
|
| 1004 |
|
|
`else
|
| 1005 |
|
|
assign frame2_ptr = {frame2_ptr_lo[`APIX_LO_MSB:0]};
|
| 1006 |
|
|
wire [16:0] frame2_ptr_lo_tmp = {{16-`APIX_LO_MSB{1'b0}}, frame2_ptr_lo};
|
| 1007 |
|
|
wire [15:0] frame2_ptr_lo_rd = frame2_ptr_lo_tmp[15:0];
|
| 1008 |
|
|
`endif
|
| 1009 |
|
|
`endif
|
| 1010 |
|
|
|
| 1011 |
|
|
//------------------------------------------------
|
| 1012 |
|
|
// FRAME3_PTR_HI Register
|
| 1013 |
|
|
//------------------------------------------------
|
| 1014 |
|
|
`ifdef WITH_FRAME3_POINTER
|
| 1015 |
|
|
`ifdef VRAM_BIGGER_4_KW
|
| 1016 |
|
|
reg [`APIX_HI_MSB:0] frame3_ptr_hi;
|
| 1017 |
|
|
|
| 1018 |
|
|
wire frame3_ptr_hi_wr = reg_wr[FRAME3_PTR_HI];
|
| 1019 |
|
|
|
| 1020 |
|
|
always @ (posedge mclk or posedge puc_rst)
|
| 1021 |
|
|
if (puc_rst) frame3_ptr_hi <= {`APIX_HI_MSB+1{1'b0}};
|
| 1022 |
|
|
else if (frame3_ptr_hi_wr) frame3_ptr_hi <= per_din_i[`APIX_HI_MSB:0];
|
| 1023 |
|
|
|
| 1024 |
|
|
wire [16:0] frame3_ptr_hi_tmp = {{16-`APIX_HI_MSB{1'b0}},frame3_ptr_hi};
|
| 1025 |
|
|
wire [15:0] frame3_ptr_hi_rd = frame3_ptr_hi_tmp[15:0];
|
| 1026 |
|
|
`endif
|
| 1027 |
|
|
`endif
|
| 1028 |
|
|
|
| 1029 |
|
|
//------------------------------------------------
|
| 1030 |
|
|
// FRAME3_PTR_LO Register
|
| 1031 |
|
|
//------------------------------------------------
|
| 1032 |
|
|
`ifdef WITH_FRAME3_POINTER
|
| 1033 |
|
|
reg [`APIX_LO_MSB:0] frame3_ptr_lo;
|
| 1034 |
|
|
|
| 1035 |
|
|
wire frame3_ptr_lo_wr = reg_wr[FRAME3_PTR_LO];
|
| 1036 |
|
|
|
| 1037 |
|
|
always @ (posedge mclk or posedge puc_rst)
|
| 1038 |
|
|
if (puc_rst) frame3_ptr_lo <= {`APIX_LO_MSB+1{1'b0}};
|
| 1039 |
|
|
else if (frame3_ptr_lo_wr) frame3_ptr_lo <= per_din_i[`APIX_LO_MSB:0];
|
| 1040 |
|
|
|
| 1041 |
|
|
`ifdef VRAM_BIGGER_4_KW
|
| 1042 |
|
|
assign frame3_ptr = {frame3_ptr_hi[`APIX_HI_MSB:0], frame3_ptr_lo};
|
| 1043 |
|
|
wire [15:0] frame3_ptr_lo_rd = frame3_ptr_lo;
|
| 1044 |
|
|
`else
|
| 1045 |
|
|
assign frame3_ptr = {frame3_ptr_lo[`APIX_LO_MSB:0]};
|
| 1046 |
|
|
wire [16:0] frame3_ptr_lo_tmp = {{16-`APIX_LO_MSB{1'b0}}, frame3_ptr_lo};
|
| 1047 |
|
|
wire [15:0] frame3_ptr_lo_rd = frame3_ptr_lo_tmp[15:0];
|
| 1048 |
|
|
`endif
|
| 1049 |
|
|
`endif
|
| 1050 |
|
|
|
| 1051 |
|
|
//------------------------------------------------
|
| 1052 |
|
|
// VID_RAM0 Interface
|
| 1053 |
|
|
//------------------------------------------------
|
| 1054 |
|
|
wire [15:0] vid_ram0_cfg;
|
| 1055 |
|
|
wire [15:0] vid_ram0_width;
|
| 1056 |
|
|
`ifdef VRAM_BIGGER_4_KW
|
| 1057 |
|
|
wire [15:0] vid_ram0_addr_hi;
|
| 1058 |
|
|
`endif
|
| 1059 |
|
|
wire [15:0] vid_ram0_addr_lo;
|
| 1060 |
|
|
wire [15:0] vid_ram0_data;
|
| 1061 |
|
|
|
| 1062 |
|
|
wire vid_ram0_we;
|
| 1063 |
|
|
wire vid_ram0_ce;
|
| 1064 |
|
|
wire [15:0] vid_ram0_din;
|
| 1065 |
|
|
wire [`APIX_MSB:0] vid_ram0_addr_nxt;
|
| 1066 |
|
|
wire vid_ram0_access;
|
| 1067 |
|
|
|
| 1068 |
|
|
ogfx_reg_vram_if ogfx_reg_vram0_if_inst (
|
| 1069 |
|
|
|
| 1070 |
|
|
// OUTPUTs
|
| 1071 |
|
|
.vid_ram_cfg_o ( vid_ram0_cfg ), // VID_RAM0_CFG Register
|
| 1072 |
|
|
.vid_ram_width_o ( vid_ram0_width ), // VID_RAM0_WIDTH Register
|
| 1073 |
|
|
`ifdef VRAM_BIGGER_4_KW
|
| 1074 |
|
|
.vid_ram_addr_hi_o ( vid_ram0_addr_hi ), // VID_RAM0_ADDR_HI Register
|
| 1075 |
|
|
`endif
|
| 1076 |
|
|
.vid_ram_addr_lo_o ( vid_ram0_addr_lo ), // VID_RAM0_ADDR_LO Register
|
| 1077 |
|
|
.vid_ram_data_o ( vid_ram0_data ), // VID_RAM0_DATA Register
|
| 1078 |
|
|
|
| 1079 |
|
|
.vid_ram_we_o ( vid_ram0_we ), // Video-RAM Write strobe
|
| 1080 |
|
|
.vid_ram_ce_o ( vid_ram0_ce ), // Video-RAM Chip enable
|
| 1081 |
|
|
.vid_ram_din_o ( vid_ram0_din ), // Video-RAM Data input
|
| 1082 |
|
|
.vid_ram_addr_nxt_o ( vid_ram0_addr_nxt ), // Video-RAM Next address
|
| 1083 |
|
|
.vid_ram_access_o ( vid_ram0_access ), // Video-RAM Access
|
| 1084 |
|
|
|
| 1085 |
|
|
// INPUTs
|
| 1086 |
|
|
.mclk ( mclk ), // Main system clock
|
| 1087 |
|
|
.puc_rst ( puc_rst ), // Main system reset
|
| 1088 |
|
|
|
| 1089 |
|
|
.vid_ram_cfg_wr_i ( reg_wr[VID_RAM0_CFG] ), // VID_RAM0_CFG Write strobe
|
| 1090 |
|
|
.vid_ram_width_wr_i ( reg_wr[VID_RAM0_WIDTH] ), // VID_RAM0_WIDTH Write strobe
|
| 1091 |
|
|
`ifdef VRAM_BIGGER_4_KW
|
| 1092 |
|
|
.vid_ram_addr_hi_wr_i ( reg_wr[VID_RAM0_ADDR_HI] ), // VID_RAM0_ADDR_HI Write strobe
|
| 1093 |
|
|
`endif
|
| 1094 |
|
|
.vid_ram_addr_lo_wr_i ( reg_wr[VID_RAM0_ADDR_LO] ), // VID_RAM0_ADDR_LO Write strobe
|
| 1095 |
|
|
.vid_ram_data_wr_i ( reg_wr[VID_RAM0_DATA] ), // VID_RAM0_DATA Write strobe
|
| 1096 |
|
|
.vid_ram_data_rd_i ( reg_rd[VID_RAM0_DATA] ), // VID_RAM0_DATA Read strobe
|
| 1097 |
|
|
|
| 1098 |
|
|
.dbg_freeze_i ( dbg_freeze_i ), // Freeze auto-increment on read when CPU stopped
|
| 1099 |
|
|
.display_width_i ( display_width_o ), // Display width
|
| 1100 |
|
|
.gfx_mode_1_bpp_i ( gfx_mode_1_bpp ), // Graphic mode 1 bpp resolution
|
| 1101 |
|
|
.gfx_mode_2_bpp_i ( gfx_mode_2_bpp ), // Graphic mode 2 bpp resolution
|
| 1102 |
|
|
.gfx_mode_4_bpp_i ( gfx_mode_4_bpp ), // Graphic mode 4 bpp resolution
|
| 1103 |
|
|
.gfx_mode_8_bpp_i ( gfx_mode_8_bpp ), // Graphic mode 8 bpp resolution
|
| 1104 |
|
|
.gfx_mode_16_bpp_i ( gfx_mode_16_bpp ), // Graphic mode 16 bpp resolution
|
| 1105 |
|
|
|
| 1106 |
|
|
.per_din_i ( per_din_i ), // Peripheral data input
|
| 1107 |
|
|
.vid_ram_base_addr_i ( vid_ram0_base_addr ), // Video-RAM base address
|
| 1108 |
|
|
.vid_ram_dout_i ( vid_ram_dout_i ) // Video-RAM data input
|
| 1109 |
|
|
);
|
| 1110 |
|
|
|
| 1111 |
|
|
//------------------------------------------------
|
| 1112 |
|
|
// VID_RAM1 Interface
|
| 1113 |
|
|
//------------------------------------------------
|
| 1114 |
|
|
wire [15:0] vid_ram1_cfg;
|
| 1115 |
|
|
wire [15:0] vid_ram1_width;
|
| 1116 |
|
|
`ifdef VRAM_BIGGER_4_KW
|
| 1117 |
|
|
wire [15:0] vid_ram1_addr_hi;
|
| 1118 |
|
|
`endif
|
| 1119 |
|
|
wire [15:0] vid_ram1_addr_lo;
|
| 1120 |
|
|
wire [15:0] vid_ram1_data;
|
| 1121 |
|
|
|
| 1122 |
|
|
wire vid_ram1_we;
|
| 1123 |
|
|
wire vid_ram1_ce;
|
| 1124 |
|
|
wire [15:0] vid_ram1_din;
|
| 1125 |
|
|
wire [`APIX_MSB:0] vid_ram1_addr_nxt;
|
| 1126 |
|
|
wire vid_ram1_access;
|
| 1127 |
|
|
|
| 1128 |
|
|
ogfx_reg_vram_if ogfx_reg_vram1_if_inst (
|
| 1129 |
|
|
|
| 1130 |
|
|
// OUTPUTs
|
| 1131 |
|
|
.vid_ram_cfg_o ( vid_ram1_cfg ), // VID_RAM1_CFG Register
|
| 1132 |
|
|
.vid_ram_width_o ( vid_ram1_width ), // VID_RAM1_WIDTH Register
|
| 1133 |
|
|
`ifdef VRAM_BIGGER_4_KW
|
| 1134 |
|
|
.vid_ram_addr_hi_o ( vid_ram1_addr_hi ), // VID_RAM1_ADDR_HI Register
|
| 1135 |
|
|
`endif
|
| 1136 |
|
|
.vid_ram_addr_lo_o ( vid_ram1_addr_lo ), // VID_RAM1_ADDR_LO Register
|
| 1137 |
|
|
.vid_ram_data_o ( vid_ram1_data ), // VID_RAM1_DATA Register
|
| 1138 |
|
|
|
| 1139 |
|
|
.vid_ram_we_o ( vid_ram1_we ), // Video-RAM Write strobe
|
| 1140 |
|
|
.vid_ram_ce_o ( vid_ram1_ce ), // Video-RAM Chip enable
|
| 1141 |
|
|
.vid_ram_din_o ( vid_ram1_din ), // Video-RAM Data input
|
| 1142 |
|
|
.vid_ram_addr_nxt_o ( vid_ram1_addr_nxt ), // Video-RAM Next address
|
| 1143 |
|
|
.vid_ram_access_o ( vid_ram1_access ), // Video-RAM Access
|
| 1144 |
|
|
|
| 1145 |
|
|
// INPUTs
|
| 1146 |
|
|
.mclk ( mclk ), // Main system clock
|
| 1147 |
|
|
.puc_rst ( puc_rst ), // Main system reset
|
| 1148 |
|
|
|
| 1149 |
|
|
.vid_ram_cfg_wr_i ( reg_wr[VID_RAM1_CFG] ), // VID_RAM1_CFG Write strobe
|
| 1150 |
|
|
.vid_ram_width_wr_i ( reg_wr[VID_RAM1_WIDTH] ), // VID_RAM1_WIDTH Write strobe
|
| 1151 |
|
|
`ifdef VRAM_BIGGER_4_KW
|
| 1152 |
|
|
.vid_ram_addr_hi_wr_i ( reg_wr[VID_RAM1_ADDR_HI] ), // VID_RAM1_ADDR_HI Write strobe
|
| 1153 |
|
|
`endif
|
| 1154 |
|
|
.vid_ram_addr_lo_wr_i ( reg_wr[VID_RAM1_ADDR_LO] ), // VID_RAM1_ADDR_LO Write strobe
|
| 1155 |
|
|
.vid_ram_data_wr_i ( reg_wr[VID_RAM1_DATA] ), // VID_RAM1_DATA Write strobe
|
| 1156 |
|
|
.vid_ram_data_rd_i ( reg_rd[VID_RAM1_DATA] ), // VID_RAM1_DATA Read strobe
|
| 1157 |
|
|
|
| 1158 |
|
|
.dbg_freeze_i ( dbg_freeze_i ), // Freeze auto-increment on read when CPU stopped
|
| 1159 |
|
|
.display_width_i ( display_width_o ), // Display width
|
| 1160 |
|
|
.gfx_mode_1_bpp_i ( gfx_mode_1_bpp ), // Graphic mode 1 bpp resolution
|
| 1161 |
|
|
.gfx_mode_2_bpp_i ( gfx_mode_2_bpp ), // Graphic mode 2 bpp resolution
|
| 1162 |
|
|
.gfx_mode_4_bpp_i ( gfx_mode_4_bpp ), // Graphic mode 4 bpp resolution
|
| 1163 |
|
|
.gfx_mode_8_bpp_i ( gfx_mode_8_bpp ), // Graphic mode 8 bpp resolution
|
| 1164 |
|
|
.gfx_mode_16_bpp_i ( gfx_mode_16_bpp ), // Graphic mode 16 bpp resolution
|
| 1165 |
|
|
|
| 1166 |
|
|
.per_din_i ( per_din_i ), // Peripheral data input
|
| 1167 |
|
|
.vid_ram_base_addr_i ( vid_ram1_base_addr ), // Video-RAM base address
|
| 1168 |
|
|
.vid_ram_dout_i ( vid_ram_dout_i ) // Video-RAM data input
|
| 1169 |
|
|
);
|
| 1170 |
|
|
|
| 1171 |
|
|
//------------------------------------------------
|
| 1172 |
|
|
// GPU Interface (GPU_CMD/GPU_STAT) Registers
|
| 1173 |
|
|
//------------------------------------------------
|
| 1174 |
|
|
|
| 1175 |
|
|
wire [3:0] gpu_stat_fifo_cnt;
|
| 1176 |
|
|
wire gpu_stat_fifo_empty;
|
| 1177 |
|
|
wire gpu_stat_fifo_full;
|
| 1178 |
|
|
|
| 1179 |
|
|
ogfx_reg_fifo ogfx_reg_fifo_gpu_inst (
|
| 1180 |
|
|
|
| 1181 |
|
|
// OUTPUTs
|
| 1182 |
|
|
.fifo_cnt_o ( gpu_stat_fifo_cnt ), // Fifo counter
|
| 1183 |
|
|
.fifo_data_o ( gpu_data_o ), // Read data output
|
| 1184 |
|
|
.fifo_done_evt_o ( gpu_fifo_done_evt ), // Fifo has been emptied
|
| 1185 |
|
|
.fifo_empty_o ( gpu_stat_fifo_empty ), // Fifo is currentely empty
|
| 1186 |
|
|
.fifo_full_o ( gpu_stat_fifo_full ), // Fifo is currentely full
|
| 1187 |
|
|
.fifo_ovfl_evt_o ( gpu_fifo_ovfl_evt ), // Fifo overflow event
|
| 1188 |
|
|
|
| 1189 |
|
|
// INPUTs
|
| 1190 |
|
|
.mclk ( mclk ), // Main system clock
|
| 1191 |
|
|
.puc_rst ( puc_rst ), // Main system reset
|
| 1192 |
|
|
|
| 1193 |
|
|
.fifo_data_i ( per_din_i ), // Read data input
|
| 1194 |
|
|
.fifo_enable_i ( gpu_enable_o ), // Enable fifo (flushed when disabled)
|
| 1195 |
|
|
.fifo_pop_i ( gpu_get_data_i ), // Pop data from the fifo
|
| 1196 |
|
|
.fifo_push_i ( reg_wr[GPU_CMD] ) // Push new data to the fifo
|
| 1197 |
|
|
);
|
| 1198 |
|
|
|
| 1199 |
|
|
assign gpu_data_avail_o = ~gpu_stat_fifo_empty;
|
| 1200 |
|
|
|
| 1201 |
|
|
wire [15:0] gpu_stat = {10'h000, gpu_stat_fifo_full, gpu_stat_fifo_empty, gpu_stat_fifo_cnt};
|
| 1202 |
|
|
|
| 1203 |
|
|
|
| 1204 |
|
|
//============================================================================
|
| 1205 |
|
|
// 4) DATA OUTPUT GENERATION
|
| 1206 |
|
|
//============================================================================
|
| 1207 |
|
|
|
| 1208 |
|
|
// Data output mux
|
| 1209 |
|
|
wire [15:0] gfx_ctrl_read = gfx_ctrl & {16{reg_rd[GFX_CTRL ]}};
|
| 1210 |
|
|
wire [15:0] gfx_status_read = gfx_status & {16{reg_rd[GFX_STATUS ]}};
|
| 1211 |
|
|
wire [15:0] gfx_irq_read = gfx_irq & {16{reg_rd[GFX_IRQ ]}};
|
| 1212 |
|
|
|
| 1213 |
|
|
wire [15:0] display_width_read = display_width_rd & {16{reg_rd[DISPLAY_WIDTH ]}};
|
| 1214 |
|
|
wire [15:0] display_height_read = display_height_rd & {16{reg_rd[DISPLAY_HEIGHT ]}};
|
| 1215 |
|
|
`ifdef WITH_DISPLAY_SIZE_HI
|
| 1216 |
|
|
wire [15:0] display_size_hi_read = display_size_hi_rd & {16{reg_rd[DISPLAY_SIZE_HI ]}};
|
| 1217 |
|
|
`endif
|
| 1218 |
|
|
wire [15:0] display_size_lo_read = display_size_lo_rd & {16{reg_rd[DISPLAY_SIZE_LO ]}};
|
| 1219 |
|
|
wire [15:0] display_cfg_read = display_cfg & {16{reg_rd[DISPLAY_CFG ]}};
|
| 1220 |
|
|
|
| 1221 |
|
|
wire [15:0] lt24_cfg_read = lt24_cfg & {16{reg_rd[LT24_CFG ]}};
|
| 1222 |
|
|
wire [15:0] lt24_refresh_read = lt24_refresh & {16{reg_rd[LT24_REFRESH ]}};
|
| 1223 |
|
|
wire [15:0] lt24_refresh_sync_read = lt24_refresh_sync & {16{reg_rd[LT24_REFRESH_SYNC ]}};
|
| 1224 |
|
|
wire [15:0] lt24_cmd_read = lt24_cmd & {16{reg_rd[LT24_CMD ]}};
|
| 1225 |
|
|
wire [15:0] lt24_cmd_param_read = lt24_cmd_param_o & {16{reg_rd[LT24_CMD_PARAM ]}};
|
| 1226 |
|
|
wire [15:0] lt24_cmd_dfill_read = lt24_cmd_dfill_o & {16{reg_rd[LT24_CMD_DFILL ]}};
|
| 1227 |
|
|
wire [15:0] lt24_status_read = lt24_status & {16{reg_rd[LT24_STATUS ]}};
|
| 1228 |
|
|
|
| 1229 |
|
|
wire [15:0] lut_ram_addr_read = lut_ram_addr_rd & {16{reg_rd[LUT_RAM_ADDR ]}};
|
| 1230 |
|
|
wire [15:0] lut_ram_data_read = lut_ram_data & {16{reg_rd[LUT_RAM_DATA ]}};
|
| 1231 |
|
|
|
| 1232 |
|
|
wire [15:0] frame_select_read = frame_select & {16{reg_rd[FRAME_SELECT ]}};
|
| 1233 |
|
|
`ifdef VRAM_BIGGER_4_KW
|
| 1234 |
|
|
wire [15:0] frame0_ptr_hi_read = frame0_ptr_hi_rd & {16{reg_rd[FRAME0_PTR_HI ]}};
|
| 1235 |
|
|
`endif
|
| 1236 |
|
|
wire [15:0] frame0_ptr_lo_read = frame0_ptr_lo_rd & {16{reg_rd[FRAME0_PTR_LO ]}};
|
| 1237 |
|
|
`ifdef WITH_FRAME1_POINTER
|
| 1238 |
|
|
`ifdef VRAM_BIGGER_4_KW
|
| 1239 |
|
|
wire [15:0] frame1_ptr_hi_read = frame1_ptr_hi_rd & {16{reg_rd[FRAME1_PTR_HI ]}};
|
| 1240 |
|
|
`endif
|
| 1241 |
|
|
wire [15:0] frame1_ptr_lo_read = frame1_ptr_lo_rd & {16{reg_rd[FRAME1_PTR_LO ]}};
|
| 1242 |
|
|
`endif
|
| 1243 |
|
|
`ifdef WITH_FRAME2_POINTER
|
| 1244 |
|
|
`ifdef VRAM_BIGGER_4_KW
|
| 1245 |
|
|
wire [15:0] frame2_ptr_hi_read = frame2_ptr_hi_rd & {16{reg_rd[FRAME2_PTR_HI ]}};
|
| 1246 |
|
|
`endif
|
| 1247 |
|
|
wire [15:0] frame2_ptr_lo_read = frame2_ptr_lo_rd & {16{reg_rd[FRAME2_PTR_LO ]}};
|
| 1248 |
|
|
`endif
|
| 1249 |
|
|
`ifdef WITH_FRAME3_POINTER
|
| 1250 |
|
|
`ifdef VRAM_BIGGER_4_KW
|
| 1251 |
|
|
wire [15:0] frame3_ptr_hi_read = frame3_ptr_hi_rd & {16{reg_rd[FRAME3_PTR_HI ]}};
|
| 1252 |
|
|
`endif
|
| 1253 |
|
|
wire [15:0] frame3_ptr_lo_read = frame3_ptr_lo_rd & {16{reg_rd[FRAME3_PTR_LO ]}};
|
| 1254 |
|
|
`endif
|
| 1255 |
|
|
wire [15:0] vid_ram0_cfg_read = vid_ram0_cfg & {16{reg_rd[VID_RAM0_CFG ]}};
|
| 1256 |
|
|
wire [15:0] vid_ram0_width_read = vid_ram0_width & {16{reg_rd[VID_RAM0_WIDTH ]}};
|
| 1257 |
|
|
`ifdef VRAM_BIGGER_4_KW
|
| 1258 |
|
|
wire [15:0] vid_ram0_addr_hi_read = vid_ram0_addr_hi & {16{reg_rd[VID_RAM0_ADDR_HI ]}};
|
| 1259 |
|
|
`endif
|
| 1260 |
|
|
wire [15:0] vid_ram0_addr_lo_read = vid_ram0_addr_lo & {16{reg_rd[VID_RAM0_ADDR_LO ]}};
|
| 1261 |
|
|
wire [15:0] vid_ram0_data_read = vid_ram0_data & {16{reg_rd[VID_RAM0_DATA ]}};
|
| 1262 |
|
|
|
| 1263 |
|
|
wire [15:0] vid_ram1_cfg_read = vid_ram1_cfg & {16{reg_rd[VID_RAM1_CFG ]}};
|
| 1264 |
|
|
wire [15:0] vid_ram1_width_read = vid_ram1_width & {16{reg_rd[VID_RAM1_WIDTH ]}};
|
| 1265 |
|
|
`ifdef VRAM_BIGGER_4_KW
|
| 1266 |
|
|
wire [15:0] vid_ram1_addr_hi_read = vid_ram1_addr_hi & {16{reg_rd[VID_RAM1_ADDR_HI ]}};
|
| 1267 |
|
|
`endif
|
| 1268 |
|
|
wire [15:0] vid_ram1_addr_lo_read = vid_ram1_addr_lo & {16{reg_rd[VID_RAM1_ADDR_LO ]}};
|
| 1269 |
|
|
wire [15:0] vid_ram1_data_read = vid_ram1_data & {16{reg_rd[VID_RAM1_DATA ]}};
|
| 1270 |
|
|
wire [15:0] gpu_cmd_read = 16'h0000 & {16{reg_rd[GPU_CMD ]}};
|
| 1271 |
|
|
wire [15:0] gpu_stat_read = gpu_stat & {16{reg_rd[GPU_STAT ]}};
|
| 1272 |
|
|
|
| 1273 |
|
|
|
| 1274 |
|
|
wire [15:0] per_dout_o = gfx_ctrl_read |
|
| 1275 |
|
|
gfx_status_read |
|
| 1276 |
|
|
gfx_irq_read |
|
| 1277 |
|
|
|
| 1278 |
|
|
display_width_read |
|
| 1279 |
|
|
display_height_read |
|
| 1280 |
|
|
`ifdef WITH_DISPLAY_SIZE_HI
|
| 1281 |
|
|
display_size_hi_read |
|
| 1282 |
|
|
`endif
|
| 1283 |
|
|
display_size_lo_read |
|
| 1284 |
|
|
display_cfg_read |
|
| 1285 |
|
|
|
| 1286 |
|
|
lt24_cfg_read |
|
| 1287 |
|
|
lt24_refresh_read |
|
| 1288 |
|
|
lt24_refresh_sync_read |
|
| 1289 |
|
|
lt24_cmd_read |
|
| 1290 |
|
|
lt24_cmd_param_read |
|
| 1291 |
|
|
lt24_cmd_dfill_read |
|
| 1292 |
|
|
lt24_status_read |
|
| 1293 |
|
|
|
| 1294 |
|
|
lut_ram_addr_read |
|
| 1295 |
|
|
lut_ram_data_read |
|
| 1296 |
|
|
|
| 1297 |
|
|
frame_select_read |
|
| 1298 |
|
|
`ifdef VRAM_BIGGER_4_KW
|
| 1299 |
|
|
frame0_ptr_hi_read |
|
| 1300 |
|
|
`endif
|
| 1301 |
|
|
frame0_ptr_lo_read |
|
| 1302 |
|
|
`ifdef WITH_FRAME1_POINTER
|
| 1303 |
|
|
`ifdef VRAM_BIGGER_4_KW
|
| 1304 |
|
|
frame1_ptr_hi_read |
|
| 1305 |
|
|
`endif
|
| 1306 |
|
|
frame1_ptr_lo_read |
|
| 1307 |
|
|
`endif
|
| 1308 |
|
|
`ifdef WITH_FRAME2_POINTER
|
| 1309 |
|
|
`ifdef VRAM_BIGGER_4_KW
|
| 1310 |
|
|
frame2_ptr_hi_read |
|
| 1311 |
|
|
`endif
|
| 1312 |
|
|
frame2_ptr_lo_read |
|
| 1313 |
|
|
`endif
|
| 1314 |
|
|
`ifdef WITH_FRAME3_POINTER
|
| 1315 |
|
|
`ifdef VRAM_BIGGER_4_KW
|
| 1316 |
|
|
frame3_ptr_hi_read |
|
| 1317 |
|
|
`endif
|
| 1318 |
|
|
frame3_ptr_lo_read |
|
| 1319 |
|
|
`endif
|
| 1320 |
|
|
vid_ram0_cfg_read |
|
| 1321 |
|
|
vid_ram0_width_read |
|
| 1322 |
|
|
`ifdef VRAM_BIGGER_4_KW
|
| 1323 |
|
|
vid_ram0_addr_hi_read |
|
| 1324 |
|
|
`endif
|
| 1325 |
|
|
vid_ram0_addr_lo_read |
|
| 1326 |
|
|
vid_ram0_data_read |
|
| 1327 |
|
|
|
| 1328 |
|
|
vid_ram1_cfg_read |
|
| 1329 |
|
|
vid_ram1_width_read |
|
| 1330 |
|
|
`ifdef VRAM_BIGGER_4_KW
|
| 1331 |
|
|
vid_ram1_addr_hi_read |
|
| 1332 |
|
|
`endif
|
| 1333 |
|
|
vid_ram1_addr_lo_read |
|
| 1334 |
|
|
vid_ram1_data_read |
|
| 1335 |
|
|
gpu_cmd_read |
|
| 1336 |
|
|
gpu_stat_read;
|
| 1337 |
|
|
|
| 1338 |
|
|
|
| 1339 |
|
|
//============================================================================
|
| 1340 |
|
|
// 5) VIDEO MEMORY INTERFACE
|
| 1341 |
|
|
//============================================================================
|
| 1342 |
|
|
|
| 1343 |
|
|
// Write access strobe
|
| 1344 |
|
|
assign vid_ram_wen_o = ~(vid_ram0_we | vid_ram1_we);
|
| 1345 |
|
|
|
| 1346 |
|
|
// Chip enable.
|
| 1347 |
|
|
assign vid_ram_cen_o = ~(vid_ram0_ce | vid_ram1_ce);
|
| 1348 |
|
|
|
| 1349 |
|
|
// Data to be written
|
| 1350 |
|
|
assign vid_ram_din_o = (vid_ram0_din | vid_ram1_din);
|
| 1351 |
|
|
|
| 1352 |
|
|
// Detect memory accesses for ADDR update
|
| 1353 |
|
|
wire vid_ram_access = (vid_ram0_access | vid_ram1_access);
|
| 1354 |
|
|
|
| 1355 |
|
|
// Next Address
|
| 1356 |
|
|
wire [`APIX_MSB:0] vid_ram_addr_nxt = (vid_ram0_addr_nxt | vid_ram1_addr_nxt);
|
| 1357 |
|
|
|
| 1358 |
|
|
// Align according to graphic mode
|
| 1359 |
|
|
wire [`VRAM_MSB:0] vid_ram_addr_align = ({`VRAM_AWIDTH{gfx_mode_1_bpp }} & vid_ram_addr_nxt[`APIX_MSB-0:4]) |
|
| 1360 |
|
|
({`VRAM_AWIDTH{gfx_mode_2_bpp }} & vid_ram_addr_nxt[`APIX_MSB-1:3]) |
|
| 1361 |
|
|
({`VRAM_AWIDTH{gfx_mode_4_bpp }} & vid_ram_addr_nxt[`APIX_MSB-2:2]) |
|
| 1362 |
|
|
({`VRAM_AWIDTH{gfx_mode_8_bpp }} & vid_ram_addr_nxt[`APIX_MSB-3:1]) |
|
| 1363 |
|
|
({`VRAM_AWIDTH{gfx_mode_16_bpp}} & vid_ram_addr_nxt[`APIX_MSB-4:0]) ;
|
| 1364 |
|
|
|
| 1365 |
|
|
// Generate Video RAM address
|
| 1366 |
|
|
reg [`VRAM_MSB:0] vid_ram_addr_o;
|
| 1367 |
|
|
always @ (posedge mclk or posedge puc_rst)
|
| 1368 |
|
|
if (puc_rst) vid_ram_addr_o <= {`VRAM_AWIDTH{1'b0}};
|
| 1369 |
|
|
else if (vid_ram_access) vid_ram_addr_o <= vid_ram_addr_align;
|
| 1370 |
|
|
|
| 1371 |
|
|
|
| 1372 |
|
|
endmodule // ogfx_reg
|
| 1373 |
|
|
|
| 1374 |
|
|
`ifdef OGFX_NO_INCLUDE
|
| 1375 |
|
|
`else
|
| 1376 |
|
|
`include "openGFX430_undefines.v"
|
| 1377 |
|
|
`endif
|