Computer Architecture: Part III - Chiang Mai University 3.pdf · Computer Architecture: Part III...

36
Computer Architecture: Part III First Semester 2013 Department of Computer Science Faculty of Science Chiang Mai University

Transcript of Computer Architecture: Part III - Chiang Mai University 3.pdf · Computer Architecture: Part III...

Page 1: Computer Architecture: Part III - Chiang Mai University 3.pdf · Computer Architecture: Part III First Semester 2013 Department of Computer Science Faculty of Science Chiang Mai University

Computer Architecture: Part III

First Semester 2013Department of Computer Science

Faculty of ScienceChiang Mai University

Page 2: Computer Architecture: Part III - Chiang Mai University 3.pdf · Computer Architecture: Part III First Semester 2013 Department of Computer Science Faculty of Science Chiang Mai University

OutlineOutline

• Decoders• MultiplexersMultiplexers• Registers• Shift Registers• Binary CountersBinary Counters• Memory Unit

204231: Computer Organization and Architecture 2

Page 3: Computer Architecture: Part III - Chiang Mai University 3.pdf · Computer Architecture: Part III First Semester 2013 Department of Computer Science Faculty of Science Chiang Mai University

Decoders• A decoder is a combinational circuit that converts binary information from the n coded inputs to a maximum of 2n unique outputs.

• The decoders presented in this sections are called n‐to‐m‐line decoders, where m <= 2n.ca ed to e decode s, e e .

• Their purpose is to generate the 2n (or fewer) binary combinations of the n input variablesbinary combinations of the n input variables.

• A decoder has n inputs and m outputs and is l f d t d dalso referred to as an n x m decoder.

204231: Computer Organization and Architecture 3

Page 4: Computer Architecture: Part III - Chiang Mai University 3.pdf · Computer Architecture: Part III First Semester 2013 Department of Computer Science Faculty of Science Chiang Mai University

3‐to‐8‐line decoder

204231: Computer Organization and Architecture 4

Page 5: Computer Architecture: Part III - Chiang Mai University 3.pdf · Computer Architecture: Part III First Semester 2013 Department of Computer Science Faculty of Science Chiang Mai University

3‐to‐8‐line decoder• The three data inputs, A0, A1, and A2, are decoded into eight outputs, each output represent one of the combinations of the three binary input variables.

• A particular application of this decoder is a pa t cu a app cat o o t s decode s abinary‐to‐octal conversion.

• Commercial decoders include one or more enable• Commercial decoders include one or more enable inputs to control the operation of the circuit.Th d d i bl d h E i l t 1 d• The decoder is enabled when E is equal to 1 and disabled when E is equal to 0.

204231: Computer Organization and Architecture 5

Page 6: Computer Architecture: Part III - Chiang Mai University 3.pdf · Computer Architecture: Part III First Semester 2013 Department of Computer Science Faculty of Science Chiang Mai University

Truth Table for 3‐to‐8‐Line DecoderTruth Table for 3‐to‐8‐Line Decoder• When the enable input E is equal to 0, all the outputs areWhen the enable input E is equal to 0, all the outputs are equal to 0 regardless of the values of the other there data inputs.

• The there x’s in the table designate don’t‐care conditions.• When the enable input is equal to 1, the decoder p q ,operates in a normal fashion.

• For each possible input combination, there are seven outputs that are equal to 0 and only one that is equal to 1.

• The output variable whose value is equal to 1 represents the octal number equivalent of the binary number that is available in the input data linesavailable in the input data lines.

204231: Computer Organization and Architecture 6

Page 7: Computer Architecture: Part III - Chiang Mai University 3.pdf · Computer Architecture: Part III First Semester 2013 Department of Computer Science Faculty of Science Chiang Mai University

Truth Table for 3‐to‐8‐Line DecoderTruth Table for 3‐to‐8‐Line Decoder

204231: Computer Organization and Architecture 7

Page 8: Computer Architecture: Part III - Chiang Mai University 3.pdf · Computer Architecture: Part III First Semester 2013 Department of Computer Science Faculty of Science Chiang Mai University

NAND Gate Decoder• Some decoders are constructed with NAND instead 

f AND tof AND gates.• The decoder is enabled when E is equal to 0.• As indicated by the truth table, only one output is equal to 0 at any give time; the other three outputsequal to 0 at any give time; the other three outputs are equal to 1.Th t t h l i l t 0 t th• The output whose value is equal to 0 represents the equivalent binary number in inputs A1 and A0.

• The circuit is disabled when E is equal to 1, regardless of the values of the other two inputs.

