This problem set closes the Combinational Logic & Basic Circuits chapter. Each article's practice exercise drills one idea; these 8 problems mix the whole chapter, so part of the work is deciding which idea applies.

Most problems hand you code to extend, fix or review rather than a blank file, the way RTL work usually starts. Each one runs in ChipVerify Lab, and when your design fails, the grader explains what went wrong and which article covers it.

8 problems | Beginner Level

What You'll Learn

  • Keep always blocks combinational, with every output assigned on every path
  • Tell apart a design that passes its testbench from one that is correct
  • Size select signals, indexes and counts so every value fits
  • Build priority logic with casez, if-else-if and for loops, and know which input wins
  • Review generated RTL and its testbench before trusting either

What You'll Build

Across the set you build the front end of an interrupt controller. Several devices raise requests at the same time, and the request router decides who is served next, passes that device's data on and reports how busy the system is.

Each problem adds or hardens one piece, and the last problem puts them together into a router for any number of requesters.

OutputMeaningBuilt in
validAt least one request is activeProblems 1 and 5
idxIndex of the winning requestProblems 5 and 6
grantOne-hot grant to the winnerProblems 1 and 2
doutThe winner's dataProblems 3 and 4
countNumber of pending requestsProblem 7

The Problems

Work through the problems in order: later problems reuse what you built in earlier ones. Each starts with a short spec and, for the first few, a testbench you can run before you submit.

1

Grant only when someone askedExtend

Extend a working decoder so it only grants when a request is active.

Practise: Handling the case where nobody is asking
Builds on: Verilog Priority Encoder, Combinational Logic with assign

Open in ChipVerify Lab →
2

Same grant, written with caseConstrain

A teammate rewrote your decoder as an always block with a case statement. Make it meet the synthesis rules.

Practise: Writing always blocks that stay combinational
Builds on: Combinational Logic with always, Verilog 4 to 1 Multiplexer

Open in ChipVerify Lab →
3

The mux that passes its testbenchFix

A data mux passes its testbench, but a reviewer rejects it. Find out why, then improve the testbench.

Practise: Reading a testbench critically
Builds on: Combinational Logic with always, Verilog 4 to 1 Multiplexer

Open in ChipVerify Lab →
4

A data mux for any number of requestersExtend

Turn a fixed 4-input mux into one that works for any number of requesters.

Practise: Sizing selects and handling unused select values
Builds on: Verilog 4 to 1 Multiplexer

Open in ChipVerify Lab →
5

Review the AI's priority encoderReview

An AI assistant wrote a priority encoder and a testbench that passes. Review it like a colleague's code.

Practise: Reviewing generated RTL
Builds on: Verilog Priority Encoder

Open in ChipVerify Lab →
6

A priority encoder for any NExtend

Grow your encoder to any width with a for loop.

Practise: Writing loops that describe hardware
Builds on: Verilog Priority Encoder

Open in ChipVerify Lab →
7

How many requests are pending?Write

Count how many requests are pending at once.

Practise: Choosing result widths
Builds on: Verilog Full Adder

Open in ChipVerify Lab →
8

The request routerWrite, final problem

Combine everything into a request router with grant, data and count outputs.

Practise: Putting the chapter together
Builds on: Combinational Logic with assign, Combinational Logic with always, Verilog Full Adder, Verilog 4 to 1 Multiplexer, Verilog Priority Encoder

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 checks every input pattern, at more than one size for the parameterized problems, and the design is synthesized to check that it contains no latches and no 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 five articles in this chapter, and the case, casez and for loop constructs from the Conditionals & Loops chapter. If a problem stops you, the article it builds on is the place to look.

After This Chapter

The router always favours the highest request, so a busy device can keep the others waiting forever. The 4-Way Round-Robin Arbiter challenge fixes that by adding one register that remembers who was served last, which is where the Sequential Logic chapter picks up.

Did you find what you were looking for?

Quiz

No quiz questions available for this article.