-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdistance_counterL.sv
47 lines (42 loc) · 1.1 KB
/
distance_counterL.sv
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
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 12/23/2016 08:07:48 PM
// Design Name:
// Module Name: distance_counterL
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module distance_counterL( input logic clk, input logic detect, input logic disStart, output int distance);
int count;
int dis;
logic true;
always@( posedge clk) begin
if ( (disStart == 1'b1) & (detect == 1'b1) ) begin
count <= count + 1;
true <= 1'b0;
end
else if ( (disStart != 1'b1) & count > 0)begin
dis = count;
count <= 0;
true <= 1'b1;
end
end
always_comb begin
if ( (disStart != 1'b1) & (true == 1'b1) ) begin
distance = dis;
end
else distance = 0;
end
endmodule