-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmeasure.v
45 lines (41 loc) · 937 Bytes
/
measure.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
`timescale 1 ps/ 1 ps
module measure (
input clk, input rst_n,
input sig_in,
output reg gate_out, input gate,
output reg[25:0]M, output reg[25:0]N
);
reg [25:0]cntclk;reg [25:0]cntsig;
always @(posedge clk or negedge rst_n) begin
if(!rst_n)begin cntclk<=0;M<=1; end
else begin
if(gate_out)cntclk<=cntclk+1;
else begin
cntclk<=0;
M<=cntclk?cntclk:M;
end
end
end
always @(posedge sig_in or negedge rst_n) begin
if(!rst_n)begin gate_out<=0; end
else begin
if (gate) gate_out<=1;
else gate_out<=0;
end
end
always @(posedge sig_in or negedge rst_n) begin
if(!rst_n)begin cntsig<=0;N<=0; end
else begin
if(gate)cntsig<=cntsig+1;//if gate_out 会多计1
else begin
cntsig<=0;
N<=cntsig?cntsig:N;
end
end
end
/*
always@(posedge clk)
begin
frec<=50_000_000*M/N;
end*/
endmodule