1
COMP541COMP541
Completing the MIPS Completing the MIPS DatapathDatapath
Montek SinghMontek Singh
Mar 27, 2007Mar 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
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
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
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…
6
Block Diagram (just lw/sw)Block Diagram (just lw/sw)
7
R-Type and lw/swR-Type and lw/sw
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
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
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?
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
12
Resulting MIPS DatapathResulting MIPS Datapath
13
With ControlWith Control
14
MemoryMemory AddressingAddressing
Byte address or word address?Byte address or word address?
15
The MIPS DatapathThe MIPS Datapath
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
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
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
19
Block RAM SpecsBlock RAM Specs
Try 2 256x16Try 2 256x16
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
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
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
23
Memory MapMemory Map
Instruction and Data Memory
Empty
CharacterMemory
0
01 0000 0000 -256
10 0000 0000 512
24
Adding I/OAdding I/O Look at memory-mapped I/OLook at memory-mapped I/O Conceptually like thisConceptually like this
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
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
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