Sie sind auf Seite 1von 64

EX No: NAME:

REG No: DATE:

VERIFICATION OF LOGIC GATES AIM: To develop VHDL code for the verification of Logic Gates, simulate it and verify the output using XILINX ISE 7.1i

ALGORITHM: Declare the name of design, entity and architecture body. Write the source code in VHDL. Compile the code and check for the errors. Simulate the program and verify the waveform using any of the simulators ISE or MODELSIM Verify the output for all the combination of the input values.

LOGIC DIAGRAM & TRUTH TABLE: AND GATE: LOGIC DIAGRAM: TRUTH TABLE:

Input A 0 0 1 1 y<= a and b;

Input B 0 1 0 1

Output Y 0 0 0 1

Page 1 of 64

EX No: NAME:

REG No: DATE:

VHDL SOURCE CODE : --Design:AND GATE (ENTITY AND ARCHITECTURE). --Filename:andgate.vhd --Description:to implement AND gate. --Limitation:NONE. --System:Model Sim 3.3 --Author: --Rollno: --regno: --Version:3.3 AND GATE: library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity andgate is Port (a: in std_logic; b: in std_logic; y: out std_logic); end andgate; architecture Behavioral of andgate is begin y<= a and b; end Behavioral; SIMULATION REPORT:

OR GATE:

Page 2 of 64

EX No: NAME:

REG No: DATE:

LOGIC DIAGRAM:

TRUTH TABLE:

Input A 0 0 1 y<= a or b; 1

Input B 0 1 0 1

Output Y 0 1 1 1

VHDL SOURCE CODE: --Design:OR GATE (ENTITY AND ARCHITECTURE). --Filename:orgate.vhd --Description:to implement OR gate. --Limitation:NONE. --System:Model Sim 3.3 --Author: --Rollno: --regno: --Version:3.3 OR GATE: library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity orgate is Port ( a : in std_logic; b : in std_logic; y : out std_logic); end orgate; architecture Behavioral of orgate is begin y<=a or b; end Behavioral;

SIMULATION REPORT:

Page 3 of 64

EX No: NAME:

REG No: DATE:

NOT GATE: LOGIC DIAGRAM: TRUTH TABLE:

Input A Output Y 0 1 y<= not a; 1 0

VHDL SOURCE CODE: --Design:NOT GATE (ENTITY AND ARCHITECTURE). --Filename:notgate.vhd --Description:to implement NOT gate. --Limitation:NONE. --System:Model Sim 3.3 --Author: --Rollno: --regno: --Version:3.3

NOT GATE: library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity notgate is Port ( a: in std_logic; y: out std_logic); end notgate;

Page 4 of 64

EX No: NAME:

REG No: DATE:

architecture Behavioral of notgate is begin y<= not a; end Behavioral; SIMULATION REPORT:

NAND GATE: LOGIC DIAGRAM: TRUTH TABLE: Input A Input B Output Y 0 0 1 1 y<= a nand b; 0 1 0 1 1 1 1 0

VHDL SOURCE CODE: --Design:NAND GATE (ENTITY AND ARCHITECTURE). --Filename:nandgate.vhd --Description:to implement NAND gate. --Limitation:NONE. --System:Model Sim 3.3 --Author: --Rollno: --regno: --Version:3.3

NAND GATE:

Page 5 of 64

EX No: NAME:

REG No: DATE:

library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL entity NANDGATE is Port ( a : in std_logic; b : in std_logic; y : out std_logic); end NANDGATE; architecture Behavioral of NANDGATE is begin y <=a nand b; end Behavioral; SIMULATION REPORT:

NOR GATE: LOGIC DIAGRAM: TRUTH TABLE:

Input A Input B Output C 0 0 1 y<= a nor b; 1 0 1 0 1 1 0 0 0

VHDL SOURCE CODE: --Design:NOR GATE (ENTITY AND ARCHITECTURE). --Filename:norgate.vhd --Description:to implement NOR gate. --Limitation:NONE. --System:Model Sim 3.3 --Author: --Rollno:

