VHDL Code:: Structural Modeling
VHDL Code:: Structural Modeling
Answer:
VHDL CODE:
Structural Modeling:
library ieee;
use ieee.std_logic_1164.all;
entity mux_4X1 is
port(c:in std_logic_vector(3 downto 0);
a,b:in std_logic;
f:out std_logic);
end mux_4X1;
component or4
port(y1,y2,y3,y4:in std_logic;
o2: out std_logic);
end component;
component not1
port(z1:in std_logic;
o3:out std_logic);
end component;
signal t1,t2:std_logic;
signal s1,s2,s3,s4:std_logic;
begin
U1:and3 port map(t1,t2,c(0),s1);
U2:and3 port map(t1,b,c(1),s2);
U3:and3 port map(a,t2,c(2),s3);
U4:and3 port map(a,b,c(3),s4);
U5:not1 port map(a,t1);
U6:not1 port map(b,t2);
U7:or4 port map(s1,s2,s3,s4,f);
end ;
-------------------------------
--and3
-------------------------------
library ieee;
use ieee.std_logic_1164.all;
entity and3 is
port(x1,x2,x3:in std_logic;
o1:out std_logic);
end and3;
architecture DF_and3 of and3 is
begin
o1<=((x1 and x2) and x3);
end;
--------------------------------
--OR4
--------------------------------
library ieee;
use ieee.std_logic_1164.all;
entity or4 is
port(y1,y2,y3,y4:in std_logic;
o2: out std_logic);
end or4;
architecture DF_or4 of or4 is
begin
o2<= (((y1 or y2)or y3) or y4);
end;
--------------------------------
--NOT1
--------------------------------
library ieee;
use ieee.std_logic_1164.all;
entity not1 is
port(z1:in std_logic;
o3:out std_logic);
end not1;
WAVE FORM:
DATAFLOW :
library ieee;
use ieee.std_logic_1164.all;
entity MUX4X1 is
port(c:in std_logic_vector(3 downto 0);
a,b:in std_logic;
f:out std_logic);
end MUX4X1;
WAVE FORM:
BEHAVIORAL:
library ieee;
use ieee.std_logic_1164.all;
entity BH_MUX4X1 is
port(c:in std_logic_vector(3 downto 0);
a,b:in std_logic;
f:out std_logic);
end BH_MUX4X1;
architecture BH_MUX4X1 of BH_MUX4X1 is
begin
process(a,b,c)
begin
if a='0' and b='0' then
f<=c(0);
elsif a='0' and b='1' then
f<=c(1);
elsif a='1' and b='0' then
f<=c(2);
elsif a='1' and b='1' then
f<=c(3);
end if;
end process;
end;
WAVEFORM:
(CASE)
library ieee;
use ieee.std_logic_1164.all;
entity BH_MUX4X1_case is
port(c:in std_logic_vector(3 downto 0);
a,b:in std_logic;
f:out std_logic);
end BH_MUX4X1_case;
WAVEFORM: