新手上路
- 积分
- 21
- 金钱
- 21
- 注册时间
- 2019-4-7
- 在线时间
- 11 小时
|
10金钱
在第二十六章频率计实验之中,有一段代码,甚至以前也有相同的问题,就是弄不明白为什么。
原代码如下:
//门控时间内对被测时钟计数
always @(posedge clk_fx or negedge rst_n) begin
if(!rst_n) begin
fx_cnt_temp <= 32'd0;
fx_cnt <= 32'd0;
end
else if(gate)
fx_cnt_temp <= fx_cnt_temp + 1'b1;
else if(neg_gate_fx) begin
fx_cnt_temp <= 32'd0;
fx_cnt <= fx_cnt_temp;
end
end
我的问题就是,为什么不能直接操作fx_cnt 加一不就好了吗?
always @(posedge clk_fx or negedge rst_n) begin
if(!rst_n)
fx_cnt <= 32'd0;
else if(gate)
fx_cnt <= fx_cnt + 1'b1;
else
fx_cnt <= fx_cnt;
end
为什么要加多一个fx_cnt_temp来缓存
|
最佳答案
查看完整内容[请看2#楼]
fx_cnt 在程序的其他地方是要用的,而且在频率计计算中统计脉冲期间不能改变。你如果 一直对它进行累加的话,其他地方还怎么用呢
|