Title: Hamming Code,Decoders and D,Tflip flops
1Hamming Code,Decoders andD,T-flip flops
Lecture 7
- Prof. Sin-Min Lee
- Department of Computer Science
2Let us play a game !
- A volunteer from the audience?
- Pick a number, any number, between 1 and 50
3Is the Number in Here?
- 1 3 5 7 9 11 13 15 17 19 21 23 25 27
29 31 33 35 37 39 41 43 45 47 49
4Is the Number in Here?
- 2 3 6 7 10 11 14 15 18 19 22 23 26 27
30 31 34 35 38 39 42 43 46 47 50
5Is the Number in Here?
- 4 5 6 7 12 13 14 15 20 21 22 23 28
29 30 31 36 37 38 39 44 45 46 47
6Is the Number in Here?
- 8 9 10 11 12 13 14 15 24 25 26 27 28
29 30 31 40 41 42 43 44 45 46 47
7Is the Number in Here?
- 16 17 18 19 20 21 22 23 24 25 26 27
28 29 30 31 49 50
8Is the Number in Here?
- 32 33 34 35 36 37 38 39 40 41 42 43
44 45 46 47 48 49 50
9And the Number is .
10(No Transcript)
11(No Transcript)
12(No Transcript)
13(No Transcript)
14(No Transcript)
15(No Transcript)
16(No Transcript)
17(No Transcript)
18(No Transcript)
19(No Transcript)
20(No Transcript)
21(No Transcript)
22(No Transcript)
23(No Transcript)
24(No Transcript)
25(No Transcript)
26Decoders
- Next, well look at some commonly used circuits
decoders and multiplexers. - These serve as examples of the circuit analysis
and design techniques from last lecture. - They can be used to implement arbitrary
functions. - We are introduced to abstraction and modularity
as hardware design principles. - We often use decoders and multiplexers as
building blocks in designing more complex
hardware.
27What a decoder does
- A n-to-2n decoder takes an n-bit input and
produces 2n outputs. The n inputs represent a
binary number that determines which of the 2n
outputs is uniquely true. - A 2-to-4 decoder operates according to the
following truth table. - The 2-bit input is called S1S0, and the four
outputs are Q0-Q3. - If the input is the binary number i, then output
Qi is uniquely true. - For instance, if the input S1 S0 10 (decimal
2), then output Q2 is true, and Q0, Q1, Q3 are
all false. - This circuit decodes a binary number into a
one-of-four code.
28How can you build a 2-to-4 decoder?
- Follow the design procedures from last time! We
have a truth table, so we can write equations for
each of the four outputs (Q0-Q3), based on the
two inputs (S0-S1). - In this case theres not much to be simplified.
Here are the equations
Q0 S1 S0 Q1 S1 S0 Q2 S1 S0 Q3 S1 S0
29A picture of a 2-to-4 decoder
30Enable inputs
- Many devices have an additional enable input,
which is used to activate or deactivate the
device. - For a decoder,
- EN1 activates the decoder, so it behaves as
specified earlier. Exactly one of the outputs
will be 1. - EN0 deactivates the decoder. By convention,
that means all of the decoders outputs are 0. - We can include this additional input in the
decoders truth table
31An aside abbreviated truth tables
- In this table, note that whenever EN0, the
outputs are always 0, regardless of inputs S1 and
S0. - We can abbreviate the table by writing xs in the
input columns for S1 and S0.
32Blocks and abstraction
- Decoders are common enough that we want to
encapsulate them and treat them as an individual
entity. - Block diagrams for 2-to-4 decoders are shown
here. The names of the inputs and outputs, not
their order, is what matters - A decoder block provides abstraction
- You can use the decoder as long as you know its
truth table or equations, without knowing exactly
whats inside. - It makes diagrams simpler by hiding the internal
circuitry. - It simplifies hardware reuse. You dont have to
keep rebuilding the decoder from scratch every
time you need it. - These blocks are like functions in programming!
Q0 S1 S0 Q1 S1 S0 Q2 S1 S0 Q3 S1 S0
33A 3-to-8 decoder
- Larger decoders are similar. Here is a 3-to-8
decoder. - The block symbol is on the right.
- A truth table (without EN) is below.
- Output equations are at the bottom right.
- Again, only one output is true for any input
combination.
Q0 S2 S1 S0 Q1 S2 S1 S0 Q2 S2 S1
S0 Q3 S2 S1 S0 Q4 S2 S1 S0 Q5 S2 S1
S0 Q6 S2 S1 S0 Q7 S2 S1 S0
34So what good is a decoder?
- Do the truth table and equations look familiar?
- Decoders are sometimes called minterm generators.
- For each of the input combinations, exactly one
output is true. - Each output equation contains all of the input
variables. - These properties hold for all sizes of decoders.
- This means that you can implement arbitrary
functions with decoders. If you have a sum of
minterms equation for a function, you can easily
use a decoder (a minterm generator) to implement
that function.
Q0 S1 S0 Q1 S1 S0 Q2 S1 S0 Q3 S1 S0
35Design example addition
- Lets make a circuit that adds three 1-bit inputs
X, Y and Z. - We will need two bits to represent the total
lets call them C and S, for carry and sum.
Note that C and S are two separate functions of
the same inputs X, Y and Z. - Here are a truth table and sum-of-minterms
equations for C and S.
C(X,Y,Z) ?m(3,5,6,7) S(X,Y,Z) ?m(1,2,4,7)
0 1 1 10
1 1 1 11
36Decoder-based adder
- Here, two 3-to-8 decoders implement C and S as
sums of minterms. - The 5V symbol (5 volts) is how you represent
a constant 1 or true in LogicWorks. We use it
here so the decoders are always active.
C(X,Y,Z) ?m(3,5,6,7) S(X,Y,Z) ?m(1,2,4,7)
37Using just one decoder
- Since the two functions C and S both have the
same inputs, we could use just one decoder
instead of two.
C(X,Y,Z) ?m(3,5,6,7) S(X,Y,Z) ?m(1,2,4,7)
38(No Transcript)
39(No Transcript)
40(No Transcript)
41(No Transcript)
42Multiplexers
- A combinational circuit that selects info from
one of many input lines and directs it to the
output line. - The selection of the input line is controlled by
input variables called selection inputs. - They are commonly abbreviated as MUX.
43(No Transcript)
44(No Transcript)
45Combinational circuit implementation using MUX
- We can use Multiplexers to express Boolean
functions also. - Expressing Boolean functions as MUXs is more
efficient than as decoders. - First n-1 variables of the function used as
selection inputs last variable used as data
inputs. - If last variable is called Z, then each data
input has to be Z, Z, 0, or 1.
46(No Transcript)
47(No Transcript)
48Karnaugh Map Method of Multiplexer Implementation
Consider the function
A is taken to be the data variable and B,C to be
the select variables.
49Example of MUX combo circuit
50(No Transcript)
514 Basic types of Flip-Flops
- SR, JK, D, and T
- JK ff has 2 inputs, J and K need to be asserted
at the same time to change the state - D ff has 1 input D (DATA), which sets the ff when
D 1 and resets it when D 0 - T ff has1 input T (Toggle), which forces the ff
to change states when T 1 - SR ff has 2 inputs, S (set) and R (reset) that
set or reset the output Q when asserted
52(No Transcript)
53(No Transcript)
54Gated D-Latch
- Ensures S and R inputs never equal to 1 at the
same time - Useful in control application where setting or
resetting a flag to some condition is needed - Stores bits of information
- Constructed from a gated SR latch and a Data
latch
55(No Transcript)
56Analysis of Sequential Systems
- Goal
- Decide the timing and functional behavior from
the implementation of a sequential system
composed of FFs and logic gates - Types
- Functional analysis
- Timing analysis
57Characteristic Equation of FFs
58D Flip-Flop
Q Next State
Characteristics ?Synchronous ?Avoids the
instability of RS flip-flop ?Retains its last
input value To set the ff, place 1 on D input
and pause the CK input To reset, place 1 on D
input and pause the CK input
59T Flip-Flop
T 1 force the state change T 0 state remain
the same
60T
CLK
Q1
61T
CLK
Q1
62How to use D to implement T Flip-Flop
D TQ TQ
63How to use D to implement T Flip-Flop
D TQ TQ
T
64How to use T to implement D Flip-Flop
T DQ DQ
65How to use T to implement D Flip-Flop
T DQ DQ
D
66Edge and level-triggered Flip Flop
- Digital circuit often form loops, flip-flops
oscillations can - Oscillation will not occur because by the time an
output change cause an input change, the
activating edge of the CK signal will be gone - Positive edge triggered ff responds to a
positive going edge of clock - Negative edge triggered responds to a
negative-going edge