-
Notifications
You must be signed in to change notification settings - Fork 22
/
alpha_blend_top.vhd
259 lines (247 loc) · 9.81 KB
/
alpha_blend_top.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
--------------------------------------------------------------------------------
-- Copyright (c) 2004 Xilinx, Inc.
-- All Rights Reserved
--------------------------------------------------------------------------------
-- ____ ____
-- / /\/ /
-- /___/ \ / Vendor: Xilinx
-- \ \ \/ Author: Reed Tidwell, Advanced Product Division, Xilinx, Inc.
-- \ \ Filename: $RCSfile: alpha_blend_top.vhd,v $
-- / / Date Last Modified: $Date: 2004-12-14 10:43:39-07 $
-- /___/ /\ Date Created: October 18, 2004
-- \ \ / \
-- \___\/\___\
--
--
-- Revision History:
-- $Log: alpha_blend_top.vhd,v $
-- Revision 1.3 2004-12-14 10:43:39-07 reedt
-- Corrected pixclk_out to clk1x for compiling with wrapper.
--
-- Revision 1.2 2004-12-06 10:11:13-07 reedt
-- Added Rounding for App note 706
--
-- Revision 1.1 2004-11-18 09:52:59-07 reedt
-- Changed clock follower, fol_clk1x, to be 2 FF stages instead of 3.
--
-- Revision 1.0 2004-11-08 12:53:21-07 reedt
-- Initial revision
--
-- Revision 1.1 2004-10-26 13:56:49-06 reedt
-- Completed blend simulation with picture files.
--
-- Revision 1.0 2004-10-19 10:55:08-06 reedt
-- Video stream blender with inputs for 2 sets of RGB & DE plus
-- an Alpha stream and alpha DE. Simulation compile OK.
--
-- Revision 1.0 2004-10-19 10:16:14-06 reedt
-- Video stream blender with inputs for 2 sets of RGB & DE plus
-- an Alpha stream and alpha DE. Initial checkin is before compile.
--
-- Revision 1.0 2004-09-20 17:22:32-06 reedt
-- Initial Checkin
--
--------------------------------------------------------------------------------
--
-- XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS"
-- SOLELY FOR USE IN DEVELOPING PROGRAMS AND SOLUTIONS FOR
-- XILINX DEVICES. BY PROVIDING THIS DESIGN, CODE, OR INFORMATION
-- AS ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE, APPLICATION
-- OR STANDARD, XILINX IS MAKING NO REPRESENTATION THAT THIS
-- IMPLEMENTATION IS FREE FROM ANY CLAIMS OF INFRINGEMENT,
-- AND YOU ARE RESPONSIBLE FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE
-- FOR YOUR IMPLEMENTATION. XILINX EXPRESSLY DISCLAIMS ANY
-- WARRANTY WHATSOEVER WITH RESPECT TO THE ADEQUACY OF THE
-- IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OR
-- REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE FROM CLAIMS OF
-- INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-- FOR A PARTICULAR PURPOSE.
--
--------------------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
use ieee.numeric_std.all;
library unisim;
use unisim.vcomponents.all;
entity alpha_blend_top is
port(
clk1x: in std_logic;
clk2x: in std_logic;
reset: in std_logic;
hsync_strm0: in std_logic;
vsync_strm0: in std_logic;
de_strm0: in std_logic;
r_strm0: in std_logic_vector(9 downto 0);
g_strm0: in std_logic_vector(9 downto 0);
b_strm0: in std_logic_vector(9 downto 0);
de_strm1: in std_logic;
r_strm1: in std_logic_vector(9 downto 0);
g_strm1: in std_logic_vector(9 downto 0);
b_strm1: in std_logic_vector(9 downto 0);
de_alpha: in std_logic;
alpha_strm: in std_logic_vector(9 downto 0);
pixclk_out: out std_logic;
hsync_blnd: out std_logic;
vsync_blnd: out std_logic;
de_blnd: out std_logic;
r_blnd: out std_logic_vector(9 downto 0);
g_blnd: out std_logic_vector(9 downto 0);
b_blnd: out std_logic_vector(9 downto 0);
dcm_locked: out std_logic
);
end alpha_blend_top;
architecture synth of alpha_blend_top is
signal fol_clk1x: std_logic; -- clock follower of clk1x in clk2x domain
signal toggle: std_logic;
signal toggle_1: std_logic;
signal video0_r: std_logic_vector(17 downto 0);
signal video0_g: std_logic_vector(17 downto 0);
signal video0_b: std_logic_vector(17 downto 0);
signal video1_r: std_logic_vector(17 downto 0);
signal video1_g: std_logic_vector(17 downto 0);
signal video1_b: std_logic_vector(17 downto 0);
signal alpha: std_logic_vector(17 downto 0);
signal one_minus_alpha: std_logic_vector(17 downto 0);
signal blend_r: std_logic_vector(47 downto 0); -- outputs from DSP48
signal blend_g: std_logic_vector(47 downto 0);
signal blend_b: std_logic_vector(47 downto 0);
signal hsync_1, hsync_2, hsync_3, hsync_4: std_logic;
signal vsync_1, vsync_2, vsync_3, vsync_4: std_logic;
signal de_1, de_2, de_3, de_4: std_logic;
signal round: std_logic_vector(47 downto 0); -- Rounding constant
component dual_stream_blend
port(
clk1x: in std_logic; -- Input and output rate clock
clk2x: in std_logic; -- Frequency doubled clock for DSP
reset: in std_logic;
fol_clk1x: in std_logic;
video0: in std_logic_vector(17 downto 0); -- Data Stream 0 A value
video1: in std_logic_vector(17 downto 0); -- Data Stream 1 A value
alpha: in std_logic_vector(17 downto 0); -- Data Stream 0 B value
one_minus_alpha: in std_logic_vector(17 downto 0); -- Data Stream 1 B value
round: in std_logic_vector(47 downto 0); -- Rounding constant
-- output port
blend: out std_logic_vector(47 downto 0) -- Blended data stream
);
end component;
component DCM_1x_2x
port ( CLKIN_IN : in std_logic;
RST_IN : in std_logic;
CLKIN_IBUFG_OUT : out std_logic;
CLK0_OUT : out std_logic;
CLK2X_OUT : out std_logic;
LOCKED_OUT : out std_logic);
end component;
signal video0_r_drive : std_logic_vector(17 downto 0);
signal video0_g_drive : std_logic_vector(17 downto 0);
signal video0_b_drive : std_logic_vector(17 downto 0);
signal video1_r_drive : std_logic_vector(17 downto 0);
signal video1_g_drive : std_logic_vector(17 downto 0);
signal video1_b_drive : std_logic_vector(17 downto 0);
begin ------------------------------------------------------------------------
-- for multiplicands, repeat MSBs in the LSBs for greater range
video0_r <= ('0' & r_strm0 & r_strm0(9 downto 3));
video0_g <= ('0' & g_strm0 & g_strm0(9 downto 3));
video0_b <= ('0' & b_strm0 & b_strm0(9 downto 3));
video1_r <= ('0' & r_strm1 & r_strm1(9 downto 3));
video1_g <= ('0' & g_strm1 & g_strm1(9 downto 3));
video1_b <= ('0' & b_strm1 & b_strm1(9 downto 3));
alpha <= ('0' &alpha_strm & alpha_strm(9 downto 3))
when de_alpha = '1' else "01" & x"FFFF";
one_minus_alpha <= ('0' & not alpha_strm & not alpha_strm(9 downto 3))
when de_alpha = '1' else "00" & x"0000";
round <= x"000000010000" ; -- round to 17 significant bits on output
--
-- select output bits from 48 bit accumulator
--
r_blnd <= blend_r(33 downto 24);
g_blnd <= blend_g(33 downto 24);
b_blnd <= blend_b(33 downto 24);
hsync_blnd <= hsync_4;
vsync_blnd <= vsync_4;
de_blnd <= de_4;
pixclk_out <= clk1x;
--
-- delay syncs to match rgb data
--
process( clk1x) begin
if clk1x'event and clk1x = '1' then
hsync_1 <= hsync_strm0;
hsync_2 <= hsync_1;
hsync_3 <= hsync_2;
hsync_4 <= hsync_3;
vsync_1 <= vsync_strm0;
vsync_2 <= vsync_1;
vsync_3 <= vsync_2;
vsync_4 <= vsync_3;
de_1 <= de_strm0;
de_2 <= de_1;
de_3 <= de_2;
de_4 <= de_3;
video0_r_drive <= video0_r;
video0_g_drive <= video0_g;
video0_b_drive <= video0_b;
video1_r_drive <= video1_r;
video1_g_drive <= video1_g;
video1_b_drive <= video1_b;
end if;
end process;
-- create clock following circuit
process( clk1x, reset) begin
if reset = '1' then
toggle <= '0';
elsif clk1x'event and clk1x = '1' then
toggle <= not toggle;
end if;
end process;
process (clk2x) begin
if clk2x'event and clk2x = '1' then
toggle_1 <= toggle;
fol_clk1x <= not (toggle xor toggle_1);
end if;
end process;
--
-- instantiate blend units for R G and B
--
red_blender : dual_stream_blend
port map(
clk1x => clk1x,
clk2x => clk2x,
reset => reset,
fol_clk1x => fol_clk1x,
video0 => video0_r_drive,
video1 => video1_r_drive,
alpha => alpha,
one_minus_alpha => one_minus_alpha,
round => round,
blend => blend_r
);
green_blender : dual_stream_blend
port map(
clk1x => clk1x,
clk2x => clk2x,
reset => reset,
fol_clk1x => fol_clk1x,
video0 => video0_g_drive,
video1 => video1_g_drive,
alpha => alpha,
one_minus_alpha => one_minus_alpha,
round => round,
blend => blend_g
);
blue_blender : dual_stream_blend
port map(
clk1x => clk1x,
clk2x => clk2x,
reset => reset,
fol_clk1x => fol_clk1x,
video0 => video0_b_drive,
video1 => video1_b_drive,
alpha => alpha,
one_minus_alpha => one_minus_alpha,
round => round,
blend => blend_b
);
end synth;