Orientation

Build a counter whose adjacent words differ by one bit

Objective

Apply your Verilog and sequential-logic skills to design the required four-bit reflected Gray counter. Advance it manually, verify all 16 states and the return to state 0, then demonstrate and explain the design.

Required resources
ResourceRequirement
DE0-NanoOne board and USB-Blaster connection
Quartus Prime25.1 Lite Edition with Cyclone IV device support
ReferenceDE0-Nano User Manual, version 1.9
Board care

This activity uses onboard switches and LEDs only. Keep the board on a non-conductive surface, confirm the target device and assignments before programming, and disconnect power before attaching or removing external hardware.

Need a refresher?
→ Gray Code

Required sequence

Record the 16-state reflected Gray sequence

Enter four bits for each regular count. Use B3 as the most-significant bit and B0 as the least-significant bit. Your sequence must begin at 0000, follow the specified reflected ordering, and return from state 15 to state 0 with only one bit changing.

Gray-counter design table
StateRegular countGray word B3B2B1B0Check
00000
10001
20010
30011
40100
50101
60110
70111
81000
91001
101010
111011
121100
131101
141110
151111

Complete all 16 words to check the sequence.

Design plan

Separate state from displayed code

  1. Use a four-bit register to hold the regular count and give it an explicit power-up value of zero.
  2. Increment that register on the positive edge of the manual advance input. Four-bit overflow returns 1111 to 0000.
  3. Translate the regular count into the required Gray word with combinational logic.
  4. Drive LED3 through LED0 from B3 through B0.
No reset input is required.

The design starts at state 0 through an explicit register initialization supported by the Quartus/Cyclone configuration flow. Do not add an unassigned reset port.

Need refreshers?
→ Combinational vs Sequential Logic · → Clock Signals and Active Edges

Verilog

Implement your design

  1. Create a Quartus project targeting EP4CE22F17C6.
  2. Create one Verilog source file and keep its module name consistent with the project top-level entity.
  3. Declare one manual-advance input and outputs LED3 through LED0.
  4. Implement the registered count and combinational Gray translation from your plan.
  5. Run Analysis & Synthesis. Resolve errors and inspect warnings before assigning pins.

This lab intentionally does not provide completed starter code. Your source file is the assessed design, and you must be able to explain it.

Need refreshers?
→ Verilog Modules and Ports · → Combinational Logic in Verilog

Compile and program

Assign SW0 and the four LEDs

DE0-Nano assignments for this design
HDL functionBoard resourceLocationBehavior
Manual advanceSW0PIN_M1LOW in upper position; HIGH in down position
Gray B3LED3PIN_A11Most-significant displayed bit
Gray B2LED2PIN_B13Displayed bit
Gray B1LED1PIN_A13Displayed bit
Gray B0LED0PIN_A15Least-significant displayed bit
  1. In Pin Planner, assign your advance port to SW0 and the outputs to LED3–LED0 as listed.
  2. Compile the complete design and confirm the assignments remain present.
  3. Connect USB-Blaster, open Programmer in JTAG mode, and program the generated .sof.
  4. Place SW0 in the upper position before beginning the controlled test.
SW0 is a slide switch, not a debounced pushbutton.

A positive edge occurs when SW0 moves from upper (LOW) to down (HIGH). Return it to upper to prepare the next positive edge. Mechanical contact bounce can create extra transitions, so move deliberately and record any skipped state rather than assuming every movement creates one ideal edge.

Need refreshers?
→ Pin Planner · → Programming the FPGA

Verify the full cycle

Observe every state and the wraparound

  1. Record the initial LED3–LED0 word before the first positive edge.
  2. For each next row, move SW0 from upper to down, read the LEDs, then return SW0 to upper.
  3. Continue through all 16 states, then create one more positive edge and confirm the display returns to state 0.
Observed LED sequence
StateObserved LED3LED2LED1LED0Check
0 (initial)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Next edge

Complete every observation to check the physical sequence.

Physical behavior

Demonstrate and explain the implementation

Analyze

Think it through

Completion

Prepare your Lab 7 submission package

Assessment distinction

Complete and export this HTML record, select files for the local ZIP, demonstrate the working counter to the instructor, and explain your code. Creating the ZIP does not perform the instructor demonstration or submit anything to Avenue.

Submission package

Download your Lab 7 submission ZIP

The ZIP includes completion.json, the final Verilog source, and programmed-board evidence.

Submission Details

Enter all four required details before downloading.

Generating this local ZIP does not submit work. Evidence files must be reselected after reopening the page.