Logic Circuits and Computer Architecture - PowerPoint PPT Presentation

1 / 110
About This Presentation
Title:

Logic Circuits and Computer Architecture

Description:

Each of the m outputs can be expressed as function of n input variables. Truth table has: ... Read Only Memories (ROMs) They are just a combinational circuits ! ... – PowerPoint PPT presentation

Number of Views:40
Avg rating:3.0/5.0
Slides: 111
Provided by: adria230
Category:

less

Transcript and Presenter's Notes

Title: Logic Circuits and Computer Architecture


1
Logic Circuits and Computer Architecture
  • Appendix A
  • Digital Logic Circuits
  • Part 2 Combinational and
  • Sequential Circuits

2
Combinational circuits
  • Each of the m outputs can be expressed as
    function of n input variables
  • Truth table has
  • n input columns
  • m output columns
  • 2n rows (all possible input combinations)

3
Binary Adder
Aa3a2a1a0
Cc4c3c2c1c0 the sum of A and B
Bb3b2b1b0
a3
a2
a0
b3
b2
b0
a1
b1
Combinational Circuit
c3
c2
c1
c0
c4
4
Seven-segment decoder
It converts a 4-bit binary-coded decimal value
into the code required to drive a seven-segment
display
a
a b c d e f g
b
f
A B C D
Combinational Circuit
g
c
e
d
A0 B1 C1 D1
A0 B0 C0 D0
5
The truth table
6
Decoder
  • Convert n inputs to exactly one of 2n outputs
  • i.e., given an n-bit value i in input the
    decoder activates only the i-th output line
  • Example a 3-to-8 decoder
  • A 3-bit value in input
  • 8 output lines
  • Write the truth table and the logic circuit

7
Decoder Examples
1-to-2 decoder
A
0
A
A
D
D
D
D
1
0
0
1
2
3
A
1
0
0
1
0
0
0
D
A
A
0
1
0
0
1
0
1
0
0
1
0
0
0
1
0
D
A
A
1
1
0
0
0
1
1
1
0
(a)
D
A
A
2
1
0
2-to-4 decoder
D
A
A
3
1
0
(b)
8
A 3-to-8 decoder
9
a
d
b
c
a
b
equivalent to
c
d
a
d
b
c
a
b
equivalent to
c
d
A2
Inputs
A1
A0
3-to-8 decoder

D0
D1
D7
10
Decoder with Enable
  • See truth table below for function
  • Note use of Xs to denote both 0 and 1
  • Combination containing two Xs represent four
    binary combinations

EN
A
A
D
D
D
D
1
0
0
1
2
3
0
X
X
0
0
0
0
1
0
0
1
0
0
0
1
0
1
0
1
0
0
1
1
0
0
0
1
0
1
1
1
0
0
0
1
11
E
S1
S0
12
3-to-8 decoder from two 2-to-4 decoder with
enable
D0
A0
D1
A1
D2
D3
A2
D4
D5
D6
D7
13
Combinational Logic Implementation- Decoder and
OR Gates
  • Implement m functions of n variables with
  • Sum-of-minterms expressions
  • One n-to-2n-line decoder
  • m OR gates, one for each output
  • Approach 1
  • Find the truth table for the functions
  • Make a connection to the corresponding OR from
    the corresponding decoder output wherever a 1
    appears in the truth table
  • Approach 2
  • Find the minterms for each output function
  • OR the minterms together

14
Decoder and OR Gates Example
Finding sum ofminterms expressions F1 ?m
(1,2,5,6,8,11,12,15)F2 ?m (1,3,4,6,8,10,13,15)
F3 ?m (2,3,4,5,8,9,14,15)
15
Read Only Memories (ROMs)
  • They are just a combinational circuits !
  • A ROM is made by a decoder followed by a second
    module combining minterms to give the desired
    functions (matrix of OR gates)
  • A simple example for a 8-cell ROM with 3 bits per
    cell

16
The implementation
OR Gates
A0
A1
A2
D0
D1
D2
17
Standard implementation
  • PLA programmable logic array
  • A PLA for sum of products is made by a first
    module combining inputs to form products,
    followed by a second module combining products to
    give the desired functions
  • A PLA having a decoder as first module is a ROM

18
Schema for a sum-of-products PLA
Array of AND gates
Array of OR gates
Output functions
Inputs
Products
  • Inputs are variables and their negation
  • Each output line realizes a boolean function

