2011-02-06 85 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相同。