热度 22
2014-4-29 17:13
2953 次阅读|
1 个评论
本节通过实例介绍一下多时钟周期路径 (multicycle paths) 的约束方法。 如图 1 中结构,主时钟 fast_clk ,时钟频率 250MHz ;时钟使能信号 div_by_two ,由主时钟 2 分频得到,作为寄存器的 clock enable 信号。 图 1 HDL 代码如下所示: 以下是代码片段: module top( fast_clk, din_a, din_b, din_x, din_y, ab_out, xy_out ); ////////////// PORT ///////////////////////////// input fast_clk; input din_a; input din_b; input din_x; input din_y; output reg ab_out; output reg xy_out; ////////////// ARCHITECTURE ///////////////////// // Clock Enable reg div_by_two; always@(posedge fast_clk) div_by_two=~div_by_two; // Input Registers reg din_a_rg; reg din_b_rg; reg din_x_rg; reg din_y_rg; always@(posedge fast_clk) begin if(div_by_two) begin din_a_rg = din_a; din_b_rg = din_b; din_x_rg = din_x; din_y_rg = din_y; end end // Multiplexer wire mult_a; wire mult_b; assign mult_a = div_by_two ? din_a : din_x; assign mult_b = div_by_two ? din_b : din_y; // Multiplier wire mult_rlt; assign mult_rlt = mult_a * mult_b; // Ouptut Select always@(posedge fast_clk) begin if(div_by_two) xy_out = mult_rlt; else ab_out = mult_rlt; end endmodule