1 of 67

Digital System Design Using Verilog�(21EC32)

2 of 67

Lesson Plan

2

SN

DATE PLANNED

TOPIC

DATE ENGAGED

REMARKS

2.1

General Approach to Combinational Logic design

2.2

Decoders

2.3

BCD Decoders

2.4

Encoders

2.5

Digital Multiplexers

2.6

Using Multiplexers as Boolean function Generators

2.7

Adders and Subtractors

2.8

Cascading Full Adders

2.9

Binary Comparators

2.10

Programmable Logic Devices

3 of 67

Combinational Circuits

  • Combinational circuit is a feed forward circuit that consists of combination of gates.

To Design a combinational circuit the following steps are followed

  1. State the given problem completely and exactly
  2. Interpret the problem, and determine the available input variables and required output variables.
  3. Assign a letter symbol to each input and output variables.
  4. Design the truth table, which defines the required relations between inputs and outputs.
  5. Obtain the simplified Boolean expression for each output using k-maps.
  6. Draw the logic circuit diagram to implement the Boolean expression.

3

4 of 67

Combinational Circuits

  • Design a combinational circuit which has 3-bit input number and a single output (F). The

output signal F is specified as follows:

• F = 1 when the input number is less than (3)

• F = 0 otherwise.

• Implement F using only NAND gates

4

5 of 67

Combinational Circuits

  • Let the three inputs be called X, Y, and Z.
  • X is the most significant variable and Z is the least significant variable. The output F goes high, that is, the output produces logic 1 value if the input is less than 011, equivalent to a decimal value of three. This means that the output will be logic one for input combinations 000, 001, and 010.
  • For other input combinations, which are 011 upto 111, the output is logic zero.

5

6 of 67

Binary Adder

  • Basic building blocks of all arithmetic circuits are ADDERS.
  • It adds two binary numbers and gives out sum and carry-out as outputs.
  • Divided into two categories 1.Half adder 2.Full-adder

6

7 of 67

Half Adder

  • Adding two single-bit binary values, X, Y produces a sum S bit and a carry out C-out bit.
  • This operation is called half addition and the circuit to realize it is called a half adder.

7

X

0

0

1

1

Y

0

1

0

1

S

0

1

1

0

C-out

0

0

0

1

Half Adder Truth Table

Inputs

Outputs

S(X,Y) = Σ (1,2)

S = X’Y + XY’

S = X Y

C-out(x, y, C-in) = Σ (3)

C-out = XY

X

Y

Sum S

C-out

Half

Adder

X

Y

S

C-OUT

8 of 67

Full Adder

  • Adding two single-bit binary values, X, Y with a carry input bit C-in produces a sum bit S and a carry out C-out bit.

8

X

0

0

0

0

1

1

1

1

Y

0

0

1

1

0

0

1

1

S

0

1

1

0

1

0

0

1

C-out

0

0

0

1

0

1

1

1

C-in

0

1

0

1

0

1

0

1

Full Adder Truth Table

S(X,Y, C-in) = Σ (1,2,4,7)

C-out(x, y, C-in) = Σ (3,5,6,7)

Inputs

Outputs

Sum S

C-in

X

0

1

00 01 11 10

Y

C-in

XY

0

1

2

3

6

7

4

5

1

1

1

1

C-in

X

0

1

00 01 11 10

Y

C-in

XY

0

1

2

3

6

7

4

5

1

1

1

1

Carry C-out

S = X’Y’(C-in) + XY’(C-in)’ + XY’(C-in)’ + XY(C-in)

S = X Y (C-in)

C-out = XY + X(C-in) + Y(C-in)

9 of 67

Full Adder Circuit Using AND-OR

9

XY

YC-in

C-out

XC-in

X

X

Y

C-in

Y

C-in

Y

Y’

Y

X

X’

X

C-in

C-in’

C-in

X’Y’C-in

XY’C-in’

Sum S

X’YC-in’

XYC-in