Page 6 of 64

EX No: NAME:

REG No: DATE:

--regno: --Version:3.3 NOR GATE:

library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity norgate is Port ( a : in std_logic; b : in std_logic; y : out std_logic); end norgate; architecture Behavioral of norgate is begin y<= a nor b; end Behavioral;

SIMULATION REPORT:

XOR GATE:

LOGIC DIAGRAM:

TRUTH TABLE: Input A Input B Output Y 0 0 1 0 1 0 1 0 1 1 0

y<= a xor b;

Page 7 of 64

EX No: NAME:

REG No: DATE:

VHDL SOURCE CODE: --Design:XOR GATE (ENTITY AND ARCHITECTURE). --Filename:xorgate.vhd --Description:to implement XOR gate. --Limitation:NONE. --System:Model Sim 3.3 --Author: --Rollno: --regno: --Version:3.3

XOR GATE: library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity xorgate is Port ( a : in std_logic; b : in std_logic; y : out std_logic); end xorgate; architecture Behavioral of xorgate is begin y<= a xor b; end Behavioral; SIMULATION REPORT:

Page 8 of 64

EX No: NAME:

REG No: DATE:

XNOR GATE: LOGIC DIAGRAM: TRUTH TABLE: Input A Input B Output Y 0 0 1 1 y<= a xnor b; 0 1 0 1 1 0 0 1

VHDL SOURCE CODE: --Design:XNOR GATE (ENTITY AND ARCHITECTURE). --Filename:xnorgate.vhd --Description:to implement XNOR gate. --Limitation:NONE. --System:Model Sim 3.3 --Author: --Rollno: --regno: --Version:3.3 XNOR GATE: library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity XNORgate is Port ( a : in std_logic; b : in std_logic; y : out std_logic); end XNORgate; architecture Behavioral of XNORgate is begin y<= a xnor b; end Behavioral;

Page 9 of 64

EX No: NAME:

REG No: DATE:

SIMULATION REPORT:

RESULT: Thus the VHDL codes for the different logic gates were written, simulated. Synthesized and the outputs verified

HALF ADDER AND FULL ADDER

Page 10 of 64

EX No: NAME:

REG No: DATE:

AIM: To develop VHDL code for Half adder and Full adder, simulate it and verify the output using XILINX ISE 7.1i

ALGORITHM: Declare the name of design, entity and architecture body. Write the source code in VHDL. Compile the code and check for the errors. Simulate the program and verify the waveform using any of the simulators ISE or MODELSIM Verify the output for all the combination of the input values.

LOGIC DIAGRAM & TRUTH TABLE:

HALF ADDER:

Page 11 of 64

EX No: NAME:

REG No: DATE:

TRUTH TABLE: Input A 0 0 1 1 Input B 0 1 0 1 Output SUM 0 1 1 1 Output CARRY 0 0 0 1

VHDL SOURCE CODE: --Design:HALF ADDER(ENTITY AND ARCHITECTURE). --Filename:halfadder.vhd --Description:to implement HALF ADDER circuit using XOR and AND gates. --Limitation:NONE. --System:Model Sim 3.3 --Author: --Rollno: --regno: --Version:3.3 HALF ADDER: library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity halfadder is Port ( a : in std_logic; b : in std_logic; sum : out std_logic; carry : out std_logic); end halfadder; architecture Behavioral of halfadder is begin sum<= a xor b; carry <= a and b; end Behavioral;

Page 12 of 64

EX No: NAME:

REG No: DATE:

SIMULATION REPORT:

FULL ADDER: LOGIC DIAGRAM:

Page 13 of 64

EX No: NAME:

REG No: DATE:

TRUTH TABLE:

Input A 0 0 0 0 1 1 1 1

Input B 0 0 1 1 0 0 1 1

Input C 0 1 0 1 0 1 0 1

Output SUM 0 1 1 0 1 0 0 1

Output CARRY 0 0 0 1 0 1 1 1

