Advanced Logic
Advanced Logic
Last lecture: Boolean logic and combinational circuits. Basic abstraction = controlled switch. In principle, can build TOY computer with a combinational circuit. 255 ! 16 = 4,080 inputs " 24080 rows in truth table! no simple pattern each circuit element used at most once
! !
This lecture: reuse circuit elements by storing bits in "memory." Next lecture: glue components together to make TOY computer.
ALU
combinational
Memory
state
Flip-Flop
Flip-flop. A small and useful sequential circuit. Abstraction that "remembers" one bit. Basis of important computer components: memory counter
! ! !
Combinational circuits. Output determined solely by inputs. Can draw solely with left-to-right signal paths.
! !
We will consider several flavors. Sequential circuits. Output determined by inputs AND previous outputs. Feedback loop.
! !
SR Flip-Flop
What is the value of Q if: S = 1 and R = 0 ? " Q is surely 1
!
SR Flip-Flop
What is the value of Q if: S = 1 and R = 0 ? " Q is surely 1. S = 0 and R = 1 ? " Q is surely 0
! !
SR Flip-Flop
What is the value of Q if: S = 1 and R = 0 ? " Q is surely 1. S = 0 and R = 1 ? " Q is surely 0. S = 0 and R = 0 ? " Q is possibly 0
! ! !
SR Flip-Flop
What is the value of Q if: S = 1 and R = 0 ? " Q is surely 1. S = 0 and R = 1 ? " Q is surely 0. S = 0 and R = 0 ? " Q is possibly 0 . . . or possibly 1 !
! ! !
0 0
1 1
SR Flip-Flop
What is the value of Q if: S = 1 and R = 0 ? " Q is surely 1. S = 0 and R = 1 ? " Q is surely 0. S = 0 and R = 0 ? " Q is possibly 0 . . . or possibly 1.
! ! !
SR Flip-Flop
SR Flip-Flop. S = 1, R = 0 (set) S = 0, R = 1 (reset) S=R=0 S=R=1
! ! ! !
Flips "bit" on. Flops "bit" off. Status quo. Not allowed.
old Q
SR flip flop
S R R
Interface Implementation
10
Clock
Clock. Fundamental abstraction. regular on-off pulse External analog device. Synchronizes operations of different circuit elements. 1 GHz clock means 1 billion pulses per second.
! ! ! !
#
Q R S
#
1 0 1 0 1 0
11
cycle time
Clock
time
12
Clocked SR Flip-Flop
Clocked SR Flip-Flop. Same as SR flip-flop except S and R only active when clock is 1.
!
S Cl R
SR flip flop
S Q R
Implementation
Cl R
Interface
14
Clocked D Flip-Flop
Clocked D Flip-Flop. Output follows D input while clock is 1. Output is remembered while clock is 0.
! !
Fetch-Execute Cycle
Fetch-execute cycle for TOY. Need 1-bit counter.
!
D Cl
1-bit counter
Clock
Cl R
Implementation
D Cl
Cl
Execute Fetch
Interface
Fetch Q Cl D
15 18
Execute Clock
1-Bit Counter
1-bit counter. Circuit that oscillates between 1 and 0.
!
1-Bit Counter
1-bit counter. Circuit that oscillates between 1 and 0.
!
1 0
1-bit counter
1
Q
0 X 1
1-bit counter
D Cl
Q1
D Cl
Q2
Slave
Cl Interface
Master
0 X 1
Q1
D Cl
Q2
Slave
Q Cl Interface
Cl
Master
1 X 0
Q2 Q1 Cl
19
Q2 Q1 Cl
20
1-Bit Counter
1-bit counter. Circuit that oscillates between 1 and 0.
!
1-Bit Counter
1-bit counter. Circuit that oscillates between 1 and 0.
!
1 X 0 0
D Cl
Q1
1 1 0 X
0 X 1
1-bit counter
D Cl
Q2
Slave
Q Cl Interface
0 0 X 1
D Cl
Q1
0 1 X 1 X 0
1-bit counter
D Cl
Q2
Slave
1
Cl
1 X
Master
Master
Interface
Q2 Q1 Cl
21
Q2 Q1 Cl
22
1-Bit Counter
1-bit counter. Circuit that oscillates between 1 and 0.
!
1-Bit Counter
1-bit counter. Circuit that oscillates between 1 and 0.
!
1 0 X 1 X 0
D Cl
Q1
D Cl
Q2
Slave
0 1 X
1-bit counter
Q Cl Interface
1-bit counter
D Cl
Q1
D Cl
Q2
Slave
Q Cl Interface
Master
1 0 X
Master
Q2 Q1 Cl
23
Q2 Q1 Cl
24
Memory Overview
Computers and TOY have many types of memory. Program counter. Registers. Main memory.
! ! !
Bus
16-bit bus. Bundle of 16 wires. Memory transfer, register transfer.
! !
16
We implement each bit of memory with a clocked D flip-flop. Need mechanism to organize and manipulate GROUPS of related bits. TOY has 16-bit words. Memory hierarchy makes architecture manageable.
! !
25
26
Stand-Alone Register
k-bit register. Stores k bits. Register contents always available on output. If write enable is asserted, k input bits get copied into register. x0
! ! !
D Q Cl D Q Cl
y0 y1
x1
16 write data
reg
16 read data
x15
Write
D Q Cl
y15
Examples. TOY registers: n = 16, k = 16. TOY main memory: n = 256, k = 16. Real computer: n = 256 million, k = 32. 1 GB memory (1 Byte = 8 bits)
! ! !
read data 16
write enable
n-Bit Decoder
n-bit decoder. n address inputs, 2n data outputs. Addressed output bit is 1; others are 0.
! !
Implementation example: TOY main memory. Use 256 16-bit registers. Multiplexer and decoder are combinational circuits.
! !
x0 x1 x2
0 000 1 Mux 16 read data 001 010 011 101 110 8 111
x0 x1 x2 x3 x4 x5 x6 x7 s2 s1 s0
x3 x4 x5 x6 x7
255
sel
ect
select s2 s1 s0
addr
29
n-Bit Decoder
n = 8 for main memory n = 8 for main memory
2n-to-1 Multiplexer
0 0 0
n-bit decoder. n address inputs, 2n data outputs. Addressed output bit is 1; others are 0.
! !
2n-to-1 multiplexer. n select inputs, 2n data inputs, 1 output. Copies "selected" data input bit to output.
! !
x0 x1 x2 x3
0 0 0 0 0 0 1 0 1 1 0
0 0 0 1 0
x0 x1 x2 x3 x4 x5 x6 x7
x4 x5 8 to 1 MUX ct le se
s0 s2s1
x6 x7
select 1 1 0
2n-to-1 Multiplexer
n = 8 for main memory
2n-to-1 multiplexer. n select inputs, 2n data inputs, 1 output. Copies "selected" data input bit to output.
! !
0 0 0 1
2n-to-1 multiplexer, width = k. Select from one of 2n k-bit buses. Copies k "selected" data bits to output. Layering k 2n-to-1 multiplexers.
! ! !
0 0 0 1 0 1 1 1
0 1 8 to 1 MUX ct le se 01 1 1 1 1
1 4
0 2-to-1 MUX 0
z3 z2 z1 z0
Summary
Sequential circuits add "state" to digital hardware. Flip-flop. Represents 1 bit. TOY register. 16 D flip-flops. TOY main memory. 256 registers.
! ! !
Actual technologies for register file and memory are different. Register files are relatively small and very fast. expensive per bit Memories are relatively large and pretty fast. amazingly cheap per bit
! !
ect
255
sel
addr
35
36
Announcments
Not-exactly Midterm Exam Wed March 23, 7:30 PM, right here Closed book, but You can bring one cheatsheet one side of one (8.5 by 11) sheet, handwritten by you P.S. No calculators, laptops, Palm Pilots, fancy cellphones, etc. Covers entire first half of course (lectures, readings, precepts, assignments)
! ! ! ! !
Helpful review session Tuesday March 22, 7:30 PM, COS 105 Not a canned presentation Driven by your questions
! ! !
37