Katz: Chapter 6.3
Katz: Chapter 7.2-7.4
The test fixture implements both the instruction memory and the data memory. This test fixture initializes the data memory and the instruction memory and then runs 100 clock cycles (which is long enough for your programs). When it's done, it prints out the first few locations in the data memory. Don't change the test fixture except to try out different programs!
The test fixture contains a simple program that uses all but a few of the instructions. Use can this program to test and debug your processor. Feel free to write new programs and mail them to the class. We will give you a program next week that tests all the instructions.
Change the processor by adding a register on the output of the ALU so that the result is saved in this register and then written back on the next clock cycle. Of course, we still want to execute an instruction every cycle, so this will require some fancy footwork to make this work. (Note that it now take three cycles to perform one instruction, but we complete an instruction every cycle because of pipelining.)
The processor uses two memories, instruction memory, which contains 32 8-bit instructions, and data memory, which contains 16 8-bit words. The processor also has a register file with 4 registers. This processor has the following instruction set:
Mnemonic Format Description -------------------------------------------- LOAD 00 AAAA RR Load register RR with data at address AAAA STORE 01 AAAA RR Store register RR to address AAAA JMP 100 AAAAA Jump to instruction at address AAAAA JMPZ 101 AAAAA Jump to address AAAAA if the last ALU result was zero ADD 1100 SS DD Add register SS to register DD SUB 1101 SS DD Subtract register SS from register DD CLR 111000 RR Clear register RR INC 111001 RR Increment register RR DEC 111010 RR Decrement register RR HALT 11111111 Halt executionThe processor uses two registers to help execute the program, the program counter (PC) and the instruction register (IR). When the processor starts, the PC is set to 0. The processor then executes one instruction at a time, using two clock cycles, as follows:
In the first clock cycle, the instruction memory is read using the PC as the address. This instruction is stored in the IR and the PC is incremented.
In the second clock cycle, the processor executes the instruction in the IR. It does this by asserting the appropriate control signals to the processor datapath (ALU, registers and memories) so that the right thing happens on the next clock tick.