ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

VGA颜色分块显示

2020-06-29 16:06:44  阅读:282  来源: 互联网

标签:11 显示 颜色 cnt1 分块 d35 VGA cnt2 &&


项目名称

Vga不同颜色分块显示

具体要求

显示任意颜色,例如上下平分屏幕,红绿上下显示。屏幕四等份平分,顺时针显示红、绿、蓝、黄。

设计架构

这个小项目在vga显示上改进的,比较简单,四等份平分需要注意 每一部分的长宽都必须相等,笔者计算每部分的计数值画的草图如下,在显示区域之外为消隐区,  不再多说直接上代码

                      

 

 

 

代码设计

红绿显示,部分代码参考上个项目,必须在显示标志区内才能正常显示

//显示区标志
always@(*)
	if(!rst_n)
		flag<=0;
	else if((cnt1>=11'd144 && cnt1<11'd784) && (cnt2>=11'd35 && cnt2<11'd515))
		flag<=1;
	else 	
		flag<=0;
//--------------------红绿显示-------------------------//		
always@(posedge clk or negedge rst_n)
	if(!rst_n)
		vga_rgb<=0;
	else if(flag)begin
		if(cnt2>=11'd35 && cnt2<=11'd274)
			vga_rgb<=green;
		else if(cnt2>=11'd275 && cnt2<=11'd514)
			vga_rgb<=red;
		else
			vga_rgb<=0;
	end
	else
		vga_rgb<=0;

 四等份显示代码

//显示区标志
always@(*)
	if(!rst_n)
		flag<=0;
	else if((cnt1>=11'd144 && cnt1<11'd784) && (cnt2>=11'd35 && cnt2<11'd515))
		flag<=1;
	else 	
		flag<=0;

always@(posedge clk or negedge rst_n)
	if(!rst_n)
		vga_rgb<=0;
	else if(flag)begin
		if((cnt1>=11'd144 && cnt1<=11'd463) && (cnt2>=11'd35 && cnt2<=11'd274))
			vga_rgb<=red;
		else if((cnt1>=11'd464 && cnt1<=11'd783) && (cnt2>=11'd35 && cnt2<=11'd274))
			vga_rgb<=green;
		else if((cnt1>=11'd464 && cnt1<=11'd783) && (cnt2>=11'd275 && cnt2<=11'd514))
			vga_rgb<=blue;
		else if((cnt1>=11'd144 && cnt1<=11'd463) && (cnt2>=11'd275 && cnt2<=11'd514))
			vga_rgb<=yellow;
		else
			vga_rgb<=0;
	end
	else
		vga_rgb<=0;

显示结果

             

 

 

 

 

标签:11,显示,颜色,cnt1,分块,d35,VGA,cnt2,&&
来源: https://blog.csdn.net/weixin_43533751/article/details/106986109

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有