CS122B Homework Assignment 1

Objective

To understand and compare the speed of processor emulation to the actual execution time (running on chip) or simulation time (running under a VHDL simulator).

Description

You are to implement an emulator for the 8051. Your emulator can be implemented in C, C++ or Java. The 8051 has 111 instruction. Your emulator should support all these instructions except for the return from interrupt and move external memory instructions. Here is a more precise list of what you have to do:

    1. Implement the 106 instructions.
    2. Load a hex file (see below).
    3. On startup, initialize the 4 8-bit output ports to "11111111".
    4. After the execution of each instruction, output the content of the 4 ports to the console.
    5. Name your emulator "emu8051", taking 1 parameter "file-name.hex".

And here is what you don't have to worry about:

    1. Access to external memory and related instructions.
    2. Interrupt related instructions.
    3. Peripherals (timers, counters, UARTSs, etc.)

Deliverables

You are to work in groups, as assigned for the class project, and turnin the following by Thursday the 1/14/99:

    1. Source code for your emulator.
    2. Make file or instruction on how to compile.

The grader should be able to compile a C program using Keil and run it on your emulator and see the content of the 4 output ports on the console after the execution of each instruction in the program. Note, you will be allowed to borrow 8051 manuals. You may use main.c and main.hex to test your emulator.

Hex File Format

This example shows you the format used in a hex file:

:10008000AF5F67F0602703E0322CFA92007780C361
:1000900089001C6B7EA7CA9200FE10D2AA00477D81
:0B00A00080FA92006F3600C3A00076CB
:00000001FF

Now look at the top line...

The last line of the file is special, and will always look like that above.

Record types: