31
LC3-2 Page 1 © 2003-2008 BYU ECEn 224 LC3-2 The LC-3 Datapath IR PC enaMARM enaPC enaALU enaMDR ALU A B

LC3-2 The LC-3 Datapath

  • Upload
    kale

  • View
    227

  • Download
    1

Embed Size (px)

DESCRIPTION

enaMARM. enaPC. PC. B. A. ALU. IR. enaALU. enaMDR. LC3-2 The LC-3 Datapath. Datapath Strategy. Take datapath elements one-by-one Determine how each works Clearly identify inputs/outputs and needed control Design the element When all done, doing control is straightforward… - PowerPoint PPT Presentation

Citation preview

Page 1: LC3-2 The LC-3  Datapath

LC3-2Page 1

© 2003-2008BYU

ECEn 224

LC3-2The LC-3 Datapath

IR

PC

enaMARM enaPC

enaALU

enaMDR

ALUAB

Page 2: LC3-2 The LC-3  Datapath

LC3-2 Page 2

© 2003-2007BYU

ECEn/CS 224

Datapath Strategy Take datapath elements one-by-one

Determine how each works

Clearly identify inputs/outputs and needed control

Design the element

When all done, doing control is straightforward… Push all the complexity into the datapath that we can

Page 3: LC3-2 The LC-3  Datapath

LC3-2 Page 3

© 2003-2007BYU

ECEn/CS 224

IR

PC

enaMARM enaPC

enaALU

enaMDR

ALU

The Bus Four major drivers:

MARMUX, PC, ALU, MDR

It is the means of data transfer between units.

AB

Page 4: LC3-2 The LC-3  Datapath

LC3-2 Page 4

© 2003-2007BYU

ECEn/CS 224

IR

PC

enaMARM enaPC

enaALU

enaMDR

ALU

Tri-State Drivers

module ts_driver ( din, dout, en ); input [15:0] din; output [15:0] dout; input en; assign dout = en ? din : 16’hZZZZ;endmodule

dout

en

din

AB

dout[n]

en

din[n]

16 16

Page 5: LC3-2 The LC-3  Datapath

LC3-2 Page 5

© 2003-2007BYU

ECEn/CS 224

More Tri-State Lots of drivers and lots of listeners

Only one driver on at any time It’s a distributed MUX!

Bus

MARMUX

PC

MDR

ALUenaALU

enaMDRenaMARM

enaPC

Be careful!If more than one driver is on at once there will be contention on the bus with unpredictable results

Page 6: LC3-2 The LC-3  Datapath

LC3-2 Page 6

© 2003-2007BYU

ECEn/CS 224

Typical Tri-State Drivers

dout

en

din

en din dout0 0 Z0 1 Z1 0 01 1 1

t din dout0 0 00 1 11 0 Z1 1 Z

dout

t

din

Page 7: LC3-2 The LC-3  Datapath

LC3-2 Page 7

© 2003-2007BYU

ECEn/CS 224

IR

PC

enaMARM enaPC

enaALU

enaMDR

ALU

An adder, two muxes, and three sign extenders

Signals:

IR[10:0] Ra[15:0] PC[15:0] selEAB1 selEAB2[1:0] eabOut[15:0]

The Effective Address Block

selMAR -

– selEAB1selEAB2 –

AB

Page 8: LC3-2 The LC-3  Datapath

LC3-2 Page 8

© 2003-2007BYU

ECEn/CS 224

The Effective Address BlockWhy are there 3 different sign extenders?

LD

LDR

JSR

0 0 1 0 DR PCoffset9

0 1 1 0 DR BaseR Offset6

0 1 1 0 1 PCoffset11

Page 9: LC3-2 The LC-3  Datapath

LC3-2 Page 9

© 2003-2007BYU

ECEn/CS 224

Designing the EAB

eabOut[15:0]

PC[15:0]

selEAB1

EABRa[15:0]

IR[10:0]

selEAB2[1:0]

Page 10: LC3-2 The LC-3  Datapath

LC3-2 Page 10

© 2003-2007BYU

ECEn/CS 224

IR

PC

enaMARM enaPC

enaALU

enaMDR

ALU

The MARMUX Simply a MUX and a zero extender

Signals:

IR[7:0] eabOut[15:0] selMAR MARMUXOut[15:0] selMAR –

AB

Page 11: LC3-2 The LC-3  Datapath

LC3-2 Page 11

© 2003-2007BYU

ECEn/CS 224

Designing the MARMUX

MARMUXOut[15:0]

selMAR

MARMUXeabOut[15:0]

IR[7:0]

Page 12: LC3-2 The LC-3  Datapath

LC3-2 Page 12

© 2003-2007BYU

ECEn/CS 224

IR

PC

enaMARM enaPC

enaALU

enaMDR

ALU

The PC A register, MUX, and an incrementer

Signals:

clk reset selPC[1:0] eabOut[15:0] ldPC PCOut[15:0] Buss[15:0]

– ldPC

– selPC

AB

Page 13: LC3-2 The LC-3  Datapath

LC3-2 Page 13

© 2003-2007BYU

ECEn/CS 224

Designing the PC

PCOut[15:0]ldPC

selPC[1:0]

PC

reset

clk

eabOut[15:0]

NOTE: Be sure your PC initializes to 0 on a global reset

Buss[15:0]

Page 14: LC3-2 The LC-3  Datapath

LC3-2 Page 14

© 2003-2007BYU

ECEn/CS 224

IR

PC

enaMARM enaPC

enaALU

enaMDR

ALU

