2013 semester 1 lecture notes lecture 9, 22mar13: … science 210 s1c computer systems 1 2013...

20
Computer Science 210 s1c Computer Systems 1 2013 Semester 1 Lecture Notes James Goodman Credits: Slides prepared by Gregory T. Byrd, North Carolina State University Finite State Machines & the von Neumann Model Lecture 9, 22Mar13:

Upload: lytram

Post on 04-May-2018

213 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: 2013 Semester 1 Lecture Notes Lecture 9, 22Mar13: … Science 210 s1c Computer Systems 1 2013 Semester 1 Lecture Notes James Goodman! Credits: “McGraw-Hill” slides prepared by

Computer Science 210 s1c Computer Systems 1

2013 Semester 1

Lecture Notes

James Goodman!

Credits: Slides prepared by Gregory T. Byrd, North Carolina State University

Finite State Machines & the von Neumann Model

Lecture 9, 22Mar13:

Page 2: 2013 Semester 1 Lecture Notes Lecture 9, 22Mar13: … Science 210 s1c Computer Systems 1 2013 Semester 1 Lecture Notes James Goodman! Credits: “McGraw-Hill” slides prepared by

Announcements

Facebook: https://www.facebook.com/groups/324132367708838/#!/groups/324132367708838/

Thanks to Gabby Freeland & Chris Petty!

2013.03.21 CS210 218

Page 3: 2013 Semester 1 Lecture Notes Lecture 9, 22Mar13: … Science 210 s1c Computer Systems 1 2013 Semester 1 Lecture Notes James Goodman! Credits: “McGraw-Hill” slides prepared by

21-Mar-13 CS210 226

Finite State Machine

A description of a system with the following components:

1.  A finite number of states

2.  A finite number of external inputs

3.  A finite number of external outputs

4.  An explicit specification of all state transitions

5.  An explicit specification of what determines each external output value

Often described by a state diagram. !  Inputs trigger state transitions.

!  Outputs are associated with each state (or with each transition).

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Page 4: 2013 Semester 1 Lecture Notes Lecture 9, 22Mar13: … Science 210 s1c Computer Systems 1 2013 Semester 1 Lecture Notes James Goodman! Credits: “McGraw-Hill” slides prepared by

21-Mar-13 CS210 227

The Clock

Frequently, a clock circuit triggers transition from one state to the next.

At the beginning of each clock cycle, state machine makes a transition, based on the current state and the external inputs.

! Not always required. In lock example, the input itself triggers a transition.

“1”

“0”

time! One Cycle

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Page 5: 2013 Semester 1 Lecture Notes Lecture 9, 22Mar13: … Science 210 s1c Computer Systems 1 2013 Semester 1 Lecture Notes James Goodman! Credits: “McGraw-Hill” slides prepared by

21-Mar-13 CS210 228

Implementing a Finite State Machine

Combinational logic ! Determine outputs and next state.

Storage elements ! Maintain state representation.

State Machine

Combinational Logic Circuit

Storage Elements

Inputs Outputs

Clock

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Page 6: 2013 Semester 1 Lecture Notes Lecture 9, 22Mar13: … Science 210 s1c Computer Systems 1 2013 Semester 1 Lecture Notes James Goodman! Credits: “McGraw-Hill” slides prepared by

21-Mar-13 CS210 230

Storage: Master-Slave Flipflop

A pair of gated D-latches, to isolate next state from current state.

During 1st phase (clock=1), previously-computed state becomes current state and is sent to the logic circuit.

During 2nd phase (clock=0), next state, computed by logic circuit, is stored in Latch A.

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

AS

Z

A

S

Z

A

S

Z

A

S

Z

A

S

Z

A

S

Z

AS

Z

A

S

Z

A

S

Z

A

S

Z

A

S

Z A

S

Z

A

S

Z

A

S

Z

A

S

Z

A

S

Z

AS

Z

A

S

Z

A

S

Z

A

S

Z

A

S

Z

A

S

Z

AS

Z

A

S

Z

A

S

Z

A

S

Z

A

S

Z A

S

Z

A

S

Z

A

S

Z

A

S

Z

A

S

Z

Page 7: 2013 Semester 1 Lecture Notes Lecture 9, 22Mar13: … Science 210 s1c Computer Systems 1 2013 Semester 1 Lecture Notes James Goodman! Credits: “McGraw-Hill” slides prepared by

21-Mar-13 CS210 232

Storage

Each master-slave flipflop stores one state bit.

The number of storage elements (flipflops) needed is determined by the number of states (and the representation of each state).

Examples: ! Sequential lock

• Four states – two bits

! Basketball scoreboard

•  7 bits for each score, 5 bits for minutes, 6 bits for seconds, 1 bit for possession arrow, 1 bit for half, …

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Page 8: 2013 Semester 1 Lecture Notes Lecture 9, 22Mar13: … Science 210 s1c Computer Systems 1 2013 Semester 1 Lecture Notes James Goodman! Credits: “McGraw-Hill” slides prepared by

21-Mar-13 CS210 233

Complete Example

A blinking traffic sign ! No lights on

! 1 & 2 on

! 1, 2, 3, & 4 on

! 1, 2, 3, 4, & 5 on

!  (repeat as long as switch is turned on)

DANGER MOVE RIGHT

1

2

3 4

5

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Page 9: 2013 Semester 1 Lecture Notes Lecture 9, 22Mar13: … Science 210 s1c Computer Systems 1 2013 Semester 1 Lecture Notes James Goodman! Credits: “McGraw-Hill” slides prepared by

21-Mar-13 CS210 234

Traffic Sign State Diagram

State bit S1 State bit S0

Switch on Switch off

Outputs

