[英]How to return packed array to localparam in Verilog
I have a Verilog localparam and a function declared as: 我有一个Verilog localparam和一个声明为的函数:
localparam [7:0] someParam[0:15] = someFunc(8'h10);
function [7:0][15:0] someFunc();
input [7:0] some_input;
someFunc[0] = 8'h00;
...
...
endfunction
The error I get is: cannot assign packed to unpacked. 我得到的错误是:无法将打包的分配给未打包的。 Any solutions?
有什么办法吗?
Thanks. 谢谢。
Verilog doesn't support multi-dimensional parameter arrays as stated in: Verilog不支持多维参数数组,具体说明如下:
There is a ways to do it with SystemVerilog. 有一种方法可以使用SystemVerilog。 Multi-dimensional declarations are not supported, however a parameter type can be
typdef
which can be multi-dimensional. 不支持多维声明,但是参数类型可以是
typdef
,可以是多维的。 The same is true for the return type of a function. 函数的返回类型也是如此。 See IEEE1800-2012 § 6.20.1 Parameter declaration syntax and § 6.18 User-defined types .
请参阅IEEE1800-2012§6.20.1 参数声明语法和§6.18 用户定义类型 。
Example: 例:
typedef logic [7:0] someType [16];
localparam someType someParam = someFunc(8'h10);
function someType someFunc (input [7:0] some_input);
someFunc[0] = 8'h00;
// ...
endfunction
Similarly, Verilog does not support double packed arrays (ex [7:0][15:0] someFunc
). 同样,Verilog不支持双压缩数组(例如
[7:0][15:0] someFunc
)。
SystemVerilog does support double packed arrays. SystemVerilog确实支持双压缩阵列。 So another solution is:
因此,另一个解决方案是:
localparam [15:0][7:0] someParam = someFunc(8'h10);
function [15:0][7:0] someFunc (input [7:0] some_input);
someFunc[0] = 8'h00;
// ...
endfunction
Note: you want [15:0][7:0]
which is 16 arrays of 8-bits, not [7:0][15:0]
which is 8 arrays of 16-bits. 注意:您要
[15:0][7:0]
是16位8位数组,而不是[7:0][15:0]
是8位16位数组。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.