Download presentation
Presentation is loading. Please wait.
1
Digital Circuits and Logic
Gates Combinatorial logic adder ALU Sequential logic flip-flop memory CPU fetch-decode-execute cycle 17/05/2019 CMPUT 229
2
How to make a computer Computers are electronic equipment
contain many connected electronic components memory Central Processing Unit (CPU) specialized devices (network, video, etc.) components largely made of circuits containing wires and gates 17/05/2019 CMPUT 229
3
Logic Level one (1) / zero (0)
A Boolean logical signal always takes one of two logic levels. on / off high (H) / low (L) one (1) / zero (0) true (T) / false (F) positive / negative Why two levels ? Why not use, say, 4 levels? For example, electrical voltage as 0 v, 5v, 10v, and 20v 17/05/2019 CMPUT 229
4
Gates Tiny electronic switches made of transistors
implement Boolean logic 0/1 low/high voltage digital for given inputs, produce known output according to truth table represented in circuit diagrams by symbols 17/05/2019 CMPUT 229
5
Gates NOT In Out 1 1 17/05/2019 CMPUT 229
6
Gates 1 Out In 2 In 1 AND 17/05/2019 CMPUT 229
7
Gates NAND In 1 In 2 Out 1 1 1 1 1 1 1 17/05/2019 CMPUT 229
8
Gates OR 1 Out In 2 In 1 17/05/2019 CMPUT 229
9
Gates 1 Out In 2 In 1 XOR 17/05/2019 CMPUT 229
10
Implementation of Logic Gates
The NAND gate, the basic logic gate easier to manufacture any other logic gate can be made from a combination of NAND gates 17/05/2019 CMPUT 229
11
17/05/2019 CMPUT 229
12
Implementation of Logic Gates
CMOS The standard, 4000 series (4011) 17/05/2019 CMPUT 229
13
Implementation of Logic Gates
TTL The 4011's TTL counterpart is the 7400 17/05/2019 CMPUT 229
14
Logic Circuits Combinatorial Logic Sequential logic
Output depends solely on the input values Example: arithmetic logic unit (ALU) Sequential logic output depends on the present input, and the history of the input Examle: Flip-flop, Memory 17/05/2019 CMPUT 229
15
Combinatorial logic What about more complex truth tables?
Made by combining many gates together wires connect inputs and outputs each wire can carry only one bit, 0 or 1 17/05/2019 CMPUT 229
16
Combinatorial logic Circuits made from collections of gates
outputs depend only on inputs not on prior state characterized by truth table comparable to Boolean expression 17/05/2019 CMPUT 229
17
are equivalent; each can be converted to the other two.
Combinatorial logic boolean expression X = (A & ~B) | (B & C) truth table logic circuit A B C X 1 A B C X 1 1 1 1 1 1 all three of forms are equivalent; each can be converted to the other two. 17/05/2019 CMPUT 229
18
DeMorgan’s Law 17/05/2019 CMPUT 229
19
1 Out In 2 In 1 17/05/2019 CMPUT 229
20
Combinatorial logic Many parts of a computer are constructed of combinatorial logic adder circuit performs addition arithmetic logic unit (ALU) performs many kinds of arithmetic and bitwise logical operations contains adder circuit multiplexer and decoder direct bit traffic between components 17/05/2019 CMPUT 229
21
Adder A combinatorial circuit that adds binary values
according to this truth table In 1 In 2 Sum Carry 1 Carry is equivalent to AND Sum is equivalent to XOR 17/05/2019 CMPUT 229
22
This circuit can add two binary digits and is called a half-adder
Carry In 1 In 2 Sum This circuit can add two binary digits and is called a half-adder 17/05/2019 CMPUT 229
23
Adder 5 3 8 1 4 + 9 1 Why “half-adder”. . . ? 1
. . . because to add multi-digit numbers each column requires two additions 17/05/2019 CMPUT 229
24
Full adder in 1 This circuit is called a full adder and can add three binary digits in 2 half adders carry out carry in This OR gate combines the carries from the two half-adders sum 17/05/2019 CMPUT 229
25
Ripple-carry adder A3 A2 A1 A0 B3 B2 B1 B0 out3 out2 out1 out0
17/05/2019 CMPUT 229
26
Ripple-carry adder 0101 + 0110 = 1011 A3 A2 A1 A0 B3 B2 B1 B0 out3
1 1 1 1 1 1 out3 out2 out1 out0 17/05/2019 CMPUT 229
27
Ripple-carry adder So named because gate results (including carries) propagate (“ripple”) from LSB to MSB right to left corresponds to how humans add numbers with pen and paper More sophisticated, faster, adder circuits exist that can create the higher order carries more quickly 17/05/2019 CMPUT 229
28
Adder A3-A0 B3-B0 Adders (and other arithmetic circuits) are usually drawn like this in block diagrams inputs + output collections of parallel, related wires like this are known as buses; they carry multi-bit values between components out3-out0 17/05/2019 CMPUT 229
29
Arithmetic Computers need to do more than just addition
logic: & | ~ << >> Need a circuit that can select operation to perform 17/05/2019 CMPUT 229
30
Multiplexer (Mux) A B A B S S C C 17/05/2019 CMPUT 229
31
Arithmetic Logic Unit (ALU)
B more operations here . . . op 0 op 1 op 2 op 3 + * & << Multiplexer: a combinatorial circuit which selects exactly one input MUX 1 2 3 .. op op selects operation: 0 = add, 1 = multiply, ... out 17/05/2019 CMPUT 229
32
Arithmetic Logic Unit (ALU)
B = 2 for example: compute 15 << 2 more operations here . . . op 0 op 1 op 2 op 3 + * & << other results also computed but ignored by multiplexer MUX 1 2 3 .. op = 3 out = 60 17/05/2019 CMPUT 229
33
How to design a logic circuit for a given truth table?
For each row in the truth table whose output value is 1, construct a logic expression of the conjunction of all input column values Form the disjunction of all conjunctive formulas obtained in step 1 Simplify the disjunction obtained from Step 2 Construct the logic circuit from the simplified logical expression in Step 3 17/05/2019 CMPUT 229
34
Memory Computers need memory for storage
Different kinds of memory distinguished by speed, size, cost and proximity to CPU main memory slowish, huge, cheap, far from CPU typical size 109 bits cache fast, medium-sized, expensive, near to CPU typical size 106 bits registers extremely fast, tiny, very expensive, located on CPU in MIPS (32 GPRs)×32 bits = 1024 bits 17/05/2019 CMPUT 229
35
Memory The smallest piece of memory is a single binary digit (bit)
can hold 0 or 1 only A one-bit memory is called a flip-flop or a data latch because its value can flip and flop between 0 and 1 because it can latch onto a data value and store it 17/05/2019 CMPUT 229
36
Flip-flop Flip-flop needs two operation modes Also need
write: store (memorize) a value read: load (recall) a previously stored value Also need data in for telling flip-flop what value to store (0 or 1) used only when writing data out for finding out what value flip-flop currently contains (0 or 1) used only when reading 17/05/2019 CMPUT 229
37
Flip-flop Flip-flop can be implemented with gates
Not combinatorial logic because current output may depend on previous state Example of sequential logic current output depends on inputs and prior output 17/05/2019 CMPUT 229
38
Flip-flop NOR gate: OR gate followed by NOT gate data in data out
read/write read/write control: 0 = read, 1 = write 17/05/2019 CMPUT 229
39
Flip-flop: writing Try changing data in to 0 and watch data out
1 1 1 1 1 1 data out = 1 1 when read/write = 1, data out = data in read/write = 1 (write) 17/05/2019 CMPUT 229
40
Flip-flop: reading data in = ? data out = 1 read/write = 0 (read)
when read/write = 0, no signals in box can change, data out holds value regardless of data in 1 ? ? 1 data out = 1 read/write = 0 (read) 17/05/2019 CMPUT 229
41
Flip-flops are often drawn like this in block diagrams
D = data in Q = data out Flip-flops are often drawn like this in block diagrams D Q CK CK is read/write (“clock” because this input is often connected to computer’s processor clock) 17/05/2019 CMPUT 229
42
Flip-flop using NAND Gates
17/05/2019 CMPUT 229
43
Flip-flop using NAND Gates
Data In Data Out read/write 17/05/2019 CMPUT 229
44
Memory Memory can store many bits independently
many flip-flops Need to identify which bit (flip-flop) to read or write Give each flip-flop a unique number (address) 17/05/2019 CMPUT 229
45
Memory Decoder: feeds input to selected output, 0 to all others DEC
data in D Q address 0 CK D Q data out address 1 rd/wr 1 CK 1 DEC MUX 2 2 3 D Q 3 ... address 2 ... CK D Q address address 3 CK . . . millions more flip-flops . . . 17/05/2019 CMPUT 229
46
Memory: writing Writing value 1 to flip-flop at address 2 DEC MUX 1
data in ? D Q 1 address 0 CK ? D Q data out address 1 rd/wr 1 CK 1 DEC MUX 2 2 1 3 1 D Q 3 ... 1 address 2 ... 1 CK ? D Q address address 3 CK 2 . . . millions more flip-flops . . . 17/05/2019 CMPUT 229
47
Memory: reading Reading value from flip-flop at address 2 DEC MUX 1 1
data in D Q address 0 CK D Q data out address 1 rd/wr 1 CK 1 DEC MUX 2 2 1 3 1 D Q 3 ... 1 address 2 ... CK D Q address address 3 CK 2 . . . millions more flip-flops . . . 17/05/2019 CMPUT 229
48
Memory Memory usually operates in terms of bytes (8 bits), not single bits Repeat memory circuit eight times connect each memory circuit to one of the eight lanes of the data bus reads and writes occur in parallel for each bit in byte 17/05/2019 CMPUT 229
49
Central Processing Unit (CPU)
Coordinates all computer’s components according to program being run Contains registers ALU program counter (PC) address of current instruction instruction register (IR) copy of current instruction control logic Runs programs using fetch-(decode)-execute cycle 17/05/2019 CMPUT 229
50
CPU out Registers Memory in Control logic rd/wr addr IR ALU PC
17/05/2019 CMPUT 229
51
Fetch-execute cycle: fetch
IR Registers out Stage 1 of fetch-execute cycle: instruction at address pointed to by PC is fetched into IR Memory in Control logic rd/wr addr ALU PC 17/05/2019 CMPUT 229
52
Fetch-execute cycle: decode
IR Registers out Memory Stage 2 of fetch-execute cycle: instruction (now in IR) is decoded by control logic to determine which operation to perform in Control logic rd/wr addr ALU PC 17/05/2019 CMPUT 229
53
Fetch-execute cycle: execute
IR Registers out Stage 3 of fetch-execute cycle: CPU performs the operation (for example, arithmetic on two registers) Memory in Control logic rd/wr addr ALU PC 17/05/2019 CMPUT 229
54
Fetch-execute cycle: update PC
IR Registers out Stage 4 of fetch-execute cycle: PC’s value is updated to point to the next instruction Memory in Control logic rd/wr addr ALU PC 17/05/2019 CMPUT 229
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.