summaryrefslogtreecommitdiffstats
path: root/fpga/hp_lcd_driver/tmds_phy_cyclone4.vhdl
blob: 6160636836e446a72e6457e2c831a4c463c91c85 (plain)
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
library ieee;
use ieee.std_logic_1164.all;
use IEEE.NUMERIC_STD.all;

library altera_mf;
use altera_mf.altera_mf_components.all;

entity tmds_phy_cyclone4 is
    port (
        sys_rst_n  : in  std_logic;
        pclk_phy   : in  std_logic;
        b          :     natural;
        din        : in  std_logic_vector(9 downto 0);
        tmds_out_p : out std_logic;
        tmds_out_n : out std_logic
        );
end tmds_phy_cyclone4;


architecture beh of tmds_phy_cyclone4 is


    signal d_rise : std_logic_vector(4 downto 0);
    signal d_fall : std_logic_vector(4 downto 0);

    signal out_p : std_logic_vector(0 downto 0);
    signal out_n : std_logic_vector(0 downto 0);

    signal bb : natural;

begin


    process (pclk_phy)
    begin
        if rising_edge(pclk_phy) then
            if b = 4 then
                d_rise <= (4 => din(8), 3 => din(6), 2 => din(4), 1 => din(2), 0 => din(0));
                d_fall <= (4 => din(9), 3 => din(7), 2 => din(5), 1 => din(3), 0 => din(1));
            --d_rise <= (4 => din(1), 3 => din(3), 2 => din(5), 1 => din(7), 0 => din(9));
            --d_fall <= (4 => din(0), 3 => din(2), 2 => din(4), 1 => din(6), 0 => din(8));
            else
                d_rise(3 downto 0) <= d_rise(4 downto 1);
                d_fall(3 downto 0) <= d_fall(4 downto 1);
            end if;
        end if;
    end process;


    obuf_p : ALTDDIO_OUT
        generic map (
            extend_oe_disable      => "OFF",
            intended_device_family => "Cyclone IV E",
            invert_output          => "OFF",
            lpm_hint               => "UNUSED",
            lpm_type               => "altddio_out",
            oe_reg                 => "UNREGISTERED",
            power_up_high          => "OFF",
            width                  => 1
            )
        port map (
            aclr     => not sys_rst_n,
            datain_h => d_rise(0 downto 0),
            datain_l => d_fall(0 downto 0),
            outclock => not pclk_phy,
            dataout  => out_p
            );
    tmds_out_p <= out_p(0);

    obuf_n : ALTDDIO_OUT
        generic map (
            extend_oe_disable      => "OFF",
            intended_device_family => "Cyclone IV E",
            invert_output          => "OFF",
            lpm_hint               => "UNUSED",
            lpm_type               => "altddio_out",
            oe_reg                 => "UNREGISTERED",
            power_up_high          => "OFF",
            width                  => 1
            )
        port map (
            aclr     => not sys_rst_n,
            datain_h => not d_rise(0 downto 0),
            datain_l => not d_fall(0 downto 0),
            outclock => not pclk_phy,
            dataout  => out_n
            );
    tmds_out_n <= out_n(0);


end beh;