Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
16943 Discussions

VGA interface with cyclone v de1_soc 5CEM5

estif
Beginner
1,060 Views

i have this code that will take a hex file and display it through VGA but i want to change the code to use instead of hex to image ppm format how can i achieve that ?                                                                               here is the code:                                                                                                                                          

module vgaaaa( CLOCK_50, VGA_CLK, VGA_HS, VGA_VS, VGA_BLANK_N, VGA_SYNC_N, VGA_R, VGA_G, VGA_B
);
 
input CLOCK_50; // 50 MHz
output VGA_CLK;    // VGA Clock
output VGA_HS; // VGA H_SYNC
output VGA_VS; // VGA V_SYNC
output VGA_BLANK_N; // VGA BLANK
output VGA_SYNC_N; // VGA SYNC
output [7:0] VGA_R;    // VGA Red[9:0]
output [7:0] VGA_G; // VGA Green[9:0]
output [7:0] VGA_B;    // VGA Blue[9:0]
reg vga_clock=0;
wire [9:0] x;
wire [9:0] y;
 
always@(posedge CLOCK_50)begin
 
vga_clock<=~vga_clock;
 
end
 
vga_controller vga_controller_inst(
 
   .CLOCK_50(CLOCK_50),
.vga_clock(vga_clock),
.x(x), 
.y(y),
.VGA_R(VGA_R),
.VGA_G(VGA_G),
.VGA_B(VGA_B),
.VGA_HS(VGA_HS),
.VGA_VS(VGA_VS),
.VGA_BLANK(VGA_BLANK_N),
.VGA_SYNC(VGA_SYNC_N),
.VGA_CLK(VGA_CLK)
);
 
endmodule
                                                                                                                                                                                                                                                                                                                                                                      
module vga_controller( CLOCK_50, vga_clock, x, y, VGA_R, VGA_G, VGA_B, VGA_HS, VGA_VS, VGA_BLANK,
VGA_SYNC, VGA_CLK);
 
parameter C_VERT_NUM_PIXELS  = 10'd480;
parameter C_VERT_SYNC_START  = 10'd493;
parameter C_VERT_SYNC_END    = 10'd494; //(C_VERT_SYNC_START + 2 - 1); 
parameter C_VERT_TOTAL_COUNT = 10'd525;
parameter C_HORZ_NUM_PIXELS  = 10'd640;
parameter C_HORZ_SYNC_START  = 10'd659;
parameter C_HORZ_SYNC_END    = 10'd754; //(C_HORZ_SYNC_START + 96 - 1); 
parameter C_HORZ_TOTAL_COUNT = 10'd800;
 
 
 
 
 
input CLOCK_50;
input vga_clock;
output [9:0] x;
output [9:0] y;
output reg[7:0] VGA_R;
output reg[7:0] VGA_G;
output reg[7:0] VGA_B;
output reg VGA_HS;
output reg VGA_VS;
output reg VGA_BLANK;
output VGA_SYNC;
output VGA_CLK;
 
 
 
reg VGA_HS1;
reg VGA_VS1;
reg VGA_BLANK1; 
reg [9:0] xCounter=0;
reg [9:0] yCounter=0;
wire xCounter_clear;
wire yCounter_clear;
 
 
 
always @(posedge vga_clock)
begin
if (xCounter_clear)
xCounter <= 10'd0;
else
begin
xCounter <= xCounter + 1'b1;
end
end
assign xCounter_clear = (xCounter == (C_HORZ_TOTAL_COUNT-1));
 
 
 
always @(posedge vga_clock)
begin
if (xCounter_clear && yCounter_clear)
yCounter <= 10'd0;
else if (xCounter_clear) //Increment when x counter resets
yCounter <= yCounter + 1'b1;
end
 
assign yCounter_clear = (yCounter == (C_VERT_TOTAL_COUNT-1)); 
assign x = xCounter;
assign y = yCounter;
 
 
 
always @(posedge vga_clock)
begin
VGA_HS1 <= ~((xCounter >= C_HORZ_SYNC_START) && (xCounter <= C_HORZ_SYNC_END));
VGA_VS1 <= ~((yCounter >= C_VERT_SYNC_START) && (yCounter <= C_VERT_SYNC_END));
VGA_BLANK1 <= ((xCounter < C_HORZ_NUM_PIXELS) && (yCounter < C_VERT_NUM_PIXELS));
 
//DELAY//
VGA_HS <= VGA_HS1;
VGA_VS <= VGA_VS1;
VGA_BLANK <= VGA_BLANK1;
 
end
 
 
 
/* VGA sync should be 1 at all times. */
 
assign VGA_SYNC = 1'b1;
 
 
 
/* Generate the VGA clock signal. */
 
assign VGA_CLK = vga_clock;
reg [7:0] rom[0:80000];
reg signed [10:0]X = 10'd400;
reg signed [10:0]Y = 10'd300;
wire [16:0] FUNC;
   assign FUNC = y*240+x;
  reg [7:0] Q1
 
initial
    begin
        $readmemh("image.hex", rom);
    end
always @ (posedge CLOCK_50)
begin
        Q1<=rom[FUNC]
end
 
 
    always @ (posedge CLOCK_50)
    begin
 
if ( x<240 && y<320)
begin
 
      VGA_R<= Q1;
VGA_G<= Q1;
VGA_B<= Q1;
    end
 
end
 
 
endmodule

I really appreciate your support

 

0 Kudos
3 Replies
ZH_Intel
Employee
983 Views

Hi Estif,

 

Thank you for reaching out.

At the moment, Intel does not provide any VGA solution.

However you may refer to the example design in the below link for your reference:

Terasic - DE1-SoC-MTL2 landing page 

 

Thank you. 

Best Regards,

ZulsyafiqH_Intel

 

0 Kudos
ZH_Intel
Employee
962 Views

Hi Estif,

 

Good day.

I wish to follow up with you about this case.

Do you still have further inquiries?

Is there anything else I can help you with regards to this case?

Otherwise, the community users will continue to help you on this thread


Thank you.

Best Regards,

ZulsyafiqH_Intel


0 Kudos
ZH_Intel
Employee
896 Views

Hi Estif,

 

Good day.

We do not receive any response from you to the previous reply that I have provided. 

This thread will be transitioned to community support. If you have a new question, feel free to open a new thread to get the support from Intel experts. Otherwise, the community users will continue to help you on this thread.


Thank you.

Best Regards,

ZulsyafiqH_Intel


0 Kudos
Reply