Title image Fall 2019

Lab 5: Machine instructions

The purpose of this lab is to go over the new design for a programmable light display. The new design has a more complex instruction set that enables more general purpose programs.

Programmable Circuit Design

The project this week involves designing a more general programmable circuit that includes branching. The conceptual organization of the circuit is shown below.

The program is stored in the ROM. The accumulator and light register are general purpose 8-bit registers. The IR holds the current instruction, and the PC holds the address of the next instruction.

We will implement four types of instructions for this circuit: move, binary operations, unconditional branch, and a conditional branch. The move instruction will copy bits from a source to a destination. The binary operations will execute some binary operation on two source operands and write the result to a destination. One of the source operands will also be the destination. The unconditional branch will write an address value from the IR to the PC. The conditional branch will write an address value from the IR to the PC only if the selected test register (ACC or LR) is equal to 0.

The instruction set for this machine will be 10 bits. The two leftmost bits, C0 and C1, will always specify the type of instruction. The remaining bits will specify the rest of the required information. The table below shows the organization of the four instructions.

00[C1 C0] [Dest1 Dest0] [Src1 Src0] [Val3 Val2 Val1 Val0]Move from
Dest10: 00 = ACC, 01 = LR, 10 = ACC low 4 bits, 11 = ACC high 4 bits
Src10: 00 = ACC, 01 = LR, 10 = IR low 4 bits sign extended, 11 = all 1s
01[C1 C0] [Op2 Op1 Op0] [Src1 Src0] [Dest0] [Val1 Val0]Binary operator
Op210: 000 = add, 001 = sub, 010 = shift left, 011 = shift right maintain sign bit
Op210: 100 = xor, 101 = and, 110 = rotate left, 111 = rotate right
Src10: 00 = ACC, 01 = LR, 10 = IR low 2 bits sign extended, 11 = all 1s
Dest0: 0 = ACC, 1 = LR
10[C1 C0] [U3 U2 U1 U0] [Addr3 Addr2 Addr1 Addr0]Branch to ADDR
11[C1 C0] [Src0] [U2 U1 U0] [Addr3 Addr2 Addr1 Addr0]Branch to ADDR if SRC is 0
Src0: 0 = ACC, 1 = LR

Bits labeled as UX are unused and can be set to any value.


  1. Write a program for this circuit

    Try writing a program, by hand, that does the following.

    Load an alternating series of bits, 10101010 into the light register. Then make the register switch back and forth between 10101010 and 01010101 eight times. The program should then return to the beginning. Use a loop to repeat the instruction.

    Here is one possible solution

When you have completed the lab assignment, go ahead and get started on the current project.