You are on page 1of 4

3-BIT RIPPLE COUNTER USING T-FF - USE INSTANTIATION TECHNIQUE T-FLIPFLOP 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; clk : in STD_LOGIC; rst : in STD_LOGIC; q : out STD_LOGIC; qb : out STD_LOGIC); end tff; architecture Behavioral of tff is begin process(clk,rst) begin if(rst='1')then q<='1'; qb<='0'; elsif (clk'event and clk='1')then qb<= t; q<= not t; end if; end process; end Behavioral; 3-BIT RIPPLE library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity ripplecount is Port ( clk : in STD_LOGIC; rst : in STD_LOGIC; count : out STD_LOGIC_VECTOR (2 downto 0)); end ripplecount; architecture structural of ripplecount is component tff Port ( t : in STD_LOGIC; clk : in STD_LOGIC; rst : in STD_LOGIC; q : out STD_LOGIC; qb : out STD_LOGIC); end component; signal ncount : STD_LOGIC_VECTOR (2 downto 0); begin bit0: tff port map (clk => clk, rst=> rst, t=> ncount(0), q=> ncount(0), qb=> count(0)); bit1: tff port map (clk => ncount(0), rst=> rst, t=> ncount(1), q=> ncount(1), qb=> count(1)); bit2: tff port map (clk => ncount(1), rst=> rst, t=> ncount(2), q=> ncount(2), qb=> count(2)); end structural;

You might also like