This problem set closes the Counters & Shift Registers chapter. Each article's practice exercise and drills cover one counter; these 6 problems use them for what they are good at, in and around a transmitter.

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

  • Count exactly N values, for any N
  • Shift in the right direction, and keep what comes in
  • Build a Gray sequence of any even length
  • Decode a counter without glitches
  • Keep a one going round a ring

What You'll Build

Across the set you build the parts of a serial transmitter, the block that sends a word over one wire, bit by bit.

Each problem adds or fixes one part: the clock of the bits, the shift register, counters for the position and the lane, and the signal that says it is done. The last problem writes the transmitter for any word size and speed.

OutputMeaningBuilt in
tickThe end of every bitProblem 1
sout, txdThe bits on the wireProblems 2 and 6
doneThe end of a frameProblems 4 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

The bit clockFix

A counter that marks every bit of a serial line passes its bench test. Make it right for every divider.

Practise: Counters that start over
Builds on: Verilog Mod-N counter, 4-bit counter

Open in ChipVerify Lab →
2

The shift registerExtend

Extend a register so that it sends its bits in the right order and takes new ones in at the other end.

Practise: Shifting in both the register and its serial input
Builds on: Verilog n-bit Bidirectional Shift Register

Open in ChipVerify Lab →
3

Review a generated sequence counterReview

A generated Gray counter passes the testbench that came with it. Review every step of its sequence.

Practise: Gray sequences of any length
Builds on: Verilog Gray Counter

Open in ChipVerify Lab →
4

Done, without a glitchFix

A small counter says when a frame is over, and passes its bench test. Make its output free of glitches.

Practise: Decoding a counter
Builds on: Verilog Ripple Counter

Open in ChipVerify Lab →
5

The lane selectorFix

A ring counter that should serve one lane after another never selects any. Make it go round at any size.

Practise: Ring counters
Builds on: Verilog Ring Counter, Verilog Johnson Counter

Open in ChipVerify Lab →
6

The transmitterWrite, final problem

Write the whole transmitter, from the start bit to the stop bit, for any word size and speed.

Practise: Counters and a shift register together
Builds on: Verilog Mod-N counter, Verilog n-bit Bidirectional Shift Register

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, at several parameter values where there are any, 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 mod-N counters and shift registers. If a problem stops you, the article it builds on is the place to look.

After This Chapter

The transmitter's frame is a fixed sequence of steps. The State Machines chapter shows how to write down sequences that depend on what comes in.

Did you find what you were looking for?

Quiz

No quiz questions available for this article.