FPGA基于计数器的分频器时序违例的解决方法

现象:约束分频出来的时钟编译后:建立时间或保持时间违例。

原因:分频器关键路径过长。

解决方案:使用流水线优化。

XML 复制代码
// 流水线化分频器
module pipelined_divider (
    input wire clk_in,
    input wire rst_n,
    output reg clk_out
);

    reg [7:0] counter_pipe1, counter_pipe2;
    reg clk_out_pipe;

    // 第一级流水线
    always @(posedge clk_in or negedge rst_n) begin
        if (!rst_n) begin
            counter_pipe1 <= 0;
        end else begin
            counter_pipe1 <= counter_pipe1 + 1;
        end
    end

    // 第二级流水线
    always @(posedge clk_in or negedge rst_n) begin
        if (!rst_n) begin
            counter_pipe2 <= 0;
            clk_out_pipe <= 0;
        end else begin
            counter_pipe2 <= counter_pipe1;
            clk_out_pipe <= (counter_pipe2 == 255);
        end
    end

    // 输出寄存器
    always @(posedge clk_in or negedge rst_n) begin
        if (!rst_n) begin
            clk_out <= 0;
        end else begin
            clk_out <= clk_out_pipe;
        end
    end

endmodule
相关推荐
水云桐程序员16 小时前
单片机项目从入门到精通
单片机·嵌入式硬件
Wave84517 小时前
STM32 裸机中断与 FreeRTOS 中断管理的四大核心差异
单片机·嵌入式硬件
若忘即安17 小时前
【硬件电路设计18】WIFI+BlueTooth
单片机·嵌入式硬件
森利威尔电子-18 小时前
森利威尔SL3150H替代MRDC88-1 10V-150V宽压输入、5V固定输出 SOP7封装
单片机·嵌入式硬件·物联网
xiebingsuccess18 小时前
LC谐振电路分析
嵌入式硬件
恒森宇电子有限公司18 小时前
南麟LN1173 低压差LDO线性稳压器芯片
单片机·嵌入式硬件
白又白、18 小时前
时序优化和上板调试小结
fpga开发
LS_learner19 小时前
ESP-IDF 多版本共存安装方案
嵌入式硬件
AzusaFighting20 小时前
STM32F103R HAL CAN 通信实战 with Copilot
stm32·单片机·嵌入式硬件
himobrinehacken20 小时前
Windows调试技巧:从Hello到I Love C++
stm32·单片机·嵌入式硬件