-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpixelAlpha.vhd
71 lines (44 loc) · 1.8 KB
/
pixelAlpha.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
library ieee;
use ieee.std_logic_1164.all;
use IEEE.std_logic_arith.all;
use IEEE.std_logic_unsigned.all;
entity pixelAlpha is
port(
--reset
reset: in std_logic;
clock: in std_logic;
colorInA: in std_logic_vector( 15 downto 0 );
colorInB: in std_logic_vector( 15 downto 0 );
alpha: in std_logic_vector( 4 downto 0 );
colorOut: out std_logic_vector( 15 downto 0 )
);
end pixelAlpha;
architecture behavior of pixelAlpha is
begin
main: process( all )
variable mulAR: std_logic_vector( 9 downto 0 );
variable mulAG: std_logic_vector( 9 downto 0 );
variable mulAB: std_logic_vector( 9 downto 0 );
variable mulBR: std_logic_vector( 9 downto 0 );
variable mulBG: std_logic_vector( 9 downto 0 );
variable mulBB: std_logic_vector( 9 downto 0 );
variable beta: std_logic_vector( 4 downto 0 );
variable outR: std_logic_vector( 4 downto 0 );
variable outG: std_logic_vector( 4 downto 0 );
variable outB: std_logic_vector( 4 downto 0 );
begin
if rising_edge( clock ) then
beta := not alpha;
mulAR := colorInA( 4 downto 0 ) * alpha;
mulAG := colorInA( 10 downto 6 ) * alpha;
mulAB := colorInA( 15 downto 11 ) * alpha;
mulBR := colorInB( 4 downto 0 ) * beta;
mulBG := colorInB( 10 downto 6 ) * beta;
mulBB := colorInB( 15 downto 11 ) * beta;
outR := mulAR( 9 downto 5 ) + mulBR( 9 downto 5 );
outG := mulAG( 9 downto 5 ) + mulBG( 9 downto 5 );
outB := mulAB( 9 downto 5 ) + mulBB( 9 downto 5 );
colorOut <= outB & outG & "0" & outR;
end if; -- rising_edge( clock )
end process;
end behavior;