系统Verilog中的复杂数据类型(队列哈希)

发布于 2025-01-29 19:05:03 字数 226 浏览 4 评论 0原文

假设我声明了一个队列:axi4_req_txn_t wr_req_queue [$];> 现在,我想拥有一个队列,关键是地址,数据是排队的指针。在Systemverilog中是否有可能?

当我像这样编写代码时:typedef wr_req_queue waw_hash [*];编译器报告wr_req_queue不是有效的类型。

Suppose I declared a queue: axi4_req_txn_t wr_req_queue[$];
Now I want to have a hash of queue, key is the address and data is the pointer to the queue; Is it possible in systemverilog ?

when I write code like this: typedef wr_req_queue waw_hash[*]; the compiler reports that wr_req_queue is not a valid type.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

桜花祭 2025-02-05 19:05:03

一条经验法则是,如果您想在另一个Typedef中使用,则将任何复杂的结构表示为Typedef。因此,这是一系列排队的简单示例:

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

A rule of thumb is to express any complicated struct as a typedef if you want to use in another typedef. So, here is a simple example of array of queues:

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

Or vice versa, queue of arrays:

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文