27
1 COMP541 COMP541 Completing the MIPS Completing the MIPS Datapath Datapath Montek Singh Montek Singh Mar 27, 2007 Mar 27, 2007

1 COMP541 Completing the MIPS Datapath Montek Singh Mar 27, 2007

  • View
    218

  • Download
    0

Embed Size (px)

Citation preview

Page 1: 1 COMP541 Completing the MIPS Datapath Montek Singh Mar 27, 2007

1

COMP541COMP541

Completing the MIPS Completing the MIPS DatapathDatapath

Montek SinghMontek Singh

Mar 27, 2007Mar 27, 2007

Page 2: 1 COMP541 Completing the MIPS Datapath Montek Singh Mar 27, 2007

2

Datapath LabDatapath Lab Last Friday’s lab: Included thisLast Friday’s lab: Included this

Need more: also memory/controlNeed more: also memory/control

Page 3: 1 COMP541 Completing the MIPS Datapath Montek Singh Mar 27, 2007

3

Next few labsNext few labs March 30: lw and sw and branchingMarch 30: lw and sw and branching April 6: Complete CPU (Holiday?)April 6: Complete CPU (Holiday?)

Add VGA, keyboard/joystickAdd VGA, keyboard/joystick

Page 4: 1 COMP541 Completing the MIPS Datapath Montek Singh Mar 27, 2007

4

Next LabNext Lab Implement the lw and sw instructions.Implement the lw and sw instructions. The address for lw/sw generated by ALUThe address for lw/sw generated by ALU

FormatFormat

sw $r1, 100($r2)sw $r1, 100($r2) Store contents of register 1 toStore contents of register 1 to address $r2 + 100address $r2 + 100

Implement branch instructionsImplement branch instructions

Page 5: 1 COMP541 Completing the MIPS Datapath Montek Singh Mar 27, 2007

5

Store WordStore Word EasierEasier Just disable writing to registerJust disable writing to register Set an address and write to memorySet an address and write to memory

Could use second memory port and write on same Could use second memory port and write on same cycle as next instructioncycle as next instruction

Let’s look at block diagram…Let’s look at block diagram…

Page 6: 1 COMP541 Completing the MIPS Datapath Montek Singh Mar 27, 2007

6

Block Diagram (just lw/sw)Block Diagram (just lw/sw)

Page 7: 1 COMP541 Completing the MIPS Datapath Montek Singh Mar 27, 2007

7

R-Type and lw/swR-Type and lw/sw

Page 8: 1 COMP541 Completing the MIPS Datapath Montek Singh Mar 27, 2007

8

Load WordLoad Word Need to determine memory addressNeed to determine memory address

Using ALUUsing ALU

Then need to read memory and write to Then need to read memory and write to registerregister

Page 9: 1 COMP541 Completing the MIPS Datapath Montek Singh Mar 27, 2007

9

CarefulCareful If you use one memory port, your instruction If you use one memory port, your instruction

will disappearwill disappear You could use the other memory portYou could use the other memory port Could add an instruction registerCould add an instruction register

More complex controlMore complex control

Harvard Architecture another possibilityHarvard Architecture another possibility

Page 10: 1 COMP541 Completing the MIPS Datapath Montek Singh Mar 27, 2007

10

Sign ExtensionSign Extension Don’t get sidetracked into complexityDon’t get sidetracked into complexity Just extend value of bit 15 to upper 16 bitsJust extend value of bit 15 to upper 16 bits

How?How?

Page 11: 1 COMP541 Completing the MIPS Datapath Montek Singh Mar 27, 2007

11

BranchingBranching Add beq (branch on equal)Add beq (branch on equal) That should give enough breadth to actually That should give enough breadth to actually

write full programswrite full programs

Page 12: 1 COMP541 Completing the MIPS Datapath Montek Singh Mar 27, 2007

12

Resulting MIPS DatapathResulting MIPS Datapath

Page 13: 1 COMP541 Completing the MIPS Datapath Montek Singh Mar 27, 2007

13

