美文网首页
VGA彩色信号发生器

VGA彩色信号发生器

作者: 程序猿Cyinen | 来源:发表于2020-10-12 07:18 被阅读0次
    
    LIBRARY IEEE ; 
    -- 显示器彩条发生器
    USE IEEE.STD_LOGIC_1164.ALL ; 
    USE IEEE.STD_LOGIC_UNSIGNED.ALL ; 
    ENTITY COLOR IS
    
    
    PORT ( CLK, MD : IN STD_LOGIC ;--扫描时钟/显示模式选择时钟
    
    HS, VS, R, G, B : OUT STD_LOGIC); --行场同步/红 绿 蓝
    END COLOR ; 
    ARCHITECTURE behav OF COLOR IS
    SIGNAL HS1, VS1, FCLK, CCLK : STD_LOGIC ;
    SIGNAL MMD : STD_LOGIC_VECTOR(1 DOWNTO 0) ; --方式选择
    SIGNAL FS : STD_LOGIC_VECTOR (3 DOWNTO 0) ;
    SIGNAL CC : STD_LOGIC_VECTOR(4 DOWNTO 0); --行同步/横彩条生成 
    SIGNAL LL : STD_LOGIC_VECTOR(8 DOWNTO 0); --场同步/竖彩条生成
    SIGNAL GRBX : STD_LOGIC_VECTOR(3 DOWNTO 1) ; --X 横彩条 
    SIGNAL GRBY : STD_LOGIC_VECTOR(3 DOWNTO 1) ; --Y 竖彩条 
    SIGNAL GRBP : STD_LOGIC_VECTOR(3 DOWNTO 1) ; 
    SIGNAL GRB : STD_LOGIC_VECTOR(3 DOWNTO 1) ;
    
    BEGIN 
        GRB(2) <= (GRBP(2) XOR MD) AND HS1 AND VS1 ; 
        GRB(3) <= (GRBP(3) XOR MD) AND HS1 AND VS1 ; 
        GRB(1) <= (GRBP(1) XOR MD) AND HS1 AND VS1 ; 
        PROCESS( MD )
            begin
                if md'event and md = '0' then
                    if mmd = "10" then mmd <= "00";
                    else mmd <=mmd+1;
                    end if;
                end if;
         end process;
         PROCESS( MMD ) 
                    BEGIN 
                        IF MMD = "00" THEN GRBP <= GRBX ; --选择横彩条 
                        ELSIF MMD = "01" THEN GRBP <= GRBY ; --选择竖彩条 
                        ELSIF MMD = "10" THEN GRBP <= GRBX XOR GRBY;--产生棋盘格 
                        ELSE GRBP <= "000" ; 
                        END IF ; 
         END PROCESS ;
         PROCESS( CLK ) 
                            BEGIN 
                                IF CLK'EVENT AND CLK = '1' THEN -- 12MHz 13 分频 
                                    IF FS = 24 THEN FS <= "0000" ; 
                                    ELSE FS <= FS + 1 ; 
                                    END IF ; 
                                END IF ; 
        END PROCESS ; 
        FCLK <= FS(2) ; 
        PROCESS( FCLK )
                          begin
                              IF FCLK'EVENT AND FCLK = '1' THEN
                                  IF CC = 48 THEN CC <= "00000";                                ELSE CC <= CC + 1 ; 
                                  END IF; 
                              END IF ;
       end process;
       CCLK <= CC(4) ; 
       PROCESS( CCLK )
       BEGIN 
           IF CCLK'EVENT AND CCLK = '0' THEN 
               IF LL = 481 THEN LL <= "000000000" ; 
               ELSE LL <= LL + 1 ; 
               END IF ; 
           END IF ; 
       END PROCESS ;
       PROCESS( CC,LL )
          begin
              IF CC > 23 THEN HS1 <= '0' ; --行同步
              ELSE HS1 <= '1' ; END IF ;
              IF LL > 479 THEN VS1 <= '0' ;--场同步
              ELSE VS1 <= '1' ; END IF ;
       END PROCESS ;
       process(CC, LL)
         begin
             IF CC < 3 THEN GRBX <= "111" ; --横彩条
             ELSIF CC < 6 THEN GRBX <= "110" ;
             ELSIF CC < 9 THEN GRBX <= "101" ; 
             ELSIF CC < 12 THEN GRBX <= "100" ; 
             ELSIF CC < 15 THEN GRBX <= "011" ; 
             ELSIF CC < 18 THEN GRBX <= "010" ; 
             ELSIF CC < 21 THEN GRBX <= "001" ;
             ELSE GRBX <= "000" ; END IF;
             IF LL < 60 THEN GRBY <= "111" ;  --竖彩条
                 ELSIF LL < 120 THEN GRBY <= "110" ; 
                 ELSIF LL < 180 THEN GRBY <= "101" ; 
                 ELSIF LL < 240 THEN GRBY <= "100" ; 
                 ELSIF LL < 300 THEN GRBY <= "011" ; 
                 ELSIF LL < 360 THEN GRBY <= "010" ; 
                 ELSIF LL < 420 THEN GRBY <= "001" ; 
             ELSE GRBY <= "000"; END IF ;
                     
                            
    

    相关文章

      网友评论

          本文标题:VGA彩色信号发生器

          本文链接:https://www.haomeiwen.com/subject/smwspktx.html