Decode a 4-bit status code onto an active-low seven-segment display, with a lamp test and no latch.
Hardware context: A common-anode seven-segment digit on a washing machine, driven by a 4-bit status code. Decode digits, four letters and two blank codes in one always_comb block with no latch.
A washing machine shows its state on one seven-segment digit. The digit counts down the minutes, and a few letters report faults. The display is common-anode: a segment lights when its line is driven to 0.
This is an Implement problem. Write status7 as one always_comb block. Each code from 0 to 9 shows its digit. Codes 10 to 13 show the letters E, r, a dash and L. Codes 14 and 15 show nothing. When lamp_test is 1, every segment lights, whatever the code.
The check applies eight inputs, one per nanosecond, and records seg_n after each. The check also synthesizes the module on the site's flow and rejects any latch.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
script | 40 | input of each check |
Full specification
module status7 (
input logic [3:0] code, // 0-9 digits, 10 E, 11 r, 12 -, 13 L, 14 and 15 blank
input logic lamp_test, // 1: light every segment
output logic [6:0] seg_n // {g, f, e, d, c, b, a}; a 0 lights the segment
);
// your design
endmodule
| code | shows | lit segments |
|---|---|---|
| 0 | the digit 0 | a b c d e f |
| 1 | the digit 1 | b c |
| 2 | the digit 2 | a b d e g |
| 3 | the digit 3 | a b c d g |
| 4 | the digit 4 | b c f g |
| 5 | the digit 5 | a c d f g |
| 6 | the digit 6 | a c d e f g |
| 7 | the digit 7 | a b c |
| 8 | the digit 8 | a b c d e f g |
| 9 | the digit 9 | a b c d f g |
| 10 | the letter E | a d e f g |
| 11 | the letter r | e g |
| 12 | a dash | g |
| 13 | the letter L | d e f |
| 14 | nothing | none |
| 15 | nothing | none |
| Segment | Position | Bit of seg_n |
|---|---|---|
| a | top bar | 0 |
| b | upper right | 1 |
| c | lower right | 2 |
| d | bottom bar | 3 |
| e | lower left | 4 |
| f | upper left | 5 |
| g | middle bar | 6 |
The result fields are named seg_n_step0 to seg_n_step7, shown in binary as {g, f, e, d, c, b, a}. Remember: 0 means lit.
Examples
Example 1
The Digits 0 to 7- Input
code 0; code 1; code 2; code 3; code 4; code 5; code 6; code 7
- Output
seg_n_step0 = 'b1000000, seg_n_step1 = 'b1111001, seg_n_step2 = 'b0100100, seg_n_step3 = 'b0110000, seg_n_step4 = 'b0011001, seg_n_step5 = 'b0010010, seg_n_step6 = 'b0000010, seg_n_step7 = 'b1111000
Each digit lights the segments of its table row. The display is active-low, so every lit segment is a 0. The digit 1 lights b and c only: 1111001.
Example 2
The Digits 8 and 9 Between Others- Input
code 8; code 9; code 0; code 9; code 8; code 1; code 7; code 4
- Output
seg_n_step0 = 'b0000000, seg_n_step1 = 'b0010000, seg_n_step2 = 'b1000000, seg_n_step3 = 'b0010000, seg_n_step4 = 'b0000000, seg_n_step5 = 'b1111001, seg_n_step6 = 'b1111000, seg_n_step7 = 'b0011001
The digit 8 lights all seven segments, so seg_n is all zeros. The digit 9 is the 8 without segment e.
Example 3
Lamp Test over Two Digits- Input
code 3; code 3 with lamp test; code 3; code 6 with lamp test; code 6; code 1 with lamp test; code 1; code 0
- Output
seg_n_step0 = 'b0110000, seg_n_step1 = 'b0000000, seg_n_step2 = 'b0110000, seg_n_step3 = 'b0000000, seg_n_step4 = 'b0000010, seg_n_step5 = 'b0000000, seg_n_step6 = 'b1111001, seg_n_step7 = 'b1000000
While lamp_test is 1, every segment lights whatever the code. When it returns to 0, the digit shows again.
Constraints and Contract
- Inputs are known 0/1 values. Each input is held for one nanosecond and seg_n is sampled at its end.
- Keep the module name and the ports. The design is combinational: it must not remember an earlier code.
Hints
Hint 1
Write the lit segments of one code as seven bits, g f e d c b a, with 1 for lit. Then invert every bit, because the display is active-low.
Hint 2
Codes 14 and 15 need a value too. If no arm assigns seg_n for them, the output keeps the last pattern, and that needs a latch.
Hint 3
Test lamp_test first, in an if. Put the case statement in the else branch.
What the grader checks: Eight directed and eight seeded cases of eight steps each cover every code, with and without lamp test. Each output is compared with a model written in JavaScript after every step. A blank code right after a lit one catches an output that remembers. The synthesis check rejects a latch.
The submitted design must synthesize with 0 latches and no combinational loop. Counts come from the pinned open-source synthesis flow. They are proxies for logic size and depth, not physical area or timing.
16 checks on Icarus Verilog + Yosys · server. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain public samples only. A passing result establishes the tested cases, not a proof for all possible inputs.
See all 1 steps and the final capstone