Torrid Fish

Back

Storage element introduction#

Synchronous v.s. Asychronous#

Now, we are going to discuss about sequential circuit.

But before we start, we need to define two types of sequential circuit:

SynchronousAsynchronous
SynchronousYes, by a clockNo
When does circuit updateUpon receiving a clock pulseAny time when an input change occurs
Most popular

Here is a graph of synchronous circuit:

Latch#

The main idea to storage is keeping a 0-bit or a 1-bit by regenerating it in a logic loop!

Here, we introduce latch:

  • the most basic storage elements
  • asynchronous circuits (have no clock input)
  • flip-flops can be constructed from latches

There are four types of latch:

SRS’R’SR + EnD

SR latch#

Cross cupling two NOR gates: In SR latch, there are few operation:

SSRRQ+Q^+ (next state)
00QQ (last state)
010 (Reset)
101 (Set)
11Indeterminate state

This is the logic simulation of SR latch behavior:

S’R’ latch#

Using NAND gates: In S’R’ latch, there are few operation:

SSRRQ+Q^+ (next state)
11QQ (last state)
100 (Reset)
011 (Set)
00Indeterminate state

SR latch with Enable#

Now, we try to add enable ( EnE_n ) on S’R’ latch: Notice that the input has been change, so output is opposite with S’R’ latch.

D latch (Transparent latch)#

  • Use only a single input DD to eliminate the undesirable state
  • Q+=DQ^+ = D when En=1E_n = 1
  • no changes when En=0E_n = 0

We can express D latch with Verilog:

always @(En, D) begin
    if (En == 1’b1) begin
        Q = D;
    end
end
verilog

Latch v.s. Flip-flop#

Latch is (a), level triggered and transparent as long as En=1En=1. As for flip-flop, it is (b) or (c), edge triggered and the signal will hold for a peroid.

Flip-Flop (FF)#

  • It is a storage element whose state cannot change more than once in a clock cycle.
  • It is edge triggered, which means state transition happens only on active clock edge.
  • By using flip flop, we can eliminate the multiple-transition problem.

Flip-Flop timing parameters#

Info:

  • tSt_S setup time minimum time for which the input data must be stable before the trigger edge
  • tHt_H hold time minimum time for which the input data must remain stable after the trigger edge
  • tPt_P propagation delay interval between the trigger edge and the stabilization of the output to its new value

We are going to introduce flip-flop. There are four types of Flip-Flop:

D ( Pos )D ( Neg )D + ControlJKT

D Flip-Flop (DFF)#

  • Output changes only at active clock dege. (either positve or negative edge triggered).
  • Characteristic table:
DDQ(t+1)Q(t+1)
0000ResetReset
1111SetSet
  • Characteristic equation:
Q(t+1)=DQ(t+1) = D

We can use the wave diagram to demonstrate the idea of D flip-flop.

We express pos-dege triggered D Flip-Flop in Verilog:

reg Q;
always @(posedge clk) begin
    Q <= D;
end
verilog

D flip-flop with additional inputs#

Asynchronous Set / Reset#

We can also describe in Verilog:

reg Q;
always @(posedge clk, posedge rst, posedge st) begin
    if (rst == 1 && st == 0)
        Q <= 0;
    else if (rst == 0 && st == 1)
        Q <= 1;
    else 
        Q <= D;
    // rst == 0 && st == 0 is undefined.
end
verilog

Enable input#

If CE=0CE=0, disabled, Q(t+1)=QQ(t+1)=Q. Else, act like a normal D flip-flop, Q(t+1)=DQ(t+1)=D. Hence, we have:

Q(t+1)=QCE+DCEQ(t+1) = Q\cdot CE'+D\cdot CE

D register with synchronous / asynchronous clear#

  • Synchronous
module dff_sync_clear(
input d, clearb, clock,
output reg q
);
    always @(posedge clock) begin
        if (!clearb) q <= 1'b0;
        else q <= d;
    end
endmodule
verilog
  • Asyncronous
module dff_async_clear(
input d, clearb, clock,
output reg q
);
    always @(posedge clock or negedge clearb) begin
        if (!clearb) q <= 1'b0;
        else q <= d;
    end
endmodule
verilog

The main difference is between the timing of activating always block!

JK flip-flop#

  • It can perform set, reset, and complement.
  • Characteristic table:
JJKKQ(t+1)Q(t+1)
0000Q(t)Q(t)NochangeNo change
001100ResetReset
110011SetSet
1111Q(t)Q'(t)ComplementComplement
  • Characteristic equation:
Q(t+1)=JQ(t)+KQ(t)Q(t+1) = JQ'(t)+K'Q(t)

This is the implementation of positive-edge triggered.

Also the wave diagram:

T flip-flop#

  • It can only perform complement.
  • Characteristic table:
TTQ(t+1)Q(t+1)
00Q(t)Q(t)NochangeNo change
11Q(t)Q'(t)ComplementComplement
  • Characteristic equation:
Q(t+1)=TQ(t)Q(t+1) = T\oplus Q(t)

This is the implementation of positive-edge triggered.

Characteristic equations#

DD+CEJKT
Q(t+1)=DQ(t+1) = DQ(t+1)=QCE+DCEQ(t+1) = Q\cdot CE'+D\cdot CEQ(t+1)=JQ(t)+KQ(t)Q(t+1) = JQ'(t)+K'Q(t)Q(t+1)=TQ(t)Q(t+1) = T\oplus Q(t)
tags: Logic Design EECS1010#