module SevenSeg (i,o); // Seven-segment display driver. // // Accepts 4-bit binary number as input, generates a 7-bit pattern as output // to drive a 7-segment display. Patterns are zero to nine, followed by A to F. // // Segment ordering is o[6] -> a, o[5] -> b, ..., o[1] -> f, o[0] -> g // // ---a--- // | | // f b // | | // ---g--- // | | // e c // | | // ---d--- // // Port mode declarations: input [3:0] i; output [6:0] o; // Registered identifiers: reg [6:0] o; // Functionality: always @ (i) case (i) // abcdefg 4'h0 : o <= 7'b1111110; 4'h1 : o <= 7'b0110000; 4'h2 : o <= 7'b1101101; 4'h3 : o <= 7'b1111001; 4'h4 : o <= 7'b0110011; 4'h5 : o <= 7'b1011011; 4'h6 : o <= 7'b1011111; 4'h7 : o <= 7'b1110000; 4'h8 : o <= 7'b1111111; 4'h9 : o <= 7'b1111011; 4'ha : o <= 7'b1110111; 4'hb : o <= 7'b0011111; 4'hc : o <= 7'b1001110; 4'hd : o <= 7'b0111101; 4'he : o <= 7'b1001111; 4'hf : o <= 7'b1000111; default : o <= 7'b1001001; endcase // All done. endmodule