25 / 63 · Lab
Lab: exhaustive MUX testing and registered-output analysis
Apply the same inputs to combinational and registered paths, and verify results against the truth table and sampling times.
Lessons are free to read. Enroll to save your learning progress.
The circuit and observation conditions
When sel is 0, y equals a; when sel is 1, y equals b. sampled_y stores y at a rising clock edgeRising edge The instant at which the clock changes from 0 to 1. Distinguish it from a level, which refers to the entire interval during which CLK=1. Learn more. Even if inputs change, sampled_y holds until the next rising edge.
Before starting
Prepare a Digital Design Studio Desktop project with permission to run it normally. Save each example as rtl/top.sv in a separate folder.
First make a and b different. Verify y=a for sel=0 and y=b for sel=1, then compare against each row of the input file.
y = sel ? b : a
SystemVerilog source
module top (
input logic clk,
input logic a,
input logic b,
input logic sel,
output logic y,
output logic sampled_y
);
assign y = sel ? b : a;
// Explicit observation register: y remains purely combinational.
// The register makes this design eligible for logic-netlist-1 simulation.
always_ff @(posedge clk) sampled_y <= y;
endmoduleRunning the lab
In New analysis, select Two-state single-clock v1. Set Clock port to clk and period to 1000ps. Use the following settings, run Preflight, then Run RTL simulation, and compare results.
| Setting | Value |
|---|---|
| Initial register values (LSB first) | [false] |
| Reset port | Leave empty |
| Maximum cycles / time | 8 / 8000ps |
Each column below corresponds to one item in the input file. Expected combinational y is 0,0,0,1,1,0,1,1. This diagram predicts the function in input order; it does not include sampled_y update times.
View waveform data
| Signal | Wave | Bus values |
|---|---|---|
| a | 0...1... | |
| b | 0.1.0.1. | |
| sel | 01010101 | |
| y expected | 0..1.01. |
Input stimulus
[
{
"inputs": {
"a": [
false
],
"b": [
false
],
"sel": [
false
]
}
},
{
"inputs": {
"a": [
false
],
"b": [
false
],
"sel": [
true
]
}
},
{
"inputs": {
"a": [
false
],
"b": [
true
],
"sel": [
false
]
}
},
{
"inputs": {
"a": [
false
],
"b": [
true
],
"sel": [
true
]
}
},
{
"inputs": {
"a": [
true
],
"b": [
false
],
"sel": [
false
]
}
},
{
"inputs": {
"a": [
true
],
"b": [
false
],
"sel": [
true
]
}
},
{
"inputs": {
"a": [
true
],
"b": [
true
],
"sel": [
false
]
}
},
{
"inputs": {
"a": [
true
],
"b": [
true
],
"sel": [
true
]
}
}
]Compare results
8 cycles · y=1 · sampled_y=1. At 3000ps, check that y=1 while sampled_y=0.
This lab uses 0/1 single-clock RTL. It does not include a #delay, initial or X/Z testbench. A lesson-completion mark records learning progress; it does not represent an actual simulation result.
Write down predictions first
Before running the simulator, calculate combinational output for the input sequence yourself. The expected sequence is . It covers all eight input combinations and provides stronger evidence than a single correct final value.
The registerRegister A circuit that stores multiple bits of state. The synchronous registers in this course store their specified inputs at a clock edge. Learn more output updates at the rising edge, not when the stimulus changes. Record the combinational output just before the edge separately from the register output just after it.
Here the inputs sampled at edge define post-edge state . sampled_y is that state. Even when values appear at the same time coordinate, check the event order between applying inputs and updating the register.
Three checks to distinguish the defects
- Reversed selection: before changing the expression to
sel ? a : b, predict which vector first fails. Vectors with cannot detect this error. - Confused observation points: explain why comparing
sampled_y, rather thany, immediately against the combinational answer makes even a correct circuit appear to fail. - Input-independence check: change only the unselected input and confirm that holds. Changes to the selected input must be reflected in .
For each failure, record input, observation time, expected value and actual value on one line. “The waveform looks wrong” does not distinguish a selection error from a one-cycle delay.
Extension exercise
Widening the data to four bits gives combinational inputs. Exhaustive checking is still practical, but begin with 0, the maximum value, 0101, 1010 and walking-one patterns to quickly reveal bit-position errors. Update the settings and input file together with the widened circuit.
Try it yourself
After capturing at a rising edge, change only to 1 before the next edge. Find after logic delay and sampled_y before and after the next rising edge.
Read the explanation
The combinational output is . sampled_y holds 0 until the next rising edge, then stores 1. This assumes the input remains stable for the required sampling interval.