2011-02-06 91 views
2

我可以找到几个与谷歌v2k完整语法 - 但要么我失去了我的想法,或者他们都以同样的方式关于港口声明破碎。 例输入:寻找verilog 2001模块声明语法

module foo ( 
    input x, 
    output [2:0] y); 
endmodule; 

我无法找到一个语法,将解析语法,但他们会接受这样的事情 作为list_of_port一个“口”:

  { name[3:0], name2[2:0]} 
.. or .. .name(othername) 

即我期望在模块实例化端口绑定的语法中看到的东西被提供给模块端口声明。

例子

http://www.externsoft.ch/download/verilog.html#module_declaration

http://www.syncad.com/VeriLogger_bnf_Syntax_Verilog_2001.htm#list_of_ports

我想我可以看看伊卡洛斯源,或Perl :: Verilog的。尽管如此,我希望得到上述语法已被破解的确认 - 或者如果没有人能指出我错过了什么。一个正确的语法源将是伟大的...

回答

3

您的第一个代码块使用在IEEE 1364-2001(Sec 12.3.3)和所有更高版本中有效的list_of_port_declarations语法。从第一个链接的语法是不完整的,第二个链接看起来像它包括this construct

你的第二个代码块肯定是有效的。看起来像模块定义中的实例端口的语法是显式端口结构。不常用,当你想在外部提供不同于内部使用的信号接口时使用这些。下面是一些例子:

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相同。