Prev Problem
Next Problem

15. Elevator Indicator

module elevator_floor16 (
    input  [3:0]  floor,
    output [15:0] leds
);
    // One-hot from shift; width is 16 bits so every 4'b0000..4'b1111 is valid
    assign leds = (16'b0000_0000_0000_0001 << floor);
endmodule

💡Remember

  • Sized shift source: use 16'b1 (or 16'h0001) so the result is 16-bit.
  • No comparisons needed because all floor values 0..15 are valid with a 16-bit one-hot.
  • Vector orientation: leftmost printed bit is MSB (floor 15); rightmost is LSB (floor 0).