相关文章推荐
怕老婆的卤蛋  ·  Oracle ...·  3 月前    · 
俊逸的热带鱼  ·  SQLite Database ...·  1 年前    · 
冷冷的松鼠  ·  Git: Could not ...·  1 年前    · 
首发于 硅农
这才是用Gvim写Verilog的正确方式

这才是用Gvim写Verilog的正确方式

环境:RedHat Linux,工具:GVim,Emacs

为了高效的编写Verilog,通常有些编辑器插件可以自动生成代码,比如自动端口定义,自动连线,自动实例化等等。公司的环境有很好用的自动化插件,想给自己的电脑也整个怎么做。比如Emacs中有个插件叫verilog-mode。但是博主习惯了用Vim,查询后发现Vim也可以调用这个插件来实现自动化。

verilog-mode开发者网站在这里,更多内容去上网查询。

veripool.org/wiki/veril

自动化前

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;
    douty <= doutx;
assign 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

自动化后

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 automatics
assign doutx = i;
always @(posedge clk or negedge rst_n)begin
  if(!rst_n)begin
    douty <= 1'd0;
    douty <= doutx;
assign 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
   // Inputs
input i;
output [DWIDTH-1:0] o;