频率计

频率测量(数个数)

等精度测量

门限由被测信号决定
image
image

传统(适合高频)

门限由基准信号决定
image

``

have a look?
module high_freq_pulse_counter(
    input clk_sample,
    input rst_n,
    input [31:0] single_imp,
    output reg [18:0] imp_count,
    output end_of_gate
);

parameter MY_GATE_CNT = 19'd100;

reg[18:0] clk_sample_cnt;

always @(posedge clk_sample or negedge rst_n) begin
    if(!rst_n)begin
        clk_sample_cnt <= 1'b0;
    end
    else if(clk_sample_cnt < MY_GATE_CNT)begin
        clk_sample_cnt <= clk_sample_cnt + 1;
    end
    else begin
        clk_sample_cnt <= 1'b0;
    end
end

always @(posedge single_imp) begin
    if (!rst_n) begin
        imp_count <= 0;
    end
    else if (~end_of_gate) begin
        imp_count <= imp_count + single_imp;
    end
    else 
        imp_count <= 0;
end 

assign end_of_gate = (clk_sample_cnt)?0:1;

endmodule

基准信号的反转可能没法检测到
image

周期测量(测一个周期)

被测为闸门,适合低频

posted @ 2023-07-04 21:30  银脉河  阅读(105)  评论(0编辑  收藏  举报