Verilog problems / Sequential Design
What you must build
Drive two digits from one shared set of segment lines by rapidly alternating which digit is active — the real technique behind every multi-digit 7-segment display.
Engineers use “2-Digit 7-Segment Multiplexer” as a building block in sequential design. Interviewers ask for the same ports and the same corner cases this judge covers. Completing it in the browser is the same skill as writing synthesizable RTL at work, minus the EDA license.
active_bcd = toggle ? digit1 : digit0) and which physical digit is enabled (digit_sel). If the toggle never flips, one digit is permanently dark — a real symptom on physical multiplexed displays.Port contract
The judge instantiates exactly these ports. Extra ports or a different module name fail to elaborate.
| Name | Dir | Width | Description |
|---|---|---|---|
| clk | input | 1 | Clock (multiplex rate) |
| rst | input | 1 | Sync active-high reset |
| digit0 | input | 4 | BCD value for digit 0 |
| digit1 | input | 4 | BCD value for digit 1 |
| digit_sel | output | 1 | Which digit is currently active (0 or 1) |
| active_bcd | output | 4 | BCD value of the currently active digit |
How to approach this kata
This is a medium kata: you will need sequential logic or a small FSM. Decide what is registered versus combinational before you type. Reset polarity and clock edge must match the spec; the judge will fail you on the first mismatched cycle.
Hidden tests instantiate top_module, drive the ports, and compare every sample against a golden model. They do not grade coding style. They do grade X/Z, off-by-one counters, and ignoring enables. Sign in only when you want the run saved on the leaderboard — the specification below is public.
Starter shape
Copy this skeleton into the editor (or press Reset starter). Fill the body; do not rename the module.
module top_module( input clk, input rst, input [3:0] digit0, input [3:0] digit1, output digit_sel, output [3:0] active_bcd ); // Your code here — a free-running toggle alternates which digit is presented each cycle. endmodule
Why this shows up in interviews
2-Digit 7-Segment Multiplexer sits under Sequential Design (sequential, display). Concept: A free-running 1-bit toggle flips every cycle; that bit both selects which digit's BCD value to present ( active_bcd = toggle ? digit1 : digit0 ) and which physical digit is enabled ( digit_sel ). If the toggle never flips, one digit is permanently dark — a real symptom on physical multiplexed displays.
A passing solution is synthesizable intent: no delays in the DUT, no initial blocks inside top_module, and no reference to testbench tasks. Use blocking assignments only in combinational always blocks; use non-blocking for registers clocked by clk.
Related problems
- D Flip-Flop with Asynchronous Reset — Standard D flip-flop with an active-low asynchronous reset. Reset clears q immediately, without waiting for a clock edge.
- 4-Bit Shift Register (SIPO) — Serial-in, parallel-out shift register. Each clock, shift left and load sin into the LSB. Sync active-high reset clears q.
- JK Flip-Flop — The flip-flop with no forbidden state: j=k=1 toggles instead of racing. Classic building block for counters.
- 4-Bit Up/Down Counter — A synchronous counter that increments or decrements each clock edge depending on a direction input, with a synchronous reset.
FAQ
What does this problem require?
What does the 2-Digit 7-Segment Multiplexer problem ask for? Drive two digits from one shared set of segment lines by rapidly alternating which digit is active — the real technique behind every multi-digit 7-segment display. Implement it as Verilog module top_module with the listed ports.
Combinational or sequential?
Is 2-Digit 7-Segment Multiplexer combinational or sequential? Tags: sequential, display. Follow the clock/reset ports if they appear in the table; if there is no clock, use continuous assignment or combinational always @(*).
How does the auto-grader work?
How is 2-Digit 7-Segment Multiplexer graded? A hidden SystemVerilog/Verilog testbench in the EcrioniX judge simulates your module in the browser. You pass when every directed vector matches, including the waveform contract shown on this page.