欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 教育 > 培训 > fpga系列 HDL:verilog 常见错误与注意事项 quartus13 bug 初始失效 reg *** = 1;

fpga系列 HDL:verilog 常见错误与注意事项 quartus13 bug 初始失效 reg *** = 1;

2025/2/27 16:20:03 来源:https://blog.csdn.net/ResumeProject/article/details/145308889  浏览:    关键词:fpga系列 HDL:verilog 常见错误与注意事项 quartus13 bug 初始失效 reg *** = 1;

代码

  • 顶层模块
module bug(input wire clk,output wire BitOut
);reg BitIn = 1;Encoder encoder (.clk(clk),.BitIn(BitIn),.BitOut(BitOut) );
endmodule
  • 内部逻辑模块
module Encoder(input wire clk,input wire BitIn,output reg BitOut  
);always @(posedge clk) beginif (BitIn)BitOut <= 1'b1;  elseBitOut <= 1'b0;end
endmodule

quartus13 综合结果

  • 在quartus13中综合得到的BitIn为0:
    在这里插入图片描述

quartus18 综合结果

在这里插入图片描述

修改方法

module bug(input wire clk,output wire BitOut
);reg BitIn;  // 不给 BitIn 初始值,而是通过时序逻辑赋值。(或者用wire BitIn=1;)always @(posedge clk) beginBitIn <= 1; endEncoder encoder (.clk(clk),.BitIn(BitIn),.BitOut(BitOut));endmodule

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词