1 COMP541 Final Missing Pieces of MIPS: Adding Memory & I/O Montek Singh Oct 29, 2014
Memory-Mapped I/O Simple technique for accessing I/O give each I/O device a “fake” memory address give each I/O device a “fake” memory address i.e., CPU reads and writes a specific range of memory locations for I/O devices i.e., CPU reads and writes a specific range of memory locations for I/O devices using lw and sw pretending I/O devices were simply memory locations net effect is reading and writing I/O each device is assigned its own range of memory each device is assigned its own range of memory “address space” example: example: data memory from ’h0000_2000 to ’h0000_3FFF VGA display (screen memory) from ’h0000_4000 to ’h0000_40FF joystick status at ’h0000_6000 mouse status at ’h0000_6004 keyboard status at ’h0000_6008 … etc. 2
Memory-Mapped I/O Putting data mem at 0x2000 also helps with MARS “Compact, Text at 0” puts data at 0x2000 “Compact, Text at 0” puts data at 0x2000 data mem data mem screen mem screen mem 0x x0000 3FFF x x0000 4FFF joystick/kbd 0x gap 0x (the upper limit will depend on your screen size)
data mem data mem screen mem screen mem 0x x0000 3FFF x x0000 4FFF joystick/kbd 0x gap starting at Multicycle MIPS (later) Can combine data and instr memories into one MARS assumes this type of unified memory MARS assumes this type of unified memory starting at 0x instr mem instr mem
The Big Picture CPU, memory and I/O unit, display and joystick data mem data mem screen mem screen mem joystick/kbd pass thru VGA Display Driver memory mapper MIPS Memory and I/O Unit 2 read ports 1 write port 1 read port 1 write port instr mem instr mem
6 Adding I/O Look at memory-mapped I/O Conceptually like this
7 In Reality Isolated from CPU On standard buses PCI PCI Ours will typically be simpler Just memory addresses Just memory addresses
Memory Mapping How to do in Verilog? Let’s do this interactively! Let’s do this interactively! 8
9 Joystick, mouse, etc. You’ll add joystick or keyboard (or both) into memory locations that you can read e.g., at two locations right above character memory e.g., at two locations right above character memory I will show you next week
10 How Does Processor Begin? One way is to initialize PC to 0 or some other predefined address or some other predefined address Another possibility is to have a reset each time you hit a reset button, PC starts again at 0 each time you hit a reset button, PC starts again at 0 Make sure to have instructions there Modern computers have flash memory to boot CPU or go to configuration utility Modern computers have flash memory to boot CPU or go to configuration utility On (very) old computers had to enter boot program on front panel On (very) old computers had to enter boot program on front panel
Summary Add I/O to complete the MIPS processor I/O is “memory-mapped” I/O is “memory-mapped” shares the address space with memory different regions of memory reserved for data mem, display, input devices, etc. Final Project: start thinking about what you want for your demo! start thinking about what you want for your demo! 11