Verilog HDL--VGA Display

Source: Internet
Author: User

ModuleVGA (Clk,rst_n, Hsync,vsync, vga_r,vga_g,vga_b);inputClk//50MHzinputRst_n;//low-Power resetOutputHSync//Line Sync SignalOutputVSync//Field Sync SignalOutputVga_r;OutputVga_g;OutputVga_b;//--------------------------------------------------Reg[Ten:0] x_cnt;//Line coordinatesReg[9:0] y_cnt;//Column coordinates always@ (PosedgeClassor Negedgerst_n)if(!rst_n) x_cnt <= One'D0;    Else if(x_cnt = = One'd1039) x_cnt <='D0; Elsex_cnt <= x_cnt+1'B1; always@ (PosedgeClassor Negedgerst_n)if(!rst_n) y_cnt <=Ten'D0;    Else if(y_cnt = =Ten'd665) y_cnt <='D0; Else if(x_cnt = = One'd1039) y_cnt <= y_cnt+1'B1;//-------------------------------------------------- WireValid//Valid display area flagAssignValid = (x_cnt >= One'd187) && (x_cnt < one'd987)&& (y_cnt >=Ten'd31) && (y_cnt <'d631);  Wire[9:0] Xpos,ypos;//valid display area coordinatesAssignXpos = x_cnt- One'd187;AssignYpos = y_cnt-Ten'D31;//--------------------------------------------------RegHsync_r,vsync_r;//Synchronous Signal Generation always@ (PosedgeClassor Negedgerst_n)if(!rst_n) Hsync_r <=1'B1;    Else if(x_cnt = = One'd0) hsync_r <= 1'B0;//Generate HSync Signal    Else if(x_cnt = = One'd120) hsync_r <= 1'B1; always@ (PosedgeClassor Negedgerst_n)if(!rst_n) Vsync_r <=1'B1;    Else if(y_cnt = =Ten'd0) vsync_r <= 1'B0;//Generate VSync Signal    Else if(y_cnt = =Ten'd6) vsync_r <= 1'B1;AssignHSync =Hsync_r;AssignVSync =Vsync_r;//--------------------------------------------------    //Display a rectangular box WireA_dis,b_dis,c_dis,d_dis;//rectangular box display area positioningAssignA_dis = ((xpos>= $) && (xpos<= -) )                 && (ypos>= $) && (ypos<=460) ); AssignB_dis = ((xpos>=580) && (xpos<= -) )                && (ypos>= $) && (ypos<=460) );AssignC_dis = ((xpos>= -) && (xpos<=580) )                 && (ypos> $) && (ypos<= the) ); AssignD_dis = ((xpos>= -) && (xpos<=580) )                && (ypos>= the) && (ypos<=460) ); //show a small rectangle WireE_rdy;//rectangular display of valid rectangular areasAssignE_rdy = ((xpos>=385) && (xpos<=415) )                && (ypos>=285) && (ypos<=315) );//--------------------------------------------------     //r,g,b Control LCD color display, background display blue, rectangular box shows red and blueAssignVga_r = valid? E_rdy:1'B0;AssignVga_g = valid? (A_dis | b_dis | c_dis | d_dis):1'B0;AssignVga_b = valid? ~ (A_dis | b_dis | c_dis | d_dis):1'B0; Endmodule

Verilog HDL--VGA Display

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.