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 reg [6:0] seg   // {a,b,c,d,e,f,g}, ACTIVE-HIGH
);
    always @* begin
        case (hex)
            4'h0: seg = 7'b1111110; // a b c d e f
            4'h1: seg = 7'b0110000; // b c
            4'h2: seg = 7'b1101101; // a b   d e   g
            4'h3: seg = 7'b1111001; // a b c d     g
            4'h4: seg = 7'b0110011; //   b c     f g
            4'h5: seg = 7'b1011011; // a   c d   f g
            4'h6: seg = 7'b1011111; // a   c d e f g
            4'h7: seg = 7'b1110000; // a b c
            4'h8: seg = 7'b1111111; // a b c d e f g
            4'h9: seg = 7'b1111011; // a b c d   f g
            4'hA: seg = 7'b1110111; // a b c   e f g
            4'hB: seg = 7'b0011111; //     c d e f g  (looks like 'b')
            4'hC: seg = 7'b1001110; // a       d e f
            4'hD: seg = 7'b0111101; //   b c d e   g  (looks like 'd')
            4'hE: seg = 7'b1001111; // a       d e f g
            4'hF: seg = 7'b1000111; // a         e f g
            default: seg = 7'b0000000; // blank
        endcase
    end
endmodule

 

Was this helpful?
Upvote
Downvote