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

module sevenseg_hex (
    input  [3:0] hex,
    output [6:0] seg
);

    // seg[6:0] = {a,b,c,d,e,f,g} (ACTIVE-HIGH)
    assign seg =
        (hex == 4'h0) ? 7'b1111110 :
        (hex == 4'h1) ? 7'b0110000 :
        (hex == 4'h2) ? 7'b1101101 :
        (hex == 4'h3) ? 7'b1111001 :
        (hex == 4'h4) ? 7'b0110011 :
        (hex == 4'h5) ? 7'b1011011 :
        (hex == 4'h6) ? 7'b1011111 :
        (hex == 4'h7) ? 7'b1110000 :
        (hex == 4'h8) ? 7'b1111111 :
        (hex == 4'h9) ? 7'b1111011 :
        (hex == 4'hA) ? 7'b1110111 :
        (hex == 4'hB) ? 7'b0011111 :
        (hex == 4'hC) ? 7'b1001110 :
        (hex == 4'hD) ? 7'b0111101 :
        (hex == 4'hE) ? 7'b1001111 :
        (hex == 4'hF) ? 7'b1000111 :
                        7'b0000000; // DEFAULT

endmodule

 

Was this helpful?
Upvote
Downvote