1 |
221 |
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_if_lt24.v
|
26 |
|
|
//
|
27 |
|
|
// *Module Description:
|
28 |
|
|
// Interface to the LT24 LCD display.
|
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_if_lt24 (
|
44 |
|
|
|
45 |
|
|
// OUTPUTs
|
46 |
|
|
event_fsm_done_o, // Event - FSM is done
|
47 |
|
|
event_fsm_start_o, // Event - FSM is starting
|
48 |
|
|
|
49 |
|
|
lt24_cs_n_o, // LT24 Chip select (Active low)
|
50 |
|
|
lt24_d_o, // LT24 Data output
|
51 |
|
|
lt24_d_en_o, // LT24 Data output enable
|
52 |
|
|
lt24_rd_n_o, // LT24 Read strobe (Active low)
|
53 |
|
|
lt24_rs_o, // LT24 Command/Param selection (Cmd=0/Param=1)
|
54 |
|
|
lt24_wr_n_o, // LT24 Write strobe (Active low)
|
55 |
|
|
|
56 |
|
|
refresh_active_o, // Display refresh on going
|
57 |
|
|
refresh_data_request_o, // Display refresh new data request
|
58 |
|
|
|
59 |
|
|
status_o, // Status - FSM
|
60 |
|
|
|
61 |
|
|
// INPUTs
|
62 |
|
|
mclk, // Main system clock
|
63 |
|
|
puc_rst, // Main system reset
|
64 |
|
|
|
65 |
|
|
cfg_lt24_clk_div_i, // Clock Divider configuration for LT24 interface
|
66 |
|
|
cfg_lt24_display_size_i, // Display size (number of pixels)
|
67 |
|
|
cfg_lt24_refresh_i, // Refresh rate configuration for LT24 interface
|
68 |
|
|
cfg_lt24_refresh_sync_en_i, // Refresh sync enable configuration for LT24 interface
|
69 |
|
|
cfg_lt24_refresh_sync_val_i, // Refresh sync value configuration for LT24 interface
|
70 |
|
|
|
71 |
|
|
cmd_dfill_i, // Display refresh data
|
72 |
|
|
cmd_dfill_trig_i, // Trigger a full display refresh
|
73 |
|
|
|
74 |
|
|
cmd_generic_cmd_val_i, // Generic command value
|
75 |
|
|
cmd_generic_has_param_i, // Generic command to be sent has parameter(s)
|
76 |
|
|
cmd_generic_param_val_i, // Generic command parameter value
|
77 |
|
|
cmd_generic_trig_i, // Trigger generic command transmit (or new parameter available)
|
78 |
|
|
|
79 |
|
|
cmd_refresh_i, // Display refresh command
|
80 |
|
|
|
81 |
|
|
lt24_d_i, // LT24 Data input
|
82 |
|
|
|
83 |
|
|
refresh_data_i, // Display refresh data
|
84 |
|
|
refresh_data_ready_i // Display refresh new data is ready
|
85 |
|
|
);
|
86 |
|
|
|
87 |
|
|
// OUTPUTs
|
88 |
|
|
//=========
|
89 |
|
|
output event_fsm_done_o; // LT24 FSM done event
|
90 |
|
|
output event_fsm_start_o; // LT24 FSM start event
|
91 |
|
|
|
92 |
|
|
output lt24_cs_n_o; // LT24 Chip select (Active low)
|
93 |
|
|
output [15:0] lt24_d_o; // LT24 Data output
|
94 |
|
|
output lt24_d_en_o; // LT24 Data output enable
|
95 |
|
|
output lt24_rd_n_o; // LT24 Read strobe (Active low)
|
96 |
|
|
output lt24_rs_o; // LT24 Command/Param selection (Cmd=0/Param=1)
|
97 |
|
|
output lt24_wr_n_o; // LT24 Write strobe (Active low)
|
98 |
|
|
|
99 |
|
|
output refresh_active_o; // Display refresh on going
|
100 |
|
|
output refresh_data_request_o; // Display refresh new data request
|
101 |
|
|
|
102 |
|
|
output [4:0] status_o; // LT24 FSM Status
|
103 |
|
|
|
104 |
|
|
// INPUTs
|
105 |
|
|
//=========
|
106 |
|
|
input mclk; // Main system clock
|
107 |
|
|
input puc_rst; // Main system reset
|
108 |
|
|
|
109 |
|
|
input [2:0] cfg_lt24_clk_div_i; // Clock Divider configuration for LT24 interface
|
110 |
|
|
input [`SPIX_MSB:0] cfg_lt24_display_size_i; // Display size (number of pixels)
|
111 |
|
|
input [11:0] cfg_lt24_refresh_i; // Refresh rate configuration for LT24 interface
|
112 |
|
|
input cfg_lt24_refresh_sync_en_i; // Refresh sync enable configuration for LT24 interface
|
113 |
|
|
input [9:0] cfg_lt24_refresh_sync_val_i; // Refresh sync value configuration for LT24 interface
|
114 |
|
|
|
115 |
|
|
input [15:0] cmd_dfill_i; // Display refresh data
|
116 |
|
|
input cmd_dfill_trig_i; // Trigger a full display refresh
|
117 |
|
|
|
118 |
|
|
input [7:0] cmd_generic_cmd_val_i; // Generic command value
|
119 |
|
|
input cmd_generic_has_param_i; // Generic command to be sent has parameter(s)
|
120 |
|
|
input [15:0] cmd_generic_param_val_i; // Generic command parameter value
|
121 |
|
|
input cmd_generic_trig_i; // Trigger generic command transmit (or new parameter available)
|
122 |
|
|
|
123 |
|
|
input cmd_refresh_i; // Display refresh command
|
124 |
|
|
|
125 |
|
|
input [15:0] lt24_d_i; // LT24 Data input
|
126 |
|
|
|
127 |
|
|
input [15:0] refresh_data_i; // Display refresh data
|
128 |
|
|
input refresh_data_ready_i; // Display refresh new data is ready
|
129 |
|
|
|
130 |
|
|
|
131 |
|
|
//=============================================================================
|
132 |
|
|
// 1) WIRE, REGISTERS AND PARAMETER DECLARATION
|
133 |
|
|
//=============================================================================
|
134 |
|
|
|
135 |
|
|
// State machine registers
|
136 |
|
|
reg [4:0] lt24_state;
|
137 |
|
|
reg [4:0] lt24_state_nxt;
|
138 |
|
|
|
139 |
|
|
// Others
|
140 |
|
|
reg refresh_trigger;
|
141 |
|
|
wire status_gts_match;
|
142 |
|
|
|
143 |
|
|
// State definition
|
144 |
|
|
parameter STATE_IDLE = 0, // IDLE state
|
145 |
|
|
|
146 |
|
|
STATE_CMD_LO = 1, // Generic command to LT24
|
147 |
|
|
STATE_CMD_HI = 2,
|
148 |
|
|
STATE_CMD_PARAM_LO = 3,
|
149 |
|
|
STATE_CMD_PARAM_HI = 4,
|
150 |
|
|
STATE_CMD_PARAM_WAIT = 5,
|
151 |
|
|
|
152 |
|
|
STATE_RAMWR_INIT_CMD_LO = 6, // Initialize display buffer with data
|
153 |
|
|
STATE_RAMWR_INIT_CMD_HI = 7,
|
154 |
|
|
STATE_RAMWR_INIT_DATA_LO = 8,
|
155 |
|
|
STATE_RAMWR_INIT_DATA_HI = 9,
|
156 |
|
|
|
157 |
|
|
STATE_SCANLINE_CMD_LO = 10, // Wait for right scanline
|
158 |
|
|
STATE_SCANLINE_CMD_HI = 11,
|
159 |
|
|
STATE_SCANLINE_DUMMY_LO = 12,
|
160 |
|
|
STATE_SCANLINE_DUMMY_HI = 13,
|
161 |
|
|
STATE_SCANLINE_GTS1_LO = 14,
|
162 |
|
|
STATE_SCANLINE_GTS1_HI = 15,
|
163 |
|
|
STATE_SCANLINE_GTS2_LO = 16,
|
164 |
|
|
STATE_SCANLINE_GTS2_HI = 17,
|
165 |
|
|
|
166 |
|
|
|
167 |
|
|
STATE_RAMWR_REFR_CMD_LO = 18, // Refresh display buffer
|
168 |
|
|
STATE_RAMWR_REFR_CMD_HI = 19,
|
169 |
|
|
STATE_RAMWR_REFR_WAIT = 20,
|
170 |
|
|
STATE_RAMWR_REFR_DATA_LO = 21,
|
171 |
|
|
STATE_RAMWR_REFR_DATA_HI = 22;
|
172 |
|
|
|
173 |
|
|
|
174 |
|
|
//============================================================================
|
175 |
|
|
// 5) STATE MACHINE SENDING IMAGE DATA TO A SPECIFIED DISPLAY
|
176 |
|
|
//============================================================================
|
177 |
|
|
|
178 |
|
|
//--------------------------------
|
179 |
|
|
// LT24 Controller Clock Timer
|
180 |
|
|
//--------------------------------
|
181 |
|
|
reg [3:0] lt24_timer;
|
182 |
|
|
|
183 |
|
|
wire lt24_timer_done = lt24_d_en_o ? (lt24_timer == {1'b0, cfg_lt24_clk_div_i}) :
|
184 |
|
|
(lt24_timer == {cfg_lt24_clk_div_i, 1'b0}) ; // Use slower timing for read accesses
|
185 |
|
|
|
186 |
|
|
wire lt24_timer_run = (lt24_state != STATE_IDLE) &
|
187 |
|
|
(lt24_state != STATE_CMD_PARAM_WAIT) &
|
188 |
|
|
(lt24_state != STATE_RAMWR_REFR_WAIT) &
|
189 |
|
|
~lt24_timer_done;
|
190 |
|
|
|
191 |
|
|
wire lt24_timer_init = (lt24_timer_done & // Init if counter reaches limit:
|
192 |
|
|
!((lt24_state == STATE_CMD_PARAM_HI) & cmd_generic_has_param_i) & // -> if not moving to STATE_CMD_PARAM_WAIT
|
193 |
|
|
!((lt24_state == STATE_CMD_PARAM_WAIT))) | // -> if not in STATE_CMD_PARAM_WAIT
|
194 |
|
|
((lt24_state == STATE_CMD_PARAM_WAIT) & (cmd_generic_trig_i | ~cmd_generic_has_param_i)); // Init when leaving the STATE_CMD_PARAM_WAIT state
|
195 |
|
|
|
196 |
|
|
always @(posedge mclk or posedge puc_rst)
|
197 |
|
|
if (puc_rst) lt24_timer <= 4'h0;
|
198 |
|
|
else if (lt24_timer_init) lt24_timer <= 4'h0;
|
199 |
|
|
else if (lt24_timer_run) lt24_timer <= lt24_timer+4'h1;
|
200 |
|
|
|
201 |
|
|
|
202 |
|
|
//--------------------------------
|
203 |
|
|
// Pixel counter
|
204 |
|
|
//--------------------------------
|
205 |
|
|
reg [`SPIX_MSB:0] lt24_pixel_cnt;
|
206 |
|
|
|
207 |
|
|
wire lt24_pixel_cnt_run = (lt24_state==STATE_RAMWR_INIT_DATA_HI) |
|
208 |
|
|
(lt24_state==STATE_RAMWR_REFR_DATA_HI);
|
209 |
|
|
|
210 |
|
|
wire lt24_pixel_cnt_done = (lt24_pixel_cnt==1) | (lt24_pixel_cnt==0);
|
211 |
|
|
|
212 |
|
|
wire lt24_pixel_cnt_init = (lt24_state==STATE_RAMWR_INIT_CMD_HI) |
|
213 |
|
|
(lt24_state==STATE_RAMWR_REFR_CMD_HI) |
|
214 |
|
|
(lt24_pixel_cnt_done & lt24_pixel_cnt_run);
|
215 |
|
|
|
216 |
|
|
always @(posedge mclk or posedge puc_rst)
|
217 |
|
|
if (puc_rst) lt24_pixel_cnt <= {`SPIX_MSB+1{1'h0}};
|
218 |
|
|
else if (lt24_timer_init)
|
219 |
|
|
begin
|
220 |
|
|
if (lt24_pixel_cnt_init) lt24_pixel_cnt <= cfg_lt24_display_size_i;
|
221 |
|
|
else if (lt24_pixel_cnt_run) lt24_pixel_cnt <= lt24_pixel_cnt-{{`SPIX_MSB{1'h0}},1'b1};
|
222 |
|
|
end
|
223 |
|
|
|
224 |
|
|
|
225 |
|
|
//--------------------------------
|
226 |
|
|
// States Transitions
|
227 |
|
|
//--------------------------------
|
228 |
|
|
always @(lt24_state or cmd_dfill_trig_i or cmd_generic_trig_i or refresh_trigger or cfg_lt24_refresh_sync_en_i or status_gts_match or refresh_data_request_o or cmd_generic_has_param_i or lt24_timer_done or lt24_pixel_cnt_done)
|
229 |
|
|
case(lt24_state)
|
230 |
|
|
STATE_IDLE : lt24_state_nxt = cmd_dfill_trig_i ? STATE_RAMWR_INIT_CMD_LO :
|
231 |
|
|
refresh_trigger ?
|
232 |
|
|
(cfg_lt24_refresh_sync_en_i ? STATE_SCANLINE_CMD_LO : STATE_RAMWR_REFR_CMD_LO) :
|
233 |
|
|
cmd_generic_trig_i ? STATE_CMD_LO : STATE_IDLE ;
|
234 |
|
|
|
235 |
|
|
// GENERIC COMMANDS
|
236 |
|
|
STATE_CMD_LO : lt24_state_nxt = ~lt24_timer_done ? STATE_CMD_LO : STATE_CMD_HI ;
|
237 |
|
|
STATE_CMD_HI : lt24_state_nxt = ~lt24_timer_done ? STATE_CMD_HI :
|
238 |
|
|
cmd_generic_has_param_i ? STATE_CMD_PARAM_LO : STATE_IDLE ;
|
239 |
|
|
|
240 |
|
|
STATE_CMD_PARAM_LO : lt24_state_nxt = ~lt24_timer_done ? STATE_CMD_PARAM_LO : STATE_CMD_PARAM_HI ;
|
241 |
|
|
STATE_CMD_PARAM_HI : lt24_state_nxt = ~lt24_timer_done ? STATE_CMD_PARAM_HI :
|
242 |
|
|
cmd_generic_has_param_i ? STATE_CMD_PARAM_WAIT : STATE_IDLE ;
|
243 |
|
|
|
244 |
|
|
STATE_CMD_PARAM_WAIT : lt24_state_nxt = cmd_generic_trig_i ? STATE_CMD_PARAM_LO :
|
245 |
|
|
cmd_generic_has_param_i ? STATE_CMD_PARAM_WAIT : STATE_IDLE ;
|
246 |
|
|
|
247 |
|
|
// MEMORY INITIALIZATION
|
248 |
|
|
STATE_RAMWR_INIT_CMD_LO : lt24_state_nxt = ~lt24_timer_done ? STATE_RAMWR_INIT_CMD_LO : STATE_RAMWR_INIT_CMD_HI ;
|
249 |
|
|
STATE_RAMWR_INIT_CMD_HI : lt24_state_nxt = ~lt24_timer_done ? STATE_RAMWR_INIT_CMD_HI : STATE_RAMWR_INIT_DATA_LO ;
|
250 |
|
|
|
251 |
|
|
STATE_RAMWR_INIT_DATA_LO : lt24_state_nxt = ~lt24_timer_done ? STATE_RAMWR_INIT_DATA_LO : STATE_RAMWR_INIT_DATA_HI ;
|
252 |
|
|
STATE_RAMWR_INIT_DATA_HI : lt24_state_nxt = lt24_timer_done &
|
253 |
|
|
lt24_pixel_cnt_done ? STATE_IDLE :
|
254 |
|
|
~lt24_timer_done ? STATE_RAMWR_INIT_DATA_HI : STATE_RAMWR_INIT_DATA_LO ;
|
255 |
|
|
|
256 |
|
|
// WAIT FOR RIGHT SCANLINE BEFORE REFRESH
|
257 |
|
|
STATE_SCANLINE_CMD_LO : lt24_state_nxt = ~lt24_timer_done ? STATE_SCANLINE_CMD_LO : STATE_SCANLINE_CMD_HI ;
|
258 |
|
|
STATE_SCANLINE_CMD_HI : lt24_state_nxt = ~lt24_timer_done ? STATE_SCANLINE_CMD_HI : STATE_SCANLINE_DUMMY_LO ;
|
259 |
|
|
|
260 |
|
|
STATE_SCANLINE_DUMMY_LO : lt24_state_nxt = ~lt24_timer_done ? STATE_SCANLINE_DUMMY_LO : STATE_SCANLINE_DUMMY_HI ;
|
261 |
|
|
STATE_SCANLINE_DUMMY_HI : lt24_state_nxt = ~lt24_timer_done ? STATE_SCANLINE_DUMMY_HI : STATE_SCANLINE_GTS1_LO ;
|
262 |
|
|
|
263 |
|
|
STATE_SCANLINE_GTS1_LO : lt24_state_nxt = ~lt24_timer_done ? STATE_SCANLINE_GTS1_LO : STATE_SCANLINE_GTS1_HI ;
|
264 |
|
|
STATE_SCANLINE_GTS1_HI : lt24_state_nxt = ~lt24_timer_done ? STATE_SCANLINE_GTS1_HI : STATE_SCANLINE_GTS2_LO ;
|
265 |
|
|
|
266 |
|
|
STATE_SCANLINE_GTS2_LO : lt24_state_nxt = ~lt24_timer_done ? STATE_SCANLINE_GTS2_LO : STATE_SCANLINE_GTS2_HI ;
|
267 |
|
|
STATE_SCANLINE_GTS2_HI : lt24_state_nxt = ~lt24_timer_done ? STATE_SCANLINE_GTS2_HI :
|
268 |
|
|
(status_gts_match |
|
269 |
|
|
~cfg_lt24_refresh_sync_en_i) ? STATE_RAMWR_REFR_CMD_LO : STATE_SCANLINE_CMD_LO ;
|
270 |
|
|
|
271 |
|
|
// FRAME REFRESH
|
272 |
|
|
STATE_RAMWR_REFR_CMD_LO : lt24_state_nxt = ~lt24_timer_done ? STATE_RAMWR_REFR_CMD_LO : STATE_RAMWR_REFR_CMD_HI ;
|
273 |
|
|
STATE_RAMWR_REFR_CMD_HI : lt24_state_nxt = ~lt24_timer_done ? STATE_RAMWR_REFR_CMD_HI :
|
274 |
|
|
~refresh_data_request_o ? STATE_RAMWR_REFR_DATA_LO : STATE_RAMWR_REFR_WAIT ;
|
275 |
|
|
|
276 |
|
|
STATE_RAMWR_REFR_WAIT : lt24_state_nxt = ~refresh_data_request_o ? STATE_RAMWR_REFR_DATA_LO : STATE_RAMWR_REFR_WAIT ;
|
277 |
|
|
|
278 |
|
|
STATE_RAMWR_REFR_DATA_LO : lt24_state_nxt = ~lt24_timer_done ? STATE_RAMWR_REFR_DATA_LO : STATE_RAMWR_REFR_DATA_HI ;
|
279 |
|
|
STATE_RAMWR_REFR_DATA_HI : lt24_state_nxt = lt24_timer_done &
|
280 |
|
|
lt24_pixel_cnt_done ? STATE_IDLE :
|
281 |
|
|
~lt24_timer_done ? STATE_RAMWR_REFR_DATA_HI :
|
282 |
|
|
~refresh_data_request_o ? STATE_RAMWR_REFR_DATA_LO : STATE_RAMWR_REFR_WAIT ;
|
283 |
|
|
|
284 |
|
|
// pragma coverage off
|
285 |
|
|
default : lt24_state_nxt = STATE_IDLE;
|
286 |
|
|
// pragma coverage on
|
287 |
|
|
endcase
|
288 |
|
|
|
289 |
|
|
// State machine
|
290 |
|
|
always @(posedge mclk or posedge puc_rst)
|
291 |
|
|
if (puc_rst) lt24_state <= STATE_IDLE;
|
292 |
|
|
else lt24_state <= lt24_state_nxt;
|
293 |
|
|
|
294 |
|
|
|
295 |
|
|
// Output status
|
296 |
|
|
assign status_o[0] = (lt24_state != STATE_IDLE); // LT24 FSM BUSY
|
297 |
|
|
|
298 |
|
|
assign status_o[1] = (lt24_state == STATE_CMD_PARAM_WAIT); // LT24 Waits for command parameter
|
299 |
|
|
|
300 |
|
|
assign status_o[2] = (lt24_state == STATE_RAMWR_REFR_CMD_LO) | (lt24_state == STATE_RAMWR_REFR_CMD_HI) | // LT24 REFRESH BUSY
|
301 |
|
|
(lt24_state == STATE_RAMWR_REFR_DATA_LO) | (lt24_state == STATE_RAMWR_REFR_DATA_HI) |
|
302 |
|
|
(lt24_state == STATE_RAMWR_REFR_WAIT);
|
303 |
|
|
|
304 |
|
|
assign status_o[3] = (lt24_state == STATE_SCANLINE_CMD_LO) | (lt24_state == STATE_SCANLINE_CMD_HI) | // LT24 WAIT FOR SCANLINE
|
305 |
|
|
(lt24_state == STATE_SCANLINE_DUMMY_LO) | (lt24_state == STATE_SCANLINE_DUMMY_HI) |
|
306 |
|
|
(lt24_state == STATE_SCANLINE_GTS1_LO) | (lt24_state == STATE_SCANLINE_GTS1_HI) |
|
307 |
|
|
(lt24_state == STATE_SCANLINE_GTS2_LO) | (lt24_state == STATE_SCANLINE_GTS2_HI);
|
308 |
|
|
|
309 |
|
|
assign status_o[4] = (lt24_state == STATE_RAMWR_INIT_CMD_LO) | (lt24_state == STATE_RAMWR_INIT_CMD_HI) | // LT24 INIT BUSY
|
310 |
|
|
(lt24_state == STATE_RAMWR_INIT_DATA_LO) | (lt24_state == STATE_RAMWR_INIT_DATA_HI);
|
311 |
|
|
|
312 |
|
|
assign refresh_active_o = status_o[2];
|
313 |
|
|
|
314 |
|
|
|
315 |
|
|
// Refresh data request
|
316 |
|
|
wire refresh_data_request_set = ((lt24_state == STATE_RAMWR_REFR_CMD_LO) & (lt24_state_nxt == STATE_RAMWR_REFR_CMD_HI)) |
|
317 |
|
|
((lt24_state == STATE_RAMWR_REFR_DATA_LO) & (lt24_state_nxt == STATE_RAMWR_REFR_DATA_HI)) |
|
318 |
|
|
(lt24_state == STATE_RAMWR_REFR_WAIT);
|
319 |
|
|
wire refresh_data_request_clr = refresh_data_ready_i;
|
320 |
|
|
reg refresh_data_request_reg;
|
321 |
|
|
always @(posedge mclk or posedge puc_rst)
|
322 |
|
|
if (puc_rst) refresh_data_request_reg <= 1'b0;
|
323 |
|
|
else refresh_data_request_reg <= refresh_data_request_clr ? 1'b0 :
|
324 |
|
|
refresh_data_request_set ? 1'b1 : refresh_data_request_reg;
|
325 |
|
|
|
326 |
|
|
assign refresh_data_request_o = refresh_data_request_reg & ~refresh_data_ready_i;
|
327 |
|
|
|
328 |
|
|
assign event_fsm_start_o = (lt24_state_nxt != STATE_IDLE) & (lt24_state == STATE_IDLE);
|
329 |
|
|
assign event_fsm_done_o = (lt24_state != STATE_IDLE) & (lt24_state_nxt == STATE_IDLE);
|
330 |
|
|
|
331 |
|
|
|
332 |
|
|
//============================================================================
|
333 |
|
|
// 6) LT24 CONTROLLER OUTPUT ASSIGNMENT
|
334 |
|
|
//============================================================================
|
335 |
|
|
|
336 |
|
|
// LT24 Chip select (active low)
|
337 |
|
|
reg lt24_cs_n_o;
|
338 |
|
|
always @(posedge mclk or posedge puc_rst)
|
339 |
|
|
if (puc_rst) lt24_cs_n_o <= 1'b1;
|
340 |
|
|
else lt24_cs_n_o <= (lt24_state_nxt==STATE_IDLE);
|
341 |
|
|
|
342 |
|
|
// Command (0) or Data (1)
|
343 |
|
|
reg lt24_rs_o;
|
344 |
|
|
always @(posedge mclk or posedge puc_rst)
|
345 |
|
|
if (puc_rst) lt24_rs_o <= 1'b1;
|
346 |
|
|
else lt24_rs_o <= ~((lt24_state_nxt==STATE_CMD_LO) | (lt24_state_nxt==STATE_CMD_HI) |
|
347 |
|
|
(lt24_state_nxt==STATE_SCANLINE_CMD_LO) | (lt24_state_nxt==STATE_SCANLINE_CMD_HI) |
|
348 |
|
|
(lt24_state_nxt==STATE_RAMWR_INIT_CMD_LO) | (lt24_state_nxt==STATE_RAMWR_INIT_CMD_HI) |
|
349 |
|
|
(lt24_state_nxt==STATE_RAMWR_REFR_CMD_LO) | (lt24_state_nxt==STATE_RAMWR_REFR_CMD_HI));
|
350 |
|
|
|
351 |
|
|
// LT24 Write strobe (Active low)
|
352 |
|
|
reg lt24_wr_n_o;
|
353 |
|
|
|
354 |
|
|
wire lt24_wr_n_clr = (lt24_state_nxt==STATE_CMD_LO) | (lt24_state_nxt==STATE_CMD_PARAM_LO) | (lt24_state_nxt==STATE_SCANLINE_CMD_LO) |
|
355 |
|
|
(lt24_state_nxt==STATE_RAMWR_INIT_CMD_LO) | (lt24_state_nxt==STATE_RAMWR_INIT_DATA_LO) |
|
356 |
|
|
(lt24_state_nxt==STATE_RAMWR_REFR_CMD_LO) | (lt24_state_nxt==STATE_RAMWR_REFR_DATA_LO);
|
357 |
|
|
|
358 |
|
|
always @(posedge mclk or posedge puc_rst)
|
359 |
|
|
if (puc_rst) lt24_wr_n_o <= 1'b1;
|
360 |
|
|
else if (lt24_wr_n_clr) lt24_wr_n_o <= 1'b0;
|
361 |
|
|
else lt24_wr_n_o <= 1'b1;
|
362 |
|
|
|
363 |
|
|
// LT24 Read strobe (active low)
|
364 |
|
|
reg lt24_rd_n_o;
|
365 |
|
|
|
366 |
|
|
wire lt24_rd_n_clr = (lt24_state_nxt==STATE_SCANLINE_DUMMY_LO) |
|
367 |
|
|
(lt24_state_nxt==STATE_SCANLINE_GTS1_LO) | (lt24_state_nxt==STATE_SCANLINE_GTS2_LO);
|
368 |
|
|
|
369 |
|
|
always @(posedge mclk or posedge puc_rst)
|
370 |
|
|
if (puc_rst) lt24_rd_n_o <= 1'b1;
|
371 |
|
|
else if (lt24_rd_n_clr) lt24_rd_n_o <= 1'b0;
|
372 |
|
|
else lt24_rd_n_o <= 1'b1;
|
373 |
|
|
|
374 |
|
|
|
375 |
|
|
// LT24 Data
|
376 |
|
|
reg [15:0] lt24_d_nxt;
|
377 |
|
|
always @(lt24_state_nxt or cmd_generic_cmd_val_i or cmd_generic_param_val_i or lt24_d_o or cmd_dfill_i or refresh_data_i)
|
378 |
|
|
case(lt24_state_nxt)
|
379 |
|
|
STATE_IDLE : lt24_d_nxt = 16'h0000;
|
380 |
|
|
|
381 |
|
|
STATE_CMD_LO,
|
382 |
|
|
STATE_CMD_HI : lt24_d_nxt = {8'h00, cmd_generic_cmd_val_i};
|
383 |
|
|
STATE_CMD_PARAM_LO,
|
384 |
|
|
STATE_CMD_PARAM_HI : lt24_d_nxt = cmd_generic_param_val_i;
|
385 |
|
|
STATE_CMD_PARAM_WAIT : lt24_d_nxt = lt24_d_o;
|
386 |
|
|
|
387 |
|
|
STATE_RAMWR_INIT_CMD_LO,
|
388 |
|
|
STATE_RAMWR_INIT_CMD_HI : lt24_d_nxt = 16'h002C;
|
389 |
|
|
STATE_RAMWR_INIT_DATA_LO,
|
390 |
|
|
STATE_RAMWR_INIT_DATA_HI : lt24_d_nxt = cmd_dfill_i;
|
391 |
|
|
|
392 |
|
|
STATE_SCANLINE_CMD_LO,
|
393 |
|
|
STATE_SCANLINE_CMD_HI : lt24_d_nxt = 16'h0045;
|
394 |
|
|
|
395 |
|
|
STATE_RAMWR_REFR_CMD_LO,
|
396 |
|
|
STATE_RAMWR_REFR_CMD_HI : lt24_d_nxt = 16'h002C;
|
397 |
|
|
STATE_RAMWR_REFR_DATA_LO : lt24_d_nxt = refresh_data_i;
|
398 |
|
|
STATE_RAMWR_REFR_DATA_HI : lt24_d_nxt = lt24_d_o;
|
399 |
|
|
STATE_RAMWR_REFR_WAIT : lt24_d_nxt = lt24_d_o;
|
400 |
|
|
|
401 |
|
|
// pragma coverage off
|
402 |
|
|
default : lt24_d_nxt = 16'h0000;
|
403 |
|
|
// pragma coverage on
|
404 |
|
|
endcase
|
405 |
|
|
|
406 |
|
|
reg [15:0] lt24_d_o;
|
407 |
|
|
always @(posedge mclk or posedge puc_rst)
|
408 |
|
|
if (puc_rst) lt24_d_o <= 16'h0000;
|
409 |
|
|
else lt24_d_o <= lt24_d_nxt;
|
410 |
|
|
|
411 |
|
|
// Output enable
|
412 |
|
|
reg lt24_d_en_o;
|
413 |
|
|
always @(posedge mclk or posedge puc_rst)
|
414 |
|
|
if (puc_rst) lt24_d_en_o <= 1'h0; // Don't drive output during reset
|
415 |
|
|
else lt24_d_en_o <= ~((lt24_state_nxt == STATE_SCANLINE_DUMMY_LO) |
|
416 |
|
|
(lt24_state_nxt == STATE_SCANLINE_DUMMY_HI) |
|
417 |
|
|
(lt24_state_nxt == STATE_SCANLINE_GTS1_LO ) |
|
418 |
|
|
(lt24_state_nxt == STATE_SCANLINE_GTS1_HI ) |
|
419 |
|
|
(lt24_state_nxt == STATE_SCANLINE_GTS2_LO ) |
|
420 |
|
|
(lt24_state_nxt == STATE_SCANLINE_GTS2_HI ));
|
421 |
|
|
|
422 |
|
|
//============================================================================
|
423 |
|
|
// 7) LT24 GTS VALUE (i.e. CURRENT SCAN LINE)
|
424 |
|
|
//============================================================================
|
425 |
|
|
|
426 |
|
|
reg [1:0] status_gts_msb;
|
427 |
|
|
wire status_gts_msb_wr = ((lt24_state == STATE_SCANLINE_GTS1_LO) & (lt24_state_nxt == STATE_SCANLINE_GTS1_HI));
|
428 |
|
|
always @(posedge mclk or posedge puc_rst)
|
429 |
|
|
if (puc_rst) status_gts_msb <= 2'h0;
|
430 |
|
|
else if (status_gts_msb_wr) status_gts_msb <= lt24_d_i[1:0];
|
431 |
|
|
|
432 |
|
|
reg [7:0] status_gts_lsb;
|
433 |
|
|
wire status_gts_lsb_wr = ((lt24_state == STATE_SCANLINE_GTS2_LO) & (lt24_state_nxt == STATE_SCANLINE_GTS2_HI));
|
434 |
|
|
always @(posedge mclk or posedge puc_rst)
|
435 |
|
|
if (puc_rst) status_gts_lsb <= 8'h00;
|
436 |
|
|
else if (status_gts_lsb_wr) status_gts_lsb <= lt24_d_i[7:0];
|
437 |
|
|
|
438 |
|
|
wire [7:0] unused_lt24_d_15_8 = lt24_d_i[15:8];
|
439 |
|
|
wire [9:0] status_gts = {status_gts_msb, status_gts_lsb};
|
440 |
|
|
|
441 |
|
|
assign status_gts_match = (status_gts == cfg_lt24_refresh_sync_val_i);
|
442 |
|
|
|
443 |
|
|
//============================================================================
|
444 |
|
|
// 8) REFRESH TIMER & TRIGGER
|
445 |
|
|
//============================================================================
|
446 |
|
|
|
447 |
|
|
// Refresh Timer
|
448 |
|
|
reg [23:0] refresh_timer;
|
449 |
|
|
wire refresh_timer_disable = (cfg_lt24_refresh_i==12'h000) | ~cmd_refresh_i;
|
450 |
|
|
wire refresh_timer_done = (refresh_timer[23:12]==cfg_lt24_refresh_i);
|
451 |
|
|
|
452 |
|
|
always @(posedge mclk or posedge puc_rst)
|
453 |
|
|
if (puc_rst) refresh_timer <= 24'h000000;
|
454 |
|
|
else if (refresh_timer_disable) refresh_timer <= 24'h000000;
|
455 |
|
|
else if (refresh_timer_done) refresh_timer <= 24'h000000;
|
456 |
|
|
else refresh_timer <= refresh_timer + 24'h1;
|
457 |
|
|
|
458 |
|
|
// Refresh Trigger
|
459 |
|
|
wire refresh_trigger_set = (lt24_state==STATE_IDLE) & cmd_refresh_i & (refresh_timer==24'h000000);
|
460 |
|
|
wire refresh_trigger_clr = (lt24_state==STATE_RAMWR_REFR_CMD_LO);
|
461 |
|
|
|
462 |
|
|
always @(posedge mclk or posedge puc_rst)
|
463 |
|
|
if (puc_rst) refresh_trigger <= 1'b0;
|
464 |
|
|
else if (refresh_trigger_set) refresh_trigger <= 1'b1;
|
465 |
|
|
else if (refresh_trigger_clr) refresh_trigger <= 1'b0;
|
466 |
|
|
|
467 |
|
|
endmodule // ogfx_if_lt24
|
468 |
|
|
|
469 |
|
|
`ifdef OGFX_NO_INCLUDE
|
470 |
|
|
`else
|
471 |
|
|
`include "openGFX430_undefines.v"
|
472 |
|
|
`endif
|