logic-circuit-design / practice / 01_Octal_Counter / rtl / SEG7_LUT.v
SEG7_LUT.v
Raw
// 7 segment LED decoder
module SEG7_LUT	( 
    oSEG, 
    iDIG
);
    input  [3:0]        iDIG;
    output [6:0]        oSEG;

    assign  oSEG = SEG(iDIG);

//  7SEG-LED pin assignment
//     ----t----
//     |       |    Common Anode
//     lt     rt     => Negative logic
//     |       |
//     ----m----
//     |       |
//     lb     rb
//     |       |
//     ----b----

    function [6:0] SEG;
        input [3:0]   iDIG;
        case(iDIG)
            4'd0: SEG = 7'b1000000; // 0
            4'd1: SEG = 7'b1111001; // 1
            4'd2: SEG = 7'b0100100; // 2
            4'd3: SEG = 7'b0110000; // 3
            4'd4: SEG = 7'b0011001; // 4
            4'd5: SEG = 7'b0010010; // 5
            4'd6: SEG = 7'b0000010; // 6
            4'd7: SEG = 7'b1111000; // 7
            4'd8: SEG = 7'b0000000; // 8
            4'd9: SEG = 7'b0011000; // 9
         default: SEG = 7'b1111111; // Blank
        endcase
    endfunction

endmodule