Tanish Pathak - Assignment 02
Tanish Pathak - Assignment 02
Batch : P6
Enrollment No:21115147
Assignment -2
1.
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity bit_counter is
port(C, CLR : in std_logic;
Q : out std_logic_vector(3 downto 0));
end bit_counter;
architecture ans of bit_counter is
signal tmp: std_logic_vector(3 downto 0);
begin
process (C, CLR)
begin
if (CLR='1') then
tmp <= "0000";
elsif (C'event and C='1') then
tmp <= tmp + 1;
end if;
end process;
Q <= tmp;
end ans;
2.
a.)
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity bit_counter is
port(C, CLR : in std_logic;
Q : out std_logic_vector(3 downto 0));
end bit_counter;
architecture anss of bit_counter is
signal tmp: std_logic_vector(3 downto 0);
begin
process (C, CLR)
begin
if (CLR='1') then
tmp <= "0000";
elsif (C'event and C='1') then
tmp <= tmp + 1;
end if;
end process;
Q <= tmp;
end ans;
b.)
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity bit_counter is
port(C, CLR : in std_logic;
Q : out std_logic_vector(3 downto 0));
end bit_counter;
architecture sss of bit_counter is
signal tmp: std_logic_vector(3 downto 0);
begin
process (C, CLR)
begin
if (CLR='1') then
tmp <= "0000";
elsif (C'event and C='1') then
tmp <= tmp + 1;
end if;
end process;
Q <= tmp;
end sss;
c.)
library ieee;
use ieee.std_logic_1164.all;
entity d_flipflop is
port(d,clk,reset:in std_logic;q:out std_logic);
end d_flipflop;
architecture sss of d_flipflop is
begin
process(clk,reset)
begin
if(reset='1') then
q<='0';
elsif(clk'event and clk='1') then
q<=d;
end if;
end process;
end sss;
3.
a.
library ieee;
use ieee.std_logic_1164.all;
entity Ring_counter is
Port ( CLOCK : in STD_LOGIC;
RESET : in STD_LOGIC;
Q : out STD_LOGIC_VECTOR (3 downto 0));
end Ring_counter;
entity Johnson_counter is
Port ( clk : in STD_LOGIC;
rst : in STD_LOGIC;
Q : out STD_LOGIC_VECTOR (3 downto 0));
end Johnson_counter;
3.b
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity Johnson_counter is
Port ( clk : in STD_LOGIC;
rst : in STD_LOGIC;
Q : out STD_LOGIC_VECTOR (3 downto 0));
end Johnson_counter;