Flip-Flop One-bit Memory Something to Remember What I Remember D - - PowerPoint PPT Presentation

flip flop
SMART_READER_LITE
LIVE PREVIEW

Flip-Flop One-bit Memory Something to Remember What I Remember D - - PowerPoint PPT Presentation

Flip-Flop One-bit Memory Something to Remember What I Remember D Q Remember Now! What I Remember Q Chapter 5 Edge-Triggered 1 3 CSc 314 T W Bennet Mississippi College CSc 314 T W Bennet Mississippi College State


slide-1
SLIDE 1

Chapter 5

CSc 314 · T W Bennet · Mississippi College

1

State

  • Combinational Elements: Adder
  • State Elements: Storage

CSc 314 · T W Bennet · Mississippi College

2

Flip-Flop

  • One-bit Memory

Something to Remember What I Remember What I Remember Remember Now!

Q Q’ D

  • Edge-Triggered

CSc 314 · T W Bennet · Mississippi College

3

Register

A collection of flip-flops

Q Q’ D Q Q’ D Q Q’ D Q Q’ D

CSc 314 · T W Bennet · Mississippi College

4

slide-2
SLIDE 2

State Machines

  • Stored bit describes the state of the object.
  • A clock generates a regular pattern of voltage changes.
  • The state changes when the clock “ticks.”

CSc 314 · T W Bennet · Mississippi College

5 ·

State changes when the clock rises.

CSc 314 · T W Bennet · Mississippi College

6

Counter: A State Machine

Oflow 1

Q Q’ D Q Q’ D Q Q’ D Q Q’ D

CSc 314 · T W Bennet · Mississippi College

7

Clocks and State Machines

  • At each tick, the machine does the “next” thing.
  • The faster the clock, the faster the machine.
  • The clock must be slow enough for changes to

propagate back to the registers during a clock cycle.

  • This is what those computer ads are talking about.

CSc 314 · T W Bennet · Mississippi College

8

slide-3
SLIDE 3

CSc 314 · T W Bennet · Mississippi College

9

Datapath and Control

  • Datapath: Moving, storing, and creating data.
  • Control: Making each of those happen at right place and

time.

CSc 314 · T W Bennet · Mississippi College

10

Building the Datapath

  • Parts.
  • Sub-assemblies.
  • Complete datapath.

CSc 314 · T W Bennet · Mississippi College

11

CSc 314 · T W Bennet · Mississippi College

12

slide-4
SLIDE 4

CSc 314 · T W Bennet · Mississippi College

13

CSc 314 · T W Bennet · Mississippi College

14

Datapath For Fetching

CSc 314 · T W Bennet · Mississippi College

15

Datapath For R-Type Instructions

Read reg 1 Read reg 2 Write reg sreg2 destreg

  • p

shft amt sreg1 funct 6 6 5 5 5 5 CSc 314 · T W Bennet · Mississippi College

16

slide-5
SLIDE 5

Datapath For Loading and Storing

Read Reg 1 Write register Read Reg 2 Others Loads

  • p

6 5 5 Rdest Rbase Offset 16 CSc 314 · T W Bennet · Mississippi College

17

Datapath for Branching

CSc 314 · T W Bennet · Mississippi College

18

Datapath Combined

CSc 314 · T W Bennet · Mississippi College

19

Control

  • Signals the devices what they must do.
  • Interprets the instruction.
  • A large combinational circuit.

CSc 314 · T W Bennet · Mississippi College

20

slide-6
SLIDE 6

Add Control Units

CSc 314 · T W Bennet · Mississippi College

21

ALU Controller

  • Inputs: Low six bits of the instruction (function code),

and two bits sent from the main controller.

sreg2 destreg

  • p

shft amt sreg1 funct 6 6 5 5 5 5

R

  • Outputs: ALU Function selection.

CSc 314 · T W Bennet · Mississippi College

22

ALU Control Signals

ALU Control Input ALU Function 0000 and 0001

  • r

0010 add 0110 subtract 0111 set on less than 1100 NOR

CSc 314 · T W Bennet · Mississippi College

23

Secondary Controller

From Main Func Output 00 XXXXXX 0010 X1 XXXXXX 0110 1X XX0000 0010 1X XX0010 0110 1X XX0100 0000 1X XX0101 0001 1X XX1010 0111 Determine what ALU needs to do based on the main controller’s direction and the function code from the instruction.

CSc 314 · T W Bennet · Mississippi College

24

slide-7
SLIDE 7

Main Control

  • Input: High six bits of the instruction (op code).

sreg2 destreg

  • p

shft amt sreg1 funct 6 6 5 5 5 5

R

  • p

6 5 5

I

