Prev Problem
Next Problem

18. Battery LED Bar

Design a Verilog module that drives an 8-LED battery bar based on a level input. The bar should light LEDs from LSB to MSB (right to left) as the level increases.

Requirements

  • Module name: battery_led_bar
  • Inputs:
    • level[3:0] — battery level from 0 to 8 (inclusive)
  • Outputs:
    • led_bar[7:0] — LED bar where the lowest level bits are 1, higher bits are 0

 

Expected behavior

levelled_bar (binary)Hex
4'd00000_000000
4'd10000_000101
4'd40000_11110F
4'd70111_11117F
4'd81111_1111FF
Need Help? Refer to the Quick Guide below