Project 1: Combinational Circuits
Due Monday 16 September 2019
Purpose: to give you experience with basic digital design components.
Create a circuit with 4 inputs, treated as a 4-bit positive binary
integer. The circuit should output a 1 if the input is a prime number
and 0 otherwise. Note, the numbers 0 and 1 are not prime numbers.
Simluate your circuit by testing all possible combinations of inputs, similar to the way we tested the circuit in the lab exercise. Take a screen shot of both your final circuit design and your simulation. Include the screen shots in your report. Note, demonstrating that your circuit works is a required part of the project report. Be sure to test your circuit and document that testing in your writeup.
Create a circuit that has two components. One component
should be a counter, which is available as a quartus
module lpm_counter. The important inputs to the counter
are a clock and a reset or clear button. In the counter
wizard process, set the counter to be four bits and check
the box for the asynchronous clear option.
The output of the counter will be a bus with four values. To access individual bits from the bus, add small wires for each input/output and assign labels to them. If you label the bus as q[3..0], then you can access the leftmost bit as q and the other bits as q, q, and q. If you have labeled your circuit inputs as A, B, C, D, you can use a wire gate and label the input to the wire gate as q and the output as A.
Note that the buttons on the board are 0 when you push them
down and 1 otherwise. Therefore, if you want to use a push
button as a reset signal, run the signal through a NOT
gate before feeding it into the counter. Then it will reset
the counter when you push down the button.
The second part of the circuit should be a combinational circuit that controls the six lights of a 4-way traffic light. The output signals are NS-red, NS-green, and NS-yellow, EW-red, EW-green, and EW-yellow. They should follow the timings below, given the 4-bit input from the counter.
Input Values Light setting 0 N/S Red, E/W Red 1-5 N/S Green, E/W Red 6-7 N/S Yellow, E/W Red 8 N/S Red, E/W Red 9-13 N/S Red, E/W Green 14-15 N/S Red, E/W Yellow
Test your circuit by driving the counter with a clock. The easiest way to test it is using the board and having a push-button as the clock input. Demonstrate your six output signals for all possible inputs. You can take a video to demonstrate your circuit working properly.
To use the board, you will need to do the following.
- Select the device Assignments::Device to a Cyclone II FPGA with device number EP2C20F484C7.
- Recompile your circuit.
- Select the output pins using Assignments::Pin Planner. You can get the pin IDs from the DE1 user manual. Use the toggle switches as inputs and the LEDs as outputs.
- Recompile your circuit.
- Get a board from the grey cabinet and plug it into the USB port on the computer body. If the board does not light up, push the big red button on the board.
- Use the Tools::Programmer to program your board. You may have to go to Hardware setup and choose USB-Blaster. You may also have to delete the current file and select the .sof file for your circuit in the output_files subdirectory. If everything is properly set, the Start button will be enabled.
- Click the start button and your board should react. When the lights come back on, your circuit is ready to test.
If you want to test using ghdl, you may want to download this VHDL counter. With your traffic project open, open the counter.vhd file. Then select Project:Add current file to project. Then select File:create/update:make symbol files from current file. After that, replace your lpm_counter with the new counter, reconnect the inputs, and try again. Note that the counter I'm providing has an enable input, which should always be 1 (you can use the symbol vcc to create a 1) and a reset signal, which should start at 1 to reset the counter and then go to 0 a short time later to let the counter run. Make the reset signal be an input to your traffic circuit.
Here is also an example of a testbench for the counter circuit. It shows you how to make a clock of arbitrary length (which might be easier for driving your traffic circuit). You can modify it to drive the traffic light circuit instead of the counter.
Take a screen capture of your final circuit and your simulation. Include them in your project report.
The following are some suggested extensions for the project. You are free to develop your own ideas as well.
- Sometimes, it is more efficient to design the inverse circuit (it outputs 1 for all zeros and 0 for all ones) and invert the output. Explore whether this is the case for one or more of the circuits in this lab.
- Extend the prime numbers circuit to 5 or even 6 bits.
- Do something interesting with the traffic light circuit, like add a walk button that makes the light leave the opposite green early (this is challenging).
- Figure out how to use an FPGA board to test your circuits in addition to doing the simulation. For example, show the traffic light outputs on the board LEDs.
- Pick a different (but simple) function, then go through the design process and implement the circuit.
Create a wiki page with your report. For each task, write a short description of the task, in your own words.
The primary purpose of your report for this class is to demonstrate that you did the assignment and that your circuits work properly. Therefore, your report needs to include pictures of required design documents, a description of your testing procedure, and a description of the results of the testing procedure.
For a simple circuit with a small number of inputs and outputs, your testing procedure might be an exhaustive evaluation of all possible input/output combinations and a visual inspection that they were all correct. For more complex circuits that generate complicated patterns or processes -which we do later in the semester--the demonstration might be a video of the circuit working. Screen captures of the ghdl waveform output is often the best evidence that your circuit is working properly.
- Include a description of the task, in your own words.
- Include a picture of your final design.
- Include a picture of your ghdl waveform simulation.
- Describe why the simulation proves your circuit works.
- If you tested your circuit using hardware, describe your procedure and explain why it is sufficient.
- Include a description, and pictures, of any extensions.
Give your wiki page the label cs232f19project1.
Put your bdf files in a folder called project1 in your private subdirectory on the Courses server in /CS232. Please put only the bdf file into your handin directory, not the whole project.