Professional Documents
Culture Documents
Collection of VHDL Lab Experiments Part - I
Collection of VHDL Lab Experiments Part - I
COMBINATIONAL CIRCUITS 1 a. b. 2 a. b. c. LOGIC GATES DATA FLOW BEHAVIORAL HALF ADDER DATA FLOW BEHAVIORAL STRUCTURAL Page No. 1 1 2 4 4 5 5
PART I : COMBINATIONAL CIRCUITS VHDL DATA FLOW MODEL FOR LOGIC GATES
library IEEE; use IEEE.STD_LOGIC_1164.ALL; --DATA FLOW --This program contains the code for all gates, but only one --gate is made active at a time and all others are commented --Remove comments for a specific gate and run simulation --ALL gates are simulated successfully on XILINX 13.2 entity dfrntgates is Port ( a : in bit; b : in bit; y : out bit); end dfrntgates; --architecture andgat of dfrntgates is --begin --y <= a and b; --end andgat; --architecture orgat of dfrntgates is --begin --y <= a or b; --end orgat; ---architecture nandgat of dfrntgates is --begin --y <= a nand b; --end nandgat; -architecture exorgat of dfrntgates is begin y <= a xor b; end exorgat; ---architecture norgat of dfrntgates is --begin --y <= a nor b; --end norgat; ---architecture notgat of dfrntgates is --begin --y <= not a; --end notgat;
--architecture nandgat of dfrntgates is --begin --process (a,b) --begin --if a & b = "00" --then y<='1'; --elsif a & b ="01" --then y<='1'; --elsif a & b ="10" --then y<='1'; --elsif a & b ="11" --then y<='0'; --end if; --end process; --end nandgat; ---architecture exorgat of dfrntgates is --begin --process (a,b) --begin --if a & b = "00" --then y<='0'; --elsif a & b ="01" --then y<='1'; --elsif a & b ="10" --then y<='1'; --elsif a & b ="11" --then y<='0'; --end if; --end process; --end exorgat; ---architecture norgat of dfrntgates is --begin --process (a,b) --begin --if a & b = "00" --then y<='1'; --elsif a & b ="01" --then y<='0'; --elsif a & b ="10" --then y<='0'; --elsif a & b ="11" --then y<='0'; --end if; --end process; --end norgat; -3
--architecture notgat of dfrntgates is --begin --process(a) --begin --if a='0' --then y<='1'; --elsif a='1' --then y<='0'; --end if; --end process; --end notgat;
--STRUCTURAL MODEL OF HALF ADDER entity andg is port(a,b:in bit; z:out bit); end andg; architecture e1 of andg is begin z<= a and b; end e1; entity xorg is port(a,b:in bit; z:out bit); end xorg; architecture e2 of xorg is begin z<= a xor b; end e2; architecture structmdl of hadrtyps is component andg port(a,b:in bit; z:out bit); end component; component xorg port(a,b:in bit; z:out bit); end component; begin a1 : xorg port map(a,b,sum); a2 : andg port map(a,b,carry); end structmdl;
--architecture DFF of fftypcal is --begin --process(d,clk) --begin --if clk='1' and clk' event --then --q<= d; --qbar<= not d; --end if; --end process; --end DFF; architecture TFF of fftypcal is begin process(t,clk) begin if clk='1' and clk' event then q<=not t; qbar<=t; end if; end process; end TFF;