← All problems

Second Largest

Easy · Sequential · SystemVerilog

Design a module that, given a clocked sequence of unsigned values, outputs the second-largest value seen so far in the sequence. If only one value is seen, then the output {dout} should equal $0$. Note that repeated values are treated as separate candidates for being the second largest value.

When the reset-low signal {resetn} goes low, the module should ignore all previous values seen in the input sequence, and {dout} should restart from $0$ on the next cycle.

Open this challenge in the editor →