Docsity

Single Cycle Datapath - Computer Architecture - Lecture Slides, Slides of Computer Science

Partial preview of the text

Download Single Cycle Datapath - Computer Architecture - Lecture Slides and more Slides Computer Science in PDF only on Docsity!

CPSC 321

Computer Architecture

Designing a Single Cycle

Datapath

The Big Picture: Where

are We Now?

  • The Five Classic Components of a Computer
  • Today’s Topic: Design a Single Cycle Processor

Control

Datapath

Memory

Processor Input

Output

How to Design a Processor:

step-by-step

    1. Analyze instruction set => datapath requirements
    • the meaning of each instruction is given by the register transfers
    • datapath must include storage element for ISA registers
      • possibly more
    • datapath must support each register transfer
    1. Select set of datapath components and establish clocking methodology
    1. Assemble datapath meeting the requirements
    1. Analyze implementation of each instruction to determine setting of control

points that effects the register transfer.

    1. Assemble the control logic

The MIPS

Instruction Formats

  • All MIPS instructions are 32 bits long. The three instruction

formats:

  • R-type
  • I-type
  • J-type
  • The different fields are:
  • op: operation of the instruction
  • rs, rt, rd: the source and destination register specifiers
  • shamt: shift amount
  • funct: selects the variant of the operation in the “op” field
  • address / immediate: address offset or immediate value
  • target address: target address of the jump instruction

op target address

6 bits 26 bits

op rs rt rd shamt funct

6 bits 5 bits 5 bits 5 bits 5 bits 6 bits

op rs rt immediate

6 bits 5 bits 5 bits 16 bits

Logical Register

Transfers

  • RTL gives the meaning of the instructions
  • All start by fetching the instruction

op | rs | rt | rd | shamt | funct = MEM[ PC ]

op | rs | rt | Imm16 = MEM[ PC ]

inst Register Transfers

ADDU R[rd] <– R[rs] + R[rt]; PC <– PC + 4

SUBU R[rd] <– R[rs] – R[rt]; PC <– PC + 4

ORi R[rt] <– R[rs] | zero_ext(Imm16); PC <– PC + 4

LOAD R[rt] <– MEM[ R[rs] + sign_ext(Imm16)]; PC <– PC + 4

STORE MEM[ R[rs] + sign_ext(Imm16) ] <– R[rt]; PC <– PC + 4

BEQ if ( R[rs] == R[rt] ) then PC <– PC + 4 +

sign_ext(Imm16)] || 00

else PC <– PC + 4

Step 1: Requirements of the

Instruction Set

  • Memory
    • instruction & data
  • Registers (32 x 32)
    • read RS
    • read RT
    • Write RT or RD
  • PC
  • Extender
  • Add and Sub register or extended immediate
  • Add 4 or extended immediate to PC

Combinational Logic Elements

(Basic Building Blocks)

• Adder

• MUX

• ALU

A

B

Sum

Carry

A

B

Result

OP

A

B

Y

Select

Adder

MUX
ALU

CarryIn

Storage Element: Register

(Basic Building Block)

• Register

– Similar to the D Flip Flop except

• N-bit input and output

• Write Enable input

– Write Enable:

• negated (0): Data Out will not change

• asserted (1): Data Out will become Data

In

Clk

Data In

Write Enable

N N

Data Out

Storage Element:

Idealized Memory

  • Memory (idealized)
    • One input bus: Data In
    • One output bus: Data Out
  • Memory word is selected by:
    • Address selects the word to put on Data Out
    • Write Enable = 1: address selects the memory

word to be written via the Data In bus

  • Clock input (CLK)
    • The CLK input is a factor ONLY during write operation
    • During read operation, behaves as a combinational logic block:
      • Address valid => Data Out valid after “access time.”

Clk

Data In

Write Enable

DataOut

Address

Clocking

Methodology

• All storage elements are clocked by the same

clock edge

• Cycle Time = CLK-to-Q + Longest Delay Path +

Setup + Clock Skew

Clk

Don’t Care

Setup Hold

Setup Hold

3a: Overview of the

Instruction Fetch Unit

  • The common RTL operations
    • Fetch the Instruction: mem[PC]
    • Update the program counter:
      • Sequential Code: PC <- PC + 4
      • Branch and Jump: PC <- “something else”

Instruction Word

Address

Instruction Memory

Clk PC

Next Address Logic

3b: Add &

Subtract

  • R[rd] <- R[rs] op R[rt] Example: addu rd, rs, rt
    • Ra, Rb, and Rw come from instruction’s rs, rt, and rd fields
    • ALUctr and RegWr: control logic after decoding the instruction

Result

ALUctr

Clk

busW

RegWr

busA

busB

Rw Ra Rb

32 32-bit Registers

Rd Rs Rt

ALU

op rs rt rd shamt funct

6 bits 5 bits 5 bits 5 bits 5 bits 6 bits

3c: Logical Operations

with Immediate

• R[rt] <- R[rs] op ZeroExt[imm16] ]

Result

ALUctr

Clk

busW

RegWr

busA

busB

Rw Ra Rb 32 32-bit Registers

Rs

ZeroExt

Mux

Rd Rt RegDst Mux

imm16 16 32

ALUSrc

ALU

op rs rt immediate

6 bits 5 bits 5 bits rd? 16 bits

immediate

16 bits 16 bits

Rt?

3d: Load

Operations

• R[rt] <- Mem[R[rs] + SignExt[imm16]]

Example: lw rt, rs, imm

op rs rt immediate

6 bits 5 bits 5 bits rd 16 bits

ALUctr

Clk

busW

RegWr

busA

busB

Rw Ra Rb 32 32-bit Registers

Rs

Rd Rt RegDst

Extender

Mux

Mux

imm

ALUSrc

ExtOp

Clk

Data In

WrEn

Adr Data Memory

ALU

MemWr x Mu

W_Src

Rt?