go-board-code/binary_to_7_segment.v

45 lines
1.1 KiB
Verilog

module Binary_to_7_Segment(
input i_Clk,
input [$clog2(15)-1:0] i_Number,
output o_SegA,
output o_SegB,
output o_SegC,
output o_SegD,
output o_SegE,
output o_SegF,
output o_SegG
);
reg [6:0] r_HexEncoding;
always @(posedge i_Clk) begin
case (i_Number)
0: r_HexEncoding <= 7'b1111110;
1: r_HexEncoding <= 7'b0110000;
2: r_HexEncoding <= 7'b1101101;
3: r_HexEncoding <= 7'b1111001;
4: r_HexEncoding <= 7'b0110011;
5: r_HexEncoding <= 7'b1011011;
6: r_HexEncoding <= 7'b1011111;
7: r_HexEncoding <= 7'b1110000;
8: r_HexEncoding <= 7'b1111111;
9: r_HexEncoding <= 7'b1111011;
10: r_HexEncoding <= 7'b1110111;
11: r_HexEncoding <= 7'b0011111;
12: r_HexEncoding <= 7'b1001110;
13: r_HexEncoding <= 7'b0111101;
14: r_HexEncoding <= 7'b1001111;
15: r_HexEncoding <= 7'b1000111;
default: r_HexEncoding <= 7'b0000000;
endcase
end
assign o_SegA = r_HexEncoding[6];
assign o_SegB = r_HexEncoding[5];
assign o_SegC = r_HexEncoding[4];
assign o_SegD = r_HexEncoding[3];
assign o_SegE = r_HexEncoding[2];
assign o_SegF = r_HexEncoding[1];
assign o_SegG = r_HexEncoding[0];
endmodule