### Project 1: Combinational Circuits

Purpose: to give you experience with basic digital design components.

1. 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.

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.

2. Create a circuit that has two components. One component should be a counter, which is available as a module. The important inputs to the counter are a clock and a reset button.

The second part of the circuit should be a combinational circuit that controls the six lights of a 4-way traffic light. There 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 ValuesLight setting
0N/S Red, E/W Red
1-5N/S Green, E/W Red
6-7N/S Yellow, E/W Red
8N/S Red, E/W Red
9-13N/S Red, E/W Green
14-15N/S Red, E/W Yellow

Test your circuit by driving the counter with a clock. Demonstrate your six output signals for all possible inputs.

Hint: To include a counter in your circuit use the LPM_COUNTER. In the symbol library, under megafunctions, under arithmetic, there is a gate called lpm_counter. Select it. it will pop up a wizard. For the most part, you can accept the default values so when it asks you to choose the width for the q bus, select the right number, then click finish (unless you want to see the remaining options). You will be prompted with a question about automatically adding Quartus II IP files to all projects. I say no. You can too. Then connect an input pin to the clock input as we talked about in lab. You can connect to each of components out the output bus by labeling your wires with things like q[0], q[1], etc.

### Extensions

• Demonstrate that one or more of your outputs are generated by a minimal logic circuit.
• Extend the prime numbers circuit to 5 bits.
• Do something interesting with the traffic light circuit, like add a walk button (this is challengine).
• Explore the capabilities of Quartus or ModelSim. Here is the ModelSim tutorial.