In this lab I wrote a VHDL description for a simple processor, wrote an assembler for it and tested it by loading it onto a hardware simulation board.
The processor is built on the Harvard architecture, with separate data and program memories. This is useful because we can use RAM for the data but ROM for the program. It also allows us to save one bit on our addresses, as it is always clear from context whether an address is for data or for instruction. A two digit signed-hexadecimal output and an 8-bit DIP-switch input are also available to the processor. It has a reset button and a button to resume processing after a WAT ("wait") instruction. It has three addressing modes available: immediate, direct, and register indirect. Each opcode only has one addressing mode it can use. To provide full support for register indirect addressing I needed to add an SMQ ("store the ACC to the address in the MQ") instruction.
|
|
To execute
LIO ADD 00000The processor goes through the following stages:
1. | Fetch1 | : Bring down "LIO". |
2. | Fetch2 | : Set the ACC to the signal from the DIP. |
3. | Fetch1 | : Bring down "ADD 00000". |
4. | Fetch2 | : Set the MAR to "00000". |
5. | AC1 | : Add the contents of the DMF to the FatACC. |
6. | AC2 | : Set the ACC to a shrunken FatACC and set flags. |
You can see it executing these steps in the simulator below:
The IO is mostly simple, connecting the DIPs through to the CPU. The display is a little more complicated, as converting the 8-bit output to the appropriate settings of the 15 segments requires many cases.
"java AssemToo input.jsm
ins_rom.mif"
. It supports variables, loops, pointers, and
arrays.
Some example code:
C | jAssem |
---|---|
int a,b;
| DEF a
|
a += b;
| LAD a
|
a = 2;
| LDD 00000010
|
int c[4];
| DEF c 3
|
for(int i = 0 ; i < 4 ; i++)
|
DEF i
|