假设我声明了一个队列:axi4_req_txn_t wr_req_queue[$];
现在我想要一个队列的散列,键是地址,数据是指向队列的指针;在systemverilog中有可能吗?
当我编写如下代码:typedef wr_req_queue waw_hash[*];
时,编译器报告wr_req_queue
不是有效类型。
发布于 2022-05-16 09:52:31
经验法则是,如果您想要在另一个ty对联f中使用,则将任何复杂的结构表示为ty胡枝子。下面是一个队列数组的简单示例:
package pkg;
typedef int mytype_t; // whatever the type of queue elements
typedef mytype_t queue_type_t[$]; // queue of mytype_t
typedef queue_type_t array_type_t[int]; // associative array of queues
endpackage // pkg
// test the above
module tb;
import pkg::*;
array_type_t arr;
initial begin
arr[0] = {0};
arr[1] = {1};
arr[3] = {arr[0], arr[1]};
$display(arr);
end
endmodule // tb
或者反之亦然,数组队列:
package pkg;
typedef int/*your type*/ mytype_t;
typedef mytype_t array_type_t[int];
typedef array_type_t queue_type_t[$];
endpackage // pkg
module tb;
import pkg::*;
array_type_t arr;
initial begin
array_type_t arr1, arr2;
queue_type_t que;
arr1[0] = 0;
arr2[0] = 1;
arr2[1] = 2;
que = {arr1};
que = {que,arr2};
$display(que);
end
endmodule // tb
https://stackoverflow.com/questions/72256005
复制相似问题