使用Verilog HDL实现一个精密计时器,精确到纳秒级别。

Verilog HDL实现精密计时器

module precision_timer (
    input wire clk,     // 时钟输入
    input wire rst,     // 复位输入
    output reg [31:0] count_ns  // 输出纳秒级别计数
);

always @(posedge clk)
begin
    if (rst) // 复位时清零
        count_ns <= 0;
    else
        count_ns <= count_ns + 1; // 每个时钟周期加一
end

endmodule