X’

X’

X

X

Y’

Y

Y

C-in

Y

C-in’

C-in’

C-in’

Full

Adder

X

Y

S

C-in

C-out

10 of 67

Full Adder Circuit Using XOR

10

Full

Adder

X

Y

S

C-in

C-out

XY

YC-in

C-out

XC-in

X

X

Y

C-in

Y

C-in

Sum S

X

Y

C-in

11 of 67

Binary parallel Adder

11

Full

Adder

X1

Y1

S1

C-in

C-out

Full

Adder

X0

Y0

S0

C-in

C-out

C0 =0

Full

Adder

X2

Y2

S2

C-in

C-out

Full

Adder

X3

Y3

S3

C-in

C-out

C1

C2

C3

C4

Data inputs to be added

Sum output

Adds two 4-bit numbers:

X = X3 X2 X1 X0

Y = Y3 Y2 Y1 Y0

producing the sum S = S3 S2 S1 S0 ,

C-out = C4 from the most significant

position j=3

4-bit parallel

Adder

X3X2X1X0

S3 S2 S1 S0

C-in

C-out

C4

Y3Y2Y1Y0

C0 =0

Inputs to be added

Sum Output

12 of 67

Look-Ahead Carry Binary Adders

  • Main disadvantage of four bit adder is that higher order bit operation can be performed only if carry out from lower order bit occurs.Hence it takes n-time’s propagation delay of full adder to complete n-bit addition.This delay can be overcome by look-ahead carry adder.
  • Carry look-ahead adders use a different method to create the needed carry bits for each full adder with a lower constant delay equal to three gate delays.
  • The carry out C-out from the full adder at position i or Cj+1 is given by:

C-out = C i+1 = Xi . Yi + (Xi + Yi) . Ci

  • By defining:
    • Gi = Xi . Yi as the carry generate function for position i (one gate delay) (If Gi =1 C i+1 will be generated regardless of the value Ci)
    • Pi = Xi + Yi as the carry propagate function for position i (one gate delay) (If Pi = 1 Ci will be propagated to C i+1)
  • By using the carry generate function Gi and carry propagate function Pi , then C i+1 can be written as:

C-out = C i+1 = Gi + Pi . Ci

  • To eliminate carry ripple the term Ci is recursively expanded and by multiplying out, we obtain a 2-level AND-OR expression for each C i+1

12

13 of 67

Carry Look-Ahead Adders

  • For a 4-bit carry look-ahead adder the expanded expressions for all carry bits are given by:

C1 = G0 + P0.C0

C2 = G1 + P1.C1 = G1 + P1.G0 + P1.P0.C0

C3 = G2 + P2.G1 + P2.P1.G0 + P2.P1.P0.C0

C4 = G3 + P3.G2 + P3.P2.G1 + P3 . P2.P1.G0 + P3.P2.P1.P0.C0

where Gi = Xi . Yi Pi = Xi + Yi

  • The additional circuits needed to realize the expressions are usually referred to as the carry look-ahead logic.
  • Using carry-ahead logic all carry bits are available after three gate delays regardless of the size of the adder.

13

14 of 67

Carry Look-Ahead Circuit

14

Ci = Gi-1 + Pi-1. Gi-2 + …. + Pi-1.P i-2. …P1 . G0 + P i-1.P i-2. …P0 . C0

15 of 67

Binary Arithmetic Operation: Subtraction

  • Two binary numbers are subtracted by subtracting each pair of bits together with borrowing, where needed.
  • Subtraction Example:

0 0 1 1 1 1 1 0 0 Borrow

X 229 1 1 1 0 0 1 0 1

Y - 46 - 0 0 1 0 1 1 1 0

183 1 0 1 1 0 1 1 1

15

16 of 67

Half Subtractor

  • Subtracting a single-bit binary value Y from anther X (I.e. X -Y ) produces a difference bit D and a borrow out bit B-out.
  • This operation is called half subtraction and the circuit to realize it is called a half subtractor.

