-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdvid.vhd
132 lines (114 loc) · 4.17 KB
/
dvid.vhd
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
--------------------------------------------------------------------------------
-- Engineer: Mike Field <hamster@snap.net.nz>
-- Description: Converts VGA signals into DVID bitstreams.
--
-- 'clk' and 'clk_n' should be 5x clk_pixel.
--
-- 'blank' should be asserted during the non-display
-- portions of the frame
--------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
--Library UNISIM;
--use UNISIM.vcomponents.all;
entity dvid is
Port ( clk : in STD_LOGIC;
clk_pixel : in STD_LOGIC;
red_p : in STD_LOGIC_VECTOR (7 downto 0);
green_p : in STD_LOGIC_VECTOR (7 downto 0);
blue_p : in STD_LOGIC_VECTOR (7 downto 0);
blank : in STD_LOGIC;
hsync : in STD_LOGIC;
vsync : in STD_LOGIC;
red_s : out STD_LOGIC;
green_s : out STD_LOGIC;
blue_s : out STD_LOGIC;
clock_s : out STD_LOGIC);
end dvid;
architecture Behavioral of dvid is
COMPONENT TDMS_encoder
PORT(
clk : IN std_logic;
data : IN std_logic_vector(7 downto 0);
c : IN std_logic_vector(1 downto 0);
blank : IN std_logic;
encoded : OUT std_logic_vector(9 downto 0)
);
END COMPONENT;
component ddrOutput IS
PORT
(
datain_h : IN STD_LOGIC_VECTOR (0 DOWNTO 0);
datain_l : IN STD_LOGIC_VECTOR (0 DOWNTO 0);
outclock : IN STD_LOGIC ;
dataout : OUT STD_LOGIC_VECTOR (0 DOWNTO 0)
);
END component;
signal encoded_red, encoded_green, encoded_blue : std_logic_vector(9 downto 0);
signal latched_red, latched_green, latched_blue : std_logic_vector(9 downto 0) := (others => '0');
signal shift_red, shift_green, shift_blue : std_logic_vector(9 downto 0) := (others => '0');
signal shift_clock : std_logic_vector(9 downto 0) := "0000011111";
constant c_red : std_logic_vector(1 downto 0) := (others => '0');
constant c_green : std_logic_vector(1 downto 0) := (others => '0');
signal c_blue : std_logic_vector(1 downto 0);
begin
c_blue <= vsync & hsync;
TDMS_encoder_red: TDMS_encoder PORT MAP(clk => clk_pixel, data => red_p, c => c_red, blank => blank, encoded => encoded_red);
TDMS_encoder_green: TDMS_encoder PORT MAP(clk => clk_pixel, data => green_p, c => c_green, blank => blank, encoded => encoded_green);
TDMS_encoder_blue: TDMS_encoder PORT MAP(clk => clk_pixel, data => blue_p, c => c_blue, blank => blank, encoded => encoded_blue);
ddrOutputClockInst: ddrOutput
port map
(
datain_h(0) => shift_clock(0),
datain_l(0) => shift_clock(1),
outclock => clk,
dataout(0) => clock_s
);
ddrOutputRedInst: ddrOutput
port map
(
datain_h(0) => shift_red(0),
datain_l(0) => shift_red(1),
outclock => clk,
dataout(0) => red_s
);
ddrOutputGreenInst: ddrOutput
port map
(
datain_h(0) => shift_green(0),
datain_l(0) => shift_green(1),
outclock => clk,
dataout(0) => green_s
);
ddrOutputBlueInst: ddrOutput
port map
(
datain_h(0) => shift_blue(0),
datain_l(0) => shift_blue(1),
outclock => clk,
dataout(0) => blue_s
);
process(clk_pixel)
begin
if rising_edge(clk_pixel) then
latched_red <= encoded_red;
latched_green <= encoded_green;
latched_blue <= encoded_blue;
end if;
end process;
process(clk)
begin
if rising_edge(clk) then
if shift_clock = "0000011111" then
shift_red <= latched_red;
shift_green <= latched_green;
shift_blue <= latched_blue;
else
shift_red <= "00" & shift_red (9 downto 2);
shift_green <= "00" & shift_green(9 downto 2);
shift_blue <= "00" & shift_blue (9 downto 2);
end if;
shift_clock <= shift_clock(1 downto 0) & shift_clock(9 downto 2);
end if;
end process;
end Behavioral;