1 Lecture 31 PLAs and Arithmetic Logic Unit (ALU).

37
1 Lecture 31 PLAs and Arithmetic Logic Unit (ALU)

Transcript of 1 Lecture 31 PLAs and Arithmetic Logic Unit (ALU).

Page 1: 1 Lecture 31 PLAs and Arithmetic Logic Unit (ALU).

1

Lecture 31

PLAs and Arithmetic Logic Unit (ALU)

Page 2: 1 Lecture 31 PLAs and Arithmetic Logic Unit (ALU).

2

Programmable Logic Array

° A ROM is potentially inefficient because it uses a decoder, which generates all possible minterms. No circuit minimization is done.

° Using a ROM to implement an n-input function requires:

• An n-to-2n decoder, with n inverters and 2n n-input AND gates.

• An OR gate with up to 2n inputs.

• The number of gates roughly doubles for each additional ROM input.

° A programmable logic array, or PLA, makes the decoder part of the ROM “programmable” too. Instead of generating all minterms, you can choose which products (not necessarily minterms) to generate.

Page 3: 1 Lecture 31 PLAs and Arithmetic Logic Unit (ALU).

3

A blank 3 x 4 x 3 PLA

° This is a 3 x 4 x 3 PLA (3 inputs, up to 4 product terms, and 3 outputs), ready to be programmed.

° The left part of the diagram replaces the decoder used in a ROM.

° Connections can be made in the “AND array” to produce four arbitrary products, instead of 8 minterms as with a ROM.

° Those products can then be summed together in the “OR array.”

Inputs

Outputs

AND array

OR array

Page 4: 1 Lecture 31 PLAs and Arithmetic Logic Unit (ALU).

4

K-map minimization

° The normal K-map approach is to minimize the number of product terms for each individual function.

° For our three functions, this would result in a total of six different product terms.

Y

0 0 0 1

X 0 0 1 1

Z

Y

0 0 0 0

X 1 0 1 1

Z

V2 V1 V0

Y

0 1 1 1

X 1 0 0 0

Z

V2 = m(1,2,3,4)V1 = m(2,6,7)V0 = m(4,6,7)

Page 5: 1 Lecture 31 PLAs and Arithmetic Logic Unit (ALU).

5

PLA minimizatio

° For a PLA, we should minimize the number of product terms for all functions together.

° We could express V2, V1 and V0 with just four total products:

Y

0 0 0 0

X 1 0 1 1

Z

Y

0 1 1 1

X 1 0 0 0

Z

Y

0 0 0 1

X 0 0 1 1

Z

V2 = xy’z ’ + x ’z + x ’yz’ V1 = x ’yz’ + xy V0 = xy’z ’ + xy

V2 = m(1,2,3,4)V1 = m(2,6,7)V0 = m(4,6,7)

Page 6: 1 Lecture 31 PLAs and Arithmetic Logic Unit (ALU).

6

PLA ° So we can implement these three functions using a

3 x 4 x 3 PLA:

V2 = m(1,2,3,4)= xy’z ’ + x ’z + x ’yz’V1 = m(2,6,7) = x ’yz’ + xyV0 = m(4,6,7) = xy’z ’ + xy

Page 7: 1 Lecture 31 PLAs and Arithmetic Logic Unit (ALU).

7

Summary° ROMs provide stable storage for data

° ROMs have address inputs and data outputs• ROMs directly implement truth tables

° ROMs can be used effectively in Mealy and Moore machines to implement combinational logic

° In normal use ROMs are read-only• They are only read, not written

° ROMs are often used by computers to store critical information

• Unlike SRAM, they maintain their storage after the power is turned off

° ROMs and PLAs are programmable devices that can implement arbitrary functions, which is equivalent to acting as a read-only memory.

• ROMs are simpler to program, but contain more gates.

• PLAs use less hardware, but it requires some effort to minimize a set of functions. Also, the number of AND gates available can limit the number of expressible functions.

Page 8: 1 Lecture 31 PLAs and Arithmetic Logic Unit (ALU).

8

