djh82uk
Newbie level 5
- Joined
- Feb 16, 2021
- Messages
- 8
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 108
module vga (clk50, v_sync, h_sync, red_signal,green_signal,blue_signal, video_en);
input clk50;
reg [10:0]h_cnt;
reg [10:0]v_cnt;
output reg h_sync;
output reg v_sync;
output reg red_signal;
output reg green_signal;
output reg blue_signal;
output video_en;
reg horizontal_en;
reg vertical_en;
always @(posedge clk50)
begin
//--Reset Horizontal Counter
if (h_cnt == 11'b010000001111)
h_cnt <= 11'b000000000000;
else
h_cnt <= h_cnt + 1;
end
always @(posedge clk50)
begin
//--Vertical Sync
//--Reset Vertical Counter
if (v_cnt >= 11'b001010011001 && h_cnt >= 11'b010000001111)
v_cnt <= 11'b000000000000;
else if (h_cnt == 11'b010000001111)
v_cnt <= v_cnt + 1;
end
always @(posedge clk50)
if (v_cnt >= 11'b000000000000 && v_cnt <= 11'b01100011111) begin
red_signal <= 1'b1;
green_signal <= 1'b0;
blue_signal <= 1'b0;
end
always @(posedge clk50)
begin
if (h_cnt <= 11'b01111001111 && h_cnt >= 11'b01101010111)
h_sync <= 0;
else
h_sync <= 1;
end
//--Generate Vertical Sync
always @(posedge clk50)
begin
if (v_cnt <= 11'b01010000010 && v_cnt >= 11'b01001111100)
v_sync <= 0;
else
v_sync <= 1;
end
always @(posedge clk50)
begin
//--Generate Horizontal Data
if (h_cnt <= 11'b01100011111)
horizontal_en <= 1;
else
horizontal_en <= 0;
end
always @(posedge clk50)
begin
//--Generate Vertical Data
if (v_cnt <= 11'b01001010111)
vertical_en <= 1;
else
vertical_en <= 0;
end
assign video_en = vertical_en && horizontal_en;
endmodule
module vga (clk50, v_sync, h_sync, red_signal,green_signal,blue_signal, video_en);
reg [10:0]h_cnt;
reg [10:0]v_cnt;
output reg h_sync;
output reg v_sync;
...
module vga (
input clk50,
output reg v_sync,
output reg h_sync,
...
);
assign video_en = vertical_en && horizontal_en;
if(a<=18'b101101001101011010&&(l!=18'b10000100101011010||f))y<=n+1;
if (some_count <= 18'd 185_178 && (another_count != 18'd 67_930 || ignore_67930)) output_signal <= Input_signal + 1;
//--Reset Horizontal Counter
//The horizontal counter is used to do set both the vertical sync and the horizontal sync and rolls over at X pixels
Most of the online tutorials for Verilog haven't seem to been updated for 15 years.On the port naming, I think I must have learnt from some really old examples (or other people with that bad practice), even while being aware that there was another way of doing it. I'll spend some time improving it I think before looking to expand it to do more than just push a solid colour to the screen.
Many Thanks
red_signal <= 1'b1;
green_signal <= 1'b0;
blue_signal <= 1'b0;
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?