204231: Computer Organization and Architecture 8

Page 9: Computer Architecture: Part III - Chiang Mai University 3.pdf · Computer Architecture: Part III First Semester 2013 Department of Computer Science Faculty of Science Chiang Mai University

2‐to‐4‐line decoder with NAND gates2‐to‐4‐line decoder with NAND gates

204231: Computer Organization and Architecture 9

Page 10: Computer Architecture: Part III - Chiang Mai University 3.pdf · Computer Architecture: Part III First Semester 2013 Department of Computer Science Faculty of Science Chiang Mai University

Decoder ExpansionDecoder Expansion• Two 2‐to‐4‐line decoders are combined to• Two 2‐to‐4‐line decoders are combined to achieve a 3‐to‐8‐line decoder.h l f b f h• The two least significant bits of the input are connected to both decoders.

• The most significant bit is connected to the enable input of one decoder and through anenable input of one decoder and through an inverter to the enable input of the other decoder.

• It is assumed that each decoder is enabled when• It is assumed that each decoder is enabled when its E input is equal to 1.

204231: Computer Organization and Architecture 10

Page 11: Computer Architecture: Part III - Chiang Mai University 3.pdf · Computer Architecture: Part III First Semester 2013 Department of Computer Science Faculty of Science Chiang Mai University

Decoder Expansionp• When E is equal to 0, the decoder is disabled and all it t t i th 0 l lits outputs are in the 0 level.

• When A2 = 0, the upper decoder is enabled and the lower is disabled.

• The outputs of the upper decoder generate outputsThe outputs of the upper decoder generate outputs D0 through D3, depending on the values of A1 and A0.Wh A 1 th l d d i bl d d th• When A2 = 1, the lower decoder is enabled and the upper is disabled.

• The lower decoder output generates the binary equivalent D4 through D7.q 4 g 7

204231: Computer Organization and Architecture 11

Page 12: Computer Architecture: Part III - Chiang Mai University 3.pdf · Computer Architecture: Part III First Semester 2013 Department of Computer Science Faculty of Science Chiang Mai University

A 3 × 8 decoder constructed withtwo 2 × 4 decoders

204231: Computer Organization and Architecture 12

Page 13: Computer Architecture: Part III - Chiang Mai University 3.pdf · Computer Architecture: Part III First Semester 2013 Department of Computer Science Faculty of Science Chiang Mai University

Encoder• An encoder is a digital circuit that performs the 

f d dinverse operation of a decoder.• An encoder has 2n (or less) input lines and n output lines.

• The output lines generate the binary code p g ycorresponding to the input value.

• An example of and encoder is the octal‐to‐binaryAn example of and encoder is the octal to binary encoder.

• It has eight inputs one for each of the octal digitsIt  has eight inputs, one for each of the octal digits, and three outputs the generate the corresponding binary number.binary number.

204231: Computer Organization and Architecture 13

Page 14: Computer Architecture: Part III - Chiang Mai University 3.pdf · Computer Architecture: Part III First Semester 2013 Department of Computer Science Faculty of Science Chiang Mai University

Truth Table for Octal‐to‐Binary EncoderTruth Table for Octal‐to‐Binary Encoder

204231: Computer Organization and Architecture 14

Page 15: Computer Architecture: Part III - Chiang Mai University 3.pdf · Computer Architecture: Part III First Semester 2013 Department of Computer Science Faculty of Science Chiang Mai University

Encoders• It is assumed that only one input has a value of 1 at any given time; otherwise., the circuit has no meaning. 

• The encoder can be implemented with OR gates p gwhose inputs are determined directly from the truth table.table.

• Output A0 = 1 if the input octal digit is 1 or 3 or 5 or 7.l d l f h h• Similar conditions apply for the other two outputs.A0 = D1 + D3 + D5 + D70 1 3 5 7

A1 = D2 + D3 + D6 + D7

A = D + D + D + DA2 = D4 + D5 + D6 + D7204231: Computer Organization and Architecture 15

Page 16: Computer Architecture: Part III - Chiang Mai University 3.pdf · Computer Architecture: Part III First Semester 2013 Department of Computer Science Faculty of Science Chiang Mai University

MultiplexersMultiplexers• A multiplexer is a combinational circuit that preceives binary information from one of 2n input data lines and directs it to a single output line.data lines and directs it to a single output line.

• The selection of a particular input data line for the output is determined by a set of selectionthe output is determined by a set of selection inputs.

• A 2n‐to‐1 multiplexer has 2n input data lines and n input selection lines whose bit combinations determine which input data are selected for the output.

