搜索
bottom↓
回复: 1

刚学CPLD 写VGA彩条显示,写竖条有用。写横条就成了线了。。

[复制链接]

出0入0汤圆

发表于 2011-7-21 11:17:45 | 显示全部楼层 |阅读模式
高手指点。。帮忙开下光啊。。不胜感激。。。




library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

entity VGA is
port(clk50MHz: in std_logic;
               sw: in std_logic_vector(1 downto 0);
               HS: out std_logic;
               VS: out std_logic;
            R,G,B: out std_logic
        );
end entity VGA;

architecture first of VGA is
signal clk: std_logic;
signal count_h: std_logic_vector(9 downto 0);
signal count_v: std_logic_vector(9 downto 0);
signal RGB,RGB_V,RGB_H: std_logic_vector(0 to 2);
signal HS1,VS1: std_logic;
begin
        p0:process(clk50MHz)
                variable aa: integer range 0 to 12587500;
                begin
                        if clk50MHz'event and clk50MHz='1' then
                                if aa<12587499 then aa:=aa+1;clk<=not clk;
                                        else aa:=0;
                                end if;
                        end if;
                end process p0;
       
        p1:process(clk)  --行像素点计数
                begin
                        if clk'event and clk='1' then
                                if count_h<800 then
                                        if count_h<96 then HS1<='0';
                                        else HS1<='1';
                                        end if;
                                        count_h<=count_h+1;
                                else count_h<="0000000000";
                                end if;
                        end if;
                end process p1;
               
--        p2:process(count_h)   --行消隐信号
--                begin
--                        if count_h<96 then HS1<='0';
--                                else HS1<='1';
--                        end if;
--                end process;
       
        p3:process(clk)  --显示竖状彩条
                begin
                        if clk'event and clk='0' then
                                if count_h<144 then RGB_H<="000";
                                elsif count_h<224 then RGB_H<="001";
                                elsif count_h<304 then RGB_H<="010";
                                elsif count_h<384 then RGB_H<="011";
                                elsif count_h<464 then RGB_H<="100";
                                elsif count_h<544 then RGB_H<="101";
                                elsif count_h<=624 then RGB_H<="110";
                                elsif count_h<704 then RGB_H<="111";
                                elsif count_h<784 then RGB_H<="010";
                                else RGB_H<="000";
                                end if;       
                        end if;       
                end process p3;

        p4:process(HS1)  --场像素点计数
                begin
                        if HS1'event and HS1='1' then
                                if count_v<525 then
                                        if count_v<10 then VS1<='0';
                                                else VS1<='1';
                                        end if;
                                        count_v<=count_v+1;
                                else count_v<="0000000000";
                                end if;
                        end if;
                end process p4;
               
--        P5:process(count_v)  --场消隐信号
--                begin
--                        if count_v<2 then VS1<='0';
--                                else VS1<='1';
--                        end if;
--                end process p5;
       
        p6:process(clk)
                begin
                        if clk'event and clk='0' then
                                if count_v<35 then RGB_V<="000";
                                elsif count_v<95 then RGB_V<="111";
                                elsif count_v<155 then RGB_V<="001";
                                elsif count_v<215 then RGB_V<="011";
                                elsif count_v<275 then RGB_V<="100";
                                elsif count_v<335 then RGB_V<="101";
                                elsif count_v<395 then RGB_V<="110";
                                elsif count_v<455 then RGB_V<="111";
                                elsif count_v<515 then RGB_V<="001";
                                else RGB_V<="000";
                                end if;
                        end if;
                end process p6;
               
        p7:process(sw,RGB_V,RGB_H)
                begin
                        if sw="01" then RGB<=RGB_V;
                                else RGB<=RGB_H;
                        end if;
                end process p7;
       
        HS<=HS1;
        VS<=VS1;
        R<=RGB(2);
        G<=RGB(1);
        B<=RGB(0);       
end first;




显示的横条。 (原文件名:图像678.jpg)

阿莫论坛20周年了!感谢大家的支持与爱护!!

知道什么是神吗?其实神本来也是人,只不过神做了人做不到的事情 所以才成了神。 (头文字D, 杜汶泽)

出0入0汤圆

 楼主| 发表于 2011-7-21 14:33:08 | 显示全部楼层
没人理我。。不过还好刚去看了下时序图,结果发现是我在 p6 进程中没有行消隐。才会出错的。
VGA时序图 (原文件名:VGA时序图.jpg)
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片。注意:要连续压缩2次才能满足要求!!】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-7-24 13:35

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表