The IR Simply a loadable register, loads from bus when enabled for

loading

Signals:

clk reset ldIR Buss[15:0] IR[15:0]

– ldIR

AB

Page 15: LC3-2 The LC-3  Datapath

LC3-2 Page 15

© 2003-2007BYU

ECEn/CS 224

Designing the IR

ldIR

IR[15:0]

Buss[15:0]

IR

clkreset

Page 16: LC3-2 The LC-3  Datapath

LC3-2 Page 16

© 2003-2007BYU

ECEn/CS 224

IR

PC

enaMARM enaPC

enaALU

enaMDR

ALU

The nzp Flags Loadable registers which

contain flags. Load on some reg writes Decode bus to determine

flag values Signals:

clk reset flagWE Buss[15:0] N Z P

– flagWEAB

Page 17: LC3-2 The LC-3  Datapath

LC3-2 Page 17

© 2003-2007BYU

ECEn/CS 224

Designing the nzp Flags

flagWE

Buss[15:0]

clk

N Z P

NZPreset

How many of N, Z, P can be high at one time?

Page 18: LC3-2 The LC-3  Datapath

LC3-2 Page 18

© 2003-2007BYU

ECEn/CS 224

IR

PC

enaMARM enaPC

enaALU

enaMDR

ALU

The ALU Has 4 functions:

add, and, not, pass

One operand always comes from regfile, other from mux

Signals:

Ra[15:0] Rb[15:0] IR[4:0] IR[5] aluControl[1:0] aluOut[15:0]

aluControl –

IR[5] –

Rb – Ra –

AB

Page 19: LC3-2 The LC-3  Datapath

LC3-2 Page 19

© 2003-2007BYU

ECEn/CS 224

The Operate Instructions

Page 20: LC3-2 The LC-3  Datapath

LC3-2 Page 20

© 2003-2007BYU

ECEn/CS 224

Designing the ALU

IR[4:0]

aluOut[15:0]

ALU

Ra[15:0]

Rb[15:0]

aluControl[1:0]

IR[5]

Page 21: LC3-2 The LC-3  Datapath

LC3-2 Page 21

© 2003-2007BYU

ECEn/CS 224

IR

PC

enaMARM enaPC

enaALU

enaMDR

ALU

The Memory Writes on clock edge

when memWE=1 Data read from and

written to memory passes through MDR

The MDRMUX controls where data is loaded from

Signals:

clk resetselMDRldMARmemWE ldMDRBuss[15:0]mdrOut[15:0]

mem

WE

ldMA

R ldM

DR

selMD

R

AB

Page 22: LC3-2 The LC-3  Datapath

LC3-2 Page 22

© 2003-2007BYU

ECEn/CS 224

Designing the MemoryBuss[15:0]

memWE

clk

MemoryldMDR

mdrOut[15:0]

selMDR

ldMAR

reset

Page 23: LC3-2 The LC-3  Datapath

LC3-2 Page 23

© 2003-2007BYU

ECEn/CS 224

IR

PC

enaMARM enaPC

enaALU

enaMDR

ALU

The Register File Triple-ported

memory (2 read ports, 1 write port)

Synchronous write, asynchronous read

Signals:

clk reset regWE DR[2:0]

SR1[2:0] SR2[2:0] Ra[15:0] Rb[15:0] Buss[15:0]

(regWE)

Rb Ra

AB

Page 24: LC3-2 The LC-3  Datapath

LC3-2 Page 24

© 2003-2007BYU

ECEn/CS 224

Register File Signals DR is either “111” (subroutine call) or comes from

IR[11:9]

SR2 is always IR[2:0]

SR1 changes depending on the instruction IR[11:9] on STI, ST IR[11:9] in one state associated with STR “111” on RET (same as IR[8:6]) IR[8:6] otherwise

regWE is generated by the control block

Page 25: LC3-2 The LC-3  Datapath

LC3-2 Page 25

© 2003-2007BYU

ECEn/CS 224

LC-3 Instructions

Page 26: LC3-2 The LC-3  Datapath

LC3-2 Page 26

© 2003-2007BYU

ECEn/CS 224

Building the Register FileBuss[15:0]

clk

DR[2:0]

regWERegFile

Ra[15:0]

Rb[15:0]

SR1[2:0]SR2[2:0]

reset

Page 27: LC3-2 The LC-3  Datapath

LC3-2 Page 27

© 2003-2007BYU

ECEn/CS 224

Reg B

Reg0

Reg1

Reg2

Reg3

Reg4

Reg5

Reg6

Reg7

WriteDecoder

DR[2:0] WE

Reg

iste

r writ

e si

gnal

s

D[15:0](Buss)

CLK

SR1

8:1 MUX

SR2

Reg A

Building the Register File

Page 28: LC3-2 The LC-3  Datapath

LC3-2 Page 28

© 2003-2007BYU

ECEn/CS 224

Each element of the datapath can be considered independently, designed independently, and debugged independently

Once this has been done the control can be easily completed

Building the Machine

Page 29: LC3-2 The LC-3  Datapath

LC3-2 Page 29

© 2003-2007BYU

ECEn/CS 224

The LC-3

flagWE

Page 30: LC3-2 The LC-3  Datapath

LC3-2 Page 30

© 2003-2007BYU

ECEn/CS 224

The LC-3

flagWE

Page 31: LC3-2 The LC-3  Datapath

LC3-2 Page 31

© 2003-2007BYU

ECEn/CS 224

LC3Datapath

ControlSignals

ProgrammedMemory

IR

N,Z,P

LC3Controller