-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path8:3 Encoder.vhd
50 lines (39 loc) · 1.11 KB
/
8:3 Encoder.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
-----------------------DataFlow Model using when/else---------------------------
library ieee;
use ieee.std_logic_1164.all;
entity 8_3E is
port( x: in std_logic_vector(7 downto 0);
y: out Std_logic_vector(2 downto 0));
end 8_3E;
Architecture DataFlow of 8_3E is
begin
y<= "000" when x="00000001" else
"001" when x="00000010" else
"010" when x="00000100" else
"011" when x="00001000" else
"100" when x="00010000" else
"101" when x="0010000" else
"110" when x="01000000" else
"111" when x="10000000" else
"ZZZ";
end DataFlow;
-----------------------DataFlow Model using with/select/when---------------------------
library ieee;
use ieee.std_logic_1164.all;
entity 8_3E is
port( x: in std_logic_vector(7 downto 0);
y: out Std_logic_vector(2 downto 0));
end 8_3E;
Architecture DataFlow of 8_3E is
begin
with x SELECT
y<= "000" when "00000001",
"001" when "00000010",
"010" when "00000100",
"011" when "00001000",
"100" when "00010000",
"101" when "00100000",
"110" when "01000000",
"111" when "10000000",
"ZZZ" when OTHERS;
end DataFlow;