19
An example
20
The PLA implementation
A
Inputs
B
AND Gates
C
W
Outputs
OR Gates
X
Y
21
Exercise
  • Build a ROM-based combinatorial circuit with
  • INPUT 3 boolean variables
  • OUTPUT the number of 1s in the input (expressed
    in binary)

22
Solution Truth Table
23
Solution the implementation
OR Gates
A0
A1
A2
D1
D0
24
Selecting
  • Selecting of data or information is a critical
    function in digital systems and computers
  • Circuits that perform selecting have
  • A set of information inputs from which the
    selection is made
  • A single output
  • A set of control lines for making the selection
  • Logic circuits that perform selecting are called
    multiplexers

25
Multiplexer (Mux)
  • 2n data inputs -- 1 output
  • n controls, to select one of the inputs to be
    sent to the output
  • Example 4-to-1 mux Truth table
  • Logic symbol

26
Logic circuit for a 4-to-1 Mux
27
Example 4-to-1-line Multiplexer
Decoder
S
1
Enabling circuits
S
0
Decoder
Decoder
S
S
1
1
D
S
S
0
0
0
D
Y
Y
1
F
D
2
D
3
28
Exercise
  • Consider a 2-to-1 multiplexer
  • 2 data inputs D0 and D1
  • 1 control input S0
  • 1 data output F
  • Write
  • Truth table
  • Logic circuits which implements it
  • Extend it to deal with 4 bits at a time

29
2-to-1 mux
D0
F
D1
S
30
Quadruple 2-to-1 mux
31
How to use multiplexers to implement functions
  • 2n-to-1 mux for a n-variable function

32
How to use multiplexers to implement functions
  • 2n-1-to-1 mux for a n-variable function

C
FC
C
F
0
FC
1
F0
A
B
F1
33
De-multiplexer (Demux)
  • 1 input -- 2n data outputs --
  • n controls, to select exactly one of the outputs
    to receive the input
  • Example 1-to-4 demux
  • input E, controls S0 , S1
  • outputs D0 , D1 , D2 , D3
  • Truth table

34
Logic circuit for a 1-to-4 Demux
It is equal to a decoder with enable ?Sometimes
it is called decoder/demultiplexer
35
Binary Addition
  • Carries
  • Addend-1 1 0 1 1 0
  • Addend-2 1 0 1 1 1
  • Sum

0
0
1
1
0
1


1
0
1
1
0
1
36
Functional Blocks Addition
  • Binary addition used frequently
  • Functional Blocks
  • Half-Adder (HA), a 2-input bit-wise addition
    functional block,
  • Full-Adder (FA), a 3-input bit-wise addition
    functional block,
  • Ripple Carry Adder, a circuit performing binary
    addition, and
  • Carry-Look-Ahead Adder (CLA), a hierarchical
    structure to improve performance.

37
Half-Adder
  • Its just a 2-input, 2-output circuit that
    performs the following computations
  • A half adder adds two bits to produce a two-bit
    sum
  • The sum is expressed as a
    sum bit , S and a
    carry bit, C

38
The half adder
  • Sum two binary inputs without the carry-in
  • Truth table Logic Circuit

39
Full-Adder
  • A full adder is similar to a half adder, but
    includes a carry-in bit from lower stages. Like
    the half-adder, it computes a sum bit, S and a
    carry bit, C.
  • For a carry-in (Z) of
    0, it is the same
    as
    the half-adder
  • For a carry- in(Z) of 1

40
Full-adder
  • Has to be able to deal Truth table
  • with the carry-in
  • Z represents the carry-in

41
Karnaughs maps for full adder
  • S XYZXYZXYZXYZ C XY XZ YZ
  • X ? Y ? Z XY XYZ XYZ

  • XY Z.(XYXY)
  • XY Z.(X ? Y)

42
The logic circuit of a full adder
43
Binary adder
  • Has to be able to deal with more bits
  • An n-bit adder can be built chaining n full
    adders
  • Its called ripple-carry adder

44
Ideal behaviour of circuits
  • Consider an inverter (NOT gate)

45
The real behaviour
  • Propagation delay time needed for a change in
    the input to affect the output (gate delay)
  • Fall time time taken for the signal to fall from
    high level to low level
  • Rise time time taken to rise from low to high

