CS 251 Fall 2019 CS 240 Principles of Programming Languages - - PowerPoint PPT Presentation

cs 251 fall 2019 cs 240 principles of programming
SMART_READER_LITE
LIVE PREVIEW

CS 251 Fall 2019 CS 240 Principles of Programming Languages - - PowerPoint PPT Presentation

CS 251 Fall 2019 CS 240 Principles of Programming Languages Foundations of Computer Systems Ben Wood Sequential Logic Latch: CC-BY Rberteig@flickr and State Output depends on inputs and stored values . (vs. combinational logic: output


slide-1
SLIDE 1

CS 251 Fall 2019 Principles of Programming Languages

Ben Wood

λ

CS 240

Foundations of Computer Systems

https://cs.wellesley.edu/~cs240/

Sequential Logic and State

Output depends on inputs and stored values. (vs. combinational logic: output depends only on inputs) Elements to store values: latches, flip-flops, registers, memory

Sequential Logic 1

Latch: CC-BY Rberteig@flickr

slide-2
SLIDE 2

ALU

Processor: Data Path Components

Sequential Logic 2

Registers Memory

Instruction Fetch and Decode

1 2 3

slide-3
SLIDE 3

Bistable latches

Sequential Logic 3

Q Q

Suppose we somehow get a 1 (or a 0?) on here.

Q Q

=

slide-4
SLIDE 4

SR latch

Sequential Logic 4

Q Q R S Set Reset S R Q Q' Q (stable) Q' (stable) 1 1 1 1 1 ? ? 1 1 ? ? 1

slide-5
SLIDE 5

SR latch

Sequential Logic 5

Q Q R S Q Q R S Q Q R S R S Q Q R S Q Q

slide-6
SLIDE 6

D latch

if C = 0, then SR latch stores current value of Q. if C = 1, then D flows to Q: if D = 0, then R = 1 and S = 0, Q = 0 if D = 1, then R = 0 and S = 1, Q = 1

Sequential Logic 6

D C R S Q Q Clock Data bit

slide-7
SLIDE 7

Time matters!

Sequential Logic 7

D C Q

Assume Q has an initial state of 0

ex

slide-8
SLIDE 8

Clocks

Clock: free-running signal with fixed cycle time = clock period = T. Clock frequency = 1 / clock period A clock controls when to update a sequential logic element's state.

Sequential Logic 8

Clock period Falling edge Rising edge

slide-9
SLIDE 9

Synchronous systems

Inputs to state elements must be valid on active clock edge.

Sequential Logic 9

State element 1 State element 2 Combinational logic

slide-10
SLIDE 10

D flip-flop with falling-edge trigger

Sequential Logic 10

D C Q E

QL DL CL

D latch

QL QF DF CF

D latch

QF

Q

leader follower

Clock

leader stores D as E follower stores E as Q Can still read Qnow Qnext becomes Qnow

Time

slide-11
SLIDE 11

Time matters!

Sequential Logic 11

D C E Q

Assume Q and E have an initial state of 0

ex

slide-12
SLIDE 12

Reading and writing in the same cycle

Sequential Logic 12

Assume Q is initially 0.

Q D C D Flip-Flop Q Clock

slide-13
SLIDE 13

D flip-flop = one bit of storage

Sequential Logic 13

Q D C D Flip-Flop Q 1

slide-14
SLIDE 14

A 1-nybble* register

(a 4-bit hardware storage cell)

Sequential Logic 14

Write Clock

1 1 Q D C D Flip-Flop Q Q D C D Flip-Flop Q Q D C D Flip-Flop Q Q D C D Flip-Flop Q

*Half a byte!

slide-15
SLIDE 15

Register file

Sequential Logic 15

Read ports Why 2?

Read register selector 1 Read register selector 2 Write register selector Write data Write? Read data 1 Read data 2

r r r w w w

r = log2 number of registers w = bits in word

Array of registers, with register selectors, write/read control, input port for writing data, output ports for reading data. Write port

0 = read 1 = write

slide-16
SLIDE 16

Read ports (data out)

Sequential Logic 16

Read register number 1 Register 0 Register 1 . . . Register n – 2 Register n – 1 M u x Read register number 2 M u x Read data 1 Read data 2

slide-17
SLIDE 17

Write 1 n-to-2n decoder n – 2 n – 1 Register 0 C D Register 1 C D Register n – 2 C D Register n – 1 C D . . . Register number . . . Register data

Write port (data in)

Sequential Logic 17

incoming data register number write control clock

slide-18
SLIDE 18

RAM (Random Access Memory)

Sequential Logic 18

Similar to register file, except… A B

slide-19
SLIDE 19

16 x 4 RAM

Sequential Logic 19

4 to 16 decoder data

  • ut

1101

4-bit address