VHDL SOURCE CODE: --Design:FULL ADDER(ENTITY AND ARCHITECTURE). --Filename:fulladder.vhd --Description:to implement full adder using XOR and AND gates. --Limitation:NONE. --System:Model Sim 3.3 --Author: --Rollno: --regno: --Version:3.3

Page 14 of 64

EX No: NAME:

REG No: DATE:

FULL ADDER: library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity fulladder is Port ( a : in std_logic; b : in std_logic; c : in std_logic; sum : out std_logic; carry : out std_logic); end fulladder; architecture Behavioral of fulladder is signal p,q,r,s: std_logic; begin p <= a xor b; q <= a and b; r <= b and c; s <= c and a; sum <= p xor c; carry<= q or r or s; end Behavioral; SIMULATION REPORT:

RESULT: Thus the VHDL codes for Half adder and Full adder were written, simulated, synthesized and the outputs verified.

Page 15 of 64

EX No: NAME:

REG No: DATE:

HALF SUBTRACTOR AND FULL SUBTRACTOR AIM: To develop VHDL code for Half adder and Full Subtractor, simulate it and verify the output using XILINX ISE 7.1i

ALGORITHM: Declare the name of design, entity and architecture body. Write the source code in VHDL. Compile the code and check for the errors. Simulate the program and verify the waveform using any of the simulators ISE or MODELSIM. Verify the output for all the combination of the input values.

LOGIC DIAGRAM & TRUTH TABLE: HALF SUBTRACTOR:

Page 16 of 64

EX No: NAME:

REG No: DATE:

TRUTH TABLE:

Input A 0 0 1 1 VHDL SOURCE CODE:

Input B 0 1 0 1

Output DIFF 0 1 1 0

Output BORR 0 1 0 0

--Design:HALF SUBTRACTOR(ENTITY AND ARCHITECTURE). --Filename:halfsub.vhd --Description:to implement HALF SUBTRACTOR circuit using NOT,XOR and AND gates. --Limitation:NONE. --System:Model Sim 3.3 --Author: --Rollno: --regno: --Version:3.3 HALF SUBTRACTOR: library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity halfsub is Port ( a : in std_logic; b : in std_logic; diff : out std_logic; borr : out std_logic); end halfsub; architecture Behavioral of halfsub is signal p:std_logic; begin p <= not a; diff <= a xor b; bor <= p and b; end Behavioral;

Page 17 of 64

EX No: NAME:

REG No: DATE:

SIMULATION REPORT:

Page 18 of 64

EX No: NAME:

REG No: DATE:

FULL SUBTRACTOR: LOGIC DIAGRAM:

TRUTH TABLE:

Input A 0 0 0 0 1 1 1 1

Input B 0 0 1 1 0 0 1 1

Input C 0 1 0 1 0 1 0 1

Output DIFF 0 1 1 0 1 0 0 1

Output BORR 0 1 1 1 0 0 0 1

Page 19 of 64

EX No: NAME:

REG No: DATE:

VHDL SOURCE CODE: --Design:FULL SUBTRACTOR(ENTITY AND ARCHITECTURE). --Filename:fullsub.vhd --Description:to implement FULL SUBTRACTOR circuit using NOT,XOR,OR and AND gates. --Limitation:NONE. --System:Model Sim 3.3 --Author: --Rollno: --regno: --Version:3.3 FULL SUBTRACTOR:

library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity fullsub is Port ( a : in std_logic; b : in std_logic; c : in std_logic; diff : out std_logic; borr : out std_logic); end fullsub; architecture Behavioral of fullsub is begin diff <= a xor b xor c; borr <= (not a and b) or (b and c) or (not a and c); end Behavioral;

Page 20 of 64

EX No: NAME:

REG No: DATE:

SIMULATION REPORT:

RESULT: Thus the VHDL codes for Half subtractor and Full subtractor were written, simulated, synthesized and the outputs verified.

Page 21 of 64

EX No: NAME:

REG No: DATE:

ENCODER AND DECODER

AIM: To develop VHDL code for Encoder (8 x 3) and Decoder (2 x 4), simulate it and verify the output using XILINX ISE 7.1i

