-
Notifications
You must be signed in to change notification settings - Fork 0
/
vga_ctr.v
606 lines (518 loc) · 23 KB
/
vga_ctr.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
module vga_ctr
(
input vga_clk,//输入时钟50M
input vga_rst_n, //复位
input shift_l, //左移按键输入 key3 Y16 按下 0
input shift_r, //右移按键输入 key2 W15
input [9:0] i_data,
input [11:0] v_num_data, // 3位BCD码 0001 0010 0011 --> 1.23 v
input [23:0] f_num_data, // 6位BCD码 123.456 khz
input f_div_select, //高电平20ms 低电平100us
input V_div_select,
input vga_rst, // 图像复位,高有效
output [11:0] o_address,
output reg[23:0] color_data,//颜色信号 红--绿--蓝
output vga_hs, //行同步信号输出
output vga_vs, //场同步信号输出
output reg clk_25M,
output blank_n, //消隐
output sync_n //信号同步
);
reg [11:0] cnt_hs; //行信号clk计数,
reg [11:0] cnt_vs; //场信号clk计数
wire lcd_request;
wire [11:0] vga_x; //VGA的x坐标
wire [11:0] vga_y; //VGA的y坐标
reg [9:0] i_temp;
reg[19:0] divider_25hz; //25m 分频至25hz
reg clk_25hz;
reg [11:0] shift_h ;
reg [11:0] position_X,position_Y;
wire area0;//网格线标志
wire area1;//界面区域标志
wire area2;//数据框标志
wire area3,area4,area_u,area_m,area_k;//
wire num0,num1,num2,num3,num4,num5,num6,num7,num8,num9;
wire [11:0] temp_x;
wire [11:0] temp_y;
//--------测试幅值、频率显示---------
//wire [11:0] v_num_data;
//wire [23:0] f_num_data;
// assign v_num_data = 12'b0000_0001_0010 ;
// assign f_num_data = 24'b0010_0000_0000_0110_0111_1000 ;
//define colors RGB--8|8|8
`define RED 24'hFF0000 /*11111111,00000000,00000000 */
`define GREEN 24'h00FF00 /*00000000,11111111,00000000 */
`define BLUE 24'h0000FF /*00000000,00000000,11111111 */
`define WHITE 24'haaaaaa/*11111111,11111111,11111111 */
`define BLACK 24'h000000 /*00000000,00000000,00000000 */
`define YELLOW 24'hFFFF00 /*11111111,11111111,00000000 */
`define CYAN 24'hFF00FF /*11111111,00000000,11111111 */
`define ROYAL 24'h00FFFF /*00000000,11111111,11111111 */
// 640 * 480
`define H_FRONT 11'd16
`define H_SYNC 11'd96
`define H_BACK 11'd48
`define H_DISP 11'd640
`define H_TOTAL 11'd800
`define V_FRONT 11'd10
`define V_SYNC 11'd2
`define V_BACK 11'd33
`define V_DISP 11'd480
`define V_TOTAL 11'd525
//---------------------------------------------------------
//功能: 产生25MHz的像素时钟
always @(posedge vga_clk or posedge vga_rst_n)
begin
if(vga_rst_n)
clk_25M <= 1'b0 ;
else
clk_25M <= ~clk_25M ;
end
//-----------------------------------------------------------
// 25M分频成50hz计数器
always @(posedge clk_25M or posedge vga_rst_n)
begin
if(vga_rst_n)
begin
clk_25hz <= 1'b0 ;
divider_25hz <= 20'd0 ;
end
else if(divider_25hz <= 20'd399999 )
begin
if(divider_25hz == 20'd199999)
clk_25hz <= ~clk_25hz ;
divider_25hz <= divider_25hz+ 20'd1 ;
end
else
divider_25hz <= 20'd0 ;
end
//按键检测,赋给水平偏移寄存器
// 0-- 4095-512 ==3583
always@(posedge clk_25hz or posedge vga_rst )
begin
if(vga_rst)
shift_h <= 0;
else if({ shift_l,shift_r} == 2'b01 ) // 左移
if( shift_h <= 3578 )
shift_h <= shift_h +5;
else
shift_h <= 3583 ;
else if( {shift_l,shift_r} == 2'b10 ) // 右移
if( shift_h>= 5 )
shift_h <= shift_h -5;
else
shift_h <= 5;
else //同时按 、不按
shift_h <= shift_h ;
end
//----------------------------------------------------
//VGA行同步信号
always @ (posedge clk_25M or posedge vga_rst_n)
begin
if (vga_rst_n)
cnt_hs <= 11'd0;
else
begin
if(cnt_hs < `H_TOTAL - 1'b1) //line over
cnt_hs <= cnt_hs + 1'b1;
else
cnt_hs <= 11'd0;
end
end
assign vga_hs = (cnt_hs <= `H_SYNC - 1'b1) ? 1'b0 : 1'b1;
//VGA场同步信号
always@(posedge clk_25M or posedge vga_rst_n)
begin
if (vga_rst_n)
cnt_vs <= 11'b0;
else if(cnt_hs == `H_TOTAL - 1'b1) //line over
begin
if(cnt_vs < `V_TOTAL - 1'b1) //frame over
cnt_vs <= cnt_vs + 1'b1;
else cnt_vs <= 11'd0;
end
end
assign vga_vs = (cnt_vs <= `V_SYNC - 1'b1) ? 1'b0 : 1'b1;
assign blank_n = lcd_request;//vga_hs & vga_vs;
assign sync_n=1'b0;
//ahead x clock
localparam H_AHEAD = 11'd1;
assign lcd_request = ((cnt_hs >= `H_SYNC + `H_BACK - H_AHEAD )&& (cnt_hs < `H_SYNC + `H_BACK + `H_DISP - H_AHEAD) &&
(cnt_vs >= `V_SYNC + `V_BACK )&& (cnt_vs < `V_SYNC + `V_BACK + `V_DISP) )
? 1'b1 : 1'b0;
//lcd vgax & vgay
assign vga_x = lcd_request ? (cnt_hs - (`H_SYNC + `H_BACK - H_AHEAD)) : 11'd0;
assign vga_y = lcd_request ? (cnt_vs - (`V_SYNC + `V_BACK)) : 11'd0;
//------------------------------------
//----------------波形平移、伸缩变换-------------
assign o_address = (vga_x + shift_h -8) >=0 ? (vga_x + shift_h -8) : 12'd0 ; // 水平偏移量+水平扫描量-前框格点
always@(posedge clk_25M )
if (V_div_select)
i_temp = (349*10-i_data*11*10/50)-2400+240;
else
i_temp = (349-i_data*11/50) ; // 1024*11/50
//------------------------------------
// 示波器界面取模区
assign area0 = ( (vga_x-10) %50 ==0 || (vga_y -20) % 55 ==0 ) ?1'b1 : 1'b0; //网格线
assign area1 = (vga_x >= 10 && vga_x <= 510 && vga_y >= 20 && vga_y <= 460) ?1'b1 : 1'b0; //波形显示与网格线总区域
assign area2 = (vga_x >= 520 && vga_x <= 620 && vga_y >= 80 && vga_y <= 400 ) ?1'b1 : 1'b0;
assign area_u =(
vga_y == 468 && vga_x == 532 //38--32
|| vga_y == 475 && vga_x == 534
|| vga_y >= 468 && vga_y <= 474 && vga_x == 533
|| vga_y == 474 && vga_x == 535
|| vga_y >= 468 && vga_y <= 475 && vga_x == 536
|| vga_y == 475 && vga_x == 537 //u
)?1'b1 : 1'b0;
assign area_m =(
vga_y == 468 && vga_x == 532 //38--32
|| vga_y == 469 && vga_x == 534
|| vga_y >= 468 && vga_y <= 475 && ( vga_x == 533 || vga_x == 535)
|| vga_y == 468 && vga_x == 536
|| vga_y >= 469 && vga_y <= 475 && vga_x == 537//m
)?1'b1 : 1'b0;
assign area_k =(
( (vga_y == 156|| vga_y == 157) && vga_x == 617 ) //显K
|| ((vga_y == 155|| vga_y == 158) && vga_x == 618 )
|| ((vga_y == 154|| vga_y == 159) && vga_x == 619 )
|| vga_y >= 153 && vga_y <= 160 && ( vga_x == 616 )
//k
)?1'b1 : 1'b0;
assign area3 = ( vga_x >= 621 && vga_x <= 626 && ( vga_y == 156 ) || //显示Hz
vga_y >= 151 && vga_y <= 161 && ( vga_x == 621 || vga_x == 626 ) ||
vga_x >= 628 && vga_x <= 633 && ( vga_y == 156 || vga_y == 161 ) || ( vga_x == 632 && vga_y == 157 )
|| ( vga_x == 631 && vga_y == 158 )|| ( vga_x == 630 && vga_y == 159 ) || ( vga_x == 629 && vga_y == 160)
//显示 0
|| vga_x >= 1 && vga_x <= 6 && ( vga_y == 234 || vga_y == 244 ) ||
vga_y >= 234 && vga_y <= 244 && ( vga_x == 1 || vga_x == 6 )
//显示电压单位V 613--610 134-->11
|| vga_y >= 101 && vga_y <= 104 && ( vga_x == 620 || vga_x == 624 )
|| vga_y >= 105 && vga_y <= 108 && ( vga_x == 621 || vga_x == 623 )
|| vga_y >= 109 && vga_y <= 111 && ( vga_x == 622 )
//显示 1 or 0.1 V/div
||vga_y >= 1 && vga_y <= 11 && ( vga_x == 15 )//1
|| vga_y >= 1 && vga_y <= 4 && ( vga_x == 19 || vga_x == 23 )
|| vga_y >= 5 && vga_y <= 8 && ( vga_x == 20 || vga_x == 22 )
|| vga_y >= 9 && vga_y <= 11 && ( vga_x == 21 )//V
|| vga_y >= 10 && vga_y <= 11 && vga_x == 25
|| vga_y >= 8 && vga_y <= 9 && vga_x == 26
|| vga_y >= 6 && vga_y <= 7 && vga_x == 27
|| vga_y >= 4 && vga_y <= 5 && vga_x == 28
|| vga_y >= 2 && vga_y <= 3 && vga_x == 29 // /
|| vga_y >= 4 && vga_y <= 6 && ( vga_x == 40 || vga_x == 44 )
|| vga_y >= 7 && vga_y <= 9 && ( vga_x == 41 || vga_x == 43 )
|| vga_y >= 10 && vga_y <= 11 && ( vga_x == 42 )//v
|| vga_y >= 4 && vga_y <= 11 && vga_x == 38
|| vga_y >= 1 && vga_y <= 2 && vga_x == 38
|| vga_y == 4 && vga_x >= 36 && vga_x <= 37 //i
|| vga_y >= 1 && vga_y <= 11 && vga_x == 34
|| vga_y >= 5 && vga_y <= 10 && vga_x == 30
||( vga_y == 4 || vga_y == 11 ) && vga_x >= 31 && vga_x <= 32
||( vga_y == 5 || vga_y == 10 ) && vga_x == 33 //d
//显示 时间 100us 20ms /div 2
||( (vga_y == 468 || vga_y == 469) || vga_y == 474 ) && vga_x == 539
|| (vga_y == 467 || vga_y == 475 ) &&( vga_x >= 540 && vga_x <= 542 )//458--443
|| vga_y == 470 && ( vga_x >= 540 && vga_x <= 541 )//s
|| vga_y == 471 && vga_x == 542
||( (vga_y == 468 || vga_y == 472) || vga_y == 473 || vga_y == 474 ) && vga_x == 543//s
|| vga_y >= 468 && vga_y <= 470 && ( vga_x == 560 || vga_x == 564 )
|| vga_y >= 471 && vga_y <= 473 && ( vga_x == 561 || vga_x == 563 )
|| vga_y >= 474 && vga_y <= 475 && ( vga_x == 562 )//v
|| vga_y >= 468 && vga_y <= 475 && vga_x == 558
|| vga_y >= 465 && vga_y <= 466 && vga_x == 558
|| vga_y == 468 && vga_x >= 556 && vga_x <= 557 //i
|| vga_y >= 465 && vga_y <= 475 && vga_x == 554
|| vga_y >= 469 && vga_y <= 474 && vga_x == 550
||( vga_y == 468 || vga_y == 475 ) && vga_x >= 551 && vga_x <= 552
||( vga_y == 469 || vga_y == 474 ) && vga_x == 553 //d
|| vga_y >= 474 && vga_y <= 475 && vga_x == 545
|| vga_y >= 472 && vga_y <= 473 && vga_x == 546
|| vga_y >= 470 && vga_y <= 471 && vga_x == 547
|| vga_y >= 468 && vga_y <= 469 && vga_x == 548
|| vga_y >= 466 && vga_y <= 467 && vga_x == 549 // /
)?1'b1 : 1'b0;
//---------------数字去摸区---------------------
assign temp_x = vga_x - position_X;
assign temp_y = vga_y - position_Y;
assign num0 = ( temp_x >= 1 && temp_x <= 6 && ( temp_y == 1 || temp_y == 11 ) ||
temp_y >= 1 && temp_y <= 11 && ( temp_x == 1 || temp_x == 6 )
) ?1'b1 : 1'b0;
assign num1 = ( temp_y >= 1 && temp_y <= 11 && ( temp_x == 6 )
) ?1'b1 : 1'b0;
assign num2 = ( temp_x >= 1 && temp_x <= 6 && ( temp_y == 1 || temp_y == 6 || temp_y == 11 ) ||
temp_y >= 6 && temp_y <= 11 && ( temp_x == 1 )||
temp_y >= 1 && temp_y <= 5 && ( temp_x == 6 )
) ?1'b1 : 1'b0;
assign num3 = ( temp_x >= 1 && temp_x <= 6 && ( temp_y == 1 || temp_y == 6 || temp_y == 11 ) ||
temp_y >= 1 && temp_y <= 11 && ( temp_x == 6 )
) ?1'b1 : 1'b0;
assign num4 = ( temp_x >= 1 && temp_x <= 6 && ( temp_y == 6 ) ||
temp_y >= 1 && temp_y <= 11 && ( temp_x == 6 ) ||
temp_y >= 1 && temp_y <= 6 && ( temp_x == 1 )
) ?1'b1 : 1'b0;
assign num5 = ( temp_x >= 1 && temp_x <= 6 && ( temp_y == 1 || temp_y == 6 || temp_y == 11 ) ||
temp_y >= 6 && temp_y <= 11 && ( temp_x == 6 )||
temp_y >= 1 && temp_y <= 5 && ( temp_x == 1 )
) ?1'b1 : 1'b0;
assign num6 = ( temp_x >= 1 && temp_x <= 6 && ( temp_y == 1 || temp_y == 6 || temp_y == 11 ) ||
temp_y >= 6 && temp_y <= 11 && ( temp_x == 6 )||
temp_y >= 1 && temp_y <= 11 && ( temp_x == 1 )
) ?1'b1 : 1'b0;
assign num7 = ( temp_x >= 1 && temp_x <= 6 && ( temp_y == 1 ) ||
temp_y >= 1 && temp_y <= 11 && ( temp_x == 6 )
) ?1'b1 : 1'b0;
assign num8 = ( temp_x >= 1 && temp_x <= 6 && ( temp_y == 1 || temp_y == 6 || temp_y == 11 ) ||
temp_y >= 1 && temp_y <= 11 && ( temp_x == 1 || temp_x == 6 )
) ?1'b1 : 1'b0;
assign num9 = ( temp_x >= 1 && temp_x <= 6 && ( temp_y == 1 || temp_y == 6 || temp_y == 11 ) ||
temp_y >= 1 && temp_y <= 6 && ( temp_x == 1 )||
temp_y >= 1 && temp_y <= 11 && ( temp_x == 6 )
) ?1'b1 : 1'b0;
//
//-----------------------------------------------
// 显示逻辑程序
always@(posedge clk_25M or posedge vga_rst_n)
begin
if(vga_rst_n)
color_data <= 24'H0;
// ------------波形显示区-------------------------------------
else if(area1)
if(vga_y == i_temp)
color_data <= `RED;
else if(area0)
color_data<= `BLACK; //格线
else
color_data <= 24'H606060; //内背景
//-------------电压幅值数值显示区-------------------------------------
else if(vga_x >= 581 && vga_x <= 588 && vga_y >=100 && vga_y <= 111 ) //幅值第一位数
begin
position_X <= 581;
position_Y <= 100;
case( v_num_data[11:8] )
4'd0: if(num0) color_data <= `BLACK; else color_data <= `WHITE;
4'd1: if(num1) color_data <= `BLACK; else color_data <= `WHITE;
4'd2: if(num2) color_data <= `BLACK; else color_data <= `WHITE;
4'd3: if(num3) color_data <= `BLACK; else color_data <= `WHITE;
4'd4: if(num4) color_data <= `BLACK; else color_data <= `WHITE;
4'd5: if(num5) color_data <= `BLACK; else color_data <= `WHITE;
4'd6: if(num6) color_data <= `BLACK; else color_data <= `WHITE;
4'd7: if(num7) color_data <= `BLACK; else color_data <= `WHITE;
4'd8: if(num8) color_data <= `BLACK; else color_data <= `WHITE;
4'd9: if(num9) color_data <= `BLACK; else color_data <= `WHITE;
default: color_data <= `WHITE;//
endcase
end
else if(vga_x >= 589 && vga_x <= 590 && vga_y >= 111 && vga_y <= 112)//小数点
color_data<= `BLACK;
else if(vga_x >= 591 && vga_x <= 598 && vga_y >=100 && vga_y <= 111 ) //幅值第二位数
begin
position_X <= 591;
position_Y <= 100;
case(v_num_data[7:4] )
4'd0: if(num0) color_data <= `BLACK; else color_data <= `WHITE;
4'd1: if(num1) color_data <= `BLACK; else color_data <= `WHITE;
4'd2: if(num2) color_data <= `BLACK; else color_data <= `WHITE;
4'd3: if(num3) color_data <= `BLACK; else color_data <= `WHITE;
4'd4: if(num4) color_data <= `BLACK; else color_data <= `WHITE;
4'd5: if(num5) color_data <= `BLACK; else color_data <= `WHITE;
4'd6: if(num6) color_data <= `BLACK; else color_data <= `WHITE;
4'd7: if(num7) color_data <= `BLACK; else color_data <= `WHITE;
4'd8: if(num8) color_data <= `BLACK; else color_data <= `WHITE;
4'd9: if(num9) color_data <= `BLACK; else color_data <= `WHITE;
default: color_data <= `WHITE;//
endcase
end
else if(vga_x >= 599 && vga_x <= 606 && vga_y >=100 && vga_y <= 111 ) //幅值第三位数
begin
position_X <= 599;
position_Y <= 100;
case(v_num_data[3:0])
4'd0: if(num0) color_data <= `BLACK; else color_data <= `WHITE;
4'd1: if(num1) color_data <= `BLACK; else color_data <= `WHITE;
4'd2: if(num2) color_data <= `BLACK; else color_data <= `WHITE;
4'd3: if(num3) color_data <= `BLACK; else color_data <= `WHITE;
4'd4: if(num4) color_data <= `BLACK; else color_data <= `WHITE;
4'd5: if(num5) color_data <= `BLACK; else color_data <= `WHITE;
4'd6: if(num6) color_data <= `BLACK; else color_data <= `WHITE;
4'd7: if(num7) color_data <= `BLACK; else color_data <= `WHITE;
4'd8: if(num8) color_data <= `BLACK; else color_data <= `WHITE;
4'd9: if(num9) color_data <= `BLACK; else color_data <= `WHITE;
default: color_data <= `WHITE;//
endcase
end
//----------------频率显示区------------------------
//---------------频率前三位+小数点+‘k’(判断显示)----------------------
else if(vga_x >= 565 && vga_x <= 572 && vga_y >=150 && vga_y <= 161 ) //频率第1位数
if(f_num_data[23:12] > 0 )
begin
position_X <= 565;
position_Y <= 150;
case(f_num_data[23 :20])
4'd0: if(num0) color_data <= `BLACK; else color_data <= `WHITE;
4'd1: if(num1) color_data <= `BLACK; else color_data <= `WHITE;
4'd2: if(num2) color_data <= `BLACK; else color_data <= `WHITE;
4'd3: if(num3) color_data <= `BLACK; else color_data <= `WHITE;
4'd4: if(num4) color_data <= `BLACK; else color_data <= `WHITE;
4'd5: if(num5) color_data <= `BLACK; else color_data <= `WHITE;
4'd6: if(num6) color_data <= `BLACK; else color_data <= `WHITE;
4'd7: if(num7) color_data <= `BLACK; else color_data <= `WHITE;
4'd8: if(num8) color_data <= `BLACK; else color_data <= `WHITE;
4'd9: if(num9) color_data <= `BLACK; else color_data <= `WHITE;
default: color_data <= `WHITE;//
endcase
end
else
color_data <= `WHITE;
else if(vga_x >= 573 && vga_x <= 580 && vga_y >=150 && vga_y <= 161 ) //频率第2位数
if(f_num_data[23:12] > 0 )
begin
position_X <= 573;
position_Y <= 150;
case(f_num_data[19 :16])
4'd0: if(num0) color_data <= `BLACK; else color_data <= `WHITE;
4'd1: if(num1) color_data <= `BLACK; else color_data <= `WHITE;
4'd2: if(num2) color_data <= `BLACK; else color_data <= `WHITE;
4'd3: if(num3) color_data <= `BLACK; else color_data <= `WHITE;
4'd4: if(num4) color_data <= `BLACK; else color_data <= `WHITE;
4'd5: if(num5) color_data <= `BLACK; else color_data <= `WHITE;
4'd6: if(num6) color_data <= `BLACK; else color_data <= `WHITE;
4'd7: if(num7) color_data <= `BLACK; else color_data <= `WHITE;
4'd8: if(num8) color_data <= `BLACK; else color_data <= `WHITE;
4'd9: if(num9) color_data <= `BLACK; else color_data <= `WHITE;
default: color_data <= `WHITE;//
endcase
end
else
color_data <= `WHITE;
else if(vga_x >= 581 && vga_x <= 588 && vga_y >=150 && vga_y <= 161 ) //频率第3位数
if(f_num_data[23:12] > 0 )
begin
position_X <= 581;
position_Y <= 150;
case(f_num_data[15 :12])
4'd0: if(num0) color_data <= `BLACK; else color_data <= `WHITE;
4'd1: if(num1) color_data <= `BLACK; else color_data <= `WHITE;
4'd2: if(num2) color_data <= `BLACK; else color_data <= `WHITE;
4'd3: if(num3) color_data <= `BLACK; else color_data <= `WHITE;
4'd4: if(num4) color_data <= `BLACK; else color_data <= `WHITE;
4'd5: if(num5) color_data <= `BLACK; else color_data <= `WHITE;
4'd6: if(num6) color_data <= `BLACK; else color_data <= `WHITE;
4'd7: if(num7) color_data <= `BLACK; else color_data <= `WHITE;
4'd8: if(num8) color_data <= `BLACK; else color_data <= `WHITE;
4'd9: if(num9) color_data <= `BLACK; else color_data <= `WHITE;
default: color_data <= `WHITE;//
endcase
end
else
color_data <= `WHITE;
else if(vga_x >= 589 &&vga_x <= 590 && vga_y >= 161 && vga_y <= 162)// 频率数值小数点,34位之间
if(f_num_data[23:12] > 0 ) color_data<= `BLACK; else color_data <= `WHITE;
else if(area_k)// 频率单位‘k’
if(f_num_data[23:12] > 0 ) color_data<= `BLACK; else color_data <= `WHITE;
//------------------频率后三位(一直显示)----------------
else if(vga_x >= 591 && vga_x <= 598 && vga_y >=150 && vga_y <= 161 ) //频率第4位数
begin
position_X <= 591;
position_Y <= 150;
case( f_num_data[11:8] )
4'd0: if(num0) color_data <= `BLACK; else color_data <= `WHITE;
4'd1: if(num1) color_data <= `BLACK; else color_data <= `WHITE;
4'd2: if(num2) color_data <= `BLACK; else color_data <= `WHITE;
4'd3: if(num3) color_data <= `BLACK; else color_data <= `WHITE;
4'd4: if(num4) color_data <= `BLACK; else color_data <= `WHITE;
4'd5: if(num5) color_data <= `BLACK; else color_data <= `WHITE;
4'd6: if(num6) color_data <= `BLACK; else color_data <= `WHITE;
4'd7: if(num7) color_data <= `BLACK; else color_data <= `WHITE;
4'd8: if(num8) color_data <= `BLACK; else color_data <= `WHITE;
4'd9: if(num9) color_data <= `BLACK; else color_data <= `WHITE;
default: color_data <= `WHITE;//
endcase
end
else if(vga_x >= 599 && vga_x <= 606 && vga_y >=150 && vga_y <= 161 ) //频率第5位数
begin
position_X <= 599;
position_Y <= 150;
case( f_num_data[7:4] )
4'd0: if(num0) color_data <= `BLACK; else color_data <= `WHITE;
4'd1: if(num1) color_data <= `BLACK; else color_data <= `WHITE;
4'd2: if(num2) color_data <= `BLACK; else color_data <= `WHITE;
4'd3: if(num3) color_data <= `BLACK; else color_data <= `WHITE;
4'd4: if(num4) color_data <= `BLACK; else color_data <= `WHITE;
4'd5: if(num5) color_data <= `BLACK; else color_data <= `WHITE;
4'd6: if(num6) color_data <= `BLACK; else color_data <= `WHITE;
4'd7: if(num7) color_data <= `BLACK; else color_data <= `WHITE;
4'd8: if(num8) color_data <= `BLACK; else color_data <= `WHITE;
4'd9: if(num9) color_data <= `BLACK; else color_data <= `WHITE;
default: color_data <= `WHITE;//
endcase
end
else if(vga_x >= 607 && vga_x <= 614 && vga_y >=150 && vga_y <= 161 ) //频率第6位数
begin
position_X <= 607;
position_Y <= 150;
case( f_num_data[3:0] )
4'd0: if(num0) color_data <= `BLACK; else color_data <= `WHITE;
4'd1: if(num1) color_data <= `BLACK; else color_data <= `WHITE;
4'd2: if(num2) color_data <= `BLACK; else color_data <= `WHITE;
4'd3: if(num3) color_data <= `BLACK; else color_data <= `WHITE;
4'd4: if(num4) color_data <= `BLACK; else color_data <= `WHITE;
4'd5: if(num5) color_data <= `BLACK; else color_data <= `WHITE;
4'd6: if(num6) color_data <= `BLACK; else color_data <= `WHITE;
4'd7: if(num7) color_data <= `BLACK; else color_data <= `WHITE;
4'd8: if(num8) color_data <= `BLACK; else color_data <= `WHITE;
4'd9: if(num9) color_data <= `BLACK; else color_data <= `WHITE;
default: color_data <= `WHITE;//
endcase
end
//----------1&0.1V切换
else if(vga_x >= 1 && vga_x <= 8 && vga_y >=0 && vga_y <= 12 ) //
begin
position_X <= 1;
position_Y <= 0;
if(V_div_select)
if(num0) color_data <= `BLACK;
else color_data <= `WHITE;
end
else if(vga_x>=9 && vga_x <= 10 && vga_y >= 10 && vga_y <= 11) //
if(V_div_select) color_data <= `BLACK;
else color_data <= `WHITE;
//-----------100us&10ns切换--------
else if(vga_x >= 523 && vga_x <= 530 && vga_y >=466 && vga_y <= 477 ) //最低位
begin
position_X <= 523;
position_Y <= 466;
if(num0) color_data <= `BLACK; else color_data <= `WHITE;
end
else if(vga_x >= 515 && vga_x <= 522 && vga_y >=466 && vga_y <= 477 ) //第二位
begin
position_X <= 515;
position_Y <= 466;
if(~f_div_select)
begin
if(num0) color_data <= `BLACK; else color_data <= `WHITE;
end
else
begin
if(num2) color_data <= `BLACK; else color_data <= `WHITE;
end
end
else if(vga_x >= 507 && vga_x <= 514 && vga_y >=466 && vga_y <= 477 ) //
begin
position_X <= 507;
position_Y <= 466;
if(~f_div_select)
if(num1) color_data <= `BLACK;
else color_data <= `WHITE;
end
//------------ 固定字符显示区------------------
else if(area3)
color_data <= `BLACK;
//-------------背景色------------------
else
if(~f_div_select)
if(area_u) color_data <= `BLACK; else color_data <= `WHITE;//背景灰色
else
if(area_m) color_data <= `BLACK; else color_data <= `WHITE;//背景灰色
end
endmodule