This problem set closes the State Machines chapter. Each article's practice exercise and drills cover one detector or controller; these 5 problems put state machines in a receiver, with bytes that come when they come.

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

  • Write next-state logic for states that wait
  • Send every mismatch to the right state, after a match too
  • Choose between a Moore and a Mealy output
  • Combine a state machine with a counter and a checksum

What You'll Build

Across the set you build a packet framer, the block that finds frames in a stream of received bytes and checks them.

Each problem adds or fixes one piece: the header search, an answer in the same cycle and a counted payload. The last problem puts them together with a length limit and a checksum.

OutputMeaningBuilt in
found, startA header was found, after the edge or at the same timeProblems 1 to 3
pv, lastPayload bytes, and the last one of a frameProblems 4 and 5
ok, errThe result of a frameProblem 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

Locking onFix

A state machine that finds a frame header passes its bench test. Make it work with a receiver that has gaps between bytes.

Practise: States that wait
Builds on: Verilog FSM

Open in ChipVerify Lab →
2

Review a generated header detectorReview

A generated header detector passes the testbench that came with it. Review it for headers that overlap what came before.

Practise: Where a mismatch goes
Builds on: Verilog Sequence Detector, Verilog Pattern Detector

Open in ChipVerify Lab →
3

At the same edgeConstrain

The logic behind a header detector needs its answer one clock earlier, and no extra registers are allowed.

Practise: Moore and Mealy outputs
Builds on: Verilog FSM, Verilog Sequence Detector

Open in ChipVerify Lab →
4

The payloadExtend

Extend a state machine that finds a header so that it counts through the payload of every frame.

Practise: A state machine with a counter
Builds on: Verilog FSM

Open in ChipVerify Lab →
5

The framerWrite, final problem

Write the whole receiver, from the header to the checksum, with gaps between bytes and lengths it must refuse.

Practise: A complete state machine with its datapath
Builds on: Verilog FSM, Verilog Sequence Detector, Verilog Pattern Detector

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 clock cycles of random bytes, with and without gaps, against a model of the spec, 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 next-state block and the reasoning behind mismatch transitions. If a problem stops you, the article it builds on is the place to look.

After This Chapter

The framer gets its bytes from a receiver that already runs on its clock. The Practical Circuits chapter covers signals that do not, and how to bring them in.

Did you find what you were looking for?

Quiz

No quiz questions available for this article.