为了高效的编写Verilog,通常有些编辑器插件可以自动生成代码,比如自动端口定义,自动连线,自动实例化等等。公司的环境有很好用的自动化插件,想给自己的电脑也整个怎么做。比如Emacs中有个插件叫verilog-mode。但是博主习惯了用Vim,查询后发现Vim也可以调用这个插件来实现自动化。verilog-mode开发者网站在这里,更多内容去上网查询。https://www.veripool.org/wiki/verilog-mode这个是vim官网上的一个插件,但是有一些小bug,但是有好用的autodefine功能,这两个可以配合着用,写代码的时候可以完全不用在意reg和wire类型的定义,直接写assign和always块,最后autodefine一下就可以了。更多内容点击上面的视频观看。https://www.vim.org/scripts/script.php?script_id=4067自动化前
module test (/*AUTOARG*/);input clk;input rst_n; input i;output douty;parameter DWIDTH=32;/*AUTOREG*//*AUTOWIRE*/assign doutx = i;always @(posedge clk or negedge rst_n)begin if(!rst_n)begin douty <= 1'd0; end else douty <= doutx;endassign doutx = i & o[DWODTH-1];foo u_foo(/*autoinst*/);endmodule//Local Variables://verilog-library-directories:("." "foo")//End:module foo(/*AUTOARG*/);input i;output [DWIDTH-1:0] o;endmodule//Local Variables://verilog-library-directories:(".")//End:自动化后module test (/*AUTOARG*/ // Outputs douty, // Inputs clk, rst_n, i );input clk;input rst_n; input i;output douty;parameter DWIDTH=32;/*AUTOREG*/// Beginning of automatic regs (for this module's undeclared outputs)reg douty;// End of automatics/*AUTOWIRE*/// Beginning of automatic wires (for undeclared instantiated-module outputs)wire [DWIDTH-1:0] o; // From u_foo of foo.v// End of automaticsassign doutx = i;always @(posedge clk or negedge rst_n)begin if(!rst_n)begin douty <= 1'd0; end else douty <= doutx;endassign doutx = i & o[DWODTH-1];foo u_foo(/*autoinst*/ // Outputs .o (o[DWIDTH-1:0]), // Inputs .i (i));endmodule//Local Variables://verilog-library-directories:("." "foo")//End:module foo(/*AUTOARG*/ // Outputs o, // Inputs i );input i;output [DWIDTH-1:0] o;endmodule//Local Variables://verilog-library-directories:(".")//End:需要在开发环境中安装Emacs,支持Windows和Linux。更多配置操作点击上方视频观看。欢迎去关注硅农 B站同名账号,硅农,更多视频敬请期待,还有不要忘记三连三连啊。Windows Emacs安装包:
链接:https://pan.baidu.com/s/1zPnschbDy1fIJRkTYiyWYQ提取码:5u2t