16

X

0

0

1

1

Y

0

1

0

1

D

0

1

1

0

B-out

0

1

0

0

Half Subtractor Truth Table

Inputs

Outputs

D(X,Y) = Σ (1,2)

D = X’Y + XY’

D = X Y

B-out(x, y, C-in) = Σ (1)

B-out = X’Y

Half

Subtractor

X

Y

D

B-OUT

X

Y

Difference D

B-out

17 of 67

Full Subtractor

  • Subtracting two single-bit binary values, Y, B-in from a single-bit value X produces a difference bit D and a borrow out B-out bit. This is called full subtraction.

17

X

0

0

0

0

1

1

1

1

Y

0

0

1

1

0

0

1

1

D

0

1

1

0

1

0

0

1

B-out

0

1

1

1

0

0

0

1

B-in

0

1

0

1

0

1

0

1

Full Subtractor Truth Table

S(X,Y, C-in) = Σ (1,2,4,7)

C-out(x, y, C-in) = Σ (1,2,3,7)

Inputs

Outputs

Difference D

B-in

X

0

1

00 01 11 10

Y

B-in

XY

0

1

2

3

6

7

4

5

1

1

1

1

B-in

X

0

1

00 01 11 10

Y

B-in

XY

0

1

2

3

6

7

4

5

1

1

1

1

Borrow B-out

S = X’Y’(B-in) + XY’(B-in)’ + XY’(B-in)’ + XY(B-in)

S = X Y (C-in)

B-out = X’Y + X’(B-in) + Y(B-in)

18 of 67

Full Subtractor Circuit Using AND-OR

18

X’Y

YB-in

B-out

X’B-in

X’

X’

Y

B-in

Y

B-in

Y

Y’

Y

X

X’

X

B-in

B-in’

B-in

X’Y’B-in

XY’B-in’

Difference D

X’YB-in’

XYB-in

X’

X’

X

X

Y’

Y

Y

B-in

Y

B-in’

B-in’

B-in’

Full

Subtractor

X

Y

D

B-in

B-out

19 of 67

Full Subtractor Circuit Using XOR

19

Difference D

X

Y

B-in

X’Y

YB-in

B-out

X’B-in

X’

X’

Y

B-in

Y

B-in

Full

Subtractor

X

Y

D

B-in

B-out

20 of 67

n-bit Subtractors

An n-bit subtracor used to subtract an n-bit number Y from another

n-bit number X (i.e X-Y) can be built in one of two ways:

  • By using n full subtractors and connecting them in series, creating a borrow ripple subtractor:
    • Each borrow out B-out from a full subtractor at position j is connected to the borrow in B-in of the full subtracor at the higher position j+1.

  • By using an n-bit adder and n inverters:
    • Find two’s complement of Y by:
      • Inverting all the bits of Y using the n inverters.
      • Adding 1 by setting the carry in of the least significant position to 1
    • The original subtraction (X - Y) now becomes an addition of X to two’s complement of Y using the n-bit adder.

20

21 of 67

4-bit Borrow Subtractor

21

Subtracts two 4-bit numbers:

Y = Y3 Y2 Y1 Y0 from

X = X3 X2 X1 X0

Y = Y3 Y2 Y1 Y0

producing the difference D = D3 D2 D1 D0 ,

B-out = B4 from the most significant

position j=3

4-bit

Subtractor

X3X2X1X0

D3 D2 D1 D0

B-in

B-out

B4

Y3Y2Y1Y0

B0 =0

Inputs

Difference Output D

Full

Subtractor

X1

Y1

D1

B-in

B-out

X0

Y0

D0

B-in

B-out

B0 =0

X2

Y2

D2

B-in

B-out

X3

Y3

D3

B-in

B-out

B1

B2

B3

B4

Data inputs to be subtracted

Difference output D

Full

Subtractor

Full

Subtractor

Full

Subtractor

22 of 67