204231: Computer Organization and Architecture 16

Page 17: Computer Architecture: Part III - Chiang Mai University 3.pdf · Computer Architecture: Part III First Semester 2013 Department of Computer Science Faculty of Science Chiang Mai University

A 4‐to‐1‐line multiplexerA 4‐to‐1‐line multiplexer• Each of the four data inputs I0 through I3 is p 0 g 3applied to one input of and AND gate.Th t l ti i t S d S• The two selection inputs S1 and S0 are decoded to select a particular AND gate.

• The outputs of the AND gates are applied to a single OR gate to provide the single output.single OR gate to provide the single output.

• A more convenient way to describe the i f l i l i b foperation of multiplexers is by means of a 

function table.

204231: Computer Organization and Architecture 17

Page 18: Computer Architecture: Part III - Chiang Mai University 3.pdf · Computer Architecture: Part III First Semester 2013 Department of Computer Science Faculty of Science Chiang Mai University

4‐to‐1 line multiplexer4‐to‐1 line multiplexer

204231: Computer Organization and Architecture 18

Page 19: Computer Architecture: Part III - Chiang Mai University 3.pdf · Computer Architecture: Part III First Semester 2013 Department of Computer Science Faculty of Science Chiang Mai University

Function Table for4‐to‐1‐Line Multiplexer

204231: Computer Organization and Architecture 19

Page 20: Computer Architecture: Part III - Chiang Mai University 3.pdf · Computer Architecture: Part III First Semester 2013 Department of Computer Science Faculty of Science Chiang Mai University

RegistersRegisters

• In its broadest definition, a register consists of a group of flip‐flops and gates that effect their g p p p gtransition.

• The flip flops hold the binary information and• The flip‐flops hold the binary information and the gates control when and how new i f ti i t f d i t th i tinformation is transferred into the register.

204231: Computer Organization and Architecture 20

Page 21: Computer Architecture: Part III - Chiang Mai University 3.pdf · Computer Architecture: Part III First Semester 2013 Department of Computer Science Faculty of Science Chiang Mai University

4 bit Register4‐bit Register

lid b h h i• Slide number 23 shows such a register constructed with four D flip‐flops.

• The common clock input triggers all flip‐flops on the rising edge of each pulse, and the g g p ,binary data available at the four inputs are transferred into the 4‐bit register.g

• The four outputs can be sampled at any time to obtain the binary information stored in theto obtain the binary information stored in the register.

204231: Computer Organization and Architecture 21

Page 22: Computer Architecture: Part III - Chiang Mai University 3.pdf · Computer Architecture: Part III First Semester 2013 Department of Computer Science Faculty of Science Chiang Mai University

4 bit Register4‐bit Register

• The clear input goes to a special terminal in each flip‐flop.p p

• When this input goes to 0, all flip‐flops are reset asynchronouslyreset asynchronously.

• The clear input is useful for clearing the register to all 0’s prior to its clocked operation.

204231: Computer Organization and Architecture 22

Page 23: Computer Architecture: Part III - Chiang Mai University 3.pdf · Computer Architecture: Part III First Semester 2013 Department of Computer Science Faculty of Science Chiang Mai University

4‐bit register4‐bit register

204231: Computer Organization and Architecture 23

Page 24: Computer Architecture: Part III - Chiang Mai University 3.pdf · Computer Architecture: Part III First Semester 2013 Department of Computer Science Faculty of Science Chiang Mai University

Shift RegistersShift Registers

i bl f hif i i bi• A register capable of shifting its binary information in one or both directions is called a shift register.

• The logical configuration of a shift register g g gconsists of a chain of flip‐flops in cascade, with the output of one flip‐flop connected to the p p pinput of the next flip‐flop.

• All flip‐flop receive common clock pulses that• All flip‐flop receive common clock pulses that initiate the shift from one stage to the next.

204231: Computer Organization and Architecture 24

Page 25: Computer Architecture: Part III - Chiang Mai University 3.pdf · Computer Architecture: Part III First Semester 2013 Department of Computer Science Faculty of Science Chiang Mai University

4‐bit shift register4‐bit shift register

204231: Computer Organization and Architecture 25

Page 26: Computer Architecture: Part III - Chiang Mai University 3.pdf · Computer Architecture: Part III First Semester 2013 Department of Computer Science Faculty of Science Chiang Mai University

Binary CountersBinary Counters

• A counter that follows the binary number sequence is called a binary counter.q y

• An n‐bit binary counter is a register of n flip‐flops and associated gates that follows aflops and associated gates that follows a sequence of stated according to the binary 

