Flip-Flops Lecture L8.2 Section 8.1
Recall the !S-!R Latch !S !R Q !Q !S !R Q !Q X Y nand 1 0 Set 1 0 Store 0 1 Reset 1 1 Disallowed Q 0 !Q 0
Edge-triggered D Flip-flop
Edge-triggered D Flip-flop with asynchronous preset and clear
D Flip-Flop CLK DQ !Q X 0 Q 0 !Q 0 D CLK Q !Q D gets latched to Q on the rising edge of the clock. Positive edge triggered
Each Xilinx macrocell contains a D flip-flop Controlled inverter
Each Xilinx macrocell contains a D flip-flop Note asynchronous preset x Q.AP = x Note asynchronous reset Q.AR = y y Q.D = z z
Divide-by-2 Counter CLK Q0 Q0.D = !Q0 CLK DQ !Q Q0.D = !Q0 Q0 Q0.D !Q0
MODULE div2cnt TITLE 'Divide By 2 Counter' DECLARATIONS " INPUT PINS " PB PIN 70; " push-button switch (clock) " OUTPUT PINS " Q0 PIN 44 ISTYPE 'reg buffer'; " LED 16 div2cnt.abl CLK DQ !Q Q0.D = !Q0 Q0 Q0.D !Q0 Registered Buffer output
EQUATIONS Q0.C = PB; Q0.D = !Q0; test_vectors(PB -> Q0).C. -> 1;.C. -> 0;.C. -> 1;.C. -> 0;.C. -> 1;.C. -> 0; END div2cnt.abl (cont’d) CLK DQ !Q Q0.D = !Q0 Q0 Q0.D !Q0.C. means clock goes LO-HI-LO Power-on output Q0 = 0
A 1-Bit Register
MODULE reg1bit TITLE '1-bit register, R. Haskell, 10/13/02' DECLARATIONS hex7seg interface([D3..D0] -> [a,b,c,d,e,f,g]); d7R FUNCTIONAL_BLOCK hex7seg; " INPUT PINS " PB PIN 70; " push-button switch (clock) LOAD PIN 11;" switch S6:1 clear PIN 7;" switch S6:2 INP0 PIN 1;" switch S7:4 " OUTPUT PINS " Q0 PIN 44 ISTYPE 'reg buffer'; " LED 16 [a,b,c,d,e,f,g] PIN 15,18,23,21,19,14,17 ISTYPE 'com'; " Rightmost (units) 7-segment LED display
EQUATIONS Q0.C = PB; Q0.AR = clear; Q0.D = Q0 & !LOAD # INP0 & LOAD; [a,b,c,d,e,f,g] = d7R.[a,b,c,d,e,f,g]; d7R.D0 = Q0; d7R.[D3..D1] = [0,0,0]; test_vectors([PB,clear,LOAD,INP0] -> Q0) [.C.,1,0,1] -> 0; [.C.,0,1,1] -> 1; [.C.,0,0,0] -> 1; [.C.,0,1,0] -> 0; [.C.,0,0,1] -> 0; [.C.,0,1,1] -> 1; [.C.,0,0,0] -> 1; [.C.,0,0,1] -> 1; [.C.,0,1,0] -> 0; END
A 4-Bit Register
4-Bit Register reset to 1010
MODULE reg4bit5 INTERFACE (clk,reset,load,[IN3..IN0] -> [Q3..Q0]); TITLE ',, ' DECLARATIONS " Input Pins " clk PIN ; reset PIN ; load PIN ; IN3..IN0 Pin ; INP = [IN3..IN0]; " 4-bit input data " Output Pins " Q3..Q0 PIN ISTYPE 'reg buffer'; Q = [Q3..Q0]; " 4-bit register EQUATIONS Q.c = clk; [Q2, Q0].ar = reset; [Q3, Q1].ap = reset; "reset Q = 5 Q.d = INP & load # Q & !load; END reg4bit5
J-K Flip-flops Q.D = J & !Q # !K & Q
J-K Flip-flops
T Flip-flops Q.D = T $ Q
T Flip-flops
MODULE Tdiv2cnt TITLE 'Divide By 2 Counter using T flip-flop' DECLARATIONS " INPUT PINS " PB PIN 70; " push-button switch (clock) " OUTPUT PINS " Q0 PIN 44 ISTYPE 'reg buffer'; " LED 16 EQUATIONS Q0.C = PB; Q0.T = 1; test_vectors(PB -> Q0).C. -> 1;.C. -> 0;.C. -> 1;.C. -> 0;.C. -> 1;.C. -> 0; END 1