Skip to end of metadata
Go to start of metadata

1. Summary

In this project, I built a more sophisticated programmable light display using both conditional and unconditional branching, enabling loops in my program.

2. Tasks

Instruction Set:

OpcodeFormatDescription
00[C1 C0] [Dest1 Dest0] [Src1 Src0] [Val3 Val2 Val1 Val0]Move from 
SRC to DEST
 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
DEST = DEST op SRC
 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


Task 6: Test the circuit

I used the VHDL file testbench.


Task 7: Write a program that loads 16 into the light register and has it count down to 0. Then it should flash between all 1s and all 0s 8 times and repeat from the beginning.

Testing using GTKWave:


Testing using the board:

pldrom.mp4


Task 8: Write two more programs

My first program using branching:

It counts up to 7, rotates right 7 times, and repeats from the beginning

Testing using the board:

pldrom1.mp4

 

My second program:

It flashes between 10101010 and 01010101 ten times

pldrom2.mp4

 

3. Extensions 

1) Write a simple assembler that converts instructions from a simple, human readable language, into the set of machine instructions for your pldrom.

I wrote my Assembler in java and used Scanner to read human instructions from Terminal. 

The assembler asks the user the type, destination, source, value, operation, and address.

 

Here is an example of converting an instruction (xor LR with all 1s) to machine code in Terminal:

The output/converted machine code is 011001110, as shown above.


2) Make longer programs (make the ROM bigger)

I modified the branch instructions so that each address is 5 bits.

OpcodeFormatDescription
00[C1 C0] [Dest1 Dest0] [Src1 Src0] [Val3 Val2 Val1 Val0]Move from 
SRC to DEST
 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
DEST = DEST op SRC
 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] [U2 U1 U0] [Addr4 Addr3 Addr2 Addr1 Addr0]Branch to ADDR
11[C1 C0] [Src0] [U1 U0] [Addr4 Addr3 Addr2 Addr1 Addr0]Branch to ADDR if SRC is 0
 Src0: 0 = ACC, 1 = LR

In my loner_pldrom, I made the addresses 5-bit long, doubled the length of the program, and used branching 4 times.

In longer_pld2, I also changed the length of bits of PC.


longer_pldrom.mp4

I speeded up the program and this video shows two repeated loops.


3) Write more programs

I wrote a program that lights up LEDs one by one from right to left, and then turns them off one by one from right to left in pldrom3.

When it finishes a loop, the program goes to the beginning and starts to display the same patterns again.

pldrom3.mp4

 

4) Add a hold/freeze button to the display

In my pld2, I added an input hold that could freeze the program. I used an if statement in the process where the counter gets incremented only when the 'hold' button is not pressed(which is 1).

 

Testing using the board:

hold.mp4

The 'hold' button is the second from the right(KEY[1]). When I pressed it, the counter paused and the lights stayed unchanged.


5) Add buttons that let you speed up or slow down the clock

I added two buttons to speed up and slow down the display.

Firstly, I added inputs speedUp and slowDown in my pld2.

Next, I assigned different bits of the counter to the slowclock based on which button is pressed.


Testing using the board:

speed.mp4

The leftmost button is 'speedUp' and the second button from the left is 'slowDown.'

 

4. Credit

Mike Zheng

Labels