首页 | 新闻 | 新品 | 文库 | 方案 | 视频 | 下载 | 商城 | 开发板 | 数据中心 | 座谈新版 | 培训 | 工具 | 博客 | 论坛 | 百科 | GEC | 活动 | 主题月 | 电子展
返回列表 回复 发帖

时钟分频引起的问题

时钟分频引起的问题

代码:
<textarea cols="87" rows="15" name="code" class="c-sharp">reg[31:0] wait_count; reg[31:0] max_wait_count; //times/1us always @(posedge clk1) max_wait_count &lt;= {sendTickH, sendTickL}; reg clk1us; parameter US_COUNT_OF_25M = 12500; reg[15:0] clk1us_count; always @(posedge clk25 or negedge gblnrst) begin if(!gblnrst) begin clk1us_count &lt;= 16'd0; clk1us &lt;= 1'b0; end else begin if(clk1us_count &lt; US_COUNT_OF_25M) clk1us_count &lt;= clk1us_count + 16'd1; else begin clk1us_count &lt;= 16'd0; clk1us &lt;= ~clk1us; end end end always @(posedge clk1us) begin if(fiber_state2 &lt; FIBER_CALC) begin wait_count &lt;= 32'd0; wait_status_ok &lt;= 1'b0; end else begin if(wait_count &gt;= max_wait_count &amp;&amp; (fiber_state2 == FIBER_CALC || fiber_state2 == FIBER_FILL)) begin wait_count &lt;= 32'd0; end else begin if(wait_count &lt; max_wait_count) wait_count &lt;= wait_count + 32'd1; else wait_status_ok &lt;= 1'b1; end end end </textarea>




STA时序分析工具出现警告时序不满足条件。查看RTL图,发现clk1us激励代码被认为clk25下的组合逻辑电路,最终造成时序不满足条件。后来想到一个办法:



改为:
<textarea cols="87" rows="15" name="code" class="c-sharp">reg[31:0] wait_count; reg[31:0] max_wait_count; //times/1us always @(posedge clk1) max_wait_count &lt;= {sendTickH, sendTickL}; reg clk1us, clk1us_1, clk1us_2; parameter US_COUNT_OF_25M = 12500; reg[15:0] clk1us_count; always @(posedge clk25 or negedge gblnrst) begin if(!gblnrst) begin clk1us_count &lt;= 16'd0; clk1us &lt;= 1'b0; end else begin if(clk1us_count &lt; US_COUNT_OF_25M) clk1us_count &lt;= clk1us_count + 16'd1; else begin clk1us_count &lt;= 16'd0; clk1us &lt;= ~clk1us; end end end always @(posedge clk25) begin clk1us_1 &lt;= clk1us; clk1us_2 &lt;= clk1us_1; end wire clk1us_posedge; assign clk1us_posedge = ~clk1us_2 &amp; clk1us_1; always @(posedge clk25) begin if(fiber_state2 &lt; FIBER_CALC) begin wait_count &lt;= 32'd0; wait_status_ok &lt;= 1'b0; end else begin if(clk1us_posedge) begin if(wait_count &gt;= max_wait_count &amp;&amp; (fiber_state2 == FIBER_CALC || fiber_state2 == FIBER_FILL)) begin wait_count &lt;= 32'd0; end else begin if(wait_count &lt; max_wait_count) wait_count &lt;= wait_count + 32'd1; else wait_status_ok &lt;= 1'b1; end end end end </textarea>
返回列表