This problem set closes the Procedural Blocks & Assignments chapter. Each article's practice exercise and drills cover one idea; these 6 problems put several always blocks together, so part of the work is deciding which rule applies to which block.

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

  • Choose between blocking and non-blocking assignments for clocked and combinational blocks
  • Write sensitivity lists that match the hardware
  • Replace an initial block with a reset that synthesis keeps
  • Keep every register in one always block
  • Order the ifs in a clocked block to give reset, flush and stall their priority

What You'll Build

Across the set you build a 3-stage data pipeline with a valid bit, the kind that sits between two blocks of a design to break up a long path.

Each problem adds or fixes one piece: the stage registers, a bypass, a reset and an enable, a flush and a stall. The last problem puts them together into a pipeline for any data width.

OutputMeaningBuilt in
qThe data leaving the pipelineProblems 1 to 6
voutIts valid bitProblems 1 to 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 three-stage pipelineFix

A 3-stage pipeline passes its bench test. Make it three stages deep for any input before it ships.

Practise: Assignments in a clocked block
Builds on: Verilog Blocking & Non-Blocking, Verilog always block

Open in ChipVerify Lab →
2

The bypass muxFix

The pipeline's output mux ignores some of its input changes. Fix it, keeping it a combinational always block.

Practise: Combinational always blocks
Builds on: Verilog always block, Verilog Blocking & Non-Blocking

Open in ChipVerify Lab →
3

A real reset and an enableExtend

Replace the pipeline's initial block with a synchronous reset that hardware can use, and add an enable.

Practise: Resets in a clocked block
Builds on: Verilog initial block, Verilog Control Blocks

Open in ChipVerify Lab →
4

Review a generated flushReview

A generated flush for the pipeline passes the testbench that came with it. Review it before it is merged.

Practise: One driver per register
Builds on: Verilog assign statement, Verilog Blocking & Non-Blocking

Open in ChipVerify Lab →
5

Stall the pipelineExtend

Make the pipeline wait when the next block is busy, without breaking the reset and the flush.

Practise: Priorities in a clocked block
Builds on: Verilog Control Blocks, Verilog always block

Open in ChipVerify Lab →
6

The pipelineWrite

Write the whole pipeline at any width, with its reset, flush, stall and bypass.

Practise: A clocked block and a combinational one together
Builds on: Verilog Blocking & Non-Blocking, Verilog always block

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 more than one width for the last problem, and the design is synthesized to check that it has no latches and the right number of flip-flops.

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 always blocks, blocking and non-blocking assignments, and if-else priority. If a problem stops you, the article it builds on is the place to look.

After This Chapter

The pipeline's stall and flush come from outside. The Conditionals & Loops chapter goes further into if, case and loops, the statements that decide what each stage does.

Did you find what you were looking for?

Quiz

No quiz questions available for this article.