-
Notifications
You must be signed in to change notification settings - Fork 0
/
DigitToSeg.v
executable file
·53 lines (48 loc) · 1.26 KB
/
DigitToSeg.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Engineer: Christian Leonard Quale
//
// Create Date: 07/01/2011
// Module Name: DigitToSeg
// Target Devices: All
//
// Description:
// Converts a digit (0-9) to the corresponding 7-segment display.
// Format: (clock, Digit, segment)
//
// Dependencies:
// None
// Revision:
// Revision 0.5
// Additional Comments:
// 0 is lit up, 1 is not lit up.
//////////////////////////////////////////////////////////////////////////////////
module DigitToSeg(clk, Digit, Segments );
input clk;
input [3:0] Digit;
output [6:0] Segments;
reg [6:0] Segments;
always @(posedge clk) begin
if (Digit == 0) begin
Segments <= 7'b1000000;
end if (Digit == 1) begin
Segments <= 7'b1111001;
end if (Digit == 2) begin
Segments <= 7'b0100100;
end if (Digit == 3) begin
Segments <= 7'b0110000;
end if (Digit == 4) begin
Segments <= 7'b0011001;
end if (Digit == 5) begin
Segments <= 7'b0010010;
end if (Digit == 6) begin
Segments <= 7'b0000010;
end if (Digit == 7) begin
Segments <= 7'b1111000;
end if (Digit == 8) begin
Segments <= 7'b0000000;
end if (Digit == 9) begin
Segments <= 7'b0011000;
end
end
endmodule