46
Carry Propagation
  • Signals must propagate from inputs for output to
    be valid
  • Carry and sum outputs of a single full-adder are
    valid c gate-delays after inputs are stable
  • Value of c depends on the used technology
  • In a binary adder of n bits the last carry is
    valid c?n gate-delays after inputs are stable
  • For n large it may be unacceptable !

47
Solution
  • Pre-compute all carry-ins
  • carry look-ahead adder
  • Write a general expression for a carry
  • When is a carry generated in the output?
  • When does an input carry propagates to the output?

48
General expression
  • General expression for the (i1)-th carry
  • ci1 xiyi ci (xi yi) gi cipi
  • gi ? generate carry
  • pi ? propagate carry
  • Iterate the expression for ci

49
General expression (2)
  • ci1 gi pici
  • gi pi(gi-1ci-1pi-1)
    gipigi-1pipi-1ci-1
  • gipigi-1pipi-1(gi-2ci-2pi-2)
  • gipigi-1pipi-1gi-2pipi-1pi-2ci-2
  • gipigi-1pipi-1gi-2pipi-1pi-2gi-3pipi-1
    pi-2pi-3gi-4...
  • It could be developed until the least significant
    input bits
  • Every ci depends only on c0, pj, gj (jlti)

50
Carry expressions for a 4-bit adder
  • c1 g0 p0c0
  • c2 g1 p1g0 p1p0c0
  • c3 g2 p2g1 p2p1g0 p2p1p0c0
  • c4 g3 p3g2 p3p2g1 p3p2p1g0 p3p2p1p0c0

51
Carry Look-Ahead the architecture
a3
a2
a0
b3
b2
b0
a1
b1
generation/propagation
p3
p2
p1
p0
g3
g2
g0
g1
c0
carry look-ahead
c3
c2
c1
c0
a3
a2
a0
b3
b2
b0
a1
b1
c4
PFA
PFA
PFA
PFA
s3
s2
s0
s1
52
A pratical problem
  • c1 g0 p0c0
  • c2 g1 p1g0 p1p0c0
  • c3 g2 p2g1 p2p1g0 p2p1p0c0
  • c4 g3 p3g2 p3p2g1 p3p2p1g0 p3p2p1p0c0

there is a limit due to circuit fan-in the
maximum number of inputs
53
Practical solution for n bits
  • Use carry look-ahead adders for just m
    consecutive bits (4-8 is typical)
  • Each of these is a stage
  • Use n/m stages connected by means of the
    ripple-carry technique
  • The overall delay is now (more or less) only
    c?n/m gate delays

54
A mixed solution
a15..12
b1512
a7..4
a11..8
b74
b118
a3..0
b30
c16
c12
c8
c4
CLA4
CLA4
CLA4
CLA4
c0
s15..12
s7..4
s11..8
s3..0
55
Sequential circuits
  • More difficult to analyze since there is
    feedback output is fed back to input
  • Need to introduce a concept of state
  • Current state and next state
  • Asynchronous change of state of an element is
    fed into other elements without any coordination
  • Synchronous change of state of each element is
    fed into other elements only at a given instant,
    the same for all elements

56
Initial examples
  • What does this circuit do ?
  • What about this one ?
  • Replace inverters with NOR gates

57
SR-Latch
  • Analyze this circuit (write truth table)

58
Analysis of SR-Latch
  • Two kinds of analysis
  • COMBINATIONAL
  • Consider all possible configurations of S,R,Q and
    check their feasibility
  • SEQUENTIAL
  • Consider all possible configurations of S,R,Q at
    a generic step k and check what happens for Q at
    step k1

59
SR-Latch Truth TableCombinational View
  • 8 possible combinations (Q NOT Q)

60
SR-Latch Truth Table Sequential View
  • Next state as a function of current state

61
First reason to avoid SR1
  • When both inputs go from 1 to 0
  • a race condition happens
  • Both outputs are driven from 0 to 1
  • Due to unpredictable physical differences one of
    the NOR gates may commute earlier from 0 to 1
  • Then it will prevent the commutation of the other
    gate
  • Conclusion output value is unpredictable !

62
Second reason to avoid SR1
  • When both inputs go from 1 to 0
  • a race condition happens
  • Both outputs are driven from 0 to 1
  • Both the NOR gates commute from 0 to 1 almost at
    the same time
  • This drives both outputs from 1 to 0
  • Both gates are again forced to commute
  • This repeats again and again
  • Conclusion output values oscillate !