Transition on each clock cycle.

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Page 10: 2013 Semester 1 Lecture Notes Lecture 9, 22Mar13: … Science 210 s1c Computer Systems 1 2013 Semester 1 Lecture Notes James Goodman! Credits: “McGraw-Hill” slides prepared by

21-Mar-13 CS210 235

Traffic Sign Truth Tables

Outputs (depend only on state: S1S0)

S1 S0 Z Y X

0 0 0 0 0

0 1 1 0 0

1 0 1 1 0

1 1 1 1 1

Lights 1 and 2 Lights 3 and 4

Light 5

Next State: S1!S0! (depend on state and input)

On S1 S0 S1!" S0!"

0 X X 0 0

1 0 0 0 1

1 0 1 1 0

1 1 0 1 1

1 1 1 0 0

Switch

Whenever On=0, next state is 00.

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Page 11: 2013 Semester 1 Lecture Notes Lecture 9, 22Mar13: … Science 210 s1c Computer Systems 1 2013 Semester 1 Lecture Notes James Goodman! Credits: “McGraw-Hill” slides prepared by

21-Mar-13 CS210 236

Traffic Sign Logic

Master-slave flipflop

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Page 12: 2013 Semester 1 Lecture Notes Lecture 9, 22Mar13: … Science 210 s1c Computer Systems 1 2013 Semester 1 Lecture Notes James Goodman! Credits: “McGraw-Hill” slides prepared by

21-Mar-13 CS210 237

From Logic to Data Path

The data path of a computer is all the logic used to process information.

! See the data path of the LC-3 on next slide.

Combinational Logic ! Decoders – convert instructions into control signals

! Multiplexers – select inputs and outputs

! ALU (Arithmetic and Logic Unit) – operations on data

Sequential Logic ! State machine – coordinate control signals and data movement

! Registers and latches – storage elements

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Page 13: 2013 Semester 1 Lecture Notes Lecture 9, 22Mar13: … Science 210 s1c Computer Systems 1 2013 Semester 1 Lecture Notes James Goodman! Credits: “McGraw-Hill” slides prepared by

21-Mar-13 CS210 238

LC-3 Data Path

Combinational Logic

State Machine

Storage

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Page 14: 2013 Semester 1 Lecture Notes Lecture 9, 22Mar13: … Science 210 s1c Computer Systems 1 2013 Semester 1 Lecture Notes James Goodman! Credits: “McGraw-Hill” slides prepared by

Computer Science 210 s1c Computer Systems 1

2013 Semester 1

Lecture Notes

James Goodman!

Credits: “McGraw-Hill” slides prepared by Gregory T. Byrd, North Carolina State University

Chapter 4: The von Neumann Model

Page 15: 2013 Semester 1 Lecture Notes Lecture 9, 22Mar13: … Science 210 s1c Computer Systems 1 2013 Semester 1 Lecture Notes James Goodman! Credits: “McGraw-Hill” slides prepared by

22-Mar-13 CS210 241

The Stored Program Computer

1943: Colossus Mark 1 ! First programmable computer

! Specifically for breaking German codes.

! Secret until 1970s!

1943: ENIAC ! Hard-wired program – settings of dials and switches.

! Presper Eckert and John Mauchly – first general-purpose electronic computer. (or was it John V. Atanasoff in 1942?) (or was it Konrad Zuse in 1941?)

1944: Beginnings of EDSAC ! Maurice Wilkes, inspired by conversations with Eckert & Mauchly

! Among other improvements, includes program stored in memory

1944: Beginnings of EDVAC (working 1949) For more history, see http://www.maxmon.com/history.htm

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Page 16: 2013 Semester 1 Lecture Notes Lecture 9, 22Mar13: … Science 210 s1c Computer Systems 1 2013 Semester 1 Lecture Notes James Goodman! Credits: “McGraw-Hill” slides prepared by

21-Mar-13 CS210 242

The Stored Program Computer (continued)

1945: John von Neumann ! Wrote a report on the stored program concept,

known as the First Draft of a Report on EDVAC

The basic structure proposed in the draft became known as the “von Neumann machine” (or model).

! a memory, containing instructions and data

! a processing unit, for performing arithmetic and logical operations

! a control unit, for interpreting instructions

For more history, see http://www.maxmon.com/history.htm

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Page 17: 2013 Semester 1 Lecture Notes Lecture 9, 22Mar13: … Science 210 s1c Computer Systems 1 2013 Semester 1 Lecture Notes James Goodman! Credits: “McGraw-Hill” slides prepared by

2013.03.21 CS210 243

John von Neumann (1903-1957) with the ENIAC

Page 18: 2013 Semester 1 Lecture Notes Lecture 9, 22Mar13: … Science 210 s1c Computer Systems 1 2013 Semester 1 Lecture Notes James Goodman! Credits: “McGraw-Hill” slides prepared by

21-Mar-13 CS210 244

Konrad Zuse, 1910-1995

Page 19: 2013 Semester 1 Lecture Notes Lecture 9, 22Mar13: … Science 210 s1c Computer Systems 1 2013 Semester 1 Lecture Notes James Goodman! Credits: “McGraw-Hill” slides prepared by

2013.03.21 CS210 246

Maurice Wilkes (1913-2011), designer of the EDSAC, the first

working stored-program computer (1949)

Page 20: 2013 Semester 1 Lecture Notes Lecture 9, 22Mar13: … Science 210 s1c Computer Systems 1 2013 Semester 1 Lecture Notes James Goodman! Credits: “McGraw-Hill” slides prepared by

21-Mar-13 CS210 248

Von Neumann Model Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

MAR MDR

MEMORY

* Monitor* Printer* LED* Disk

OUTPUT

* Keyboard* Mouse* Scanner* Card reader* Disk

INPUT

PROCESSING UNIT

TEMPALU

PCIR

CONTROL UNIT