티스토리 뷰

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
library ieee;
    use ieee.std_logic_1164.all;
    use ieee.std_logic_arith.all;
    use ieee.std_logic_unsigned.all;
    
entity VGA_Pattern_Generator is
    port(
        nRst : in std_logic;
        clk : in std_logic;
        VGA_CLK : out std_logic;
        VGA_BLANK : out std_logic;
        VGA_HS : out std_logic;
        VGA_VS : out std_logic;
        VGA_SYNC : out std_logic;
        VGA_R : out std_logic_vector(9 downto 0);
        VGA_G : out std_logic_vector(9 downto 0);
        VGA_B : out std_logic_vector(9 downto 0)
    );
end VGA_Pattern_Generator;
 
architecture BEH of VGA_Pattern_Generator is
 
    signal H_cnt : std_logic_vector(9 downto 0);
    signal V_cnt : std_logic_vector(9 downto 0);
    signal pclk : std_logic;
    
begin
 
    process(nRst, clk)
    begin
        if(nRst = '0'then
            pclk <= '0';
        elsif rising_edge(clk) then
            pclk <= not pclk;
        end if;
    end process;
    
    process(nRst, pclk)
    begin
        if(nRst = '0'then
            H_cnt <= (others => '0');
            V_cnt <= (others => '0');
        elsif rising_edge(pclk) then
            if(H_cnt = 799then
                H_cnt <= (others => '0');
                if(V_cnt = 524then
                    V_cnt <= (others => '0');
                else
                    V_cnt <= V_cnt + 1;
                end if;
            else
                H_cnt <= H_cnt + 1;
            end if;
        end if;
    end process;
    
    VGA_CLK <= pclk;
    VGA_HS <= '0' when (H_cnt >= 0and (H_cnt <= 95else '1';
    VGA_VS <= '0' when (V_cnt >= 0and (V_cnt <= 1else '1';
    VGA_BLANK <= '1' when (H_cnt >= 140and (H_cnt <= 790else '0';
    VGA_SYNC <= '0' when (H_cnt >= 140and (H_cnt <= 790else '1';
    VGA_R <= "1111111111" when (V_cnt >= 31and (V_cnt <= 153else
                "0000011111" when (V_cnt >= 396and (V_cnt <= 516else (others => '0');
    VGA_G <= "1111111111" when (V_cnt >= 154and (V_cnt <= 274else
                "0000011111" when (V_cnt >= 396and (V_cnt <= 516else (others => '0');
    VGA_B <= "1111111111" when (V_cnt >= 275and (V_cnt <= 395else
                "0000011111" when (V_cnt >= 396and (V_cnt <= 516else (others => '0');
end BEH;

cs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
library ieee;
    use ieee.std_logic_1164.all;
    use ieee.std_logic_arith.all;
    use ieee.std_logic_unsigned.all;
    
entity VGA_Pattern_Generator is
    port(
        nRst : in std_logic;
        clk : in std_logic;
        VGA_CLK : out std_logic;
        VGA_BLANK : out std_logic;
        VGA_HS : out std_logic;
        VGA_VS : out std_logic;
        VGA_SYNC : out std_logic;
        VGA_R : out std_logic_vector(9 downto 0);
        VGA_G : out std_logic_vector(9 downto 0);
        VGA_B : out std_logic_vector(9 downto 0)
    );
end VGA_Pattern_Generator;
 
architecture BEH of VGA_Pattern_Generator is
 
    signal H_cnt : std_logic_vector(9 downto 0);
    signal V_cnt : std_logic_vector(9 downto 0);
    signal pclk : std_logic;
    
begin
 
    process(nRst, clk)
    begin
        if(nRst = '0'then
            pclk <= '0';
        elsif rising_edge(clk) then
            pclk <= not pclk;
        end if;
    end process;
    
    process(nRst, pclk)
    begin
        if(nRst = '0'then
            H_cnt <= (others => '0');
            V_cnt <= (others => '0');
        elsif rising_edge(pclk) then
            if(H_cnt = 799then
                H_cnt <= (others => '0');
                if(V_cnt = 524then
                    V_cnt <= (others => '0');
                else
                    V_cnt <= V_cnt + 1;
                end if;
            else
                H_cnt <= H_cnt + 1;
            end if;
        end if;
    end process;
    
    VGA_CLK <= pclk;
    VGA_HS <= '0' when (H_cnt >= 0and (H_cnt <= 95else '1';
    VGA_VS <= '0' when (V_cnt >= 0and (V_cnt <= 1else '1';
    VGA_BLANK <= '1' when (H_cnt >= 140and (H_cnt <= 790else '0';
    VGA_SYNC <= '0' when (H_cnt >= 140and (H_cnt <= 790else '1';
    VGA_R <= "1111111111" when (V_cnt >= 31and (V_cnt <= 153else
                "1111111111" when (V_cnt >= 396and (V_cnt <= 516else (others => '0');
    VGA_G <= "1111111111" when (V_cnt >= 154and (V_cnt <= 274else
                "1111111111" when (V_cnt >= 396and (V_cnt <= 516else (others => '0');
    VGA_B <= "1111111111" when (V_cnt >= 275and (V_cnt <= 395else
                "1111111111" when (V_cnt >= 396and (V_cnt <= 516else (others => '0');
end BEH;
cs

'프로그래밍 > Quartus 2' 카테고리의 다른 글

[VHDL] DIGITAL WATCH  (0) 2018.04.10
[VHDL] 계층구조 연습, MUX 설계  (0) 2018.04.02
[VHDL] COUNTER 설계  (0) 2018.03.26
[VHDL] 논리 게이트  (0) 2018.03.16
[VHDL] VHDL 개요  (0) 2018.03.16
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2025/02   »
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28
글 보관함