63
Temporal evolution of SR-latch
  • Time -gt
  • S
  • R
  • Q
  • Q

64
Transition table for SR-Latch
A Synthetic description
65
Adding a clock to SR-latch
  • An additional input (the clock) is used to ensure
    the latch commutes only when required
  • pulses of a clock
  • The latch senses S and R only when Clock1

66
The role of the clock
  • A clock ensures commutation is propagated from
    the input to the output only when required
  • But the general system clock is running
    continuously how can it be used to control a
    circuit only when needed?
  • Enable Clock for the specific
    circuit
  • System Clock

67
Circuit clock from system clock
  • Enable Clock for the specific circuit
  • System Clock

System Clock
Circuit Enable
Circuit Clock
68
A more subtle problem
  • In a commutation from (S1,R0) to (S0,R1) or
    from (S0,R1) to (S1,R0) the SR-latch outputs
    may be (for some time) in the unacceptable state
    where both outputs are 0

69
Example
  • The NOR gate receiving the R0-to-1 input may
    commute earlier than the other gate and now
    outputs of the SR-latch are in an unacceptable
    state
  • If Q and Q are in input to a further circuit,
    this receives wrong input values, hence its
    computed output may differ from the required one

70
The solution a Flip-Flop circuit
  • A 2-stage (master and slave) circuit
  • First the master stage (connected to circuits
    inputs only) changes its state (flip) when clock
    commutes to 1
  • Then the slave stage (connected to circuits
    outputs only) reads masters outputs after they
    have stabilized, when clock commutes to 0, and
    changes its state (flop)
  • The next circuit will read slaves outputs in the
    next clock commutation to 1, when they have
    stabilized
  • Outputs from the i-th circuit are read in input
    to the (i1)-th circuit only after the transient
    unacceptable phase is ended, since adjacent
    stages are active only during different half
    periods of the clock
  • In a chain of circuits this allows to control
    exactly when the (commuted) output of the i-th
    circuit acts on the input of the (i1)-th circuit

71
SR flip-flop
72
How SR flip-flop solve the problem
  • Temporal evolution (both stages have a transient
    phase, but its effect on the next stage are
    hidden)

73
D flip-flop a secure SR flip-flop
  • Forcing R to always be NOT(S) the critical
    condition SR1 is avoided

SR flip-flop
D
S
Q
C
R
Q
74
Use of D flip-flop
  • A D flip-flop is a memory cell, since it stores
    what is presented at its input
  • Symbol Truth table
  • Read-Enable (RE) and Write-Enable (WE) signals to
    store and read values
  • Additional Preset (writes 1) and Clear (writes 0)
    signals to prepare the gate

75
4 bit register
X0
X1
X2
X3
WE
WE.Pr
D
D
D
D
Q
Q
Q
Q
Ck
Ck
Ck
Ck
WE.Ck
RE
Y3
Y2
Y0
Y1
76
Use of D flip-flop (2)
  • A D flip-flop is a delay unit, since it
    replicates at the output - one propagation delay
    later - what is presented at its input (delay
    flip-flop)
  • A chain of n D flip-flops can be used to delay a
    bit value for n clock pulses

77
4 bit delay unit
SE
D
D
D
D
Din
Q
Q
Q
Q
Dout
Ck
Ck
Ck
Ck
SE.Ck
RE
Y3
Y2
Y0
Y1
78
4 bit shift register
X0
X1
X2
X3
WE
SE
D
D
D
D
Q
Dout
Din
Q
Q
Q
Ck
Ck
Ck
Ck
(SE.Ck) (WE.Ck)
RE
Y3
Y2
Y0
Y1
79
Register Control Signals
  • WE (Write Enable) needed since many registers
    are attached to (i.e., receive data from) the
    same data bus
  • SE (Shift Enable) allows a register output to
    drive next register input
  • RE (Read Enable) needed since many registers are
    attached to (i.e., put data on) the same data bus

80
JK flip-flop using also SR1
81
JK flip-flop temporal evolution (1)
  • Sequence of events

82
JK flip-flop temporal evolution (2)
  • Sequence of events

83
Tabular description for JK-FF
  • Input J, K State Q Output Q

84
Transition Tables
  • Synthetic description of flip-flop dynamics

85
Counters
D0
I
  • IDEA A single JK-FF with a periodic input
    commutes its output with twice the period of its
    input
  • Use a chain of JK-FF each time doubling the
    period of the input
  • A counter modulo 24 is shown