4-bit Subtractor Using 4-bit Adder

22

4-bit

Adder

X3 X2 X1 X0

D3 D2 D1 D0

C-in

C-out

C4

Y3 Y2 Y1 Y0

C0 = 1

Inputs to be subtracted

Difference Output

S3 S2 S1 S0

23 of 67

Comparator-one bit

23

24 of 67

Decoders

  • A decoder is a multiple-input, multiple-output logic circuit that converts coded inputs into coded outputs, where the input and output codes are different. e.g. n-to-2n, BCD decoders.

  • Enable inputs must be on for the decoder to function, otherwise its outputs assume a single “disabled” output code word.

24

Decoder

Map

Input

Code word

Enable

inputs

Output

code word

25 of 67

Binary n-to-2n Decoders

  • A binary decoder has n inputs and 2n outputs.
  • Only the output corresponding to the input value is equal to 1.

25

:

:

n

inputs

n to 2n

decoder

2n

outputs

26 of 67

2-to-4 Binary Decoder

  • From truth table, circuit for 2x4 decoder is:
  • Note: Each output is a 2-variable minterm (X'Y', X'Y, XY' or XY)

26

F0 = X'Y'

F1 = X'Y

F2 = XY'

F3 = XY

X

Y

Truth Table:

2-to-4

Decoder

X

Y

F0

F1

F2

F3

27 of 67

3:8 Decoder

27

ABC

ABC

ABC

ABC

ABC

ABC

ABC

ABC

3:8

dec

O0

O1

O2

A

B

C

Enb

S2

S1

S0

O3

O4

O5

O6

O7

A

B

C

O0

O1

O2

O3

O4

O5

O6

O7

0

X

X

X

0

0

0

0

0

0

0

0

0

0

0

1

0

0

0

0

0

0

0

0

0

1

0

1

0

0

0

0

0

0

0

1

0

0

0

1

0

0

0

0

0

0

1

1

0

0

0

1

0

0

0

0

1

0

0

0

0

0

0

1

0

0

0

1

0

1

0

0

0

0

0

1

0

0

1

1

0

0

0

0

0

0

0

1

0

1

1

1

0

0

0

0

0

0

0

1

E

1

1

1

1

1

1

1

1

28 of 67

3:8 Decoder

28

29 of 67

3-to-8 Binary Decoder

29

F1 = x'y'z

x

z

y

F0 = x'y'z'

F2 = x'yz'

F3 = x'yz

F5 = xy'z

F4 = xy'z'

F6 = xyz'

F7 = xyz

Truth Table:

3-to-8

Decoder

X

Y

F0

F1

F2

F3

F4

F5

F6

F7

Z

30 of 67

Encoders

  • If the a decoder's output code has fewer bits than the input code, the device is usually called an encoder.

e.g. 2n-to-n, priority encoders.

  • The simplest encoder is a 2n-to-n binary encoder, where it has only one of 2n inputs = 1 and the output is the n-bit binary number corresponding to the active input.

  • For an 8-to-3 binay encoder with inputs I0-I7 the logic expressions of the outputs Y0-Y2 are:

Y0 = I1 + I3 + I5 + I7

Y1= I2 + I3 + I6 + I7

Y2 = I4 + I5 + I6 +I7

30

.

.

.

.

.

.

2n

inputs

n

outputs

Binary

encoder

31 of 67

8-to-3 Binary Encoder

31

At any one time, only

one input line has a value of 1.

Inputs

Outputs

I

0

I

1

I

2

I

3

I

4

I

5

I

6

I

7

y2

y1

y2

1

0

0

0

0

0

0

0

0

0

0

0

1

0

0

0

0

0

0

0

0

1

0

0

1

0

0

0

0

0

0

1

0

0

0

0

1

0

0

0

0

0

1

1

0

0

0

0

1

0

0

0

1

0

0

0

0

0

0

0

1

0

0

1

0

1

0

0

0

0

0

0

1

0

