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
);
    always @* begin
        case (hex)
            4'b0000: seg = 7'b1111110;	// a b c d e f
            4'b0001: seg = 7'b0110000; //	b c
            4'b0010: seg = 7'b1101101;	// a b d e g
            4'b0011: seg = 7'b1111001;	// a b c d g
            4'b0100: seg = 7'b0110011;	// b c f g
            4'b0101: seg = 7'b1011011;	// a c d f g
            4'b0110: seg = 7'b1011111;	// a c d e f g
            4'b0111: seg = 7'b1110000;	// a b c
            4'b1000: seg = 7'b1111111;	// a b c d e f g
            4'b1001: seg = 7'b1111011;	//a b c d f g
            4'b1010: seg = 7'b1110111;	// a b c e f g
            4'b1011: seg = 7'b0011111;	// c d e f g (styled ‘b’)
            4'b1100: seg = 7'b1001110;	// a d e f
            4'b1101: seg = 7'b0111101;	// b c d e g (styled ‘d’)
            4'b1110: seg = 7'b1001111;	// a d e f g
            4'b1111: seg = 7'b1000111;	// a e f g
            default: seg = 7'b0000000;
        endcase
    end

endmodule

 

Was this helpful?
Upvote
Downvote