如果我有 2D 整数队列,我希望能够像这样内联声明它:
int my_queue[$][$] = {{1, 2}, {3, 4}};
我也看过
typedef int int_queue[$];
int_queue my_queue[$] = {{1, 2}, {3, 4}};
相反,当我编译时,VCS 为我提供了一个不兼容的复杂类型错误:
Type of source expression is incompatible with type of target expression.
Mismatching types cannot be used in assignments, initializations and
instantiations. The type of the target is 'int$[$][$]', while the type of
the source is 'bit[63:0]'.
这对我来说意味着 VCS 期望等式的右侧能够正确转换。我一直在使用的解决方法是:
typedef int int_queue[$];
typedef int_queue int_queue_of_queues[$];
int_queue_of_queues my_queue = int_queue_of_queues'{{1, 2}, {3, 4}};
但这为 N 维添加了 N 个额外的 typedef 和行,我宁愿在一行中执行此操作。如果我有办法在没有 typedef 的情况下转换声明的右侧,那么这很简单,但我不知道这是否可能。