1

1

0

0

0

0

0

0

0

0

1

1

1

1

I0

I1

I2

I3

I4

I5

I6

I7

Y0 = I1 + I3 + I5 + I7

y1 = I2 + I3 + I6 + I7

Y2 = I4 + I5 + I6 + I7

32 of 67

Multiplexers

  • A multiplexer (MUX) is a digital switches which connects data from one of n sources to the output.
  • A number of select inputs determine which data source is connected to the output.

32

Multiplexer

b bits

b bits

b bits

.

.

Data

output

n Data

Sources

s bits

Select

Enable

EN

SEL

D0

D1

Dn-1

Y

EN

.

.

.

D0

D1

Dn-1

.

.

.

1Y

2Y

bY

SEL

33 of 67

2:1 Multiplexer and 4:1 Multiplexer

Truth table for a 4-to-1 multiplexer and 2:1 Multiplexer

33

mux

Y

Inputs

select

S1 S0

I0

I1

I2

I3

4:1

MUX

Y

Inputs

select

S1 S0

I0

I1

I2

I3

0

1

2

3

Output

34 of 67

4-to-1 MUX Circuit

34

S1

S0

0 1 2 3

2-to-4 Decoder

I0

I1

I2

I3

Y

S1

S0

I0

I1

I2

I3

Y

35 of 67

Larger Multiplexers

  • Larger multiplexers can be constructed from smaller ones.
  • An 8-to-1 multiplexer can be constructed from smaller multiplexers as shown:

35

4:1 MUX

I0

I1

I2

I3

S1 S0

4:1 MUX

I4

I5

I6

I7

S1 S0

2:1 MUX

S2

Y

36 of 67

Demultiplexers

  • Digital switches to connect data from one input source to one of n outputs.
  • Usually implemented by using n-to-2n binary decoders where the decoder’s enable line is used for data input of the demultiplexer.

36

2X4

Decoder

Select

lines

Input

data (1bit)

Enable

One of

four 1-bit

outputs

One of n

Data

Sources

selected

s bits

Select

b bits

b bits

b bits

.

.

Data

Input

Demux

One of n outputs

1-bit 4-output demultiplexer using

a 2x4 binary decoder.

37 of 67

1-to-4 Demultiplexer

37

demux

Data D

Outputs

select

S1 S0

Y0 = D.S1'.S0'

Y1 = D.S1'.S0

Y2 = D.S1.S0'

Y3 = D.S1.S0

2x4 Decoder

D

S1

S0

Y0 = D.S1'.S0'

Y1 = D.S1'.S0

Y2 = D.S1.S0'

Y3 = D.S1.S0

E

38 of 67

38

PLDs (Programmable Logic Devices)

39 of 67

General Structure of PLD

  • Inputs to the PLD are applied to a set of buffer/inverters. These devices have both the true value of the input as well as the complemented value of the input as its outputs.
  • Outputs from these devices are the inputs to an array of and-gates. The AND array generates a set of p product terms.
  • The product terms are inputs to an array of or-gates to realize a set of m sum-of-product expressions.

39

40 of 67

General Structure of PLD

40

41 of 67

General Structure of PLD

  • One or both of the gate arrays are programmable.
  • The logic designer can specify the connections within an array.
  • PLDs serve as general circuits for the realization of a set of Boolean functions.

41

Device

AND-array

OR-array

PROM

Fixed

Programmable

PLA

Programmable

Programmable

PAL

Programmable

Fixed

42 of 67

Programming a PLD

  •  

42

43 of 67

Programming a PLD

  • Erasable PLD—connections can be reset to their original conditions and then reprogrammed.
    • Can be achieved by exposing the PLD to ultraviolet light or using electrical signals
  • PLDs programmed by a user are called field programmable.
  • User can also specify the desired connections and supply the information to the manufacturer. Manufacturer prepares an overlay that is used to complete the connections as the last step in the fabrication process.
  • Such PLDs are called mask programmable.