f b fcount of n bits, from 0 to 2n‐1.

204231: Computer Organization and Architecture 26

Page 27: Computer Architecture: Part III - Chiang Mai University 3.pdf · Computer Architecture: Part III First Semester 2013 Department of Computer Science Faculty of Science Chiang Mai University

Binary CounterBinary Counter

• Going through a sequence of binary numbers such as 0000, 0001, 0010, 0011, and so on, we note that the lower‐order bit is complemented after every count and everycomplemented after every count and every other bit is complemented from one count to the next if and only if all its lower order bitsthe next if and only if all its lower‐order bits are equal to 1.

204231: Computer Organization and Architecture 27

Page 28: Computer Architecture: Part III - Chiang Mai University 3.pdf · Computer Architecture: Part III First Semester 2013 Department of Computer Science Faculty of Science Chiang Mai University

Binary CounterBinary Counter

b h fli fl i l d• Remember that a JK flip‐flop is complemented if both its J and K inputs are 1 and the clock goes through a positive transition.

• The output of the flip‐flop does not change if J p p p g= K = 0.

• In addition the counter may be controlledIn addition, the counter may be controlled with an enable input that turns the counter on or off without removing the clock signal fromor off without removing the clock signal from the flip‐flops.

204231: Computer Organization and Architecture 28

Page 29: Computer Architecture: Part III - Chiang Mai University 3.pdf · Computer Architecture: Part III First Semester 2013 Department of Computer Science Faculty of Science Chiang Mai University

4‐bit synchronous binary counter4‐bit synchronous binary counter

204231: Computer Organization and Architecture 29

Page 30: Computer Architecture: Part III - Chiang Mai University 3.pdf · Computer Architecture: Part III First Semester 2013 Department of Computer Science Faculty of Science Chiang Mai University

Random Access MemoryRandom‐Access Memory

h d i li id h i f i• The n data input lines provide the information to be stored in memory, and the n data output lines supply the information coming out of memory.

• The k address lines provide a binary number of k bits that specify a particular word chosen p y pamong the 2k available inside the memory.

• The two control inputs specify the direction of• The two control inputs specify the direction of transfer desired.

204231: Computer Organization and Architecture 30

Page 31: Computer Architecture: Part III - Chiang Mai University 3.pdf · Computer Architecture: Part III First Semester 2013 Department of Computer Science Faculty of Science Chiang Mai University

Block diagram of random access memory (RAM)

204231: Computer Organization and Architecture 31

Page 32: Computer Architecture: Part III - Chiang Mai University 3.pdf · Computer Architecture: Part III First Semester 2013 Department of Computer Science Faculty of Science Chiang Mai University

Transferring a new word to be stored into memory

1. Apply the binary address of the desired word into the address lines.

2. Apply the data bits that must be stored in memory into the data input linesmemory into the data input lines.

3. Activate the write input.

204231: Computer Organization and Architecture 32

Page 33: Computer Architecture: Part III - Chiang Mai University 3.pdf · Computer Architecture: Part III First Semester 2013 Department of Computer Science Faculty of Science Chiang Mai University

Transferring a stored word out of memory

1. Apply the binary address of the desired word into the address lines.

2. Activate the read input.

204231: Computer Organization and Architecture 33

Page 34: Computer Architecture: Part III - Chiang Mai University 3.pdf · Computer Architecture: Part III First Semester 2013 Department of Computer Science Faculty of Science Chiang Mai University

Read Only MemoryRead‐Only Memory

i f bi ll• An m x n ROM is an array of binary cells organized into m words of n bits each.

• A ROM has k address input lines to select one of 2k = m words of memory, and n output y, plines, one for each bit of the word.

• The ROM does not need a read‐control lineThe ROM does not need a read control line since at any given time, the output lines automatically provide the n bits of the wordautomatically provide the n bits of the word selected by the address value.

204231: Computer Organization and Architecture 34

Page 35: Computer Architecture: Part III - Chiang Mai University 3.pdf · Computer Architecture: Part III First Semester 2013 Department of Computer Science Faculty of Science Chiang Mai University

Block diagram of read only memory (ROM)

204231: Computer Organization and Architecture 35

Page 36: Computer Architecture: Part III - Chiang Mai University 3.pdf · Computer Architecture: Part III First Semester 2013 Department of Computer Science Faculty of Science Chiang Mai University

ReferenceReference

• M. Moris Mano, Computer System Architecture, 3rd ed. NJ: Prentice Hall, 1992.

204231: Computer Organization and Architecture 36