设计网站建设选题报告,企业解决方案ppt模板,城市文化网站开发背景,787878域名文章目录 示例 #1示例 #2示例 #3 Verilog是一种硬件描述语言#xff08;HDL#xff09;#xff0c;用于设计数字电路和系统。统一、良好的代码编写风格#xff0c;可以提高代码的可维护性和可读性。
同样的功能#xff0c;不同的Verilog 编码风格也会对综合过程产生重大影… 文章目录 示例 #1示例 #2示例 #3 Verilog是一种硬件描述语言HDL用于设计数字电路和系统。统一、良好的代码编写风格可以提高代码的可维护性和可读性。
同样的功能不同的Verilog 编码风格也会对综合过程产生重大影响在综合的过程中Verilog 代码被转换为门级电路不同的代码风格综合出的电路可能是不同的对应资源的占用和功耗也会有差异。
下面以一个模3计数器为例演示3种不同写法对综合后电路的影响。
示例 #1
module cntr_mod3 (//Inputsinput clk, input rstn, //Outputsoutput reg [1:0] out,
);always (posedge clk) beginif ((!rstn) | (out[1] out[0]))out 0;elseout out 1;
endendmodule综合出的电路如下图所示三个基本的门电路 示例 #2
module cntr_mod3(//Inputsinput clk, input rstn, //Outputsoutput reg [1:0] out
);always (posedge clk) beginif (!rstn)out 0;else beginif (out 3)out 0;elseout out 1;end
endendmodule综合出了两个选择器和一个加法器相比于前一种写法将会占用更多的资源。 示例 #3
module cntr_mod3(//Inputsinput clk, input rstn, //Outputsoutput reg [1:0] out
);always (posedge clk) beginif (!rstn)out 0;else beginif (out)out 0;elseout out 1;end
endendmodule相比于上一个写法少了一个选择器。