Parsing 寻找verilog 2001模块声明语法

Parsing 寻找verilog 2001模块声明语法,parsing,syntax,verilog,Parsing,Syntax,Verilog,我可以在google上找到几个v2k完整语法——但要么我疯了,要么它们在端口声明方面都以同样的方式被破坏。 输入示例: module foo ( input x, output [2:0] y); endmodule; 我找不到一种语法来解析这种语法,但他们会接受这样的东西 作为\u端口列表\u中的“端口”: { name[3:0], name2[2:0]} .. or .. .name( othername ) 也就是说,我希望在模块实例化端口

我可以在google上找到几个v2k完整语法——但要么我疯了,要么它们在端口声明方面都以同样的方式被破坏。 输入示例:

module foo ( 
    input x, 
     output [2:0] y);
endmodule;
我找不到一种语法来解析这种语法,但他们会接受这样的东西 作为\u端口列表\u中的“端口”:

         { name[3:0], name2[2:0]} 
.. or ..   .name( othername )
也就是说,我希望在模块实例化端口绑定的语法中看到的东西是为模块端口声明提供的

例子


我想我可以查看icarus源代码,或者Perl::Verilog。我希望得到一个确认,上面的语法是错误的,或者有人能指出我遗漏了什么。提供正确语法的源代码非常好…

您的第一个代码块使用在IEEE 1364-2001(第12.3.3节)和所有更高版本中有效的“端口声明列表”语法。第一个链接的语法不完整,第二个链接看起来包含

您的第二个代码块绝对有效。模块定义中类似实例端口的语法是显式端口构造。不经常使用,当您希望在外部呈现不同于内部使用的信号接口时,可以使用这些接口。以下是几个例子:

module mod1(portA);
input portA; //Implicit port named portA connected to implicit wire portA
endmodule
这里,portA是隐式的,并从输入声明继承属性,因为它共享相同的标识符portA

module mod2(.expA(sigA));
wire sigA;
endmodule

module top;
wire sigB;
mod2 modInst(.expA(sigB));
endmodule
在本例中,我们为mod2模块使用显式端口。内部expA连接到sigA,但正如您在实例modInst中看到的,我们使用外部名称来命名连接

module mod3 (.expA({sigC,sigD}), sigF, .expB(sigG[1],sigB[3:0]));
output reg [3:0] sigC, sigD;
input wire [1:0] sigG;
input wire [7:0] sigB;
output wire sigF;
endmodule
这也是有效的。端口expA假定sigC和sigD串联的宽度。与端口expB相同