Prev Problem
Next Problem

72. 7-Segment Display Decoder

Back To All Submissions
Previous Submission
Next Submission

Solving Approach

How do you plan to solve it?

 

Code

/*Write your code here*/
module sevenseg_hex(
    input [3:0] hex,
    output [6:0] seg
);
    localparam [7*16-1:0] SEG_LUT = {
        7'b1000111, // F
        7'b1001111, // E
        7'b0111101, // D (looks like 'd')
        7'b1001110, // C
        7'b0011111, // B (lowercase 'b' on 7-seg)
        7'b1110111, // A
        7'b1111011, // 9
        7'b1111111, // 8
        7'b1110000, // 7
        7'b1011111, // 6
        7'b1011011, // 5
        7'b0110011, // 4
        7'b1111001, // 3
        7'b1101101, // 2
        7'b0110000, // 1
        7'b1111110  // 0
    };

    wire [6:0] seg_lut = SEG_LUT[hex*7 +: 7];
    assign seg = seg_lut; 
endmodule

 

Was this helpful?
Upvote
Downvote