Skip to end of metadata
Go to start of metadata

Goals: 

The purpose of Project 4: Programmable Lights is to create a programmable lights display by creating a simple state machine. This simple state machine will be able to carry out eight different kinds of instructions and read a program consisting of 16 instructions. These instructions will be displayed on the light register. One of the main goals for this project is to have a better understanding of ALUs. An ALU is an arithmetic logic unit and is a digital circuit that is able to perform arithmetic and logical operations. However, instead of performing arithmetic operations, a Moore Machine was used to program the lights and create a fun pattern. In order to create these specific patterns on the 8-bit light registers, instructions for the lights were stored in a simple read-only memory(ROM) using VHDL. After, lights.vhd was then written and used to create a control circuit to execute the program. 

Creating a ROM to hold a program:

Lightrom.vhd contains an input(addr)  and an output(data). The input, addr, is a binary integer that holds the order in which the pattern is carried out. The output, data, is an opcode given to the ALU to interpret. There are eight different opcodes and they all hold a different instruction for the light registers to carry out. For example, the opcode "011" adds 1 to the light register and the opcode "101" inverts all of the bits of the light register. These opcodes and instructions were created based on the given table. The instructions for the opcodes are held in lights.vhd. 

Creating the control circuit to execute the program:

The control circuit, lights.vhd, contains the inputs clk and reset. The clock input is used as asignal to control the timing of the circuit and the reset input is used to reset the Moore Machine to its starting state. The control circuit also contains the outputs lights, IRView, and PCView. The lights signal is an 8-bit standard logic vector that sends signals to the green LED lights on the board, the IRView signal is a 3-bit standard logic vector that monitors the values of the IR registers which are displayed in the redLED lights, and the PCView signal is a 4-but standard logic vector that monitors the values of the PC registers which are displayed in the redLED lights. The internal signals in lights.vhd are IR, PC, ROMvalue, and state. IR is a 3-bit standard logic vector that takes the ROMvalue during the fetch state. PC is a 4-bit unsigned that increments the address binary integer shown in the ROM. ROMvalue is a 3-but standard logic vector that takes in the data output shown in ROM. LR is a 8-bit unsigned light register that creates the light pattern based off of the opcodes in the execute state. Slow clock is a standard logic and is used to slow down the circuit and see the pattern at a reasonable pace on the board.  

Connecting the ROM to the control circuit:

In order to connect the ROM to the control circuit, I had to take the port statement from the lightrom circuit and copypaste it into lights.vhd. After doing so, I had to make an instance of lightrom with a port map statement. By doing so, I was able to connect the addr input of to the PC signal and data output to the ROMvalue signal. 

Simulating the circuit: gtkwave

Hardware Testing:


To test my light show using the board, I checked whether or not the green lights followed the pattern represented in each of my lightroms. In my lightroms, I commented the expected patterns and looked at which lights lit up and checked if it corresponded with the given pattern. For example, if the expected pattern is "11110000" then the 1's should light up in the register. The first four lights on the left should light up while the right lights should remain off. 

lightrom: 

lightrom2: 

lightrom3: 



Extensions:

Extension #1: Make a Longer Program

In order to make the program longer, I needed to change the address from 4-bits to 5-bits. In extlights.vhd, I changed PC from (3 downto 0) to (4 downto 0) and in extlightrom.vhd, I changed addr from (3 downto 0) to (4 downto 0). I also needed to add a '0' in front of all of the previous four-bit binary integers in extlightrom.vhd. For example, instead of using the address "01100" I would have to use the address "001100". These two are the same numbers but I have to add the extra 0 in front in order to make the binary integer a 5 bit number. After doing so, I continued making the 5-bit numbers until I reached the highest 5-bit number. By doing this, there are 32 instructions in the pattern instead of the original 16.

Extension #2: Adding a hold Button

In order to make a hold button, I created a std_logic input called 'holding' and an unsigned signal called hold in extlights.vhd. I made hold start at the same point as counter at "00000000000000000000000000". When the user pressed down on the hold button, the light display paused at the point the counter was at. This was done by making hold <= counter. I used the pin assignments to create the hold button.

Extension #3: Using toggle switches to speed up/slow down the light-show

In this extension I added three extra inputs: fast, faster, and fastest. I assigned each of the inputs to a specific toggle, using the pin planner. I assigned each toggle to a specific speed. The original and default speed is counter(24). If the user flipped toggle SW0 then the speed would get faster at counter(22). If the user flipped toggle SW1, the display would run faster at counter(20). If the user flipped toggle SW3, then the speed would be at its fastest at counter(19). 

Extension #4: Making the light-show go along with a song

Because I was able to control the speed of the light display with my toggle switched, I thought it would be fun to make the light display play to the rhythm of a song. As a result, it would almost be like a real lightshow. I did this by recording the light display, controlling the speed with the toggles, and placing the song over the video using iMovie (I didn't want to play the music out loud and disturb my fellow computer scientists around me!) I put the song Bohemian Rhapsody on top of the light display. The video was too long to post here so it will be on my folder. Please watch the whole thing (smile)

Conclusion:

One of the main lessons I've learned in this project was how to create circuits without using a Block Diagram/Schematic File. It was much simpler writing the circuit in VHD and less tedious. It would have been very time consuming to create the circuit. In addition, I gained a better understanding of ALUs and how opcodes are used to carry out various instructions. This project was very fun and creative!

People Worked With:

Bruce

Deka

Labels