D IGITAL S YSTEM
A digital system takes in a set of discrete information inputs and discrete internal
information (system state) and generates a set of discrete information outputs. There
are three main types of digital systems:
Combinational Logical System: a system which has no system state present and
hence
Synchronous Sequential System: a system which has a system state that is updated
at discrete intervals.
An example of a sequential digital system would be a digital counter. Its input could be
Reset and to Count Up, its output could be a binary sequence representing a
number and its state could be the value of the currently displayed digit.
Other examples include the computer and other embedded systems found in mobiles,
video games, tvs, GPSs etc.
R EPRESENTING I NFORMATION
In the natural world, information is represented by physical quantities and is often
continuous. In digital systems, the variables take on discrete values most notably a
binary value. Binary values are represented abstractly by:
Digits
Words
Words
Words
0 and 1
False (F) and True (T)
Low (L) and High (H)
On and Off
When we are dealing with signals, we use voltages. We may represent it as shown. The
regions for an output high and low are smaller than the regions for input high and low to
compensate for noise and errors.
Edmund Li
N UMBER S YSTEMS
Number systems are usually represented by a positive radix (base) and relies heavily on
the position of the numbers. A number with radix r can be represented as:
Where
, given in base 5.
B INARY N UMBERS
Binary numbers (base 2) are widely used in digital systems and are represented with 0
and 1s. The binary numbers are called bits from Binary Digits. A binary number is a
weighted number:
Fractional numbers can also be represented in binary by placing bits to the right of the
binary point. The left most bit (MSB) in the fractional mantissa has a weight of
. The fractional weights decrease from left to right by a negative power of two
i.e
.
Find the decimal equivalent of
is Kilo (K)
is Mega (M)
is Giga (G)
is Tera (T)
Edmund Li
Convert
to binary
So
to binary
So
An issue arises if we try to convert
to a binary number since
will continue forever. The solution to this is to specify a set
number of bits to the right of the radix point and to round or truncate to this number.
Edmund Li
Repeatedly divide the number by the new radix and save the remainders. Stop
when the quotient is 0
The digits for the new radix are the remainders in the reverse order of their
computation.
If the new radix is greater than 10, you will need to convert digits larger than 9 to
alphanumeric characters: A, B, C.. For example in hexadecimal, if the remainder is
14, then we can expressed this as E.
Converting from a decimal fraction to any other base can be performed by:
1.
2.
3.
Repeatedly multiplying the fraction component by the new radix and saving the
integer digits that result. Stop when the fractional mantissa is 0
The digits for the new radix are the integer digits in the order of their computation
If the new radix is greater than 10, you will need to convert all integers greater than
9 to alphanumeric characters.
H EXADECIMAL
The hexadecimal number system has 16 digits/alphanumeric characters as suggested by
its base. It is a convenient system since most digital systems process binary data in
multiples of 4 bits. For digits greater than 9, the numbers are assigned alphabetic
characters as shown in the table. Hexadecimal numbers usually have the prefix 0x to
indicate that it is a hexadecimal eg. 0xA5.
Decimal
00
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
Binary
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111
Octal
00
01
02
03
04
05
06
07
10
11
12
13
14
15
16
17
Hexadecimal
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
Edmund Li
Convert
We will need to restate each hexadecimal digit as the corresponding four bits
starting at the radix and going both ways:
O CTAL
The octal number system is composed of 8 digits: 0,1,2,3,4,5,6,7. Sometimes an octal
number has a suffix Q or o. The octal number system for the first 15 numbers are
summarized on the previous table.
Convert the octal number
Octal to Binary Conversion: Each digit is translated into its corresponding 3 bit
representation and is strung together.
Binary to Hexadecimal: Group the bits into 4 bit groups starting at the radix
point and going both ways, padding with zeros as needed to make the groups
of four. Convert each group of four into a hexadecimal digit.
Binary to Octal: Group the bits into 3 bit groups starting at the radix point and
going both ways, again padding with zeros as needed to make the groups of
three. Convert each group of three into an octal digit.
Edmund Li
BCD
BCD encodes each decimal digit (in a number) with a 4 bit binary number and strings
them together. Consider:
G RAY C ODE
Gray code is a binary code where two successive values (code words) differ in only one
bit change. It is un-weighted and is not an arithmetic code. For example we could
represent
and
. Only the last bit changes between the two
numbers unlike the normal binary representations:
and
respectively
where 3 bits change on the same transition.
We find that gray code is particularly useful at minimizing errors since the error is
limited to only adjacent values. This can be seen in shaft encoders. Consider the optical
shafts encoded with traditional binary code and Gray code as shown. Sensors detect
when light shines through or when is light is blocked by the opaque surface and this
produces a 1 and a 0 respectively. If the sensor lies at the boundary, we find in the
binary code shaft, it is impossible to accurately determine the position or value because
all 3 bits can change in one transition and hence there is room for error in all 3 bits.
However in Gray code, we can approximate its value or position since error is limited to
1 bit.
C O N V ER SI O N : B I N A RY
TO
G R AY C O D E
Since Gray code is un-weighted and not arithmetic code, it is not unique. It is possible to
perform some sort of conversion to obtain a gray code as follows.
1.
2.
C O N V ER SI O N : G RA Y C O D E
1.
2.
TO
B I N AR Y
Edmund Li
B INARY L OGIC
Binary logic details with binary variables which take on two discrete values, and with the
operations of mathematical logic applied to these variables. Variables are usually
identified by letters of the alphabet: A, B, C, X,Y,Z etc but can also be represents by
strings of letters, numbers and special letters: X1, Cin RESET, CLK, En etc.
L OGICAL O PERATORS
Associated with the binary variables are three basic logical operations:
OR represented by +:
We can define these three operations on the values 0 and 1 and present them using a
truth table:
X
0
0
1
1
Y
0
1
0
1
Z
0
0
0
1
X
0
0
1
1
Y
0
1
0
1
Z
0
1
1
1
X
0
1
Z
1
0
But for the purposes of implementing them or showing them in a logic diagram, we use
the following symbols:
Edmund Li
R EPRESENTING F UNCTIONS
For the following function we see that the Boolean equation, truth table and logic
diagram represent the same function truth tables are unique to the particular function
but expressions and logic diagrams can be manipulated so that they appear different.
Consider the function
. The associated truth table and logic diagram are
shown:
X
0
0
0
0
1
1
1
1
Y
0
0
1
1
0
0
1
1
Z
0
1
0
1
0
1
0
1
0
1
0
0
1
1
1
1
B OOLEAN A LGEBRA
The order of evaluation in a Boolean expression is:
1.
2.
3.
4.
Parentheses
NOT
AND
OR
Any expression can be substituted for the variables in the identities set
then
.
Edmund Li
D U A LI T Y
Note how the identities were expressed in pairs, this is due to duality. The dual of an
algebraic expression is obtained by interchanging + and and interchanging 0s and
1s. The duality is not a way to manipulate expressions but rather a statement about
theorems and hence an expression cannot usually be replaced by its dual. However, any
Boolean theorem that can be proven is thus also proven for its dual due to duality.
There are also a few theorems that will be useful in the process of minimization:
Absorption
Minimisation
Simplification
Consensus
DeMorgans
We can prove the minimization and simplification rule algebraically using the identities
stated previously:
Then by using duality, we prove it for its dual. The consensus theorem can also be
proven, but we must make use of a trick noting that
The consensus theorem tells us that we can remove the term corresponding to the two
variables which were present in the terms with the third variable in its complemented
and un-complemented form.
DeMorgans theorem can be extended to any number of terms:
Edmund Li
Prove
Prove
S TANDARD F ORMS
Standard forms are ways of expressing an algebraic expression in a desirable form such
that it facilities the simplification procedures for these expressions and frequently result
in more desirable logic circuit.
S UM
OF
P RODUCTS
The sum of products form is an equation written as an OR of AND terms. This form is
useful for a two-level circuit implementation. An example would be
.
A more specific SOP is the sum of minterms that have a value of 1 for the function and
all the variables must be present in each minterm in its complemented or non
complemented form.
P RODUCT
OF
S UMS
The product of sums is an equation written as an AND of OR terms and is also useful for
a two-level circuit implementation. Take for example
. A
more specific POS is the product of maxterms each maxterm present has a value of 0
for the function and contains all the input variables in its complemented or non
complemented form.
10
Edmund Li
M INTERMS
Minterms are AND terms with every variable present once (in each minterm) in either
its true or complement form. For a function of n variables there are
minterms
hence every combination in a truth table has a corresponding minterm.
Its defining characteristic is that the minterm is 1 for that combination and 0 for all
others. Hence a variable is complemented for 0 and is not complemented for 1. This is
illustrated in the following table.
X
0
0
0
0
1
1
1
1
S UM
X
0
0
0
0
1
1
1
1
Y
0
0
1
1
0
0
1
1
Z
0
1
0
1
0
1
0
1
F
0
0
0
1
0
1
1
1
OF
Y
0
0
1
1
0
0
1
1
Z
0
1
0
1
0
1
0
1
Minterm
Symbol
M INTERMS
A Boolean function can be represented algebraically from a given truth table by forming
the logical sum of all the minterms that produce a 1 in the function. Consider the
following function:
To make the sum of minterms expression, we take all the combinations of inputs for
which F=1, complement the variable inputs which are 0 and sum the minterms:
M AXTERMS
Maxterms are OR terms (logical sums of its variables) with every variable present once
in its complemented form if the variable input is 1 and not complemented if the input is
0. Again for n inputs, there are
maxterms.
X
0
0
0
0
1
1
1
1
Y
0
0
1
1
0
0
1
1
Z
0
1
0
1
0
1
0
1
11
Maxterm
Symbol
Edmund Li
P RODUCT
OF
M AXTERMS
and
so if we complement it then:
F UNCTION C OMPLEMENTS
The complement of a function expressed as a sum of minterms is constructed by
selecting the minterms missing in the expression. Due to the minterm-maxterm
relationship described above, we can also expressed the complement of a function
originally expressed as a sum of minterms as a product of maxterms with the same
indices.
Consider the function
Then:
12
Edmund Li
Adjacent squares differ in the value of one variable (application of gray code)
squares.
C OST C RITERIA
There is a need to measure the complexity and performance of a logic circuit. The gateinput cost method measures the number of inputs to the gates in a particular
implementation and is a measure of space since the number of inputs is roughly
proportional to the number of transistors. Consider
The
S IMPLIFICATION A PPROACH
1.
2.
3.
13
Edmund Li
When we group terms together we are essentially finding the product of all the literals
that are common to the entire group. We are simply taking advantage of the Boolean
theorem
How we should group and sum up the rectangles matter. A systematic approach allows
us to optimize the function. Consider the three variable k-map shown for the function
. We find that not all groups are needed the less groups
the better! We could say
. We need to identify
specific types of groups before proceeding
DEFINITIONS
1.
2.
3.
A rectangle with 2 squares
represents a product of 3
literals.
A rectangle with 4 squares is a
product of 2 literals
A rectangle with 8 squares is a
product of one literal
A rectangle of 16 squares is
always equal to logic 1
Implicant: A product term for which the function has the value 1 for all
minterms in the product term.
Is an implicant because the group contains all 1s however it is not a prime implicant
because it can be extended to include the 1s satisfied by
.
Is a prime implicant because it cannot be enlarged further, but is not essential
because all of its minterms can be covered by other prime implicants:
Is an essential prime implicant because the top left 1 cannot be covered by any
other prime implicant.
O PTIMISATION A LGORITHM
Armed with the simplification process stated previously and with the definitions of
implicants, prime and essential prime implicants we can optimize a Boolean function by:
1.
2.
3.
4.
14
Edmund Li
Find a SOP expression for the complement of the function by grouping the 0s
instead of 1s.
Invert the function back and apply DeMorgans theorem.
Simply
into POS
Collecting all the 0s and identifying the essential prime implicants and prime
implicants:
15
Edmund Li
Where convenient, we treat the Xs as 1s. There are 2 possible groupings that
result in 2 functions the function values will be the same for the combinations of
inputs we care about, but will differ for the dont cares.
Similarly we can find an optimized POS with dont cares in the function by grouping
together the 0s, and where convenient the Xs can be treated as 0s.
Find a simplified POS with reference to the k-map.
16
Edmund Li
Factoring: finding a factored form from either a SOP or POS expression for a
function
Initial gate input cost was 17, final gate input cost is 9.
Performing GIC:
17
by
Edmund Li
We shall focus our explanations on the NAND, NOR, XOR gates and 3 state buffers.
18
Edmund Li
NAND
The NAND represents Not-AND. Its output is the inverse of AND. By applying
DeMorgans theorem, we can find an equivalent logic design of a NAND gate:
We can extend this for any number of inputs. Since NAND is a universal gate- a gate type
that can implement any Boolean function, we find that it is the natural implementation
for CMOS technology in terms of chip area and speed.
NOR
NOR (NOT OR) is another universal gate. We find that we can build an equivalent NOR
circuit using inverted inputs to an AND gate as suggested by DeMorgans theorem:
E XCLUSIVE -N OR (XNOR)
XNOR (equivalence) outputs a 1 if both of its inputs are 0, or both 1. It is defined as:
19
Edmund Li
Similarly, XNOR operations can have three or more variables and is known as an even
function. It is implemented by adding an inverter to the output of the odd function.
B UFFER
A buffer is a gate with the function
. It acts as an electrical amplifier used to
improve circuit voltage levels and increase the speed of circuit operation.
3-S TATE
BUFFER
3-State buffer adds a third logic value high impedance denoted as Hi-Z or Z. The input
EN (enable) acts as the control line for the buffer. A Hi-Z value behaves as an open
circuit i.e. the output appears to be disconnected. Consider the 2 three state buffers
shown.
EN1
0
0
0
1
1
1
1
1
1
EN0
0
1
1
0
0
1
1
1
1
IN1
X
X
X
0
1
0
1
0
1
IN0
X
0
1
X
X
0
1
1
0
OL
Z
0
1
0
1
0
1
We find that two or more Hi-Z capable gates can be connected to the output line, but
for the last two truth values, the output line will cause an electric clash electrical
current flowing from one buffer output that is 1 will flow into the buffer output that is
at 0. This current is often large enough to cause heating and destroy the circuit.
S
0
0
1
1
IN1
X
X
0
1
IN0
0
1
X
X
OL
0
1
0
1
To ensure no electric clashes occur in the circuit, we can invert one of the enable
signals. This circuit will then act as a multiplexer with control input S (select).
20
Edmund Li
D ESIGN P ROCEDURES
1.
2.
3.
4.
5.
T ECHNOLOGY M APPING
For the purpose of implementation we are usually required to implement various gates
using NANDs or NORs since they are the natural implementation for CMOS technology
in terms of chip area and speed. We shall see how the process of conversion to NAND
gates:
The trick is to use involution - add bubbles to the AND gates, and bubbles to the inputs
that come from the outputs of the original AND gates. Note also for an OR gate with
inverted inputs, using DeMorgans theorem we find this is a NAND gate:
Implement the following function using NAND gates only:
Add the bubbles to the outputs of the AND gates and input of the OR gates. We find
that we no longer need the top inverter.
V ERIFICATION
We need to find a way to check that a circuit design fulfils the specifications exactly. For
simple circuits, we can usually work backwards to derive the Boolean equations from
the circuit and hence the truth table. However, this is tedious for complex circuits. In
these circumstances, computer simulations are employed to test all possible input
combinations and verify the output correctness.
21
Edmund Li
F ORMULATION
We define the inputs to be A, B, C, D and outputs to be W, X, Y, Z since 9 can only be
represented with 4 bits and the corresponding excess 3 code is 12, which can only be
represented by 4 bits. The following is the truth table for the converter.
Decimal
Digit
0
1
2
3
4
5
6
7
8
9
Input BCD
0
0
0
0
0
0
0
0
1
1
0
0
0
0
1
1
1
1
0
0
0
0
1
1
0
0
1
1
0
0
Output Excess 3
0
1
0
1
0
1
0
1
0
1
0
0
0
0
0
1
1
1
1
1
0
1
1
1
1
0
0
0
0
1
1
0
0
1
1
0
0
1
1
0
1
0
1
0
1
0
1
0
1
0
O PTIMISATION
The best way to optimize this circuit is to try two level optimization first using k-maps
then seeing if we can perform multilevel optimization.
22
Edmund Li
and
, we can factor
T ECHNOLOGY M APPING
Again we use the trick with adding bubbles at the outputs of the ANDS and at the inputs
to the other gates.
23
Edmund Li
H IERARCHICAL D ESIGN
For large and complex designs, we use a module
approach by breaking the circuit into sub-functions.
We do this by enclosing the sub functions in blocks
and define an interface for them that specifies the
input and output signals to the block and its function.
For example we could have done a hierarchical
design for the BCD to excess-3 function as shown.
Note that we could have implemented the MX sub function using XNOR since that
would yield a 1 if the inputs were equal and 0 otherwise. ME would then have to be an
AND gate.
24
Edmund Li
Consider the 0-value fixing function. We can use this in the implementation of an
inverter using a NOR gate.
B USES
A group of single bit variables that are used together can be gathered into a bus a
vector signal. We can express input signals such as those in the 4 bit equality
comparator as
. Traditionally, buses are represented graphically using
thicker lines and an integer to specify their size.
Intuitively, we can see how buses can make circuits clearer to read and significantly
simplify design and simulation in software. Look at how we can represent the 4 bit
equality comparator.
E NABLING F UNCTION
Enabling permits an input signal to pass through to an output. We saw this with a buffer
which outputs a Hi-Z when enable is 0. With other gates, when enable is disabled, we
can also replace the output with a fixed value as shown.
EN
0
1
F
0
A
EN
0
1
F
1
A
25
Edmund Li
D ECODER
Decoders are circuits that convert n-bit input code to an m-bit output code with
such that each valid code word produces a unique output code-the
decoder generates
or fewer minterms. Functional blocks for decoding are called to nto-m decoders.
We can create decoders from using inverters and AND gates as shown.
A 1- TO -2 DECODER
A 2- TO -4 DECODER
We can already see that larger decoders get far more complex since we can cascade
decoders using only 2-input AND gates:
26
Edmund Li
Let
2.
3.
4.
For each decoder resulting in step 2, repeat step 2 with equal to the values
obtained in step 2 until k=1. For k=1, we use a 1-to-2 decoder which only consists of
an inverter.
The number of inverters is equal to
How many AND gates and inverters do we need to build a 5-to-32 decoder?
We need 5 inverters since for each signal it can be in 2 possible states.
Hence, we need,
AND gates. We need 32 AND gates in the
last cascade, 32 in the second last.and 4 in the first.
X
0
0
1
1
X
0
1
0
1
0
1
0
0
0
0
0
1
0
0
0
0
0
1
0
0
0
0
0
1
A decoder with enable allows all outputs to be 0 when disabled. In essence, the enable
signal adds another set of AND gate layer to the end the same number as in the
previous layer. The inputs are the enable signal and the outputs from the previous AND
gates.
27
Edmund Li
Since there are 8 possible input entries, a 3-to-8 decoder can be used to generate
unique outputs based on each valid code word. We can then use 2 OR gates to create
the C and S output signals since only one possible minterm part of the carry and sum
functions can be 1 at any one time.
28
Edmund Li
E NCODERS
Encoders perform the inverse operation to decoders- it takes in
or fewer inputs and
has n output lines. The output generates a binary code corresponding to the input
value; typically only one of the inputs is 1 at any one time.
The problem with this particular encoder design is that we have no output combination
available for the case when all the inputs are 0. Moreover, what happens if more than
one input is 1? To solve this problem we use priority encoders.
P RIORIT Y E NCODERS
Priority encoders solve the restriction that only one input can be 1 at any time. It
outputs the binary value corresponding to the most significant input equal to 1. It also
solves the ambiguity between all inputs equal 0 and
by adding a valid output.
29
Edmund Li
M ULTIPLEXERS (MUX)
A multiplexer selects information from one of many input lines and directs it to the
output line. A typical multiplexer has n selection inputs
and
information
inputs
. A typical multiplexer is often simplified to a block diagram.
Y
A 4-to-1 multiplexer
0
0
1
1
0
1
0
1
To build larger multiplexers, we can cascade smaller multiplexers. For example, we can
build an 8-to-1 multiplexer: there are 8 information inputs, so we need 3 selection
inputs. We can use 2 4-to-1 multiplexers that which will choose 2 signals out of 8, then
we implement a 2-to-1 multiplexer that will choose the correct output signal.
Edmund Li
D EMULTIPLEXERS
Demultiplexers direct information from a single input line to one of
is controlled by n control lines denoted as S.
0
0
1
1
0
1
0
1
I
I
I
I
Demultiplexers can be implemented using a decoder with enable. The enable signal
becomes the input signal, while the inputs A become the control lines S, and the outputs
D becomes the outputs denoted Y.
31
Edmund Li
S EQUENTIAL C IRCUITS
In sequential circuits, storage elements allow us to output values which are functions of
the current state and possibly even its inputs. The next state the binary information to
be stored at the next instance is also shown to be a function of the inputs and the
present state. This is opposed to the combinational circuits we have been dealing with
that are only dependent on the current inputs.
Mealy:
Moore:
We see that a sequential circuit is specified by a time sequence of inputs, internal states
and outputs. The timing sequence may be either synchronous the behavior is defined
from the knowledge of its signals at discrete time instances or asynchronous the
behavior depends upon the inputs at any instant of time and the order in continuous
time in which the inputs change.
at 1, which feeds backs to the first inverter creating a loop which maintains the
state infinitely. We find however, that there is no way to change the information in this
loop. The solution is to use NOR or NAND gates.
32
Edmund Li
SR L ATCH
By rearranging the previous circuit and replacing the ground signals with signals S (for
set) and R (for reset) we create a SR latch. When S=1, R=0, Q is set: Q=1, and when S=0,
R=1, Q is reset Q=0. When S=R=0, then we have a keep state, and the outputs remain
unchanged.
Reset State
Undefined
Set State
Note that when both S and R are both 1, we have an undefined state, since it violates
the requirement that the outputs be complements of each other.
A simulation shows that a transition from the undefined state (which outputs both 0s)
to the keep state will lead to the waveforms of the output set midway between 0 and
1. This is because a race condition occurs.
The race condition describes a situation in which the output is dependent on the time
sequence of the circuit elements. Suppose the propagation delay is shorter for the
upper NOR gate, then the transition from (1,1) to (0,0) will let it output a 0, and the
second NOR gate will then output a 1. But suppose the propagation delay is shorter for
the lower NOR gate, then the lower NOR gate will first output a 1 and will cause the
upper NOR gate to output a 0. We see that the output is actually unpredictable.
33
Edmund Li
L ATCH
The (active low)
latch is a cross coupled NAND gate. It maintains the state if the
inputs are 1, and for variations in the input, the state is changed.
0
1
1
1
0
1
1
0
1
0
1
1
0
0
1
0
0
1
1
1
Set State
Reset State
Undefined
X
0
0
1
1
X
0
1
0
1
Q
Q
0
1
1
Forbidden state
D L ATCH
Note that the undefined state is undesirable, and a way to ensure that the inputs S and
R are never equal to 1 simultaneously is to have 1 input D and to feed it to S and feed
the complement to R. This will create a D-latch the output will follow the input D when
C=1.
0
1
1
X
0
1
Q
0
1
Edmund Li
F LIP F LOPS
Note that the latches are transparent as soon as an input changes, shortly thereafter
the corresponding output changes to match it. Consider the D-latch connected to a
combinational circuit as shown.
We recall that the output follows D. While the clock is high, the D latch will read the
input, and output the next state. But now, an inverter from the output connects it back
to D, creating the output Y to oscillate whenever the clock is high.
Flip flops are designed to output a state based upon its preceding state and do not go
through multiple changes of state in one clock pulse. There are two ways that latches
are combined to form a flip-flop:
Master Slave: the state of the flip flop changes only when a clock pulse is not
high
Edge triggered: the state of the flip flop changes on a transition from 0 to 1
(positive edge) or 1 to 0 (negative edge).
SR M AS T E R S LAV E F LI P F LO P
By cascading 2 SR latches with controls, and inverting the clock signal for the signal SR
latch, we design a master slave flip flop. When the clock is high (C=1), the master latch
will operate and the new states propagate to Y. When the clock is low (C=0), the master
latch is disabled and the slave is enabled and hence any changes in the SR inputs do
not affect the state of the flip flop now. The output Q from the slave latch will be
determined based upon the Y and value stored by the master latch.
The simulation shows the 1s catching behavior of the SR master slave flip flop at 125ns.
A narrow pulse to 1 occurs on S initially, and the master latch responds by changing Y to
1. Then S=0 and R=1; the master latch responds by setting Y=0 and
. During this
clock cycle, the master latch caught both the 1 on S and on R, but since R=1 was
caught last, this stored state was Q=0. The simulation also shows an unknown state of Q
when SR=(1,1) which causes
which then propagates to the slave.
35
Edmund Li
N E G AT I V E E D G E T RI G G ER E D D F LI P F LO P
The correct operation is for the flip flop to change states at the falling edge of the clock
(negative edge triggered) . This is achieved by replacing the master SR latch with a
master D latch.
When C=1, the master D latch is enabled and its output follows D, but when C changes
from 1 to 0, the master latch is disabled and stores the last value seen at D, and this
value is seen by the slave SR latch and changes its state accordingly. Note that any
changes to the input signal D do not propagate through until the negative edge of the
clock.
P O SI T I V E E D G E T RI GG E RE D D F LI P F LO P
Inverting the clock signal means that the last valued to be stored by the master latch will
occur on a transition of C from 0 to 1. When C=1, the master latch will be disabled, the
slave latch will be enabled and respond accordingly such that Q follows D at the rising
edge of the clock.
When we need to force a value to the output of a flip flop independent of the clock
(such as when we want to initialize a circuit to known values at start up), we use
asynchronous set and reset inputs. The following active low set and reset (to set,
,
reset
) positive edge D flip flop will have these asynchronous signals fed into the
last lot of
36
Edmund Li
By convention, the current state is denoted by q, while the next state as, Q. We find that
the next state Q will be the input to D in the above circuit. From a state transition table
that tells us the relationship between the inputs, outputs and the states:
Current State
0
0
1
1
0
1
0
1
Next State
0
0
0
0
0
0
0
0
0
1
1
1
Output
1
1
0
0
Y
0
1
1
1
Y
0
0
0
0
We find that since Y is dependent on both the current state and on inputs, then it is a
Mealy model. If the outputs only depend on the states, then only 1 column for output
would suffice, resulting in a Moore model circuit.
37
Edmund Li
S T AT E D I A GR A MS
State diagrams are diagrammatic representations of a sequential circuit. For a mealy
model, we find that each state is represented with a circuit. Each possible transition
combination is indicated with connecting arrows and are labeled in the form of
INPUTS/OUTPUTS. Then for the previous circuit, we have:
We find that the number of arrows going out from each state corresponds to the total
number of possible input combinations that can be achieved. In this case, there is 1
input X that can be 0 or 1.
At state 00, if the input is 0, go
back to state 00 and output 0. On
input 1, output 0 and go to state
01.
For a Moore model, each state is represented with a circle and is labeled as
STATE/OUTPUT, since the output in a Moore machine is only dependent on its current
state. Transitions are represented using arrows and are labeled according to its input
combination.
Current State
q
0
1
XY=00
Q
0
1
XY=01
Q
1
0
Next State
XY=10
Q
1
0
Output
XY=11
Q
0
1
Z
0
1
We find that
, Z=q and that there are 2 states and the output is
only dependent on the current state. So the Moore state diagram will be:
38
Edmund Li
S EQ UE N C E R E CO GN I Z E R E XA M P L E
Specification
Design a circuit that recognizes the occurrence of the sequence 1101 at the input X
(which is read at every clock cycle). The circuit is to output Z=1 every time the last 1 of
the 1101 is detected and Z=0 otherwise.
We first recognize we need a Mealy model circuit since the output is dependent not just
on the state, but also on the input the last 1 of 1101 causes the output Z=1.
Moreover, the circuit needs to remember what the previous inputs were.
FORMULATION
Note that since we do not know the number of states yet, we use generic names for the
state e.g A, B, C
1.
2.
3.
4.
5.
Note that we dont actually need state E since it could also be the first 1 in the next
sequence of 1101, so in actual fact we can loop back to state B.
Consider at state A, if input is 0, then we get 0/0. At state B, if we get an input 0, then
nd
we transit back to A. At C, if the input is 1, it could be the 2 1 in the sequence e.g
11101, so we transit back to 1. At D, if the input is 0 then we need to transit back to A.
We note that the number of arrows coming out of each state is 2 the maximum
number of input combinations.
39
Edmund Li
Current
State
A
B
C
D
Next State
X=0
A
A
D
A
Output Z
X=1
B
C
C
B
X=0
0
0
0
0
X=1
0
0
0
1
STATE ASSIGNMENT
We can either assign a counting binary code, gray code or one hot (only one 1 in each
sequence with the rest being 0). We shall choose gray code for convenience: A=00,
B=01, C=11, D=10. The state transition table can then be illustrated as:
Current
State
00
01
11
10
We could have alternatively used another 2 columns for the output Z as in the first state
table. If we chose to use a one hot code: A=0001, B=0010, C=0100, D=1000, then we
would need 4 D flip flops and this tends to be more costly and some states go unused.
DERIVING EQUATIONS
Look at the column corresponding to
Similarly:
TECHNOLOGY MAPPING
Since there were 4 states, a minimum of 2 D flip flops are required.
40
Edmund Li
Alternatively, we can label these unused states as a valid initialization next state. For
example, send all unused states back to 001.
The approach best to take depends on the situation. Although both circuits perform the
same function for the valid inputs, they will differ at the unused states. If we can be
certain that the machine will never enter an undefined state, then we can use dont
cares.
By fixing the next state for unused state generally results in a more complex circuit but
assures that if we do end up in an undefined state, it will transit back to a valid one.
41
Edmund Li
We modify the state transition table by representing the NEXT STATE/OUTPUT in two
columns. Note that the output should correspond to the next state. Consider the
following Moore to Mealy example. We pull the outputs to the incoming transitions for
the state diagram and shift the outputs in the state transition table to the next state/
output columns.
Current
State
T
h
A
e
B
r
C
D
E
Next State
X=0
X=1
A
B
D
B
D
B
A
E
D
C
Output Z
Current State
0
0
1
0
0
A
B
C
D
E
The functionality of both the Moore and Mealy function is the same and only differs in
the implementation. This could result in the timing of transitions to be different.
42
Edmund Li
MEALY TO MOORE
Conversion from Mealy to Moore requires the splitting of each state corresponding to
the number of different outputs coming in and then pushing the outputs into the
state.
The new state transition table is obtained by creating new states corresponding to all
next state-output combinations and by copying down the corresponding outputs.
For example, we note that the mealy state transition table illustrates for the next state
B, there are 2 possible outputs, and hence we create an additional state to account for
each output combination of state B.
Current
State
A
B
C
D
Current State
X=1
B, 0
B, 0
D, 0
B, 1
Next State
X=0
Output z
X=1
0
0
1
0
0
Edmund Li
S TATE M INIMISATION
Using an implication chart a table with all possible state pairs we can minimize the
number of states.
1.
2.
3.
4.
Current
State
A
B
C
D
E
F
G
Cross out entries that have unequal outputs for all input combinations
corresponding to each state pair.
For each of the remaining entries, write the matching next state pairs for
all input combinations
Cross out entries that have non-equivalent next state pairs in them (by
identifying state pairs already crossed out). Keep iterating until no more
entries can be crossed out.
Two states are equivalent if they have the same output and transition to
the same states for all input combinations combine these states
together.
Consider the mealy state transition table shown. We shall first cross out all the state
pairs with unequal entries:
since for X=1, the outputs are 0 and 1 respectively
We then write the next state pairs in each square.
X=1
A, 0
E, 1
B, 0
A, 0
B, 1
E, 0
G, 0
Notice for the state pair A-C, if these states are to be equal, then states B and D must be
equal, but as we can already see, this is not the case. So we cross the square A-C out.
We continue iterating until no more squares can be crossed out, as shown on the left.
So we end up having:
Rebuilding our state table (taking care that the next states exist) now, we get:
Current
State
A
B
C
X=1
A, 0
B, 1
B, 0
Edmund Li
J
0
0
1
1
K
0
1
0
1
Q
q
0
1
Q
0
1
0
1
J
0
1
X
X
K
X
X
1
0
An interesting concept is that we can implement a JK flip flop using a D flip flop, by
noting that D=Q in such a sequential circuit.
T O G G L E F LI P F LO P
The T flip flop is equivalent to the JK flip flop with J and K tied
together. When T=0, it stores its state, and complements it
when T=1. The characteristic equation can be derived:
Q
0
1
0
1
T
0
1
1
0
45
Edmund Li
Current
State
Next state
00
01
10
11
q
0
0
1
1
Q
0
1
0
1
J
0
1
X
X
X=1
01
11
11
01
K
X
X
1
0
We first begin by drawing up the excitation table and identifying the JK inputs for each
Q-input combination. For example, let us consider
when x=0:
0
0
1
1
00
01
10
11
0
0
1
0
0
0
X
X
X
X
0
1
Next State
X=0
X=1
00
00
10
00
JK Flip Flops
X=0
01
11
11
01
0X
0X
X0
X1
0X
X1
0X
X1
X=1
0X
1X
X0
X1
1X
X0
1X
X0
We then use k maps to optimize & derive the input equations for
in terms of
and X since the circuit is a sequential circuit its next state is dependent on its
current state and its input.
46
Edmund Li
Q
0
1
0
1
T
0
1
1
0
00
01
10
11
Next State
X=0
X=1
T Flip Flops
X=0
X=1
00
00
10
00
00
01
00
11
01
11
11
01
01
10
01
10
47
Edmund Li
A RITHMETIC C IRCUITS
Arithmetic circuits perform arithmetic operations and form the basis for a
microprocessors ALU. They typically operate on binary input vectors, and output a
resulting vector.
As it is not practical in developing a truth table for a many bit vector (n bits means 64
inputs, 32 outputs and a
row truth table), we use arithmetic blocks or sub-functions
in each bit position. The sub-function blocks are referred to as cells and the overall
implementation is an (iterative) array of cells. The cells in the array are often, but not
always, identical. The above diagram shows an iterative array of cells.
B INARY A DDERS
Binary adders add 2 bits together. Notice that the first three operations produce a sum
requiring a one bit representation, but when both the augend and addend are equal to
1, the binary sum requires 2 bits. Hence, the result is always represented by 2 bits the
carry and the sum.
H AL F A D D E R
X
0
0
1
1
Y
0
1
0
1
C
0
0
0
1
S
0
1
1
0
A half adder generates the sum of two binary digits using two inputs and two outputs.
By drawing up the truth table, we can derive the equations for the Sum and the Carry.
48
Edmund Li
F UL L A D D E R
X
0
0
0
0
1
1
1
1
Y
0
0
1
1
0
0
1
1
Z
0
1
0
1
0
1
0
1
C
0
0
0
1
0
1
1
1
S
0
1
1
0
1
0
0
1
A full adder is a combinational circuit that forms the arithmetic sum of three input bits.
X and Y are the two significant bits to be added, while Z represents the carry in. Using
the truth table, and k-maps we derive the sum and carry out equations:
B I N A R Y R I P P L E C AR RY A D D ER
A binary ripple carry adder is a n-bit parallel adder formed by cascading n full adders.
Since a 1 carry may appear near the LSB, just as wave ripples outward from a pebble
dropped in a pond, the carry may ripple towards the MSB carry out since the carry
output from one full adder is the carry input of the next.
The problem with ripple carry adders is that in practice they have long circuit delays
since the carry has to propagate through many gates until the final result is obtained.
For example a 16 bit adder has at least 32 gate layers since each full adder is
approximately a 2 level combinational logic circuit. A better estimate is given by
.
49
Edmund Li
CARRY LOOK
A H EA D
A DD E R
Carry look ahead adders are combinational circuits that add n bits in parallel and can
calculate all the carry bits straight from the inputs, minimizing the gate delay. We first
define a carry generate we must generate a carry when the two bits are 1 so:
Next we define a carry propagate: determines whether in that bit position is going to
propagate a carry from the right. A carry propagates if only one of the bits is a 1 so:
We can thus express the sum (S) and carry (C) in terms of the generate and propagate
function:
Hence the carry equations for a 4 bit carry look ahead adder will be as shown on the
left. In theory there will be 3 gate delays regardless of the number of bits, at a cost of
more complex logic 1 to calculate the propagate, 1 for the AND gates and 1 for the OR
gate. The carry look ahead logic is connected to a partial full adder which is the
implementation of
and the carry generate.
50
Edmund Li
Consider in decimal:
. We shall reverse the operation
and add
append a minus in front to give us -11 which is the solution to 89-100. We just applied
this concept to binary subtraction a process called taking the 2s complement whereby
we subtract the binary number from .
If we apply such a design to a circuit, our circuit becomes unnecessarily complex since
we need a separate sub function just for subtraction. A better way would be to find a
shared logic for both addition and subtraction by using the complements approach.
C OMPLEMENTS
There are two types of complmenets:
Diminished radix ((
number N.
) complement: is defined as
, for some
For binary numbers, r=2 and n equals the number of bits in the string. Hence we get the
names binary 1s complements and 2s complement.
1S
CO MP L E ME N T
The 1s complement are easily obtained by inverting all the bits in N. Formally it is
defined as (
. So for N=0111 0011, n=8 and r=2 then:
Then
2S
CO MP L E M EN T
The 2s complement can be found by taking the 1s complement and adding 1. This idea is
the foundation for subtraction using addition in digital logics. Formally the 2s
complement is
.
Consider r=2, N=0111 0011 n=8. Then:
51
Edmund Li
Consider
operations.
, perform
.
and
using 2s complement
Using signed binary numbers, we can thus represent integers in signed magnitude or
signed complement form.
52
Edmund Li
S I GN ED M AG N I T UD E
In signed magnitude form, the MSB stands for the sign, while the rest of the bits are
interpreted as a positive magnitude. For example:
The problem that arises with signed magnitude arithmetic is that it becomes very
complex it is necessary to check the sign of the bits to determine the operation and
the carry out or borrow determines whether a correction step should be applied to the
result.
S I GN ED C O MP L E M EN T
In signed complement form, the MSB corresponds to the sign and the positive numbers
are a usual, but for negative numbers, we take the 2s complement of the respective
positive number.
We could choose to use the 1s complement, but the 2s complement allows us to use the
same hardware as for unsigned numbers alone. Suppose we want to represent 7 and -7
using 8 bits (sign extension) instead of 4, then in 2s complement form:
Notice that we extend the MSB at the front of the number when we need to perform
sign extension on signed numbers. For unsigned numbers, we pad the front with 0s.
Take the 2s complement of the negative number and append a minus sign
Consider the 8 bit number: 1110 1101. If we take the 2s complement we get:
53
Edmund Li
When the selection signal S is 0, the vector B propagates as normal and the carry in is 0;
computing A+B. When S=1, the vector B is complemented and the carry in is 1, and
hence we obtain the 2s complement of B; calculating A-B.
O VERFLOW
Overflow occurs if n+1 bits are required to contain the result from an n bit addition or
subtraction. Consider for example an 8 bit number. Any 8 bit string can represent any
number between
to
we perform 70+80 and -70-80.
Note that the 8 bit result that should have been positive has a negative sign bit and that
the 8 bit result that should have been negative has a positive sign bit. We say that an
th
overflow has occurred, since the carry out could be used as the 9 bit to represent the
answers correctly.
Overflow occurs when the carry in to the MSB is not equal to the carry out from the
MSB. A simple XOR gate that takes the carry in and carry out from the MSB can
determine whether an overflow has occurred:
For unsigned addition, C will detect for overflows. If C=0, no overflow occurs while, C=1
indicates an overflow. For signed addition & subtraction, V=0 indicates no overflow
while V=1 indicates an overflow.
54
Edmund Li
This means that an overflow occurred (V=1) and the sum is not actually correct since the
flag N is 1, when in fact, the sum should be positive.
55
Edmund Li
CMOS T ECHNOLOGY
Digital integrated circuits can be classified according to their implementation
technology. Currently, complementary metal oxide semiconductors (CMOS) technology
dominates due to its high circuit density, high performance and low power
consumption.
There are two main types of CMOS transistors, the NMOS and PMOS.
NMOS L O GI C
The NMOS usually has its Source connected to GND and the
Gate to some input X. Note that in order for the NMOS to be
active, then voltage difference between the gate and source
must be greater than some threshold voltage. If the Source
were connected to
then this condition could never be
achieved.
PMOS L O GI C
A PMOS transistor has its source usually connected to
and
the gate to some input X. Note that the voltage across the gate
needs to be less than the threshold voltage for it to be active.
Since we do not deal with negative voltages, then connecting
the source to ground will violate this condition.
I NVERTER
Combining the two transistors together, we get an inverter.
For any logical value X, there is only one path to either
or
GND. If X is high (suppose 5V), then the NMOS is active and
pulls F to GND. But if X is low (suppose 0V), then the PMOS is
active and F is connected to
.
56
Edmund Li
NAND G AT E
The NAND gate function is defined as:
. The PDN
will be constructed using 2 NMOS transistors in series with
X and Y being the gate inputs. The PUN will be the dual of
this, so the PMOS gates are connected in parallel.
To construct a 3 input NAND gate, we use 3 NMOS
transistors in series, and 3 PMOS transistors in parallel.
NOR G A T E
The NOR gate:
is designed by connecting the
NMOS gates in parallel and the PMOS gates in series with the
gate inputs being X and Y.
57
Edmund Li
M O R E C O MP L EX G AT E S
Consider
Implementing the NMOS first, we connect B and C in parallel and series it with A. This
whole connection is then in parallel to D. The PMOS is the dual of this B and C will be
in series but A will be parallel to A and B, and D will be in series with the lot.
Consider
We need to parallel Y and Z and series
this with X using NMOS transistors, and
put the two lots in parallel. We take the
dual for the PUN. Since the CMOS
technology is naturally inverting, we
need to invert the output to get F.
T RANSITION G ATES
A transmission gate is constructed using one NMOS and one PMOS transistor that have
its source and drain connected together.
When
, one of the transistors will be on (depending on the value
of X) and a path exists between X and Y.
o If the gate voltage is higher than the source, then the NMOS switches
on, if the gate voltage is lower than the source, the PMOS switches on.
When
both transistors will be off regardless of X, and no path
exists between X and Y.
The schematic shows an implementation of a XOR gate using transmission gates. Note
how when A=B=L, then the upper transmission gate is active, allowing A propagate. But
when A=L and B=H, the lower transmission gate is active, and is propagated.
58