module distance_display_led (
    input wire [8:0] distance,
    output reg [5:0] leds
);

    // Constante
    parameter MIN_DIST = 2;
    parameter MAX_DIST = 349;
    parameter LEVELS = 5;
    parameter PART_SIZE = (MAX_DIST - MIN_DIST + 1) / LEVELS;

    always @(*) begin
        if (distance <= MIN_DIST + PART_SIZE*0)
            leds = 6'b111111;
        else if (distance <= MIN_DIST + PART_SIZE*1)
            leds = 6'b111110;
        else if (distance <= MIN_DIST + PART_SIZE*2)
            leds = 6'b111100;
        else if (distance <= MIN_DIST + PART_SIZE*3)
            leds = 6'b111000;
        else if (distance <= MIN_DIST + PART_SIZE*4)
            leds = 6'b110000;
        else if (distance <= MIN_DIST + PART_SIZE*5)
            leds = 6'b100000;
        else
            leds = 6'b000000; 
    end

endmodule