-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathproyecto.v
More file actions
124 lines (102 loc) · 1.73 KB
/
proyecto.v
File metadata and controls
124 lines (102 loc) · 1.73 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
module proyecto ( input clk,
input Eco,
input on,
output reg trig,
output reg [6:0] display,
output reg [7:0] anodos,
output reg l,
output reg in1,
output reg in2,
output reg in3,
output reg in4
);
reg [26:0] cont;
reg [26:0] dist;
initial
begin
cont = 0;
trig = clk;
dist = 0;
l=0;
cont_t = 0;
cont_clk1 = 0;
cont_anodos = 0;
clk1 = 0;
end
always @(posedge clk)
begin
cont = cont + 1;
if (cont < 1024)
trig = 1'b1;
else
begin
trig = 1'b0;
if (Eco == 1)
begin
cont_t = cont_t + 1;
dist = (cont_t*34/100_000);
end
else if (Eco == 0)
begin
cont_t = 0;
cont=0;
end
end
end
reg [26:0] cont_t;
reg [13:0] cont_clk1;
wire [6:0] display1;
wire [6:0] display2;
wire [6:0] display3;
reg [1:0] cont_anodos;
reg clk1;
always @(posedge clk)
begin
if (cont_clk1<5_000)
cont_clk1=cont_clk1+13'b0000000000001;
else begin
clk1=~clk1;
cont_clk1=0;
end
end
Displays distt(clk,dist,display1,display2,display3);
always @(posedge clk1)
begin
cont_anodos=cont_anodos+2'b01;
case (cont_anodos)
0 : begin anodos=8'b01111111; display=display1; end
1 : begin anodos=8'b10111111; display=display2; end
2 : begin anodos=8'b11011111; display=display3; end
endcase
end
always @(posedge clk)
begin
if (dist < 15)
l=1;
else begin
l=0;
end
end
always @(*)
case(on)
1: begin if (l==0)begin
in1=0;
in2=1;
in3=0;
in4=1;
end
else begin
in1=0;
in2=0;
in3=0;
in4=1;
end
end
0: begin
in1=0;
in2=0;
in3=0;
in4=0;
end
endcase
endmodule