



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Lab 2 — Mini-MIPS processor Controller modification, memory mapping, assembly code
Due Tuesday, September 23rd, 2008
To understand and extend a very very simply processor which will give you a start on seeing the bigger picture for your project. In particular:
This may seem like a daunting lab, but break it into pieces and it’s not so bad! First you should read the handout from the book and make sure you understand the processor’s instruction set, and the given Fibonacci code. If you understand what each instruction does, then you should be able to “execute” the program in your head or on paper to see what’s happening. You don’t really need to step through each instruction on paper, but do make sure you understand what’s going on.
I would first take a look at Fig 1.54 and understand the control state machine that makes the processor work. Note that this is a strange little processor - it has 8-bit data paths (thus 8-bit registers), but a 32-bit instruction format. The memory is a 256 word, 8-bit memory. So, each instruction takes 4 bytes, and thus four locations in memory. This means that the instruction fetch portion of the state machine takes four cycles. After those four memory reads, the 32-bit instruction is in the Instruction Register and you can proceed to decode and execute that instruction. If you walk thought the state machine you should be able to understand how each of the instructions in Table 1.7 are executed. This will let you decide how to add the ADDI instruction to the processor. You may need to add states to the state machine. You may need to add other support in the Verilog code. As a hint, if you’re adding a LOT of stuff to the Verilog code you’re probably making it more complex than it needs to be. It’s a fairly simple change to the code. Once you have the ADDI instruction added to the code, you should be able to execute the Fibonacci code in Fib 1.51 in the ISE simulator and make sure that your ADDI is working properly. The code is working properly if it correcly computes the 8th Fibonacci number (starting at 0 the 8th Fibonacci number is 1101 or 0D hex) and stores it in memory location 255. See the exmem.v code on the web site to see both how to implement memory in the Block RAM, and how to initialize that memory with a program. You basically use a data file that Verilog loads into that memory. This data file is also used by the ISE tool when it’s building the Xilinx programming information so that the Block RAM on the FPGA also gets loaded with that data.
Now that you have a working mini-MIPS processor with an ADDI instruction, you should look at modifying the memory system so that you can read a value from the switches and write to the LEDs. The technique to use is to map those I/O devices into the memory space of your mini-MIPS. What this means is that for a certain range of memory addresses, reading and writing to that range of addresses has the side effect of reading or writing to the I/O device instead of actually writing to memory. In this case, you should divide your memory space into four equal sections. The memory for this processor is extremely limited - it’s only 256 memory locations because the address is only 8-bits. For this lab the memory will be divided into four regions of 64 locations each. The first three will be “regular” memory, and the upper section will be I/O. You can decide what region of memory you’re in by looking at the top two address bits. If those top address bits are 00, 01, or 10, you are in “regular” memory. If those top two address bits are 11, then you are in the “I/O” region of memory. If you read from a memory address with 11 in the top two bits you should get the value that’s on the switches. If you write to the an address with 11 in the top two bits you should cause the value to be written to the LEDs. To achieve this memory mapping you will design a circuit that looks at the top two bits of the address
000000 00101 00110 00100 00000 100000
Index Fibonacci Number Dec Bin Dec Bin 0 0000 0 00000000 1 0001 1 00000001 2 0010 1 00000001 3 0011 2 00000010 4 0100 3 00000011 5 0101 5 00000101 6 0110 8 00001000 7 0111 13 00001101 8 1000 21 00010101 9 1001 34 00100010 10 1010 55 00110111 11 1011 89 01011001 12 1100 144 10010000 13 1101 233 11101001