-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseven_segment.v
76 lines (68 loc) · 1.19 KB
/
seven_segment.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 11:12:13 09/11/2017
// Design Name:
// Module Name: seven_segment
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module seven_segment(
input clk,
input [3:0] in,
output [6:0] seg,
output [3:0] an
);
reg [16:0] contador = 0;
reg [1:0] an_select = 0;
reg [3:0] x = 0;
reg [3:0] unidades = 0;
reg decenas = 0;
binto7seg toseg (
.clk(clk),
.binary(x),
.seg(seg)
);
deco deco (
.clk(clk),
.in(an_select),
.out(an)
);
always @(posedge clk)
begin
contador <= contador + 1;
if(contador == 131071)
begin
if (in > 9)
begin
decenas <= 1;
unidades <= in - 10;
end
else
begin
decenas <= 0;
unidades <= in;
end
contador <= 0;
an_select <= an_select + 1;
case (an_select)
2'b01 : x <= unidades;
2'b10 : x <= decenas;
2'b11 : x <= 0;
2'b00 : x <= 0;
default : x <= 0;
endcase
end
end
endmodule