ALGORITHM: Declare the name of design, entity and architecture body. Write the source code in VHDL. Compile the code and check for the errors. Simulate the program and verify the waveform using any of the simulators ISE or MODELSIM. Verify the output for all the combination of the input values.

Page 22 of 64

EX No: NAME:

REG No: DATE:

LOGIC DIAGRAM & TRUTH TABLE: ENCODER:

D0 1 0 0 0 0

D1 0 1 0 0 0

D2 0 0 1 0 0

D3 0 0 0 1 0

D3 0 0 0 0 1

D4 0 0 0 0 0

D5 0 0 0 0 0

D6 0 0 0 0 0

X 0 0 0 0 1

Y 0 0 1 1 0

Z 0 1 0 1 0 TRUTH TABLE :

Page 23 of 64

EX No: NAME:

REG No: DATE:

0 0 0

0 0 0

0 0 0

0 0 0

0 0 0

1 0 0

0 1 0

0 0 1

1 1 1

0 1 1

1 0 1

VHDL SOURCE CODE: --Design:3 to 8 LINE ENCODER(ENTITY AND ARCHITECTURE). --Filename:encoder.vhd --Description:to implement 3 to 8 LINE ENCODER using OR gates. --Limitation:NONE. --System:Model Sim 3.3 --Author: --Rollno: --regno: --Version:3.3

3 to 8 LINE ENCODER: library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity encoder is Port ( d : in std_logic_vector(0 to 7); x : out std_logic; y : out std_logic; z : out std_logic); end encoder; architecture Behavioral of encoder is begin z <= d(1) or d(3) or d(5) or d(7);

Page 24 of 64

EX No: NAME:

REG No: DATE:

y <= d(2) or d(3) or d(6) or d(7); x <= d(4) or d(5) or d(6) or d(7); end Behavioral;

SIMULATION REPORT:

Page 25 of 64

EX No: NAME:

REG No: DATE:

DECORDER: LOGIC DIAGRAM:

Page 26 of 64

EX No: NAME:

REG No: DATE:

TRUTH TABLE:

A 0 0 1 1

B 0 1 0 1

Enable 1 1 1 1

Z(0) 0 1 1 1

Z(1) 1 0 1 1

Z(2) 1 1 0 1

Z(3) 1 1 1 0

