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.
| Output | Meaning | Built in |
|---|---|---|
found, start | A header was found, after the edge or at the same time | Problems 1 to 3 |
pv, last | Payload bytes, and the last one of a frame | Problems 4 and 5 |
ok, err | The result of a frame | Problem 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.
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.
Open in ChipVerify Lab →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.
Open in ChipVerify Lab →At the same edgeConstrain
The logic behind a header detector needs its answer one clock earlier, and no extra registers are allowed.
Open in ChipVerify Lab →The payloadExtend
Extend a state machine that finds a header so that it counts through the payload of every frame.
Open in ChipVerify Lab →The framerWrite, final problem
Write the whole receiver, from the header to the checksum, with gaps between bytes and lengths it must refuse.
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.