emacs verilog-mode对IC顶层集成的帮助

  • 背景介绍
  • AUTOINST和AUTOWIRE的应用

背景介绍

emacs默认自带verilog-mode插件,不仅仅支持语法高亮、代码段自动补全等功能,核心应用还有/*AUTOXXX*/
IC顶层集成,最常见的工作就是实例化和端口线网的连接。可以利用/*AUTOINST*//*AUTOWIRE*/节省很多工作量,减少出错可能性。

AUTOINST和AUTOWIRE的应用

下面是示例。用到的技巧包括:
1. ctrl+c ctrl+a是把/*AUTOINST*/等关键词展开;得到实例化等代码段。连续操作,可以更新。
2. ctrl+c ctrl+k是把/*AUTOINST*/等关键词收起;
3. AUTOWIRE,是把output变量进行wire类型声明;如果input也想声明wire类型,可以临时改为output。
4. AUTOINST,默认的线网连接名称与端口名称相同;如对此有要求,可以利用AUTO_TEMPLATE。
5. 虽然实例化代码和设计代码可以不放在一个文件里,只需要在一个目录里。但个人还是推荐,把module声明和实例化放在一个临时文件里,进行生成,这样代码干净思路清晰一些。

下面有两段代码,第一段代码,按键ctrl+c ctrl+a之后,会自动生成第二段代码。
==================================
module noc(
           output        z1,
           output        z2,
           output [31:0] z3,
           input         a1,
           input         a2,
           input [31:0]  a3
           );
endmodule
module noc1(
            output        z1,
            output        z2,
            output [31:0] z3,
            output        a1,
            output        a2,
            output [31:0] a3
            );
endmodule
module a;
   /*AUTOWIRE*/
   noc u_noc(/*AUTOINST*/);
endmodule
module a;
   /*AUTOWIRE*/
   noc1 u_noc1(/*AUTOINST*/);
endmodule
module a;
   /*AUTOWIRE*/
   /* noc AUTO_TEMPLATE(
    .z1 (output1),
    .z2 (output2),
    .z3 (output3),
    .a3 (input3),
    );
    */
   noc u_noc(/*AUTOINST*/);
endmodule


===========================================================
module noc(
           output        z1,
           output        z2,
           output [31:0] z3,
           input         a1,
           input         a2,
           input [31:0]  a3
           );
endmodule
module noc1(
            output        z1,
            output        z2,
            output [31:0] z3,
            output        a1,
            output        a2,
            output [31:0] a3
            );
endmodule
module a;
   /*AUTOWIRE*/
   // Beginning of automatic wires (for undeclared instantiated-module outputs)
   wire                 output1;                // From u_noc of noc.v
   wire                 output2;                // From u_noc of noc.v
   wire                 output3;                // From u_noc of noc.v
   // End of automatics
   noc u_noc(/*AUTOINST*/
             // Outputs
             .z1                        (output1),               // Templated
             .z2                        (output2),               // Templated
             .z3                        (output3),               // Templated
             // Inputs
             .a1                        (a1),
             .a2                        (a2),
             .a3                        (input3));                // Templated
endmodule
module a;
   /*AUTOWIRE*/
   // Beginning of automatic wires (for undeclared instantiated-module outputs)
   wire                 a1;                     // From u_noc1 of noc1.v
   wire                 a2;                     // From u_noc1 of noc1.v
   wire [31:0]          a3;                     // From u_noc1 of noc1.v
   wire                 z1;                     // From u_noc1 of noc1.v
   wire                 z2;                     // From u_noc1 of noc1.v
   wire [31:0]          z3;                     // From u_noc1 of noc1.v
   // End of automatics
   noc1 u_noc1(/*AUTOINST*/
               // Outputs
               .z1                      (z1),
               .z2                      (z2),
               .z3                      (z3[31:0]),
               .a1                      (a1),
               .a2                      (a2),
               .a3                      (a3[31:0]));
endmodule
module a;
   /*AUTOWIRE*/
   // Beginning of automatic wires (for undeclared instantiated-module outputs)
   wire                 output1;                // From u_noc of noc.v
   wire                 output2;                // From u_noc of noc.v
   wire                 output3;                // From u_noc of noc.v
   // End of automatics
   /* noc AUTO_TEMPLATE(
    .z1 (output1),
    .z2 (output2),
    .z3 (output3),
    .a3 (input3),
    );
    */
   noc u_noc(/*AUTOINST*/
             // Outputs
             .z1                        (output1),               // Templated
             .z2                        (output2),               // Templated
             .z3                        (output3),               // Templated
             // Inputs
             .a1                        (a1),
             .a2                        (a2),
             .a3                        (input3));                // Templated
endmodule

你可能感兴趣的:(verilog,emacs)