尝试使用fpga在640x480 vga显示器上显示

问题描述 投票:0回答:1

我确实是在绝望中写下这篇文章的。我已经尝试了很多次让它发挥作用,但就是不行。 我使用 Altera DE2 板 - Cyclone II EP2C35F672C6 并尝试在 640x480 vga 屏幕上显示简单的图像。 我使用的是为不同的板子 Altera DE1 设计的 vga 控制器,效果非常好。 此 DE2 板上的差异在于不同的 DAC 组件,它具有 10 位 RGB 数据,而不是像 DE1 板中的 4 位,并且它具有额外所需的输出 - VGA_SYNC、VGA_BLANK、VGA_CLK。

因此我进行了所需的更改并找到了一个示例,其中显示将 VGA_BLANK 设置为“1”常量并将 VGA_SYNC 设置为“0”。 VGA_CLK 连接到 25.175 Mhz 像素 clk,即 pll clk 输出。

我尝试了很多变体并尝试使用另一个示例,其中他们在可见区域中将 vga_blank 设置为“1”,在可见区域中将 vga_blank 设置为“0”,但它仍然不起作用。当我运行设计时,我只是得到一个黑屏,提示没有视频输入。

下面是我的定时生成器、data_generator 和 vga_top_level 的实现

library ieee;
use ieee.std_logic_1164.all;

library work;
use work.vga_consts.all;


entity vga_toplevel is

    port
    (
        -- in --
        clk, rst : in std_logic;


        -- out --
        vga_clk, vga_blank, vga_sync : out std_logic;
        r_data, g_data, b_data : out std_logic_vector(9 downto 0);
        h_sync, v_sync : out std_logic
    );
end entity;

architecture structural of vga_toplevel is


    component pll
        port
        (
            areset      : IN STD_LOGIC  := '0';
            inclk0      : IN STD_LOGIC  := '0';
            c0          : OUT STD_LOGIC ;
            locked      : OUT STD_LOGIC 
        );
    end component;

    component timing_generator
        port
        (
            clk, rst : in std_logic;

            h_cnt : out integer range 0 to h_frame-1;
            v_cnt : out integer range 0 to v_frame-1;

            vga_blank, vga_sync : out std_logic;
            h_sync, v_sync : out std_logic
        );
    end component;

    component data_generator
        generic
        (
            vis_x : integer := visable_x;
            vis_y : integer := visable_y
        );
        port
        (
            clk, rst : in std_logic;
            h_cnt : in integer range 0 to h_frame-1;
            v_cnt : in integer range 0 to v_frame-1;

            -- RGB values
            r_data, g_data, b_data : out std_logic_vector(9 downto 0)
        );
    end component;

    signal h_cnt, v_cnt : integer range 0 to h_frame-1;

    signal pll_clk, rst_out, locked : std_logic;

    -------------------------------------------------------------------

begin
    rst_out <= not locked; -- uncomment for PLL use
    vga_clk <= pll_clk;
    -- rst_out <= rst; -- comment for PLL use
    -- pll_clk <= clk; -- comment for PLL use


    PLL1: pll
        port map
        (

            inclk0 => clk,
            areset => rst,

            c0 => pll_clk,
            locked => locked
        );

    T_GEN: timing_generator
        port map
        (
            -- in --
            clk => pll_clk,
            rst => rst_out,
            -- out --
            vga_blank   => vga_blank,
            vga_sync    => vga_sync,
            v_cnt => v_cnt,
            h_cnt => h_cnt,
            v_sync => v_sync,
            h_sync => h_sync
        );

    D_GEN: data_generator

        port map
        (
            -- in --
            clk => pll_clk,
            rst => rst_out,
            v_cnt => v_cnt,
            h_cnt => h_cnt,

            r_data => r_data,
            g_data => g_data,
            b_data => b_data
        );
end architecture;

library ieee;
use ieee.std_logic_1164.all;

library work;
use work.vga_consts.all;

entity timing_generator is

    port
    (
        clk, rst : in std_logic;

        h_cnt : out integer range 0 to h_frame-1;
        v_cnt : out integer range 0 to v_frame-1;

        vga_blank   : out std_logic;
        vga_sync    : out std_logic;
        h_sync, v_sync : out std_logic

    );

end entity;

architecture behave of timing_generator is

    signal h_cnt_inner : integer range 0 to h_frame-1;
    signal v_cnt_inner : integer range 0 to v_frame-1;

begin
    vga_blank   <= '1';
    vga_sync    <= '0';
    h_cnt <= h_cnt_inner;
    v_cnt <= v_cnt_inner;


    -- counter for pixels --
    process (clk, rst) 
    begin
        if rst = '1' then
            h_cnt_inner <= 0;
        elsif rising_edge(clk) then
            if h_cnt_inner = h_frame-1 then
                h_cnt_inner <= 0;
            else 
                h_cnt_inner <= h_cnt_inner + 1;
            end if;
        end if;
    end process;

    -- counter for lines --
    process (clk, rst)
    begin
        if rst = '1' then
            v_cnt_inner <= 0;
        elsif rising_edge(clk) then
            if v_cnt_inner = v_frame-1 then
                v_cnt_inner <= 0;
            elsif h_cnt_inner = 654 then
                v_cnt_inner <= v_cnt_inner + 1;
            end if;
        end if;
    end process;

    -- h_sync generator --
    process (clk, rst)
    begin
        if rst = '1' then
            h_sync <= '1';
        elsif rising_edge(clk) then
            if h_cnt_inner = h_sync_d(0)-1 then
                h_sync <= '0';
            elsif h_cnt_inner = h_sync_d(1) then
                h_sync <= '1';
            end if;
        end if;
    end process;

    -- v_sync generator --
    process(clk, rst)
    begin
        if rst = '1' then
            v_sync <= '1';
        elsif rising_edge(clk) then
            if v_cnt_inner = v_sync_d(0) then
                v_sync <= '0';
            elsif v_cnt_inner = v_sync_d(1) + 1 then
                v_sync <= '1';
            end if;
        end if;
    end process;





end architecture;

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

library work;
use work.vga_consts.all;



entity data_generator is
    generic (
        vis_x : integer := visable_x;
        vis_y : integer := visable_y
    );
    port
    (
        clk, rst : in std_logic;

        h_cnt : in integer range 0 to h_frame-1;
        v_cnt : in integer range 0 to v_frame-1;

        -- RGB values for each pixel
        r_data, g_data, b_data : out std_logic_vector(9 downto 0)
    );
end entity;

architecture behave of data_generator is    

begin
    -- process to handle only 1 color - blue screen
    process(clk, rst)
    begin
        if rst = '1' then
            r_data <= (others => '0');
            g_data <= (others => '0');
            b_data <= (others => '0');
        elsif rising_edge(clk) then
            if (h_cnt >= h_vis_d(0)) and (h_cnt < h_vis_d(1)) and (v_cnt >= v_vis_d(0)) and (v_cnt < v_vis_d(1)) then
                -- if in visiable area
                r_data <= (others => '1');
                g_data <= (others => '1');
                b_data <= (others => '1');
            else
                r_data <= (others => '0');
                g_data <= (others => '0');
                b_data <= (others => '0');
            end if;
        end if;
    end process;

end architecture;

vhdl fpga intel-fpga
1个回答
0
投票

它是某种协议。首先是640像素宽的显示区域。然后是前廊、Hsync 信号和后廊。 如果您想了解更多详细信息,请访问tinyvga.com。您只需搜索屏幕分辨率和帧速率,即可找到时序和像素时钟。

© www.soinside.com 2019 - 2024. All rights reserved.