Page 9: 1 Lecture 31 PLAs and Arithmetic Logic Unit (ALU).

9

Overview

° Main computation unit in most computer systems

° ALUs perform a variety of different functions• Add, subtract, OR, AND…

° Example: ALU chip (74LS382)• Has data and control inputs

° Individual chips can be chained together to make larger ALUs

° ALUs are important parts of datapaths• ROMs often are used in the control path

° Build a data and control path

Page 10: 1 Lecture 31 PLAs and Arithmetic Logic Unit (ALU).

10

Arithmetic Logic Unit

° Arithmetic logic unit functions

• Two multi-bit data inputs

• Function indicates action (e.g. add, subtract, OR…)

° DataOut is same bit width as multi-bit inputs (DataA and DataB)

° ALU is combinational

° Conditions indicate special conditions of arithmetic activity (e.g. overflow).

ALUFunctionConditions

DataA DataB

DataOut

Think of ALU as a number of other arithmetic and logic blocks in a single box! Function selects the block

Adder Subtract

AND…

Page 11: 1 Lecture 31 PLAs and Arithmetic Logic Unit (ALU).

11

ALU Integrated Circuit

° Integrated circuit – off-the-shelf components

° Examine the functionality of this ALU chip

Performs 8 functions

Page 12: 1 Lecture 31 PLAs and Arithmetic Logic Unit (ALU).

12

Example° Determine the 74HC382 ALU outputs for the following inputs: S2S1S0=010, A3A2A1A0=0100, B3B2B1B0=0001, and CN=1.

• Function code indicates subtract

• 0100 – 0001 = 0011

° Change the select code to 101 and repeat.• Function code indicates OR

• 0100 OR 0001 = 0101

ALUFunctionConditions

DataA DataB

DataOut

Synchronize ALUwith a clock

Page 13: 1 Lecture 31 PLAs and Arithmetic Logic Unit (ALU).

13

Expanding the ALU

° Multi-bit ALU created by connecting carry output of low-order chip to carry in of high order

Eight-bit ALU formed from 2 four-bit ALUs

Page 14: 1 Lecture 31 PLAs and Arithmetic Logic Unit (ALU).

14

Datapath components

° Tri-state buffer

° Loadable register

In Out

Enable

If Enable asserted, Out = InOtherwise Out open-circuit

LoadClk

Data stored on rising edge if Load is asserted (e.g. Load = 1)

Page 15: 1 Lecture 31 PLAs and Arithmetic Logic Unit (ALU).

15

Computation in a Typical Computer

° Control logic often implemented as a finite state machine (including ROMs)

° Datapath contains blocks such as ALUs, registers, tri-state buffers, and RAMs

° In a processor chip often a 5 to 1 ratio of datapath to control logic

Page 16: 1 Lecture 31 PLAs and Arithmetic Logic Unit (ALU).

16

Using a Datapath

° Consider the following computation steps1. ADD A, B and put result in A

2. Subtract A, B and put result in B

3. OR A, B put result in A

• Repeat starting from step 1

Determine valuesfor Function, LoadA, LoadB

Function

A B LoadBLoadA

ALU

Page 17: 1 Lecture 31 PLAs and Arithmetic Logic Unit (ALU).

17

Modeling Control as a State Machine

° Consider the following computation steps1. ADD A, B and put result in A

2. Subtract A, B and put result in B

3. OR A, B put result in A

• Repeat starting from step 1

Determine valuesfor Function, LoadA, LoadB

S0 S1 S2

Model control as a state machine.Determine control outputs for each state

Page 18: 1 Lecture 31 PLAs and Arithmetic Logic Unit (ALU).

18

Modeling Control as a State Machine

° Consider the following computation steps1. ADD A, B and put result in A

2. Subtract A, B and put result in B

3. OR A, B put result in A

• Repeat starting from step 1

StatesS0 = 00S1 = 01S2 = 10

Present State Next State Function LoadA LoadB

00 01 011 1 0 01 10 010 0 1 10 00 101 1 0

We know how to implement this using an SOP.Can we use a ROM?

