---------------------------------------------------------------------------- -- scan_hdmi.vhd -- Scan Generator for HDMI -- Version 1.0 -- -- Copyright (C) 2015 H.Poetzl -- -- This program is free software: you can redistribute it and/or -- modify it under the terms of the GNU General Public License -- as published by the Free Software Foundation, either version -- 2 of the License, or (at your option) any later version. ---------------------------------------------------------------------------- library IEEE; use IEEE.std_logic_1164.ALL; use IEEE.numeric_std.ALL; use work.vivado_pkg.ALL; -- Vivado Attributes entity scan_hdmi is port ( clk : in std_logic; -- Scan CLK reset : in std_logic; -- # Reset -- total_w : in std_logic_vector(11 downto 0); -- Total Width total_h : in std_logic_vector(11 downto 0); -- Total Heigth -- pream_s : in std_logic_vector(11 downto 0); -- Preamble guard_s : in std_logic_vector(11 downto 0); -- Guard hdisp_s : in std_logic_vector(11 downto 0); vdisp_s : in std_logic_vector(11 downto 0); -- hsync_s : in std_logic_vector(11 downto 0); hsync_e : in std_logic_vector(11 downto 0); vsync_s : in std_logic_vector(11 downto 0); vsync_e : in std_logic_vector(11 downto 0); -- pream : out std_logic; guard : out std_logic; blank : out std_logic; hsync : out std_logic; vsync : out std_logic; -- hpos : out std_logic_vector(11 downto 0); vpos : out std_logic_vector(11 downto 0); frame : out std_logic ); end entity scan_hdmi; architecture RTL of scan_hdmi is attribute KEEP_HIERARCHY of RTL : architecture is "TRUE"; signal cnt_h : unsigned(11 downto 0) := x"000"; signal cnt_v : unsigned(11 downto 0) := x"000"; signal ab : std_logic_vector(47 downto 0); alias a : std_logic_vector(29 downto 0) is ab(47 downto 18); alias b : std_logic_vector(17 downto 0) is ab(17 downto 0); alias lim_h : std_logic_vector(11 downto 0) is ab(11 downto 0); alias lim_v : std_logic_vector(11 downto 0) is ab(23 downto 12); alias lim_x : std_logic_vector(23 downto 0) is ab(47 downto 24); signal c : std_logic_vector(47 downto 0); alias c_cnt_h : std_logic_vector(11 downto 0) is c(11 downto 0); alias c_cnt_v : std_logic_vector(11 downto 0) is c(23 downto 12); alias c_cnt_x : std_logic_vector(23 downto 0) is c(47 downto 24); signal carry : std_logic_vector(3 downto 0); signal disp : std_logic_vector(3 downto 0); alias pream_sf : std_logic is disp(0); alias guard_sf : std_logic is disp(1); alias hdisp_sf : std_logic is disp(2); alias vdisp_sf : std_logic is disp(3); signal sync : std_logic_vector(3 downto 0); alias hsync_sf : std_logic is sync(0); alias hsync_ef : std_logic is sync(1); alias vsync_sf : std_logic is sync(2); alias vsync_ef : std_logic is sync(3); begin lim_h <= total_w; lim_v <= total_h; lim_x <= (others => '0'); c_cnt_h <= std_logic_vector(cnt_h); c_cnt_v <= std_logic_vector(cnt_v); c_cnt_x <= (others => '0'); DSP48E1_limit_inst : entity work.dsp48_wrap generic map ( USE_SIMD => "FOUR12" ) -- SIMD selection ("ONE48", "TWO24", "FOUR12") port map ( CLK => clk, -- 1-bit input: Clock input A => a, -- 30-bit input: A data input B => b, -- 18-bit input: B data input C => c, -- 48-bit input: C data input ALUMODE => "0001", -- 4-bit input: ALU control input OPMODE => "0111011", -- 7-bit input: Operation mode input -- CARRYOUT => carry ); -- 4-bit carry output scan_proc : process (clk) begin if rising_edge(clk) then frame <= '0'; if reset = '1' then cnt_h <= x"000"; cnt_v <= x"000"; elsif carry(0) = '1' then if carry(1) = '1' then cnt_v <= x"000"; frame <= '1'; else cnt_v <= cnt_v + "1"; end if; cnt_h <= x"000"; else cnt_h <= cnt_h + "1"; end if; end if; end process; scan_comp_inst0 : entity work.scan_comp port map ( clk => clk, reset => reset, -- a0 => pream_s, a1 => guard_s, a2 => hdisp_s, a3 => vdisp_s, -- b0 => std_logic_vector(cnt_h), b1 => std_logic_vector(cnt_h), b2 => std_logic_vector(cnt_h), b3 => std_logic_vector(cnt_v), -- flags => disp ); pream_proc : process (clk) begin if rising_edge(clk) then pream <= vdisp_sf and (pream_sf xor guard_sf); end if; end process; guard_proc : process (clk) begin if rising_edge(clk) then guard <= vdisp_sf and (guard_sf xor hdisp_sf); end if; end process; blank_proc : process (clk) begin if rising_edge(clk) then if hdisp_sf and vdisp_sf then hpos <= std_logic_vector(cnt_h - unsigned(hdisp_s)); vpos <= std_logic_vector(cnt_v - unsigned(vdisp_s)); blank <= '0'; else hpos <= (others => '1'); vpos <= (others => '1'); blank <= '1'; end if; end if; end process; scan_comp_inst1 : entity work.scan_comp port map ( clk => clk, reset => reset, -- a0 => hsync_s, a1 => hsync_e, a2 => vsync_s, a3 => vsync_e, -- b0 => std_logic_vector(cnt_h), b1 => std_logic_vector(cnt_h), b2 => std_logic_vector(cnt_v), b3 => std_logic_vector(cnt_v), -- flags => sync ); sync_proc : process (clk) begin if rising_edge(clk) then hsync <= hsync_sf xor hsync_ef; vsync <= vsync_sf xor vsync_ef; end if; end process; end RTL;