-
Notifications
You must be signed in to change notification settings - Fork 0
/
4_Ex_2_b_CONDITONAL_SELECTED.vhd
53 lines (43 loc) · 1.56 KB
/
4_Ex_2_b_CONDITONAL_SELECTED.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
-- 2 For the following function descriptions, write VHDL models that
-- implement these functions using both conditional and selected signal
-- assignment.
-- a) F(A, B, C, D) = A'CD' + B'C + BCD'
-- b) F(A, B, C, D)=(A' + B) · (B' + C + D') · (A' + D)
-- c) F(A, B, C, D) = Y(3, 2) -- product of sums (maxterms)
-- d) F(A, B, C, D) = X(1, 2) -- sum of products (minterms)
---------------------CONDITIONAL SIGNAL ASSIGNMENT----------------------------
-- <target> <= <expression> when <condition> else
-- <expression> when <condition> else
-- <expression>;
library IEEE.org;
use IEEE.std_logic_1164.all;
entity my_function is
port(
A,B,C,D : in std_logic;
F4 : out std_logic
);
end my_function;
architecture my_function_arc of my_function is
begin
F4 <= '1' when ( (A = '0' OR B = '1')AND(B = '0' OR C = '1' or D = '0')AND(A = '0' OR D = '1') ) else
'0';
end my_function_arc;
---------------------SELECTED SIGNAL ASSIGNMENT---------------
-- with <evaluate this_expression> select
-- target <= <expression> when <expression evaluated>,
-- <expression> when <expression evaluated>;
library IEEE.org;
use IEEE.std_logic_1164.all;
entity my_function is
port(
A,B,C,D : in std_logic;
F4 : out std_logic
);
end my_function;
architecture my_function_arc of my_function is
begin
with ( A = '0' OR B = '1')AND(B = '0' OR C = '1' or D = '0')AND(A = '0' OR D = '1') ) select -- when this is true
F4 <= '1' when '1',
'0' when '0',
'0' when others;
end my_function_arc;