120 likes | 368 Views
JK and T Flip-Flops. Discussion D4.4 Example 29. JK Flip-flops. D = J*~q + ~K*q. JK Flip-flops. -- Example 29a: JK Flip-flop library IEEE; use IEEE.STD_LOGIC_1164. all ; entity jkff is port ( clk : in STD_LOGIC; clr : in STD_LOGIC; J : in STD_LOGIC;
E N D
JK and T Flip-Flops Discussion D4.4 Example 29
JK Flip-flops D = J*~q + ~K*q
-- Example 29a: JK Flip-flop library IEEE; use IEEE.STD_LOGIC_1164.all; entity jkff is port( clk : in STD_LOGIC; clr : in STD_LOGIC; J : in STD_LOGIC; K : in STD_LOGIC; q : out STD_LOGIC ); end jkff;
architecture jkff of jkff is signal D, qs: STD_LOGIC; begin D <= (J andnot qs) or (not K and qs); -- D Flip-flop process(clk, clr) begin if(clr = '1') then qs <= '0'; elsif(clk'event and clk = '1') then qs <= D; end if; end process; q <= qs; end jkff; D = J*~q + ~K*q
T Flip-flops D = T ^ q
-- Example 29b: T flip-flop library IEEE; use IEEE.STD_LOGIC_1164.all; entity tff is port( clk : in STD_LOGIC; clr : in STD_LOGIC; t : in STD_LOGIC; q : out STD_LOGIC ); end tff;
architecture tff of tff is signal D, qs: STD_LOGIC; begin D <= t xor qs; -- D Flip-flop process(clk, clr) begin if(clr = '1') then qs <= '0'; elsif(clk'event and clk = '1') then qs <= D; end if; end process; q <= qs; end tff; D = T ^ q