This problem set closes the Basic Syntax & Structure chapter. Each article's practice exercise and drills cover one idea; these 5 problems connect modules into one design, so part of the work is deciding which connection is wrong.
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 | Beginner Level
What You'll Learn
- Connect module instances by name and see what a positional list can hide
- Find a net that the compiler created for you, and make it stop
- Slice buses to the width of each port and chain a carry between instances
- Spot a sized constant that is too small for its value
- Build a design from library modules under default_nettype none
What You'll Build
Across the set you build an 8-bit ALU from three small library modules: a 4-bit adder that can also subtract, a 4-bit logic unit and a 4-bit mux.
Each problem adds or fixes one set of connections, and the last problem puts them together into an ALU with add, subtract, four logic operations and a zero flag.
| Output | Meaning | Built in |
|---|---|---|
y | The ALU result | Problems 1 to 5 |
cout | Carry out of the adder | Problems 1 and 3 |
zero | Zero flag | Problems 1 and 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.
Add and subtractFix
An adder that can also subtract passes its bench test. Make it right for every input before it ships.
Open in ChipVerify Lab →Add a logic unitFix
A logic unit joins the adder, and its results never reach the output. Find out why and make the compiler catch it next time.
Open in ChipVerify Lab →Widen the adder to 8 bitsExtend
Build an 8-bit adder from two 4-bit slices, with the carry passed from one to the next.
Open in ChipVerify Lab →Review a generated ALUReview
A generated 8-bit ALU passes the testbench that came with it. Review it before it joins the design.
Open in ChipVerify Lab →The ALUWrite
Build an 8-bit ALU from the library's adder, logic unit and mux, with the compiler set to catch every misspelled name.
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 combination or tens of thousands of random ones, 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 module instances, port connections and number formats. If a problem stops you, the article it builds on is the place to look.
After This Chapter
The ALU works on unsigned numbers. The Data Types, Operators & Parameters chapter shows what changes when the operands are signed and how to make a module like this one work at any width with a parameter.