43

44 of 67

PLD Notation

  • Simplified notation. Each gate has only a single input line.
  • Inputs are indicated by lines at right angles to the single gate lines.
  • A cross at the intersection denotes a fusible link is intact.

44

45 of 67

PLD Notation

  • Lack of cross indicates the fuse is blown or no connection exists.

45

46 of 67

PLD Notation

  • The occurrence of a hard-wired connection that is not fusible is indicated by a junction dot.

  • For the special case when all the input fuses to a gate are kept intact, a cross is placed inside the gate symbol.

46

47 of 67

Programmable Read-Only Memory (PROM)

  •  

47

48 of 67

PROM Structure

48

Logic Diagram

49 of 67

PROM Structure

49

PLD Notation

50 of 67

Example

  •  

50

51 of 67

Why is it called PROM?

  •  

51

52 of 67

Programmable Logic Array

  •  

52

53 of 67

Programmable Logic Array

53

54 of 67

Programmable Logic Array

  •  

54

55 of 67

PROM vs PLA

  • PROM: realization of a set of Boolean functions is based on minterm canonical expressions.
    • No minimization necessary.
  • PLA: the AND gates are capable of generating product terms that are not necessarily minterms.
    • Realization using PLA is based on sum-of-product expression that may not be canonical.
    • Logic designer is bounded by the number of product terms that are realizable by the AND-array.
    • Simplifications is necessary.

55

56 of 67

Logic Design Example

56

 

 

 

57 of 67

Logic Design Example

57

 

 

 

58 of 67

Logic Design Example

58

 

 

59 of 67

Additional Features

  • For greater flexibility, PLAs make provision for either a true output or a complemented output.

59

 

60 of 67

Example of Use of Complemented Functions

60

61 of 67

Example of Use of Complemented Functions

61

62 of 67

PLA Table

  • A common way of specifying the connections in a PLA.
  • 3 sections: input section, output section, T/C section.
  • Each product term is assigned a row in the table.
    • Input section indicates connections between inputs to AND-array.
    • Output section indicates connections between outputs of AND-array and inputs to the OR-array.
    • T/C section indicates how the exclusive or gates are programmed.
      • T—true output is used.
      • C—output should be complemented.

62

63 of 67

Programmable Array Logic (PAL) Devices

  • OR-array is fixed by the manufacturer of the device.
    • PAL device is easier to program and less expensive than the PLA.
    • Less flexible.

63

64 of 67

Example of Logic Design with PAL

  •  

64

65 of 67

Example of Logic Design with PAL

65

66 of 67

University Questions

  • Define priority encoder with three inputs with middle bit at highest priority encoding to 10 most significant bit at next priority encoding to 11 and least significant at least priority encoding 01. 10M
  • Define multiplexer and demultiplexer and draw block diagram. 04M
  • Design 4:1 Multiplexer draw the circuit using gates. 06M
  • Explain how will you implement the following function using implementation table,

F(A,B,C,D)=Σm(0,1,3,4,7,10,12,14) with A,B,C select lines. 10M

  • Design Magnitude comparator .Design a two bit binary comparator and implement with suitable logic gates. 08M
  • Design a binary full adder using only two input NAND gates. Write its truth table. 06M
  • Implement the following boolean function using 4:1 multiplexer Y=f(A,B,C,D)=Σm(0,1,2,4,6,9,12,14) 06M

66

67 of 67

Assignment Questions

  • Design a combinational circuit so that output is generated when majority of four inputs is false.
  • Draw Half adder using only Nand gates and only Nor gates.
  • Design full subtractor by cascading Half-Subtractors.
  • Implement the following function by means of the decoder and fundamental gates F=πM(0,1,4,5)
  • Implement full adder circuit using decoder and OR gates.
  • Construct 1:16 demultiplexer using 1:4 demultiplexer and 2:4 line decoder.
  • Implement Σm(2,4,5,7,9,14) Using Mux.

67