Wednesday, 17 July 2013

Design of Toggle Flip Flop using J-K Flip Flop (VHDL Code).





Design of Toggle Flip Flop using  J-K Flip Flop  (Structural Modeling Style)-



Output Waveform :   Toggle Flip Flop using JK Flip Flop


VHDL Code -


-------------------------------------------------------------------------------
--
-- Title       : toggle_ff_using_jk
-- Design      : verilog upload
-- Author      : Naresh Singh Dobal
-- Company     : nsd
--
-------------------------------------------------------------------------------
--
-- File        : Design of Toggle Flip Flop using J-K Flip Flop.vhd



library IEEE;
use IEEE.STD_LOGIC_1164.all;

entity toggle_ff_using_jk is
     port(
         t : in STD_LOGIC;
         clk : in STD_LOGIC;
         reset : in STD_LOGIC;
         dout : out STD_LOGIC
         );
end toggle_ff_using_jk;

architecture toggle_ff_using_jk_arc of toggle_ff_using_jk is

component jk_flip_flop is
     port(
         clk : in STD_LOGIC;
         j : in STD_LOGIC;
         k : in STD_LOGIC;
         reset : in STD_LOGIC;
         q : out STD_LOGIC;
         qb : out STD_LOGIC
         );
end component jk_flip_flop;     

begin

    u0 : jk_flip_flop port map (clk => clk,
                                j => t,
                                k => t,
                                reset => reset,
                                q => dout,
                                qb => open);

end toggle_ff_using_jk_arc;





-------------------- J-K Flip Flop Design ---------------------



library IEEE;
use IEEE.STD_LOGIC_1164.all;

entity jk_flip_flop is
     port(
         clk : in STD_LOGIC;
         j : in STD_LOGIC;
         k : in STD_LOGIC;
         reset : in STD_LOGIC;
         q : out STD_LOGIC;
         qb : out STD_LOGIC
         );
end jk_flip_flop;

architecture jk_flip_flop_arc of jk_flip_flop is   

begin
   
    jkff : process (j,k,clk,reset) is   
    variable m : std_logic := '0' ;
    begin
        if (reset='1') then
            m := '0';
        elsif (rising_edge (clk)) then
            if (j/=k) then
                m := j;   
            elsif (j='1' and k='1') then
                m := not m;
            end if;
        end if;     
        q <= m;
        qb <= not m;
    end process jkff;


end jk_flip_flop_arc;

0 comments :

Post a Comment

 
Design by Wordpress Theme | Bloggerized by Free Blogger Templates | coupon codes