With ControlWith Control

Page 14: 1 COMP541 Completing the MIPS Datapath Montek Singh Mar 27, 2007

14

MemoryMemory AddressingAddressing

Byte address or word address?Byte address or word address?

Page 15: 1 COMP541 Completing the MIPS Datapath Montek Singh Mar 27, 2007

15

The MIPS DatapathThe MIPS Datapath

Page 16: 1 COMP541 Completing the MIPS Datapath Montek Singh Mar 27, 2007

16

Expanding Memory BlockExpanding Memory Block First let’s look in detail at data memory blockFirst let’s look in detail at data memory block See how to add block memoriesSee how to add block memories Add I/OAdd I/O

Page 17: 1 COMP541 Completing the MIPS Datapath Montek Singh Mar 27, 2007

17

Memory Block SignalsMemory Block Signals

Address – 32 bits

Write Data – 32 bits

Read Data – 32 bits

Mem Write – 1 bit

Mem Read – 1 bit

Page 18: 1 COMP541 Completing the MIPS Datapath Montek Singh Mar 27, 2007

18

Using 2 Block RAMsUsing 2 Block RAMs Illustration from bookIllustration from book Let’s work it out for Block RAMs Let’s work it out for Block RAMs Specs nextSpecs next

Page 19: 1 COMP541 Completing the MIPS Datapath Montek Singh Mar 27, 2007

19

Block RAM SpecsBlock RAM Specs

Try 2 256x16Try 2 256x16

Page 20: 1 COMP541 Completing the MIPS Datapath Montek Singh Mar 27, 2007

20

Adding More MemoryAdding More Memory Illustration from Illustration from

texttext Could add 2 more Could add 2 more

block RAMs to block RAMs to increase mem to increase mem to 512 words512 words

Page 21: 1 COMP541 Completing the MIPS Datapath Montek Singh Mar 27, 2007

21

Memory MapMemory Map Refers to how physical memory is populatedRefers to how physical memory is populated In our example, memory from 0 to 511In our example, memory from 0 to 511

It’s in two blocks, but that’s invisible to programmerIt’s in two blocks, but that’s invisible to programmer

Page 22: 1 COMP541 Completing the MIPS Datapath Montek Singh Mar 27, 2007

22

Another Portion of MemoryAnother Portion of Memory Let’s see how to add a block of x8 character Let’s see how to add a block of x8 character

memory for the VGAmemory for the VGA Need to make 24 bits be zeroNeed to make 24 bits be zero

Page 23: 1 COMP541 Completing the MIPS Datapath Montek Singh Mar 27, 2007

23

Memory MapMemory Map

Instruction and Data Memory

Empty

CharacterMemory

0

01 0000 0000 -256

10 0000 0000 512

Page 24: 1 COMP541 Completing the MIPS Datapath Montek Singh Mar 27, 2007

24

Adding I/OAdding I/O Look at memory-mapped I/OLook at memory-mapped I/O Conceptually like thisConceptually like this

Page 25: 1 COMP541 Completing the MIPS Datapath Montek Singh Mar 27, 2007

25

In RealityIn Reality Isolated from CPUIsolated from CPU On standard busesOn standard buses

PCIPCI

Ours will be simplerOurs will be simpler Just memory addressesJust memory addresses

Page 26: 1 COMP541 Completing the MIPS Datapath Montek Singh Mar 27, 2007

26

LaterLater You’ll add joystick or keyboard (or both) into You’ll add joystick or keyboard (or both) into

memory locations that you can readmemory locations that you can read

Page 27: 1 COMP541 Completing the MIPS Datapath Montek Singh Mar 27, 2007

27

How Does Processor Begin?How Does Processor Begin? One way is to initialize PC to 0One way is to initialize PC to 0 Make sure to have instructions thereMake sure to have instructions there

Real computers have flash memory to boot CPU or go Real computers have flash memory to boot CPU or go to configuration utilityto configuration utility

On (very) old computers had to enter boot program On (very) old computers had to enter boot program on front panelon front panel