# Verilog Display module

by Drao92
Tags: display, module, verilog
 P: 72 Hello, I have to make a Display module in verilog and first time i want to create a ball which is moving and i have a question, the vertial/horizontal synchronization module is done, the question is about displaying the image using RGB. So, i use 640x480 display and 25Mhz clock frequency and first time when i created the module i didnt took in consideration that the fpga displays 60 frames in 1.15 second and i wrote somthing like move evreytime when x=? and y=? with 2px and then i realised that i wouldnt be able to see the image because it will be moving too fast. Aint i am right??? I was thinking to implement a counter which counts the number of frames and makes the ball to move every 20, 30, 40 frames. So first of all i want to ask if it is right what i am saying and in this case what is the best delay to chose? Also, i will have acces to the the FPGA to test the modules in a few days, i dont know whats happening in reality :D. I only simulated the HV signals in modelsim and they look good.
 P: 72 I want to ask 1 more thing. What is happening if i dont give a specific value to a pixel? its black by default? For exemple: if(x>30&&x<80&&y>30&&y<50) begin R=3b111; G=3b000; B=2b00; end The pixels of the specified area in if statement will be red, but what is happening with the others? Do i have to make an else and to give them a color or its automatically black?
 P: 72 I will display the code. It makes me crazy, it works like a paranormal thing :D. The problem is the following. In RGB module in the always block if i say red<=x value, green <=y value etc it doesnt display anything, i must use an if-else statement to display anything. With the current code from RGB it displays a black rectangler for the positions posx<=60, posy<=100 only what is above posy=100 is magenta, the rest of the screen is black. So in this case if i combine green with red or blue, green it doesnt work. On the other hand, if i dont combine green with anything, it displays the right colors, but in the same way, with an if-else statement and anything below posy is black. meBigGuy thanks for trying to help me. As i said above, i cant display any color without if-else. If i must use if posx<=639 && posy<=479 --- give values to red,green,blue else give other values to red green blue. If i dont use the else it doesnt display any color, if i use if-else it displays the colors from if statements and the colors which must be displayed in else arent displayed below the value of posy from if.... I cant understand what is the reason of this. module VGASync( input clock, output reg HS, output reg VS, output reg [9:0] posx, output reg [9:0] posy); parameter hsync_width=799; parameter hsync_fall=655; //pozitia unde se termina front porch sau unde semnalul devin 0 parameter hsync_rise=751; //pozitia unde incepe back porch sau unde semnalul revine la 1 parameter vsync_width=524; parameter vsync_fall=490; //pozitia unde se termina front porch sau unde semnalul devin 0 parameter vsync_rise=492; //pozitia unde incepe back porch sau unde semnalul revine la 1 always @(posedge clock) begin if(posx >= hsync_fall && posx < hsync_rise) begin HS=0; end else begin HS=1; end if(posy >= vsync_fall && posy < vsync_rise) begin VS=0; end else begin VS=1; end if (posx < hsync_width) begin posx<=posx+1; end else begin posx<=0; if(posy < vsync_width) begin posy<=posy+1; end else begin posy<=0; end end end endmodule module RGB( input clock, input [9:0] posx, input [9:0] posy, output reg [2:0] red, output reg [2:0] green, output reg [1:0] blue ); reg [6:0] size=0; always @(posedge clock)begin if(posx<=60&&posy<=100) begin red<=3'b000; green<=3'b111; blue<=2'b00; end else begin blue<=2'b11; red<=3'b111; green<=3'b111; end end endmodule module clock( input clk50, output clk25 ); reg clk25_int; always @(posedge clk50) begin clk25_int<=~clk25_int; end BUFG buffer(.I(clk25_int),.O(clk25)); endmodule module testop( input clk50, output HS, output VS, output [2:0] red, output [2:0] green, output [1:0] blue ); wire clk25; wire [9:0] posx; wire [9:0] posy; clock clock_inst(.clk50(clk50), .clk25(clk25)); VGASync VGASync_inst(.clock(clk25), .HS(HS), .VS(VS), .posx(posx), .posy(posy)); RGB RGB_inst(.clock(clk25), .posx(posx), .posy(posy), .red(red), .green(green), .blue(blue)); endmodule