Lab Assignment 0
Lab Assignment 0
Lab Assignment 0
VHDL Code:
library ieee;
use ieee.std_logic_1164.all;
entity AND_Gate is
port( A, B, C, D: in std_logic;
Y: out std_logic);
end AND_Gate;
begin
end behav;
Testbench:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity tb_AND_Gate is
end tb_AND_Gate;
begin
uut: AND_Gate PORT MAP (A => A, B => B, C => C, D => D, Y => Y);
stim_proc: process
begin
wait for 10 ns;
A <= '0'; B <= '0'; C <= '0'; D <= '0';
wait for 10 ns;
A <= '0'; B <= '0'; C <= '0'; D <= '1';
wait for 10 ns;
A <= '0'; B <= '0'; C <= '1'; D <= '0';
wait for 10 ns;
A <= '0'; B <= '0'; C <= '1'; D <= '1';
wait for 10 ns;
A <= '0'; B <= '1'; C <= '0'; D <= '0';
wait for 10 ns;
A <= '0'; B <= '1'; C <= '0'; D <= '1';
wait for 10 ns;
A <= '0'; B <= '1'; C <= '1'; D <= '0';
wait for 10 ns;
A <= '0'; B <= '1'; C <= '1'; D <= '1';
wait;
end process;
end Behavioral;
Waveform:
VHDL Code:
library ieee;
use ieee.std_logic_1164.all;
entity NAND_Gate is
port( A, B, C, D: in std_logic;
Y: out std_logic);
end NAND_Gate;
begin
end behav;
Testbench:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity tb_NAND_Gate is
end tb_NAND_Gate;
component NAND_Gate is
port( A, B, C, D: in std_logic;
Y: out std_logic);
end component;
begin
uut: NAND_Gate PORT MAP (A => A, B => B, C => C, D => D, Y => Y);
stim_proc: process
begin
wait for 10 ns;
A <= '0'; B <= '0'; C <= '0'; D <= '0';
wait for 10 ns;
A <= '0'; B <= '0'; C <= '0'; D <= '1';
wait for 10 ns;
A <= '0'; B <= '0'; C <= '1'; D <= '0';
wait for 10 ns;
A <= '0'; B <= '0'; C <= '1'; D <= '1';
wait for 10 ns;
A <= '0'; B <= '1'; C <= '0'; D <= '0';
wait for 10 ns;
A <= '0'; B <= '1'; C <= '0'; D <= '1';
wait for 10 ns;
A <= '0'; B <= '1'; C <= '1'; D <= '0';
wait for 10 ns;
A <= '0'; B <= '1'; C <= '1'; D <= '1';
wait;
end process;
end Behavioral;
Waveform:
library ieee;
use ieee.std_logic_1164.all;
entity Half_Adder is
port( A, B: in std_logic;
S, C: out std_logic);
end Half_Adder;
S <= A xor B;
C <= A and B;
end behav;
Testbench:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity tb_Half_Adder is
end tb_Half_Adder;
component Half_Adder is
port( A, B: in std_logic;
S, C: out std_logic);
end component;
begin
stim_proc: process
begin
wait for 10 ns;
A <= '0'; B <= '0';
wait for 10 ns;
A <= '0'; B <= '1';
wait for 10 ns;
A <= '1'; B <= '0';
wait for 10 ns;
A <= '1'; B <= '1';
wait;
end process;
end Behavioral;
Waveform