This problem set closes the Sequential Logic & Flip-Flops chapter. Each article's practice exercise and drills cover one flip-flop; these 6 problems put registers, resets and events together in one peripheral.

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.

6 problems | Beginner Level

What You'll Learn

  • Write resets that act when they should
  • Enable a register without touching its clock
  • Give load, count and reset their priority
  • Tell a latch from a register
  • Turn a level into one event, and keep it until it is seen

What You'll Build

Across the set you build a timer, the peripheral that every processor has: it counts down from a loaded value and reports when it reaches 0.

Each problem adds or fixes one piece: the reset, the enable, the load, the capture register and the events. The last problem writes the timer for any width.

OutputMeaningBuilt in
countThe countProblems 1 to 3 and 6
snapA copy of the countProblems 4 and 6
irq, led, pendWhat a timeout doesProblems 5 and 6

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 reset that does not waitFix

A counter passes its bench test. Make its reset work even when the clock has stopped.

Practise: Asynchronous resets
Builds on: D Flip-Flop Async Reset

Open in ChipVerify Lab →
2

One clock for everythingFix

A prescaler stops its clock while it is disabled, and passes its bench test. Make the clock the only thing that changes its count.

Practise: Enables and synchronous resets
Builds on: Sequential Logic with always

Open in ChipVerify Lab →
3

Load, then countExtend

Extend a register with a load and a count down to 0, each with its own priority.

Practise: Priority in a clocked block
Builds on: D Flip-Flop Async Reset, D Latch

Open in ChipVerify Lab →
4

Review a generated capture registerReview

A generated capture register passes the testbench that came with it. Review it, and run it through synthesis.

Practise: Latch or register
Builds on: D Latch, Verilog T Flip Flop

Open in ChipVerify Lab →
5

One event per timeoutFix

A timer's interrupt, LED and pending flag go off too often. Make every timeout one event, and lose none.

Practise: Flip-flops that set, clear and toggle
Builds on: Verilog T Flip Flop, JK Flip Flop

Open in ChipVerify Lab →
6

The timerWrite, final problem

Write the whole timer, with its load, reload, capture and events, at any width.

Practise: Registers with resets, enables and priorities together
Builds on: D Flip-Flop Async Reset, Sequential Logic with always, Verilog T Flip Flop

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 runs thousands of random clock cycles against a model of the spec, with resets between clock edges, and the design is synthesized to check that it contains 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 reset template of the D flip-flop and the difference between a latch and a register. If a problem stops you, the article it builds on is the place to look.

After This Chapter

The timer's counter only counts down. The Counters & Shift Registers chapter goes through the other ways to count, and what each one costs.

Did you find what you were looking for?

Quiz

No quiz questions available for this article.