Page 19: 1 Lecture 31 PLAs and Arithmetic Logic Unit (ALU).

19

ROM Implementation of State Machine

StatesS0 = 00S1 = 01S2 = 10

Present State Next State Function LoadA LoadB

00 01 011 1 0 01 10 010 0 1 10 00 101 1 0

PS

NS

01011101001001

0010110

000110

ROM

Function, LoadA, LoadB

Note: No minimization!One line in ROM for each state

Page 20: 1 Lecture 31 PLAs and Arithmetic Logic Unit (ALU).

20

Putting the Control and Datapath Together

PS

NS

01011101001001

0010110

000110

ROM

Function

LoadAA B LoadB

ALU3

Page 21: 1 Lecture 31 PLAs and Arithmetic Logic Unit (ALU).

21

What if we replaced the ROM with RAM?

PS

NS

01011101001001

0010110

000110

RAM

Function

LoadAA B LoadB

ALU3

Possible to implement different functions!Program the RAM to perform different sequences

Looks like software!

Page 22: 1 Lecture 31 PLAs and Arithmetic Logic Unit (ALU).

22

Summary

° ALU circuit can perform many functions• Combinational circuit

° ALU chips can be combined together to form larger ALU chips

• Remember to connect carry out to carry in

° ALUs form the basis of datapaths

° ROMs can form the basis of control paths

° Combine the two together to build a computing circuit

Page 23: 1 Lecture 31 PLAs and Arithmetic Logic Unit (ALU).

23

Page 24: 1 Lecture 31 PLAs and Arithmetic Logic Unit (ALU).

24

DLD Simulators

° Circuit Maker 2000

° MultiSim

° Electronic Workbench

Page 25: 1 Lecture 31 PLAs and Arithmetic Logic Unit (ALU).

25

CircuitMaker Workspace

Page 26: 1 Lecture 31 PLAs and Arithmetic Logic Unit (ALU).

26

Connectivity° An important feature of CircuitMaker is the way electrical

connections between the elements in your design are recognized.

° The concept of connectivity is the key to using CircuitMaker to draw and simulate electronic circuits. The program stores connection information for simulation, and it is also used for creating and exporting netlists into TraxMaker or other pcb layout programs to create a working printed circuit board (PCB).

CircuitMaker sections : • Schematic Window

• Analysis Window

• Panel

° Schematic window is where the schematics are drawn. One circuit file at a time can be opened into this window

° Analysis Window is where the simulation results are

° Panel has tabs across the top which are used to select controls which are relevant to the available displayed

Page 27: 1 Lecture 31 PLAs and Arithmetic Logic Unit (ALU).

27

Anatomy of a Schematic Drawing

Schematic, including device symbols, label-values and designations, wires, and pin dots

Page 28: 1 Lecture 31 PLAs and Arithmetic Logic Unit (ALU).

28

CktMaker Conventions

° .CKT Schematic (or Circuit) files

° .DAT Data files (Hotkeys; device library classifications)

° .LIB Device library files

° .MOD Model files

° .SUB Subcircuit files

° .SDF Waveform display setup files

Page 29: 1 Lecture 31 PLAs and Arithmetic Logic Unit (ALU).

29

CktMaker Toolbar

Page 30: 1 Lecture 31 PLAs and Arithmetic Logic Unit (ALU).

30

Drawing a Schematic° Using the Browse tab in the Panel

° Selecting a transistor

° Selecting resistors

° Selecting a +V and ground device

° Changing resistor and transistor label values

° Wiring the circuit

Page 31: 1 Lecture 31 PLAs and Arithmetic Logic Unit (ALU).

31

Placing a Transistor

Begin the circuit by selecting the 2N2222A transistor [.General/BJTs/NPN Trans].

1 Select .General / BJTs / NPN Trans:C in the Browse tree. Select the 2N2222A transistor in the Model list.

2 Click Place to select this device from the library. You can also click the Search tab on the Panel, type 2n2222a , and click Find to quickly find the part.

3 Position the transistor at about mid-screen and then click the left mouse button once.