D1
I.D0
D2
I.D0.D1
D3
I.D0.D1.D2
COUT
Ck
86
Temporal behaviour (1)
ICk
D0
87
Temporal behaviour (2)
ICk
D0
D1
88
Temporal behaviour (3)
ICk
D0
D1
D2
89
Temporal behaviour (4)
ICk
D0
D1
D2
D3
90
Temporal behaviour (5)
ICk
D0
D1
D2
D3
COUT
91
Finite State Machines (FSM)
  • Called also Finite State Automata (FSA)
  • Described by a table of transitions between
    states as a consequence of inputs
  • If an input is true in a given state, a
    transition changes the state and may produce an
    output
  • Graphical representation (states are circles,
    transition are arrows, input and output are arrow
    labels)

Input / Output
Next state
Current state
92
A very simple example of FSM
  • When the tank of my car is full, if it is an
    holiday I make a trip, but if it is a week-day I
    go to work by bus. After the trip, the tank is
    empty and when I find a gas station I fill the
    tank

Holiday / Make a trip
Tank empty
Tank full
Week-day / Go to work
Gas station / Fill the tank
93
Tabular description for this FSM
  • Next state as a function of current state and
    input
  • Output as a function of current state and input

94
Abstraction process
  • FSM describe sequential networks (SN)
  • SN realizes Finite State Machines
  • The analysis of a SN allows to write the
    corresponding FSM
  • From a FSM a SN is obtain through a synthesis
    process
  • Similar to boolean functions and logical circuits
  • Boolean Functions (BF) describe logical circuits
    (LC)
  • LC realize Boolean Functions
  • The analisys of a LC produces a BF
  • LC are combinational networks (memoryless)
    synthesizing BF

95
FSA for D flip-flop
  • Use Q as state descriptor (state variable)
  • Use D as input
  • Use Q as output
  • Check for completeness

1/1
1
1/1
0/0
0
0/0
96
Its tabular description
  • Output values as a function of input and current
    state values
  • Next state values as a function of input and
    state value
  • D flip-flop
  • Output State

97
FSA for SR flip-flop
  • Use Q as state variable
  • Use S and R as input
  • Use Q as output
  • Transitions with multiple conditions
  • Unacceptable input configurations are NOT
    represented

10/1
1
00,10/1
00,01/0
0
01/0
98
FSA for JK flip-flop
  • Just add condition 11 to existing transitions
  • Note stability and instability of states
    according to input values

10,11/1
1
00,10/1
00,01/0
0
01,11/0
99
Synthesis of a SN from a FSA
  • Identify input, output and state variables
  • Build (and minimize) truth tables for output
    variables as a function of input and state values
  • Build (and minimize) transition tables for state
    variables as a function of input and state values
  • Decide which FF to use to store state values
  • a D-FF is the simplest choice
  • to store 0 present 0 at the input
  • to store 1 present 1 at the input

100
Generic architecture of a SN
101
Example 1 a given FSA
1/1
10
0/1
0/0
0/1
11
00
0/0
1/0
1/0
01
1/1
102
Example 1 variables
X
Y
Combinational circuit
An1
An
Bn1
Bn
Bn1
Bn
An1
An
Storage elements
103
Example 1 transition tables
  • Transition table for output and state variables

104
Example 1 minimization
  • State variables Output

105
Example 1 circuits
A X B X A B X
B X A B X
Bn1
An1
D
D
Ck
Ck
A B X A B A X
Y
106
Example 2 specification
  • Two input values are presented together
  • Recognize with output 10 and 01, respectively,
    when a couple 00 or a couple 11 is presented
  • Recognize with output 11 when two consecutive
    couples of identical values are presented
  • Example

107
Example 2 corresponding FSA
  • Show also the initial state (double circle)

01,10/00
00
11/11
11/01
01,10/00
00/11
00/10
01,10/00
00/10
10
01
11/01
108
Example 2 variables
W
X
Y
Z
Combinational circuit
An1
An
Bn1
Bn
Bn1
Bn
An1
An
Storage elements
109
Example 2 transition tables
Note here unspecified inputs can be used for
minimization
110
Example 2 circuits
A X Y
An1
D
Ck
B X Y
W
A X Y
Z
B X Y
Bn1
D
Ck
Write a Comment
User Comments (0)
About PowerShow.com