Altera_Forum
Honored Contributor
12 years agoAltera UP2, VGA, load image problem
Hi,
I want to display my image using Altera up2. I wrote code (below). I converted png file to txt file, which contains bit representation of RGB. When the image is small (128x128) it is ok but when the image is big( 640x480), the compilation doesn't end. Time compilation is growing and growin. What can i do to load 640x480 image and display it? Thanks
module vga(input clk, output hSync, output vSync, output r, output g, output b);
reg CounterX;
reg CounterY;
reg Counter40;
reg address;
reg address2;
always @(posedge clk)
if(CounterX==800)
CounterX <= 0;
else
CounterX <= CounterX + 1;
always @(posedge clk)
if(CounterX==800)
CounterY <= CounterY + 1;
else if(CounterY==525)
CounterY <= 0;
always @(posedge clk)
if(CounterX < 640 & CounterY < 480 )
begin
if(Counter40==40)
begin
Counter40 <= 0;
address2 <= 0;
address <= address + 1;
end
else
Counter40 <= Counter40 + 1;
end
reg vga_HS, vga_VS;
always @(posedge clk)
begin
vga_HS <= (CounterX>=656 & CounterX<752);
vga_VS <= (CounterY>=490 & CounterY<=492);
end
assign hSync = ~vga_HS;
assign vSync = ~vga_VS;
reg data ;
initial $readmemb("test.txt", data);
assign r = (CounterX < 640 & CounterY < 480 ) ? data : 0;
assign g = (CounterX < 640 & CounterY < 480 ) ? data : 0;
assign b = (CounterX < 640 & CounterY < 480 ) ? data : 0;
endmodule