Page 32: 1 Lecture 31 PLAs and Arithmetic Logic Unit (ALU).

32

Placing the Resistors

The next procedure involves placing two resistors.

1 Select a Resistor [Passive Components/Resistors/Resistor] (r) by pressing the r Hotkey on the keyboard. Notice that the resistor is oriented horizontally and moves around the screen with the mouse.

2 Press the r key again (or click the Right mouse button) to rotate the device 90°.

3 Drag the resistor above and to the left of the transistor and click the Left mouse button once to place it. This is resistor R1. Don’t worry about the value yet.

4 Place a second resistor directly above the transistor. This is resistor R2.

Page 33: 1 Lecture 31 PLAs and Arithmetic Logic Unit (ALU).

33

Placing +V and Ground Devices

Now you.’ll place a voltage source and change its settings.

1Select a +V [.General/Sources/+V] (1) by pressing the 1 (number one) Hotkey. Place it above resistor R2.

2Select a Ground [.General/Sources/Ground] (0) by pressing the 0 (zero) Hotkey. Place it below the transistor.

3 Double-click the +V device using the Left mouse button to open the Device Properties dialog box

Page 34: 1 Lecture 31 PLAs and Arithmetic Logic Unit (ALU).

34

Placing +V and Ground Devices

4 Change the Label-Value field to read +15V.

5 Click once on the topmost Visible check box. This causes the +V name to be hidden on the schematic.

6 Click once on the third Visible check box from the top. This causes the V1 designation to be hidden on the schematic. Click OK.

Changing Resistor Label-Values

1 Double-click resistor R1.

2 Change the Label-Value field to read 220k, then click OK.

3 Double-click resistor R2.

4 Change the Label-Value field to read 870k, then click OK.

Page 35: 1 Lecture 31 PLAs and Arithmetic Logic Unit (ALU).

35

Wiring the Circuit Together1 Select the Wire Tool from the Toolbar.

2 Place the cursor on the emitter pin of the transistor (the pin with the arrow.) When the cursor gets close to the pin, a small rectangle appears.

3 Click and hold the left mouse button, then drag the wire to the pin of the Ground symbol.

4 Release the mouse button to make the connection.

5 Place the cursor on the bottom pin of R2, and then click and hold the mouse button to start a new wire.

6 Drag the end of the wire to the collector pin of the transistor and release the mouse button.

7 Connect a wire from the top pin of R2 to +15V.

8 Connect another wire from the bottom pin of R1 to the base of the transistor.

9 Finally, connect a wire from the top pin of R1 to the middle of the wire which connects +15V to R2.

Page 36: 1 Lecture 31 PLAs and Arithmetic Logic Unit (ALU).

36

Digital Logic Simulation1 Click the Open button in the Toolbar.

2 Select the SIM.CKT file from the list of available circuits. The SIM.CKT circuit contains several mini-circuits and is useful for demonstrating CircuitMaker.’s digital simulation features.

3 Click the Run button on the Toolbar to start simulation. You know that simulation is running when you see a Hex Display showing a count sequence.

4 Select the Probe Tool from the Toolbar and touch its tip to the wire just to the left of the label .“Probe Wire to the Left..” The letter L will be displayed in the Probe Tool.

5 Move the tip of the Probe Tool to the Logic Switch labeled .“Toggle Switch.” and click near its center. The Logic Display connected to the output of this minicircuit should then start to toggle on and off rapidly.

6 Click the Horizontal Split button on the Toolbar to open the digital Waveforms window. Each node in the circuit that has a SCOPE device attached is charted in this window.

7 Select Simulation > Active Probe, then run the simulation again. A new waveform called Probe displays in the Waveforms window. Watch what happens to this waveform as you move the Probe Tool around the circuit.

8 Click the Trace button in the Toolbar to see the state of every wire in the circuit as the state changes. A red wire indicates a high state, a blue wire indicates a low state.

9 Click the Pause button in the Toolbar to stop simulation.

Page 37: 1 Lecture 31 PLAs and Arithmetic Logic Unit (ALU).

37

Demo with examples