2017-04-24 19:21:18 +00:00
|
|
|
----------------------------------------------------------------------------------
|
|
|
|
-- Engineer: David Banks
|
|
|
|
--
|
2018-07-15 14:36:02 +00:00
|
|
|
-- Create Date: 15/7/2018
|
2017-04-24 19:21:18 +00:00
|
|
|
-- Module Name: RGBtoHDMI CPLD
|
|
|
|
-- Project Name: RGBtoHDMI
|
|
|
|
-- Target Devices: XC9572XL
|
|
|
|
--
|
2018-07-15 14:36:02 +00:00
|
|
|
-- Version: 1.0
|
2017-04-24 19:21:18 +00:00
|
|
|
--
|
|
|
|
----------------------------------------------------------------------------------
|
|
|
|
library ieee;
|
|
|
|
use ieee.std_logic_1164.all;
|
|
|
|
use ieee.numeric_std.all;
|
|
|
|
|
|
|
|
entity RGBtoHDMI is
|
2019-12-05 14:34:59 +00:00
|
|
|
Generic (
|
|
|
|
SupportAnalog : boolean := false
|
|
|
|
);
|
2017-04-24 19:21:18 +00:00
|
|
|
Port (
|
2019-12-17 02:35:04 +00:00
|
|
|
-- From RGB Connector
|
2018-06-05 16:52:42 +00:00
|
|
|
R0: in std_logic;
|
2020-02-08 11:53:16 +00:00
|
|
|
G0: in std_logic;
|
2018-06-05 16:52:42 +00:00
|
|
|
B0: in std_logic;
|
|
|
|
R1: in std_logic;
|
2020-02-08 11:53:16 +00:00
|
|
|
G1: in std_logic;
|
2018-06-05 16:52:42 +00:00
|
|
|
B1: in std_logic;
|
2019-12-17 02:35:04 +00:00
|
|
|
csync_in: in std_logic;
|
2019-12-22 15:30:30 +00:00
|
|
|
vsync_in: in std_logic;
|
2019-12-17 02:35:04 +00:00
|
|
|
analog: inout std_logic;
|
2017-04-24 19:21:18 +00:00
|
|
|
|
|
|
|
-- From Pi
|
|
|
|
clk: in std_logic;
|
2020-08-27 22:55:25 +00:00
|
|
|
mode7_in: in std_logic;
|
2018-06-12 11:39:06 +00:00
|
|
|
mux: in std_logic;
|
2017-05-24 12:20:06 +00:00
|
|
|
sp_clk: in std_logic;
|
2018-06-06 16:51:11 +00:00
|
|
|
sp_clken: in std_logic;
|
2017-05-24 12:20:06 +00:00
|
|
|
sp_data: in std_logic;
|
2017-04-24 19:21:18 +00:00
|
|
|
|
|
|
|
-- To PI GPIO
|
|
|
|
quad: out std_logic_vector(11 downto 0);
|
|
|
|
psync: out std_logic;
|
2017-04-26 17:15:47 +00:00
|
|
|
csync: out std_logic;
|
2017-04-24 19:21:18 +00:00
|
|
|
|
2018-06-05 16:52:42 +00:00
|
|
|
-- User interface
|
2018-06-09 12:24:47 +00:00
|
|
|
version: in std_logic;
|
2019-11-10 02:30:51 +00:00
|
|
|
SW1: in std_logic;
|
|
|
|
SW2: in std_logic;
|
|
|
|
SW3: in std_logic;
|
2019-12-17 02:35:04 +00:00
|
|
|
|
2018-06-12 11:39:06 +00:00
|
|
|
LED1: in std_logic -- allow it to be driven from the Pi
|
2017-04-24 19:21:18 +00:00
|
|
|
);
|
|
|
|
end RGBtoHDMI;
|
|
|
|
|
|
|
|
architecture Behavorial of RGBtoHDMI is
|
|
|
|
|
2019-03-27 01:39:28 +00:00
|
|
|
subtype counter_type is unsigned(7 downto 0);
|
2019-03-08 10:10:20 +00:00
|
|
|
|
2018-06-09 12:24:47 +00:00
|
|
|
-- Version number: Design_Major_Minor
|
2019-12-05 14:34:59 +00:00
|
|
|
-- Design: 0 = BBC CPLD
|
|
|
|
-- 1 = Alternative CPLD
|
|
|
|
-- 2 = Atom CPLD
|
|
|
|
-- 3 = six bit CPLD (if required);
|
|
|
|
-- 4 = RGB CPLD (TTL)
|
|
|
|
-- C = RGB CPLD (Analog)
|
2019-12-22 15:56:36 +00:00
|
|
|
constant VERSION_NUM_BBC : std_logic_vector(11 downto 0) := x"066";
|
2020-09-30 15:08:19 +00:00
|
|
|
constant VERSION_NUM_RGB_TTL : std_logic_vector(11 downto 0) := x"476";
|
|
|
|
constant VERSION_NUM_RGB_ANALOG : std_logic_vector(11 downto 0) := x"C76";
|
2017-05-24 12:20:06 +00:00
|
|
|
|
|
|
|
-- Sampling points
|
2019-03-23 18:33:53 +00:00
|
|
|
constant INIT_SAMPLING_POINTS : std_logic_vector(23 downto 0) := "000000011011011011011011";
|
2019-12-22 15:30:30 +00:00
|
|
|
|
2018-06-09 10:33:01 +00:00
|
|
|
signal shift_R : std_logic_vector(3 downto 0);
|
|
|
|
signal shift_G : std_logic_vector(3 downto 0);
|
|
|
|
signal shift_B : std_logic_vector(3 downto 0);
|
2017-04-24 19:21:18 +00:00
|
|
|
|
2018-06-12 11:39:06 +00:00
|
|
|
signal csync1 : std_logic;
|
2018-10-15 15:58:29 +00:00
|
|
|
signal csync2 : std_logic;
|
2019-03-23 18:33:53 +00:00
|
|
|
signal last : std_logic;
|
2018-10-15 15:19:23 +00:00
|
|
|
|
2018-10-15 20:58:42 +00:00
|
|
|
signal csync_counter : unsigned(1 downto 0);
|
2017-04-24 19:21:18 +00:00
|
|
|
|
2017-05-24 12:20:06 +00:00
|
|
|
-- The sampling counter runs at 96MHz
|
|
|
|
-- - In modes 0..6 it is 6x the pixel clock
|
|
|
|
-- - In mode 7 it is 8x the pixel clock
|
2017-04-24 19:21:18 +00:00
|
|
|
--
|
|
|
|
-- It serves several purposes:
|
|
|
|
-- 1. Counts the 12us between the rising edge of nCSYNC and the first pixel
|
2017-05-24 12:20:06 +00:00
|
|
|
-- 2. Counts within each pixel (bits 0, 1, 2)
|
|
|
|
-- 3. Counts counts pixels within a quad pixel (bits 3 and 4)
|
|
|
|
-- 4. Handles double buffering of alternative quad pixels (bit 5)
|
2017-04-24 19:21:18 +00:00
|
|
|
--
|
|
|
|
-- At the moment we don't count pixels with the line, the Pi does that
|
2019-03-08 10:10:20 +00:00
|
|
|
signal counter : counter_type;
|
2017-04-24 19:21:18 +00:00
|
|
|
|
2017-05-24 12:20:06 +00:00
|
|
|
-- Sample point register;
|
|
|
|
--
|
|
|
|
-- In Mode 7 each pixel lasts 8 clocks (96MHz / 12MHz). The original
|
|
|
|
-- pixel clock is a regenerated 6Mhz clock, and both edges are used.
|
|
|
|
-- Due to the way it is generated, there are three distinct phases,
|
2018-06-09 10:33:01 +00:00
|
|
|
-- each with different rising/falling edge speeds, hence six sampling
|
|
|
|
-- points are used.
|
|
|
|
--
|
|
|
|
-- In Modes 0..6 each pixel lasts 6 clocks (96MHz / 16MHz). The original
|
|
|
|
-- pixel clock is a clean 16Mhz clock, so only one sample point is needed.
|
|
|
|
-- To achieve this, all six values are set to be the same. This minimises
|
|
|
|
-- the logic in the CPLD.
|
2019-03-23 18:33:53 +00:00
|
|
|
signal sp_reg : std_logic_vector(23 downto 0) := INIT_SAMPLING_POINTS;
|
2017-05-24 12:20:06 +00:00
|
|
|
|
2018-06-09 10:33:01 +00:00
|
|
|
-- Break out of sp_reg
|
2019-03-14 18:08:20 +00:00
|
|
|
signal invert : std_logic;
|
2019-03-12 18:47:03 +00:00
|
|
|
signal rate : std_logic_vector(1 downto 0);
|
2019-03-23 18:33:53 +00:00
|
|
|
signal delay : unsigned(1 downto 0);
|
2018-06-09 19:41:06 +00:00
|
|
|
signal half : std_logic;
|
2018-06-09 10:33:01 +00:00
|
|
|
signal offset_A : std_logic_vector(2 downto 0);
|
|
|
|
signal offset_B : std_logic_vector(2 downto 0);
|
|
|
|
signal offset_C : std_logic_vector(2 downto 0);
|
|
|
|
signal offset_D : std_logic_vector(2 downto 0);
|
|
|
|
signal offset_E : std_logic_vector(2 downto 0);
|
|
|
|
signal offset_F : std_logic_vector(2 downto 0);
|
2017-05-24 12:20:06 +00:00
|
|
|
|
2018-06-09 10:33:01 +00:00
|
|
|
-- Pipelined offset mux output
|
|
|
|
signal offset : std_logic_vector(2 downto 0);
|
2018-06-06 21:25:55 +00:00
|
|
|
|
2018-06-09 10:33:01 +00:00
|
|
|
-- Index to cycle through offsets A..F
|
|
|
|
signal index : std_logic_vector(2 downto 0);
|
2018-06-06 21:25:55 +00:00
|
|
|
|
2018-06-09 10:33:01 +00:00
|
|
|
-- Sample pixel on next clock; pipelined to reduce the number of product terms
|
|
|
|
signal sample : std_logic;
|
2018-06-06 21:25:55 +00:00
|
|
|
|
2019-03-12 18:47:03 +00:00
|
|
|
-- New sample available, toggle psync on next cycle
|
|
|
|
signal toggle : std_logic;
|
|
|
|
|
2018-06-09 10:33:01 +00:00
|
|
|
-- RGB Input Mux
|
2019-12-22 15:30:30 +00:00
|
|
|
signal old_mux : std_logic;
|
2020-08-27 22:55:25 +00:00
|
|
|
signal mode7 : std_logic;
|
2020-02-22 18:53:16 +00:00
|
|
|
signal mux_sync : std_logic;
|
|
|
|
|
2018-06-09 10:33:01 +00:00
|
|
|
signal R : std_logic;
|
|
|
|
signal G : std_logic;
|
|
|
|
signal B : std_logic;
|
2017-04-24 19:21:18 +00:00
|
|
|
|
2019-12-22 15:30:30 +00:00
|
|
|
signal clamp_int : std_logic;
|
|
|
|
signal clamp_enable : std_logic;
|
2019-11-10 02:30:51 +00:00
|
|
|
|
2018-06-05 16:52:42 +00:00
|
|
|
begin
|
2019-12-22 15:30:30 +00:00
|
|
|
old_mux <= mux when not(SupportAnalog) else '0';
|
2020-08-27 22:55:25 +00:00
|
|
|
|
2020-02-08 11:53:16 +00:00
|
|
|
R <= R1 when old_mux = '1' else R0;
|
|
|
|
G <= G1 when old_mux = '1' else G0;
|
|
|
|
B <= B1 when old_mux = '1' else B0;
|
2019-12-22 15:30:30 +00:00
|
|
|
|
2018-06-09 10:33:01 +00:00
|
|
|
offset_A <= sp_reg(2 downto 0);
|
|
|
|
offset_B <= sp_reg(5 downto 3);
|
|
|
|
offset_C <= sp_reg(8 downto 6);
|
|
|
|
offset_D <= sp_reg(11 downto 9);
|
|
|
|
offset_E <= sp_reg(14 downto 12);
|
|
|
|
offset_F <= sp_reg(17 downto 15);
|
2018-06-09 19:41:06 +00:00
|
|
|
half <= sp_reg(18);
|
2019-03-23 18:33:53 +00:00
|
|
|
delay <= unsigned(sp_reg(20 downto 19));
|
|
|
|
rate <= sp_reg(22 downto 21);
|
2020-09-30 15:08:19 +00:00
|
|
|
invert <= sp_reg(23) when not(SupportAnalog) else '0';
|
|
|
|
mode7 <= mode7_in when not(SupportAnalog) else sp_reg(23);
|
2017-05-24 12:20:06 +00:00
|
|
|
|
|
|
|
-- Shift the bits in LSB first
|
2020-02-22 18:53:16 +00:00
|
|
|
process(sp_clk)
|
2017-05-24 12:20:06 +00:00
|
|
|
begin
|
2018-06-06 13:48:51 +00:00
|
|
|
if rising_edge(sp_clk) then
|
2018-06-06 16:51:11 +00:00
|
|
|
if sp_clken = '1' then
|
|
|
|
sp_reg <= sp_data & sp_reg(sp_reg'left downto sp_reg'right + 1);
|
|
|
|
end if;
|
2017-05-24 12:20:06 +00:00
|
|
|
end if;
|
|
|
|
end process;
|
|
|
|
|
2017-04-24 19:21:18 +00:00
|
|
|
process(clk)
|
|
|
|
begin
|
|
|
|
if rising_edge(clk) then
|
2018-06-09 10:33:01 +00:00
|
|
|
|
2017-04-26 17:15:47 +00:00
|
|
|
-- synchronize CSYNC to the sampling clock
|
2019-03-06 02:29:27 +00:00
|
|
|
-- if link fitted sync is inverted. If +ve vsync connected to link & +ve hsync to S then generate -ve composite sync
|
2020-08-27 22:55:25 +00:00
|
|
|
csync1 <= csync_in xor invert;
|
2018-10-15 15:19:23 +00:00
|
|
|
|
|
|
|
-- De-glitch CSYNC
|
2018-10-15 15:58:29 +00:00
|
|
|
-- csync1 is the possibly glitchy input
|
|
|
|
-- csync2 is the filtered output
|
|
|
|
if csync1 = csync2 then
|
|
|
|
-- output same as input, reset the counter
|
2018-10-15 15:19:23 +00:00
|
|
|
csync_counter <= to_unsigned(0, csync_counter'length);
|
2018-10-15 15:58:29 +00:00
|
|
|
else
|
|
|
|
-- output different to input
|
2018-10-15 15:19:23 +00:00
|
|
|
csync_counter <= csync_counter + 1;
|
2018-10-15 15:58:29 +00:00
|
|
|
-- if the difference lasts for N-1 cycles, update the output
|
2018-10-15 20:58:42 +00:00
|
|
|
if csync_counter = 3 then
|
2018-10-15 15:58:29 +00:00
|
|
|
csync2 <= csync1;
|
|
|
|
end if;
|
2019-12-22 15:30:30 +00:00
|
|
|
end if;
|
|
|
|
|
|
|
|
-- Counter is used to find sampling point for first pixel
|
|
|
|
last <= csync2;
|
2019-03-23 18:33:53 +00:00
|
|
|
-- reset counter on the rising edge of csync
|
|
|
|
if last = '0' and csync2 = '1' then
|
2019-03-12 18:47:03 +00:00
|
|
|
if rate(1) = '1' then
|
2019-03-27 01:39:28 +00:00
|
|
|
counter(7 downto 3) <= "10" & delay & "0";
|
2018-06-09 19:41:06 +00:00
|
|
|
if half = '1' then
|
2019-03-12 18:47:03 +00:00
|
|
|
counter(2 downto 0) <= "000";
|
|
|
|
elsif mode7 = '1' then
|
|
|
|
counter(2 downto 0) <= "100";
|
2019-03-24 12:11:12 +00:00
|
|
|
else
|
|
|
|
counter(2 downto 0) <= "011";
|
2018-06-09 19:41:06 +00:00
|
|
|
end if;
|
2017-04-26 21:19:41 +00:00
|
|
|
else
|
2019-03-27 01:39:28 +00:00
|
|
|
counter(7 downto 3) <= "110" & delay;
|
2018-06-09 19:41:06 +00:00
|
|
|
if half = '1' then
|
2019-03-12 18:47:03 +00:00
|
|
|
counter(2 downto 0) <= "000";
|
|
|
|
elsif mode7 = '1' then
|
|
|
|
counter(2 downto 0) <= "100";
|
2019-03-24 12:11:12 +00:00
|
|
|
else
|
|
|
|
counter(2 downto 0) <= "011";
|
2018-06-09 19:41:06 +00:00
|
|
|
end if;
|
2017-04-26 21:19:41 +00:00
|
|
|
end if;
|
2018-06-07 16:13:33 +00:00
|
|
|
elsif mode7 = '1' or counter(2 downto 0) /= 5 then
|
2019-03-08 10:10:20 +00:00
|
|
|
if counter(counter'left) = '1' then
|
2019-02-25 19:57:29 +00:00
|
|
|
counter <= counter + 1;
|
|
|
|
else
|
2019-03-12 18:47:03 +00:00
|
|
|
counter(counter'left - 1 downto 0) <= counter(counter'left - 1 downto 0) + 1;
|
2019-02-25 19:57:29 +00:00
|
|
|
end if;
|
2017-04-24 19:21:18 +00:00
|
|
|
else
|
2019-03-08 10:10:20 +00:00
|
|
|
if counter(counter'left) = '1' then
|
2019-02-25 19:57:29 +00:00
|
|
|
counter <= counter + 3;
|
|
|
|
else
|
2019-03-12 18:47:03 +00:00
|
|
|
counter(counter'left - 1 downto 0) <= counter(counter'left - 1 downto 0) + 3;
|
2019-02-25 19:57:29 +00:00
|
|
|
end if;
|
2018-06-07 16:04:13 +00:00
|
|
|
end if;
|
2017-05-23 12:03:27 +00:00
|
|
|
|
2018-06-09 10:33:01 +00:00
|
|
|
-- Sample point offset index
|
2019-03-08 10:10:20 +00:00
|
|
|
if counter(counter'left) = '1' then
|
2018-06-09 10:33:01 +00:00
|
|
|
index <= "000";
|
|
|
|
else
|
2019-03-13 13:57:51 +00:00
|
|
|
-- so index offset changes at the same time counter wraps 7->0
|
2019-03-12 22:42:09 +00:00
|
|
|
-- so index offset changes at the same time counter wraps ->0
|
|
|
|
if (mode7 = '0' and counter(2 downto 0) = 4) or (mode7 = '1' and counter(2 downto 0) = 6) then
|
2018-06-09 10:33:01 +00:00
|
|
|
case index is
|
|
|
|
when "000" =>
|
|
|
|
index <= "001";
|
|
|
|
when "001" =>
|
|
|
|
index <= "010";
|
|
|
|
when "010" =>
|
|
|
|
index <= "011";
|
|
|
|
when "011" =>
|
|
|
|
index <= "100";
|
|
|
|
when "100" =>
|
|
|
|
index <= "101";
|
|
|
|
when others =>
|
|
|
|
index <= "000";
|
|
|
|
end case;
|
2017-04-24 19:21:18 +00:00
|
|
|
end if;
|
2018-06-07 16:04:13 +00:00
|
|
|
end if;
|
|
|
|
|
2018-06-09 10:33:01 +00:00
|
|
|
-- Sample point offset
|
|
|
|
case index is
|
|
|
|
when "000" =>
|
|
|
|
offset <= offset_B;
|
|
|
|
when "001" =>
|
|
|
|
offset <= offset_C;
|
|
|
|
when "010" =>
|
|
|
|
offset <= offset_D;
|
|
|
|
when "011" =>
|
|
|
|
offset <= offset_E;
|
|
|
|
when "100" =>
|
|
|
|
offset <= offset_F;
|
|
|
|
when others =>
|
|
|
|
offset <= offset_A;
|
|
|
|
end case;
|
|
|
|
|
|
|
|
-- sample/shift control
|
2019-03-12 18:47:03 +00:00
|
|
|
if counter(counter'left) = '0' and counter(2 downto 0) = unsigned(offset) and (rate(1) = '0' or rate(0) = counter(3)) then
|
2018-06-09 10:33:01 +00:00
|
|
|
sample <= '1';
|
|
|
|
else
|
|
|
|
sample <= '0';
|
|
|
|
end if;
|
|
|
|
|
|
|
|
-- R Sample/shift register
|
|
|
|
if sample = '1' then
|
2019-03-12 18:47:03 +00:00
|
|
|
if rate = "01" then
|
2019-12-17 02:35:04 +00:00
|
|
|
shift_R <= R1 & R0 & shift_R(3 downto 2); -- double
|
2019-03-08 11:13:34 +00:00
|
|
|
else
|
2019-03-12 18:47:03 +00:00
|
|
|
shift_R <= R & shift_R(3 downto 1);
|
2019-03-08 11:13:34 +00:00
|
|
|
end if;
|
2018-06-09 10:33:01 +00:00
|
|
|
end if;
|
|
|
|
|
|
|
|
-- G Sample/shift register
|
|
|
|
if sample = '1' then
|
2019-03-12 18:47:03 +00:00
|
|
|
if rate = "01" then
|
2020-02-08 11:53:16 +00:00
|
|
|
shift_G <= G1 & G0 & shift_G(3 downto 2); -- double
|
2019-03-08 11:13:34 +00:00
|
|
|
else
|
2019-03-12 18:47:03 +00:00
|
|
|
shift_G <= G & shift_G(3 downto 1);
|
2019-03-08 11:13:34 +00:00
|
|
|
end if;
|
2018-06-09 10:33:01 +00:00
|
|
|
end if;
|
|
|
|
|
|
|
|
-- B Sample/shift register
|
|
|
|
if sample = '1' then
|
2019-03-12 18:47:03 +00:00
|
|
|
if rate = "01" then
|
2019-12-17 02:35:04 +00:00
|
|
|
shift_B <= B1 & B0 & shift_B(3 downto 2); -- double
|
2019-03-08 11:13:34 +00:00
|
|
|
else
|
2019-03-12 18:47:03 +00:00
|
|
|
shift_B <= B & shift_B(3 downto 1);
|
2019-03-08 11:13:34 +00:00
|
|
|
end if;
|
2017-04-24 19:21:18 +00:00
|
|
|
end if;
|
2018-06-07 16:04:13 +00:00
|
|
|
|
2019-03-12 21:31:11 +00:00
|
|
|
-- Pipeline when to update the quad
|
2019-03-13 13:57:51 +00:00
|
|
|
if counter(counter'left) = '0' and (
|
|
|
|
(rate = "00" and counter(4 downto 0) = 0) or -- normal
|
|
|
|
(rate = "01" and counter(3 downto 0) = 0) or -- double
|
|
|
|
(rate = "10" and counter(5 downto 0) = 0) or -- subsample even
|
|
|
|
(rate = "11" and counter(5 downto 0) = 32)) then -- subsample odd
|
|
|
|
-- toggle is asserted in cycle 1
|
|
|
|
toggle <= '1';
|
|
|
|
else
|
|
|
|
toggle <= '0';
|
2019-03-12 18:47:03 +00:00
|
|
|
end if;
|
|
|
|
|
2018-06-07 16:04:13 +00:00
|
|
|
-- Output quad register
|
2018-06-09 12:24:47 +00:00
|
|
|
if version = '0' then
|
2019-12-05 14:34:59 +00:00
|
|
|
if SupportAnalog then
|
|
|
|
if analog = '1' then
|
|
|
|
quad <= VERSION_NUM_RGB_ANALOG;
|
|
|
|
else
|
|
|
|
quad <= VERSION_NUM_RGB_TTL;
|
|
|
|
end if;
|
|
|
|
else
|
|
|
|
quad <= VERSION_NUM_BBC;
|
|
|
|
end if;
|
2019-03-12 21:31:11 +00:00
|
|
|
elsif counter(counter'left) = '1' then
|
|
|
|
quad <= (others => '0');
|
|
|
|
elsif toggle = '1' then
|
2019-03-13 13:57:51 +00:00
|
|
|
-- quad changes at the start of cycle 2
|
2019-03-12 21:31:11 +00:00
|
|
|
quad(11) <= shift_B(3);
|
|
|
|
quad(10) <= shift_G(3);
|
|
|
|
quad(9) <= shift_R(3);
|
|
|
|
quad(8) <= shift_B(2);
|
|
|
|
quad(7) <= shift_G(2);
|
|
|
|
quad(6) <= shift_R(2);
|
|
|
|
quad(5) <= shift_B(1);
|
|
|
|
quad(4) <= shift_G(1);
|
|
|
|
quad(3) <= shift_R(1);
|
|
|
|
quad(2) <= shift_B(0);
|
|
|
|
quad(1) <= shift_G(0);
|
|
|
|
quad(0) <= shift_R(0);
|
2018-06-07 16:04:13 +00:00
|
|
|
end if;
|
|
|
|
|
2019-03-12 21:31:11 +00:00
|
|
|
-- Output a skewed version of psync
|
2019-03-23 18:33:53 +00:00
|
|
|
if version = '0' then
|
2019-12-17 02:35:04 +00:00
|
|
|
psync <= vsync_in;
|
2019-03-23 18:33:53 +00:00
|
|
|
elsif counter(counter'left) = '1' then
|
2019-03-12 21:31:11 +00:00
|
|
|
psync <= '0';
|
2019-03-13 13:57:51 +00:00
|
|
|
elsif counter(3 downto 0) = 3 then -- comparing with N gives N-1 cycles of skew
|
2019-03-12 21:31:11 +00:00
|
|
|
if rate = "00" then
|
|
|
|
psync <= counter(5); -- normal
|
|
|
|
elsif rate = "01" then
|
|
|
|
psync <= counter(4); -- double
|
|
|
|
elsif counter(5) = rate(0) then
|
|
|
|
psync <= counter(6); -- subsample
|
|
|
|
end if;
|
|
|
|
end if;
|
2019-12-22 15:30:30 +00:00
|
|
|
|
2017-04-24 19:21:18 +00:00
|
|
|
end if;
|
|
|
|
end process;
|
2019-12-22 15:30:30 +00:00
|
|
|
|
|
|
|
csync <= csync2; -- output the registered version to save a macro-cell
|
|
|
|
|
2019-12-22 15:56:36 +00:00
|
|
|
analog_additions: if SupportAnalog generate
|
2020-06-23 04:46:40 +00:00
|
|
|
-- csync2 is cleaned but delayed so OR with csync1 to remove delay on trailing edge of sync pulse
|
|
|
|
-- spdata is overloaded as clamp on/off
|
|
|
|
clamp_int <= not(csync1 or csync2) and sp_data;
|
2017-04-24 19:21:18 +00:00
|
|
|
|
2020-02-08 11:44:36 +00:00
|
|
|
clamp_enable <= '1' when mux = '1' else version;
|
2019-12-22 15:56:36 +00:00
|
|
|
|
|
|
|
analog <= 'Z' when clamp_enable = '0' else clamp_int;
|
|
|
|
end generate;
|
2017-05-25 14:12:09 +00:00
|
|
|
|
2017-04-24 19:21:18 +00:00
|
|
|
end Behavorial;
|