Saturday 13 July 2013

ASYNCHRONOUS COUNTER USING JK FLIPFLOP

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity jkffl is
port(j,k,rst,clk:in std_logic;
q,qbar:out std_logic);
end jkffl;

architecture Behavioral of jkffl is
begin
process(clk,j,k,rst)
variable x:std_logic:='0';
begin
if (clk' event and clk='1') then
case rst is
when '1'=>
x:='0';
when '0'=> if (j='0' and k='0')then
x:=x;
elsif(j='0' and k='1') then
x:='0';
elsif (j='1' and k='0') then
x:='1';
elsif(j='1' and k='1')then
x:=not x;
end if;
when others=> null;
end case;
end if;
q<= x;
qbar<= not x;
end process;
end Behavioral;

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity jkcounter is
port(clk,rst:in std_logic;
q,qb:inout std_logic_vector(3 downto 0));
end jkcounter;

architecture arch of jkcounter is
component jkffl is
port(j,k,rst,clk:in std_logic;
q,qbar:out std_logic);
end component;
signal k,l,m:std_logic;
begin
k<=q (0);
l<=q (1);
m<=q (2);
a1:jkffl port map('1','1',rst,clk,q(0),qb(0));
a2:jkffl port map('1','1',rst,k,q(1),qb(1));
a3:jkffl port map('1','1',rst,l,q(2),qb(2));
a4:jkffl port map('1','1',rst,m,q(3),qb(3));
end arch;






CIRCUIT DIAGRAM














No comments:

Post a Comment