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
);
    localparam [6:0]
    zero=7'b1111110,
    one=7'b0110000,
    two=7'b1101101,
    three=7'b1111001,
    four=7'b0110011,
    five=7'b1011011,
    six=7'b1011111,
    seven=7'b1110000,
    eight=7'b1111111,
    nine=7'b1111011,
    A_h=7'b1110111,
    B_h=7'b0011111,
    C_h=7'b1001110,
    D_h=7'b0111101,
    E_h=7'b1001111,
    F_h=7'b1000111;

    always @* begin 
        case(hex)
            4'h0: seg=zero;
            4'h1: seg=one;
            4'h2: seg=two;
            4'h3: seg=three;
            4'h4: seg=four;
            4'h5: seg=five;
            4'h6: seg=six;
            4'h7: seg=seven;
            4'h8: seg=eight;
            4'h9: seg=nine;
            4'hA: seg=A_h;
            4'hB: seg=B_h;
            4'hC: seg=C_h;
            4'hD: seg=D_h;
            4'hE: seg=E_h;
            4'hF: seg=F_h;
            default: seg=7'd0;
        endcase
    end
endmodule

 

Was this helpful?
Upvote
Downvote