2016-05-16 168 views
2
module sobel_CI(a,result,clock); 

input clock; 
input [31:0] a[0:3]; 

output [31:0] result; 
assign result= a[0]+a[1]+a[2]+a[3]; 
endmodule 

我試圖做的Verilog陣列的聲明,但是它顯示了一個錯誤:Verilog的數組賦值

function argument with unpacked array required systemverilog extensions.

什麼是錯我的陣列?

回答

5

在Verilog中,您不能使用多維實體作爲輸入或輸出,它在SystemVerilog中是允許的。

Verilog doesn't allow an I/O port to be a 2-D array.

在Verilog 2001中,你可以將你的數組壓縮成一個向量並通過端口傳遞,但這有些尷尬。下面是做這件事:

module top (in, out); 
input [31:0] in; 
wire  [7:0] array [0:3]; 
output [31:0] out; 

assign {array[3],array[2],array[1],array[0]} = in; 
assign out = {array[3],array[2],array[1],array[0]}; 
endmodule 
+2

同樣,除非你真的有一個很好的理由,否則我建議使用SystemVerilog的。 Verilog語言11年前變成了SystemVerilog。在這個答案中的解決方法是在Verilog中完成的唯一方法,但它很尷尬,並且容易產生打字錯誤,這些錯誤很難找到。 – nguthrie