entity jkff is
port(j,k,cp,r,s:in std_logic;
q,qb :out std_logic);
end jkff;
architecture rtl of jkff is
signal q_temp :std_logic:='0';
signal qb_temp :std_logic:='1';
begin
process(r,s,j,k,cp)
begin
if(r='0' and s='1')then
q_temp<='0';
qb_temp<='1';
elsif(r='1'and s='0')then
q_temp<='1';
qb_temp<='0';
elsif(cp'event and cp='0')then
if(q_temp='0') then
q_temp<=j;qb_temp<=not q_temp;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
---- Uncomment the following library declaration if instantiating
---- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity jkff is
Port ( j : in std_logic;
k : in std_logic;
clk : in std_logic;
s : in std_logic;
r : in std_logic;
q : out std_logic;
qb : out std_logic);
end jkff;
architecture Behavioral of jkff is
signal q_tmp,qb_tmp:std_logic;
begin
process(clk,s,r)
begin
if(s='0'and r='1')then
q_tmp<='1';
qb_tmp<='0';
elsif(s='1'and r='0')then
q_tmp<='0';
qb_tmp<='1';
elsif(clk'event and clk='1')then
if(j='0' and k='1')then
q_tmp<='0';
qb_tmp<='1';
elsif(j='1'and k='0')then
q_tmp<='1';
qb_tmp<='0';
elsif(j='1'and k='1')then
q_tmp<=not q_tmp;
qb_tmp<=not qb_tmp;
end if;
end if;
end process;
q<=q_tmp;
qb<=qb_tmp;