Beruflich Dokumente
Kultur Dokumente
1
(data-flow modelling)
1. Design and simulate a 4 input NOR Gate program using
dataflow modeling in VHDL.
entity four_input is
port (a,b,c,d :in bit; x :out bit);
end four_input;
architecture nor1 of four_input is
begin
x<= not(a or b or c or d);
end nor1;
c :out bit);
end three_input;
architecture or1 of three_input is
begin
c<= a or b or d;
end or1;
10.
Design and simulate a full adder in VHDL using dataflowmodeling style.
entity fa2_df_model is
port(a,b,c: in bit; s,cout:out bit);
end fa2_df_model;
architecture arc_fa2_df_model of fa2_df_model is
signal x,y,w: bit;
begin
x<= a xor b;
y<= x and c;
w<= a and b;
s<= x xor c;
cout<= y or w;
end arc_fa2_df_model;
11.
Design and simulate a 2-1 Mux in VHDL using dataflowmodeling style.
entity mux2_1new is
port(a,b,c,d,in1,in2:in bit;out1:out bit);
end mux2_1new;
architecture mux1 of mux2_1new is
begin
out1<= ((not in1) and (not in2) and a) or
(not in1) and in2 and b)
or
(in1 and (not in2) and c)
or
(in1 and in2 and d);
end mux1;
12. Design and simulate a 4-1 Mux in VHDL using dataflowmodeling style.
VHDL Code:
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity multiplexer_4_1 is
port( a,b,c,d,x,y: in STD_LOGIC; dout : out STD_LOGIC );
end multiplexer_4_1;
architecture multiplexer_4_1_arc of multiplexer_4_1 is
begin
dout <= ((not x) and (not y) and a) or
((not x) and y and b) or
(x and (not y) and c) or
(x and y and d);
end multiplexer_4_1_arc;
13. Design and simulate an 8-1 Mux in VHDL using dataflowmodeling style.
entity mux_8_1 is
14. Design and simulate a 16-1 Mux in VHDL using dataflowmodeling style.
entity mux_16_1 is
port(i:in bit_vector (15 downto 0);
s:in bit_vector (3 downto 0);
y:out bit);
end mux_16_1;
architecture arc_mux_16_1 of mux_16_1 is
begin
y<=
i(0) when(s="0000") else
i(1) when(s="0001") else
i(2) when(s="0010") else
i(3) when(s="0011") else
i(4) when(s="0100") else
i(5) when(s="0101") else
i(6) when(s="0110") else
i(7) when(s="0111") else
);
);
18. Design and simulate a Master Slave J-K Flip Flop in VHDL
using dataflow-modeling style.
library ieee;
use ieee.std_logic_1164.all;
entity master_slave_jk is
port(j,k,clk:in std_logic; q1,q1x,z1x:inout std_logic;
--master
q2,q2x,z2x: inout std_logic); --salve
end master_slave_jk;
architecture master_slave_jk_arc of master_slave_jk is
begin
process(clk)
begin
if clk='1' then
z1x<=(j and (not q2)) or ((not k)and q2);
q1<=z1x after 5 ns;
q1x<=not z1x after 5 ns;
else
z2x<=(q1 and (not q2)) or ((not q1x)and q2);
q2<=z2x after 5 ns;
q2x<=not z2x after 5 ns;
end if;
end process;
end master_slave_jk_arc;
01
11
01
11
10
1
1
10
1
1
F1 =0000+0011+0101+0110+1100+1111+1001+1010
+ A B C D+ A
BC D+
ABCD + A BC
D +A BC
D
= A B C D
VHDL Code:
entity qws19 is
port (a,b,c,d :in bit;
end qws19;
z :out bit);
--0000
--0011
--0101
--0110
--1100
--1111
--1001
--1010
01
01
11
1
10
1
00
01
11
10
D
+ A BC + A B D
F1= A
00
01
11
10
1
11
10
x
1
G1=_010+0_00+11_1+1_01
CD
+ A C
D
+ABD+A
G1= B
D
C
entity qws20 is
port (a,b,c,d :in bit;
f,g :out bit);
end qws20;
architecture qws20_a of qws20 is
begin
--=0_ _0 + 011_ +1001
f<= ((not a)and(not d)) or ((not a)and(b)and(c)) or ((a)and(not
b)and(d));
--=_010+0_00+11_1+1_01
end fs_1;
architecture full_sub of fs_1 is
begin
d<=(a xor b) xor c1;
br<= ((not a) and b) or (b and c1) or ((not a) and c1);
end full_sub;
01
11
10
01
11
10
1
1
1
1
X
1
end fun242;
00
00
01
11
10
01
11
10
h1,h2,h3: bit;
w1,w2,w3: bit;
x1,x2,x3,x4,x5,x6: bit;
y1,y2: bit;
begin
w1<= a nand a;
w2<= b nand c;
w3<= b nand d;
h1<= ((w1 nand w2)nand w3);
w<=h1 nand h1;
x1<= b nand b;
x2<= x1 nand c;
x3<= x1 nand d;
x4<= c nand c;
x5<= d nand d;
x6<= ((x4 nand x5)nand b);
h2<= ((x2 nand x3)nand x6);
x<=h2 nand h2;
y1<=c nand d;
28.
LIBRARY IEEE;
USE IEEE.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
ENTITY comparator IS
port(A0,A1,B0,B1: in std_logic;
X,Y,Z: out std_logic);
END comparator;
architecture behaviour of comparator is
begin
COMP:PROCESS(A0,A1,B0,B1)
begin
X<=((A1 and not B1)
or (A1 and A0 and not B0)
or (A0 and not B1 and not B0));
Y<=((not A1 and not A0 and not B1 and not B0)
or (not A1 and A0 and not B1 and B0)
or (A1 and not A0 and B1 and not B0) or (A1 and A0 and B1 and B0));
Z<=((not A1 and B1)
or (not A1 and not A0 and B0)
or (not A0 and B1 and B0));
end process COMP;
end behaviour;
Z<=((B3 AND (NOT A3)) OR(B2 AND (NOT A2)) OR(B1 AND (NOT A1)) OR(B0
AND (NOT A0)));
end process COMP;
end behaviour_1;
30.
31.
"1111111" when"1000",
"1111011" when"1001",
"0000000" when others;
end qstn;
when
when
when
when
when
when
when
when
when
when
;
(s="0000")
(s="0000")
(s="0010")
(s="0011")
(s="0100")
(s="0101")
(s="0110")
(s="0111")
(s="1000")
(s="1001")
else
else
else
else
else
else
else
else
else
else
34.
35.
36.
entity priority_encoder_8_3 is
port(
din : in STD_LOGIC_VECTOR(7 downto 0);
dout : out STD_LOGIC_VECTOR(2 downto 0)
);
end priority_encoder_8_3;
architecture priority_enc_arc of priority_encoder_8_3 is
begin
dout <= "000" when din(7)='1' else
"001" when din(6)='1'else
"010" when din(5)='1' else
"011" when din(4)='1' else
"100" when din(3)='1' else
"101" when din(2)='1' else
"110" when din(1)='1' else
"111" when din(0)='1';
end priority_enc_arc;
37.
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity Partial_Full_Adder is
Port ( A : in STD_LOGIC;
B : in STD_LOGIC;
Cin : in STD_LOGIC;
S : out STD_LOGIC;
P : out STD_LOGIC;
G : out STD_LOGIC);
end Partial_Full_Adder;
architecture Behavioral of Partial_Full_Adder is
begin
S <= A xor B xor Cin;
P <= A xor B;
G <= A and B;
end Behavioral;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity Carry_Look_Ahead is
Port ( A : in STD_LOGIC_VECTOR (3 downto 0);
B : in STD_LOGIC_VECTOR (3 downto 0);
Cin : in STD_LOGIC;
S : out STD_LOGIC_VECTOR (3 downto 0);
Cout : out STD_LOGIC);
end Carry_Look_Ahead;
architecture Behavioral of Carry_Look_Ahead is
component Partial_Full_Adder
Port ( A : in STD_LOGIC;B : in STD_LOGIC;Cin : in STD_LOGIC;
S : out STD_LOGIC;P : out STD_LOGIC;G : out STD_LOGIC);
end component;
signal c1,c2,c3: STD_LOGIC;
signal P,G: STD_LOGIC_VECTOR(3 downto 0);
begin
PFA1:
PFA2:
PFA3:
PFA4:
Partial_Full_Adder
Partial_Full_Adder
Partial_Full_Adder
Partial_Full_Adder
port
port
port
port
map(
map(
map(
map(
A(0),
A(1),
A(2),
A(3),
B(0),
B(1),
B(2),
B(3),
B
0
0
0
0
1
1
1
1
0
0
0
0
1
1
1
1
C
0
0
1
1
0
0
1
1
0
0
1
1
0
0
1
1
D
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
F
0
0
0
0
0
0
0
1
0
0
0
1
0
0
1
1
F=m(7,11,14,15) = 0111+1011+1110+1111
entity qstn_38 is
port(a,b,c,d:in bit;f:out bit);
end qstn_38;
architecture qs_38_a of qstn_38 is
begin
f<= (
(( not a) and b and c and d) or
(a and (not b) and c and d) or
(a and b and c and (not d)) or
(a and b and c and d) );
end qs_38_a;
39.
Red lights up when input A=0 and B=0 also when A=0 and B=1; which leads
to the conclusion, Red light glows when A=0 and B=Dont-care.
ii
Yellow light glows when A=0 and B=1; and also when A=1 and B=1; which
leads to the conclusion, Yellow light glows when B=1 and A=Dont-care.
iii
For Red
<= A ;
For Yellow <= B;
For Green <= A and B
entity Traffic_light is
port (a,b :in bit;
Red,Yellow,Green :out bit);
end Traffic_light;
architecture Traffic_light_a of Traffic_light is
begin
Red
<= not a ;
Yellow <= b;
Green <= a and (not b);
end Traffic_light_a;