VHDL SOURCE CODE: --Design:3 to 8 LINE DECODER(ENTITY AND ARCHITECTURE). --Filename:decoder.vhd --Description:to implement 3 to 8 LINE DECODER using NOT and AND gates. --Limitation:NONE. --System:Model Sim 3.3 --Author: --Rollno: --regno: --Version:3.3 3 to 8 LINE DECODER: library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity decoder is Port ( a : in std_logic; b : out std_logic; e : out std_logic; z : out std_logic_vector(0 to 3); end decoder; architecture archdec of decoder is signal abar,bbar : std_logic; begin Z(0) <= (abar and bbar nad e); Z(1) <=(abar and b and e); Z(2) <=(a and bbar abd e); Z(3)<=(a and b and e); end archdec; SIMULATION REPORT:

Page 27 of 64

EX No: NAME:

REG No: DATE:

SYNTHESIS REPORT:

RESULT: Thus the VHDL codes for encoder and decoder were written, simulated, synthesized and the outputs verified.

Page 28 of 64

EX No: NAME:

REG No: DATE:

MULTIPLEXER AND DE-MULTIPLEXER AIM: To develop VHDL code for Multiplexer (4 x 1) and De-Multiplexer (1 x 4), simulate it and verify the output using XILINX ISE 7.1i ALGORITHM: Declare the name of design, entity and architecture body. Write the source code in VHDL. Compile the code and check for the errors. Simulate the program and verify the waveform using any of the simulators ISE or MODELSIM Verify the output for all the combination of the input values.

LOGIC DIAGRAM & TRUTH TABLE: MULTIPLEXER:

Page 29 of 64

EX No: NAME:

REG No: DATE:

TRUTH TABLE: SELECT INPUT S0 0 0 1 1 S1 0 1 0 1 OUTPUT Y D(0) D(1) D(2) D(3)

VHDL SOURCE CODE: --Design:MULIPLEXER(ENTITY AND ARCHITECTURE). --Filename:multiplexer.vhd --Description:to implement MULTIPLEXER circuit . --Limitation:NONE. --System:Model Sim 3.3 --Author: --Rollno: --regno: --Version:3.3 MULTIPLEXER: library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity mux is Port ( d0 : in std_logic; d1 : in std_logic; d2 : in std_logic; d3 : in std_logic; s0 : in std_logic; s1 : in std_logic; y : out std_logic); end mux; architecture Behavioral of mux is begin y<=((d0 and (not s0)and (not s1))or (d1 and (not s0) and s1)or (d2 and s0 and(not s0)) or (d3 and s0 and s1));

Page 30 of 64

EX No: NAME:

REG No: DATE:

end Behavioral;

Page 31 of 64

EX No: NAME:

REG No: DATE:

SIMULATION REPORT:

Page 32 of 64

EX No: NAME:

REG No: DATE:

DE-MULTIPLEXER: LOGIC DIAGRAM:

TRUTH TABLE:

INPUT Din 1 1 1 1 S0 0 0 1 1 S1 0 1 0 1 Y0 1 0 0 0

OUTPUT Y1 0 1 0 0 Y2 0 0 1 0 Y3 0 0 0 1

Page 33 of 64

EX No: NAME:

REG No: DATE:

VHDL SOURCE CODE: --Design:DEMULIPLEXER(ENTITY AND ARCHITECTURE). --Filename:demux.vhd --Description:to implement DEMULTIPLEXER circuit . --Limitation:NONE. --System:Model Sim 3.3 --Author: --Rollno: --regno: --Version:3.3 DEMULTIPLEXER: library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity demux is Port ( e : in std_logic; s0 : in std_logic; s1 : in std_logic; din : in std_logic; y0 : out std_logic; y1 : out std_logic; y2 : out std_logic; y3 : out std_logic); end demux; architecture Behavioral of demux is begin y0<=(din and (not s0)and (not s1)and e); y1<=(din and s0 and(not s1)and e); y2<=(din and (not s0)and s1 and e); y3<=(din and s0 and s1 and e); end Behavioral;

Page 34 of 64

EX No: NAME:

REG No: DATE:

SIMULATION REPORT:

RESULT: Thus the VHDL codes for multiplexer and de-multiplexer were written, simulated, synthesized and the outputs verified.

Page 35 of 64

EX No: NAME:

REG No: DATE:

DESIGN OF CODE CONVERTERS AIM: To develop VHDL code for Code Converters, simulate it and verify the output using XILINX ISE 7.1i ALGORITHM: Declare the name of design, entity and architecture body. Write the source code in VHDL. Compile the code and check for the errors. Simulate the program and verify the waveform using any of the simulators ISE or MODELSIM Verify the output for all the combination of the input values.

CODE CONVERTER (BCD TO GRAY): LOGIC DIAGRAM:

Page 36 of 64

EX No: NAME:

REG No: DATE:

BCD B3 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 B2 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 B1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 B0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 G3 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 G2 0 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0

GRAY G1 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 G0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0

TRUTH TABLE:

VHDL SOURCE CODE: --Design:CODE CONVERTOR(ENTITY AND ARCHITECTURE). --Filename:convertor.vhd --Description:to implement CODE CONVERTOR using XOR gate. --Limitation:NONE. --System:Model Sim 3.3 --Author: --Rollno: --regno:

Page 37 of 64

EX No: NAME:

REG No: DATE:

--Version:3.3

CODE CONVERTER (BCD TO GRAY):

library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity converter is Port ( b : in std_logic_vector(0 to 3); g: out std_logic_vector(0 to 3)); end converter; architecture Behavioral of converter is begin g(0) <= b(0); g(1) <=b(1) xor b(0); g(2) <=b(2) xor b(1); g(3) <=b(3) xor b(2); end Behavioral;

SIMULATION REPORT:

Page 38 of 64

EX No: NAME:

REG No: DATE:

CODE CONVERTER (GRAY TO BINARY): LOGIC DIAGRAM:

Page 39 of 64

EX No: NAME:

REG No: DATE:

TRUTH TABLE:

GRAY G3 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 G2 0 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0 G1 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 G0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 B0 0 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1 B2 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1

BCD B1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 B0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1

VHDL SOURCE CODE: --Design:CODE CONVERTOR(ENTITY AND ARCHITECTURE). --Filename:convertor.vhd --Description:to implement CODE CONVERTOR using XOR gate. --Limitation:NONE. --System:Model Sim 3.3 --Author: --Rollno: --regno: --Version:3.3

Page 40 of 64

EX No: NAME:

REG No: DATE:

CODE CONVERTER (GRAY TO BINARY): library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity graytobinary is Port (b : inout std_logic_vector(0 to 3); g: in std_logic_vector(0 to 3)); end binarytoexcess; architecture Behavioral of graytobinary is begin b(0) <= g(0) xor b(1); b(1) <=g(1) xor b(2); b(2) <=g(2) xor b(3); b(3) <=not g(3); end Behavioral;

SIMULATION REPORT:

Page 41 of 64

EX No: NAME:

REG No: DATE:

RESULT: Thus the VHDL codes for Code Converters were written, simulated, synthesized and the outputs verified.

Page 42 of 64

EX No: NAME:

REG No: DATE:

DESIGN OF FILP FLOPS AIM: To develop VHDL code for Flip Flops (SR, JK, D,T), simulate it and verify the output using XILINX ISE 7.1i ALGORITHM: Declare the name of design, entity and architecture body. Write the source code in VHDL. Compile the code and check for the errors. Simulate the program and verify the waveform using any of the simulators ISE or MODELSIM Verify the output for all the combination of the input values.

LOGIC DIAGRAM & TRUTH TABLE:

SR FLIP FLOP:

Page 43 of 64

EX No: NAME:

REG No: DATE:

TRUTH TABLE:

Q (t) 0 0 0 0 1 1 1 1

S 0 0 1 1 0 0 1 1

R 0 1 0 1 0 1 0 1

Q (t+1) 0 0 1 X 1 0 1 X

SR FLIPFLOP: VHDL SOURCE CODE : --Design:SR FLIPFLOP (ENTITY AND ARCHITECTURE). --Filename:srff.vhd --Description:to implement NAND gate. --Limitation:NONE. --System:Model Sim 3.3 --Author: --Rollno: --regno: --Version:3.3

Page 44 of 64

EX No: NAME:

REG No: DATE:

SR FLIPFLOP: library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity srff is Port (s: in std_logic; r: in std_logic; rst: out std_logic clk: out std_logic; q:inout std_logic; qbar: inout std_logic); end srff; architecture Behavioral of srff is begin process(s,r,rst,clk) begin if(rst=1) then q<=0; qbar<=1; elsif (clk=1 and clkevent) then if(s=0 and r=0) then q<= q; qbar<=qbar; elsif(s=0 and r=1) then q<= 0; qbar<=1; elsif(s=1 and r=0) then q<= 1; qbar<=0; else q<=X; qbar<=X; end if; end if; end process; end Behavioral;

SIMULATION REPORT:

Page 45 of 64

EX No: NAME:

REG No: DATE:

JK FLIP FLOP: LOGIC DIAGRAM:

Page 46 of 64

EX No: NAME:

REG No: DATE:

TRUTH TABLE:

Q (t) 0 0 0 0 1 1 1 1

J 0 0 1 1 0 0 1 1

K 0 1 0 1 0 1 0 1

Q (t+1) 0 0 1 1 1 0 1 0

Page 47 of 64

EX No: NAME:

REG No: DATE:

VHDLSOURCE CODE: --Design:JK FLIPFLOP(ENTITY AND ARCHITECTURE). --Filename:jkff.vhd --Description:to implement JK FLIPFLOP using OR, NOT and AND gates. --Limitation:NONE. --System:Model Sim 3.3 --Author: --Rollno: --regno: --Version:3.3

JK FLIP FLOP:

library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity jkff is Port ( j : in std_logic; k : in std_logic; rst : in std_logic; clk : in std_logic; q : inout std_logic; qbar : inout std_logic); end jkff;

architecture Behavioral of srff is begin process(j,k,rst,clk)

Page 48 of 64

EX No: NAME:

REG No: DATE:

begin if(rst=1) then q<=0; qbar<=1; elsif (clk=1 and clkevent) then if(j=0 and k=0) then q<= q; qbar<=qbar; elsif(j=0 and k=1) then q<= 0; qbar<=1; elsif(j=1 and k=0) then q<= 1; qbar<=0; else q<=not q; qbar<=not qbar; end if; end if; end process; end Behavioral;

SIMULATION REPORT:

D FLIP FLOP:

Page 49 of 64

EX No: NAME:

REG No: DATE:

LOGIC DIAGRAM:

TRUTH TABLE: Q(t) 0 0 1 1 D 0 1 0 1 Q(t+1) 0 1 0 1

VHDL SOURCE CODE: --Design:D FLIPFLOP(ENTITY AND ARCHITECTURE). --Filename:dff.vhd --Description:to implement D FLIPFLOP using OR, NOT and AND gates. --Limitation:NONE. --System:Model Sim 3.3 --Author: --Rollno: --regno: --Version:3.3 D FLIP FLOP: library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity dff is Port ( d : in std_logic; rst : in std_logic; clk : in std_logic; q : out std_logic;

Page 50 of 64

EX No: NAME:

REG No: DATE:

qbar : out std_logic); end dff; architecture Behavioral of dff is signal qt,qbart:std_logic; begin p1:process(d,clk,rst) begin if(rst='1') then qt <= '0'; qbart <= '0'; elsif (clk='1' and clk'event) then qt <=((not clk) and qt) or (clk and d); qbart <= not qt; end if;

end process p1; q <= qt; qbar <= qbart; end Behavioral;

SIMULATION REPORT:

Page 51 of 64

EX No: NAME:

REG No: DATE:

T FLIP FLOP: LOGIC DIAGRAM:

TRUTH TABLE:

Q(t) 0 0 1 1

T 0 1 0 1

Q(t+1) 0 1 1 0

VHDL SOURCE CODE: --Design:T FLIPFLOP(ENTITY AND ARCHITECTURE). --Filename:tff.vhd --Description:to implement T FLIPFLOP using OR, NOT and AND gates. --Limitation:NONE. --System:Model Sim 3.3 --Author: --Rollno: --regno: --Version:3.3

Page 52 of 64

EX No: NAME:

REG No: DATE:

T FLIP FLOP: library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity tff is Port ( t : in std_logic; rst : in std_logic; clk : in std_logic; q : out std_logic; qbar : out std_logic); end tff; architecture Behavioral of tff is signal qt,qbart:std_logic; begin q<= qt; qbar<=qbart; p1:process(t,clk,rst) begin if(rst='1') then qt <= '0'; qbart <= '0'; elsif (clk='1' and clk'event) then qt <=(qt and (not t)) or ((not clk) and qt) or(clk and t and (not qt)); qbart <= not qt; end if; end process p1; end Behavioral;

SIMULATION REPORT:

Page 53 of 64

EX No: NAME:

REG No: DATE:

RESULT: Thus the VHDL codes for Flip Flops were written, simulated, synthesized and the outputs verified.

Page 54 of 64

EX No: NAME:

REG No: DATE:

COUNTERS AIM: To develop source code for up/down counter circuit by using VHDL and obtain the simulation,synthesis using XILINX ISE 7.1i

ALGORITHM: Declare the name of design, entity and architecture body. Write the source code in VHDL. Compile the code and check for the errors. Simulate the program and verify the waveform using any of the simulators ISE or MODELSIM Verify the output for all the combination of the input values.

LOGIC DIAGRAM & TRUTH TABLE:

Page 55 of 64

EX No: NAME:

REG No: DATE:

UP COUNTING Direction HIGH HIGH HIGH HIGH HIGH HIGH HIGH HIGH HIGH HIGH HIGH HIGH OUTPUT 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011

DOWN COUNTING Direction LOW LOW LOW LOW LOW LOW LOW LOW LOW LOW LOW LOW OUTPUT 1111 1110 1101 1100 1011 1010 1001 1000 0111 0110 0101 0100

Page 56 of 64

EX No: NAME:

REG No: DATE:

HIGH HIGH HIGH HIGH

1100 1101 1110 1111

LOW LOW LOW LOW

0011 0010 0001 0000

VHDL SOURCE CODE: --Design:UP/DOWN COUNTER (ENTITY AND ARCHITECTURE).

Page 57 of 64

EX No: NAME:

REG No: DATE:

--Filename:up/downcounter.vhd --Description:to implement COUNTER using OR, NOT and AND gates. --Limitation:NONE. --System:Model Sim 3.3 --Author: --Rollno: --regno: --Version:3.3

Up/ Down COUNTER: library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity count is Port ( clk : in STD_LOGIC; dir : in STD_LOGIC; output : out STD_LOGIC_VECTOR (3 downto 0)); end count; architecture Behavioral of count is signal a: STD_LOGIC_VECTOR (3 downto 0):="0000"; begin process (clk) begin if clk='1' and clk'event then if dir='1' then a <= a + 1; else a <= a - 1; end if; end if; end process; output<=a; end Behavioral;

SIMULATION REPORT:

Page 58 of 64

EX No: NAME:

REG No: DATE:

RESULT: Thus the VHDL program is simulated and the output waveform and the corresponding RTL schematic is obtained.

Page 59 of 64

EX No: NAME:

REG No: DATE:

COMPARATOR Aim: To Simulate Comparator using VHDL Algorithm: 1. Call Library functions 2. Declare the entity, the ports and its corresponding data types. 3. Define the architecture. 4. Obtain the design and equations of comparator 5. Take respective inputs and write the code to manipulate the logic of the circuit

Page 60 of 64

EX No: NAME:

REG No: DATE:

LOGIC DIAGRAM & TRUTH TABLE: COMPARATOR

Page 61 of 64

EX No: NAME:

REG No: DATE:

TRUTH TABLE

INPUT A3 0 0 0 1 1 0 A2 0 0 0 0 0 1 A1 0 0 1 0 0 0 A0 0 1 0 0 1 1 B3 0 0 0 0 1 0 B2 0 0 0 1 0 1

OUTPUT B1 0 0 1 0 0 1 B0 0 0 1 0 1 0 Eq 1 0 0 0 1 0 Bg 0 0 1 0 0 1 Ag 0 1 0 1 0 0

VHDL SOURCE CODE: --Design:COMPARATOR (ENTITY AND ARCHITECTURE). --Filename:comparator.vhd --Description:to implement comparator using OR, NOT and AND gates. --Limitation:NONE. --System:Model Sim 3.3 --Author: --Rollno: --regno: --Version:3.3

Page 62 of 64

EX No: NAME:

REG No: DATE:

COMPARATOR library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity sdfdas is Port ( a : in STD_LOGIC_VECTOR (3 downto 0); b : in STD_LOGIC_VECTOR (3 downto 0); eq : out STD_LOGIC; bg : out STD_LOGIC; ag : out STD_LOGIC); end sdfdas; architecture Behavioral of sdfdas is begin eq<='1' when a=b else '0'; bg<='1' when b>a else '0'; ag<='1' when a>b else '0'; end Behavioral;

Page 63 of 64

EX No: NAME:

REG No: DATE:

SIMULATION REPORT:

Result: Thus the VHDL program is executed and the output waveform is obtained.

Page 64 of 64

Das könnte Ihnen auch gefallen