|
才开始学怎么用vivado调用coe文件使用VGA显示图片
但是遇到了一点麻烦的问题,困惑了我好久,希望各位大神能为我提供一下解决方案,谢谢
首先原图是这样子的
然后显示出来的图片却是这样的
这图片让我困惑的地方有几点
一、为什么显示屏顶部不是蓝色的?图片的底色为什么不是白色的?
二、为什么显示出来的图片会有种向右移动了的现象
真的代码不知道看了多少遍了,感觉没问题一样,错是肯定有错的,但是实在不知道错在哪,难受
- 顶层模块
- module module_vga (
- sys_clk , rst ,
- VSYNC_Sig , HSYNC_Sig ,
- Red_Sig , Green_Sig , Blue_Sig
- );
- input sys_clk;
- input rst;
- output VSYNC_Sig;
- output HSYNC_Sig;
- output Red_Sig;
- output Green_Sig;
- output Blue_Sig;
-
- wire clk;
- module_vga_clk V1
- (
- .sys_clk(sys_clk),
- .rst(rst),
- .clk(clk)
- );
-
- wire [10:0] Column_Addr_Sig;
- wire [10:0] Row_Addr_Sig;
- wire En;
-
- module_vga_sync V2
- (
- .clk(clk),
- .rst(rst),
- .VSYNC_Sig(VSYNC_Sig),
- .HSYNC_Sig(HSYNC_Sig),
- .Column_Addr_Sig(Column_Addr_Sig),
- .Row_Addr_Sig(Row_Addr_Sig),
- .En_Sig(En)
- );
-
- wire Rom_Data;
- wire [16:0] Rom_Addr;
-
- module_vga_control V3
- (
- .clk(clk),
- .rst(rst),
- .En_Sig(En),
- .Column_Addr_Sig(Column_Addr_Sig),
- .Row_Addr_Sig(Row_Addr_Sig),
- .Rom_Addr(Rom_Addr),
- .Rom_Data(Rom_Data),
- .Red_Sig(Red_Sig),
- .Green_Sig(Green_Sig),
- .Blue_Sig(Blue_Sig)
- );
- vga_rom your_instance_name (
- .clka(clk), // input wire clka
- .addra(Rom_Addr), // input wire [16 : 0] addra
- .douta(Rom_Data) // output wire [0 : 0] douta
- );
- endmodule
- 50M时钟模块
- module module_vga_clk(sys_clk , clk , rst);
- input sys_clk;
- input rst;
- output clk;
-
- reg clk_buff;
-
- always @(posedge sys_clk or negedge rst) begin
- if(!rst) begin
- clk_buff <= 1'b0;
- end
- else
- clk_buff <= ~clk_buff;
- end
-
- assign clk = clk_buff;
-
- endmodule
- VGA扫描模块
- module module_vga_sync (
- rst , clk ,
- VSYNC_Sig , HSYNC_Sig , En_Sig ,
- Column_Addr_Sig , Row_Addr_Sig
- );
- input rst;
- input clk;
- output VSYNC_Sig;
- output HSYNC_Sig;
- output En_Sig;
- output [10:0] Column_Addr_Sig;
- output [10:0] Row_Addr_Sig;
-
- parameter Column_Max = 11'd1040;
- parameter Column_Min = 11'd240;
- parameter Row_Max = 11'd624;
- parameter Row_Min = 11'd24;
-
- reg [10:0] Count_H;
- always @(posedge clk or negedge rst)
- if (!rst)
- 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 rst)
- if (!rst)
- Count_V <= 11'd0;
- else
- if (Count_V == 11'd625)
- Count_V <= 11'd0;
- else if (Count_H == 11'd1056)
- Count_V <= Count_V + 1'b1;
-
- reg En;
- always @(posedge clk or negedge rst)
- if (!rst)
- En <= 1'b0;
- else
- if ((Count_H > Column_Min && Count_H < Column_Max) && (Count_V > Row_Min && Count_V < Row_Max))
- En <= 1'b1;
- else
- En <= 1'b0;
-
- assign VSYNC_Sig = (Count_V <= 11'd3) ? 1'b0 : 1'b1;
- assign HSYNC_Sig = (Count_H <= 11'd80) ? 1'b0 : 1'b1;
- assign En_Sig = En;
- assign Column_Addr_Sig = En ? Count_H - 11'd240 : 11'd0;
- assign Row_Addr_Sig = En ? Count_V - 11'd24 : 11'd0;
- endmodule
- VGA控制模块
- module module_vga_control(
- clk , rst ,
- En_Sig , Column_Addr_Sig , Row_Addr_Sig ,
- Rom_Data , Rom_Addr ,
- Red_Sig , Green_Sig , Blue_Sig
- );
- input rst;
- input clk;
- input En_Sig;
- input [10:0] Column_Addr_Sig;
- input [10:0] Row_Addr_Sig;
- input Rom_Data;
- output [16:0] Rom_Addr;
- output Red_Sig;
- output Green_Sig;
- output Blue_Sig;
-
- reg disp_en;
- always @(posedge clk or negedge rst) begin
- if(!rst) begin
- disp_en <= 1'b0;
- end
- else begin
- if(En_Sig && Row_Addr_Sig > 8'd200 && Row_Addr_Sig < 9'd484 && Column_Addr_Sig > 8'd200 && Column_Addr_Sig < 9'd435)
- disp_en <= 1'b1;
- else
- disp_en <= 1'b0;
- end
- end
-
- reg [16:0] m;
- always @(posedge clk or negedge rst) begin
- if (!rst) begin
- m <= 17'b0;
- end
- else begin
- if(disp_en)
- m <= m + 1'b1;
- else if(!disp_en && (Row_Addr_Sig == 9'd484 || Row_Addr_Sig == 8'd200))
- m <= 1'b0;
- end
- end
- assign Rom_Addr = m;
- assign Red_Sig = disp_en ? Rom_Data : 1'b1;
- assign Green_Sig = disp_en ? Rom_Data : 1'b1;
- assign Blue_Sig = disp_en ? Rom_Data : 1'b1;
- endmodule
复制代码 |
|