|
本帖最后由 seu_zc 于 2016-10-14 21:13 编辑
VGA时序图:
显示模式:
那么对于800x600x60hz的显示模式,显示图片的时间应该是下图所示: 说明:U1是锁相环来实现频率转换,U2是同步模块设置显示模式,U3是显示控制模块 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
问题描述:
1、如果我按照上面原理设置的话,代码如下
- always @(posedge CLK or negedge RSTn)//定义显示图片的时间
- if(!RSTn)
- isReady <= 1'b0;
- else if((Count_H > 11'd216 && Count_H <11'd1017) && (Count_V > 11'd27 && Count_V <
- 11'd628))
- isReady <= 1'b1;
- elseA
- isReady <= 1'b0;
复制代码 没有下载程序时这一块是有显示的,说明屏幕应该没问题:
显示出来是这样的,左边红框内应该显示的但没显示出来:
后来我将上面的设置修改了一下,行时序直接从同步段开始,也就是Count_H > 11'd128,结果是右边少了一小块:
下面贴出完整代码(我参照低级建模上面的代码修改的):
###同步代码
- /**
- *同步模块
- */
- module sync_module(
- CLK,RSTn,
- VSYNC_Sig,HSYNC_Sig,Ready_Sig,
- Column_Addr_Sig,Row_Addr_Sig
- );
- input CLK;
- input RSTn;
- output VSYNC_Sig;
- output HSYNC_Sig;
- output Ready_Sig;
- output [10:0] Column_Addr_Sig;
- output [10:0] Row_Addr_Sig;
- /************************************************/
- reg [10:0] Count_H;
- always @ (posedge CLK or negedge RSTn)
- if(!RSTn)
- Count_H <= 11'd0;
- else if(Count_H == 11'd1056)
- Count_H <= 11'd0;
- else
- Count_H <= Count_H + 1'b1;
- /************************************************/
- reg [10:0]Count_V;
- always @(posedge CLK or negedge RSTn)
- if(!RSTn)
- Count_V <= 11'd0;
- else if(Count_V == 11'd628)
- Count_V <= 11'd0;
- else if(Count_H == 11'd1056)
- Count_V <= Count_V + 1'b1;//&&&&
- reg isReady;
- always @(posedge CLK or negedge RSTn)//定义显示图片的时间
- if(!RSTn)
- isReady <= 1'b0;
- else if((Count_H > 11'd216 && Count_H < 11'd1017) && (Count_V > 11'd27 && Count_V <
- 11'd628))
- isReady <= 1'b1;
- else
- isReady <= 1'b0;
- /************************************************/
- assign VSYNC_Sig = (Count_V <= 11'd4)?1'b0:1'b1;//同步段为低电平,其他三段为高点平,行信号输出
- assign HSYNC_Sig = (Count_H <= 11'd128)?1'b0:1'b1;//同步段为低电平,其他三段为高点平,列信号输出
- assign Ready_Sig = isReady;//信号准备完毕标志输出
- /************************************************/
- assign Column_Addr_Sig = isReady?Count_H-11'd217:11'd0;//列地址信号输出,从0开始
- assign Row_Addr_Sig = isReady?Count_V-11'd28:11'd0;//行地址信号输出,从0开始
- /************************************************/
- endmodule
复制代码
###显示控制代码
- module vga_control_module_nine(
- CLK, RSTn,
- Ready_Sig, Column_Addr_Sig, Row_Addr_Sig,
- Pix
- );
- input CLK;
- input RSTn;
- input Ready_Sig;
- input [10:0]Column_Addr_Sig;//800列地址
- input [10:0]Row_Addr_Sig;//600行地址
- output [15:0] Pix;
-
- /************************************************************/
- parameter RED = 16'hF800;
- parameter GREEN = 16'h07e0;
- parameter BLUE = 16'h001f;
- parameter YELLOW = 16'hFFE0;
- parameter CYAN = 16'h07FF;
- parameter BLACK = 16'h0000;
- parameter WHITE = 16'hFFFF;
- /************************************************************/
- reg [15:0] PColor;
- always @(posedge CLK or negedge RSTn)
- begin
- if(!RSTn)
- PColor <= 16'd0;
- else if(( Column_Addr_Sig>0) && ( Column_Addr_Sig<800))
- begin
- if((Row_Addr_Sig>0) && (Row_Addr_Sig<100))
- PColor <= RED;
- else if((Row_Addr_Sig>101) && (Row_Addr_Sig<200))
- PColor <= GREEN;
- else if((Row_Addr_Sig>201) && (Row_Addr_Sig<300))
- PColor <= BLUE;
- else if((Row_Addr_Sig>301) && (Row_Addr_Sig<400))
- PColor <= YELLOW;
- else if((Row_Addr_Sig>401) && (Row_Addr_Sig<500))
- PColor <= CYAN;
- else if(Row_Addr_Sig >501)
- PColor <= RED;
- end
- else
- PColor <= BLACK;
- end
- assign Pix = PColor;
-
- endmodule
复制代码
|
|