Rdest Rbase Offset 16

  • Outputs: RegDst, Branch, MemRead, MemtoReg,

AULOp, MemWrite, ALUSrc, RegWrite.

CSc 314 · T W Bennet · Mississippi College

25

Main Control: Output Signals

Mem- Instruction RegDst ALUSrc toReg RegWrite R-Format 1 1 lw 1 1 1 sw X 1 X beq X X Mem- Mem- ALU ALU Instruction Read Write Branch Op1 Op2 R-Format 1 lw 1 sw 1 beq 1 1

CSc 314 · T W Bennet · Mississippi College

26

Main Control: Input Signals

Op Code: First Six Instruction Bits Instruction Op5 Op4 Op3 Op2 Op1 Op0 R-Format lw 1 1 1 sw 1 1 1 1 beq 1

  • Just a large, combinational circuit.

CSc 314 · T W Bennet · Mississippi College

27

Single-Cycle Implementation

CSc 314 · T W Bennet · Mississippi College

28

slide-8
SLIDE 8

Single-Cycle

Problems:

  • The cycle must be long enough for the longest

instruction.

  • Components must be duplicated, as the second ALU.

A Solution:

  • Shorter cycle.
  • Multiple cycles per instruction.
  • Different numbers of cycles for different instructions.

CSc 314 · T W Bennet · Mississippi College

29

CSc 314 · T W Bennet · Mississippi College

30

Changes for Multi-Cycle

  • A single memory unit for both instructions and data.
  • A single ALU, rather than an ALU and two adders.
  • Add internal registers to hold the results of each cycle for

the next.

CSc 314 · T W Bennet · Mississippi College

31

High-Level View

CSc 314 · T W Bennet · Mississippi College

32

slide-9
SLIDE 9

Full Multi-Cycle Implementation

CSc 314 · T W Bennet · Mississippi College

33

CSc 314 · T W Bennet · Mississippi College

34

CSc 314 · T W Bennet · Mississippi College

35

CSc 314 · T W Bennet · Mississippi College

36

slide-10
SLIDE 10

CSc 314 · T W Bennet · Mississippi College

37

CSc 314 · T W Bennet · Mississippi College

38

CSc 314 · T W Bennet · Mississippi College

39

CSc 314 · T W Bennet · Mississippi College

40

slide-11
SLIDE 11

Multi-Cycle Operation

CSc 314 · T W Bennet · Mississippi College

41

CSc 314 · T W Bennet · Mississippi College

42

CSc 314 · T W Bennet · Mississippi College

43

Control Logic

Compute the Outputs from the Inputs

  • Lots of gates.
  • ROM
  • Etc.

CSc 314 · T W Bennet · Mississippi College

44

slide-12
SLIDE 12

An Alternative: Microcode

CSc 314 · T W Bennet · Mississippi College

45

Address Select Logic

01 11 10 00

ROM 1 ROM 2

Addr In Addr In Data Out Data Out

Next Address (State) Curr Address + 1 Op Code (From IR) Sequence Control (From microinstruction)

Microcontroller Address Select Logic

CSc 314 · T W Bennet · Mississippi College

46

Microinstructions

  • One large instruction for each state.
  • Specifies the signals to generate.
  • Specifies the next instruction.

CSc 314 · T W Bennet · Mississippi College

47

CSc 314 · T W Bennet · Mississippi College

48

slide-13
SLIDE 13

CSc 314 · T W Bennet · Mississippi College

49

CSc 314 · T W Bennet · Mississippi College

50

Exceptions and Interrupts

Jump to the O/S upon certain events. Event Source MIPS Term I/O Device Request External Interrupt User Program Calls O/S (Syscall) Internal Exception Arithmetic Overflow Internal Exception Undefined Instruction Internal Exception Hardware Malfunction Either Either

CSc 314 · T W Bennet · Mississippi College

51

Types of Exceptions

  • Vectored: Jumps to different locations based on type of

exception or interrupt.

  • Cause Register: Store a code for the cause of the

exception in a special register, then jump to a standard place.

  • MIPS uses the later.

CSc 314 · T W Bennet · Mississippi College

52

slide-14
SLIDE 14

MIPS Exception Registers

  • EPC: Holds the address of the offending instruction.
  • Cause: Holds a code for the cause of the exception.

CSc 314 · T W Bennet · Mississippi College

53

Exceptions

For the example implementation, we consider two exceptions

  • Undefined instruction: Code 0.
  • Arithmetic overflow: Code 32.

CSc 314 · T W Bennet · Mississippi College

54

Exception Datapath

CSc 314 · T W Bennet · Mississippi College

55

CSc 314 · T W Bennet · Mississippi College

56