This problem set closes the Practical Circuits chapter. Each article's practice exercise and drills cover one circuit; these 5 problems make the circuits work with a real button and any clock.

Most problems hand you code to extend, fix or review rather than a blank file. Each one runs in ChipVerify Lab, and when your design fails, the grader explains what went wrong and which article covers it.

5 problems | Intermediate Level

What You'll Learn

  • Bring an asynchronous signal into a clock domain
  • Turn a time in milliseconds into a number of clocks
  • Convert Gray code back to binary at any width
  • Generate a test clock with an exact period

What You'll Build

Across the set you build a button interface, the block between a mechanical button and the logic that counts its presses.

Each problem adds or fixes one piece: the press detector, the debouncer, the Gray counter and the clock that tests them. The last problem writes the interface.

OutputMeaningBuilt in
pressOne clock per pressProblems 1 and 5
stateThe debounced buttonProblems 2 and 5
gray, binThe number of pressesProblems 3 and 5

The Problems

Work through the problems in order: later problems reuse what you built in earlier ones. Each starts with a short spec and a testbench you can run before you submit.

1

A pressFix

A press detector passes its bench test. Make it work for a button that changes whenever it likes.

Practise: Bringing in an asynchronous signal
Builds on: Verilog Positive Edge Detector

Open in ChipVerify Lab →
2

The debounce timeExtend

A debouncer has its time built in as a number of clocks. Extend it to a time in milliseconds, for any clock.

Practise: A time as a number of clocks
Builds on: Verilog Debounce Circuit

Open in ChipVerify Lab →
3

Review a generated press counterReview

A generated counter in Gray code passes the testbench that came with it. Review it for every count and width.

Practise: Gray code and back
Builds on: Verilog Binary to Gray

Open in ChipVerify Lab →
4

The test clockFix

A clock generator passes its bench test at 100 MHz. Make it right for any frequency and duty cycle.

Practise: Periods, precision and duty cycles
Builds on: Verilog Clock Generator

Open in ChipVerify Lab →
5

The button interfaceWrite, final problem

Write the whole interface, from a raw button that bounces to a count of presses in Gray code.

Practise: Synchronizer, debouncer, edge detector and Gray counter together
Builds on: Verilog Positive Edge Detector, Verilog Debounce Circuit, Verilog Binary to Gray

Open in ChipVerify Lab →

How Your Solution Is Graded

Every problem has a visible testbench that you can run and edit. When you submit, a hidden grading testbench presses a button that bounces and changes at any time, or measures the clock you generate, at several parameter values. The designs are also synthesized to check that they contain no latches.

When a check fails, the console ends with a short list of what to look into. Each item explains the mistake in terms of the hardware and names the article section that covers it.

Before You Start

The problems use the ideas from the articles in this chapter, especially the synchronized edge detector and the debounce counter. If a problem stops you, the article it builds on is the place to look.

After This Chapter

The Gray count goes out to logic with another clock. The Memory Elements Problem Set builds the buffers that data goes through between two parts of a chip.

Did you find what you were looking for?

Quiz

No quiz questions available for this article.