0
module testy
    #(
        parameter W = 10,
        parameter C = 2
     )
     (
         aa
     );

   generate
      if (W == 8)
        begin:W8
           if(C == 1)
                begin:W8C1
                typedef struct {
                   logic [8:0] so;
                }my_struct;

                end 
           if(C == 2)
             begin:W8C2
                typedef struct {
                   logic [10:0] so;
                }my_struct;
             end
        end
   endgenerate

input my_struct aa;

endmodule

我收到此错误:

irun(64): 14.20-p001: (c) Copyright 1995-2015 Cadence Design Systems, Inc.
file: testy.v
input my_struct aa;
              |
ncvlog: *E,SVNOTY (testy.v,30|14): Syntactically this identifier appears to begin a datatype but it does not refer to a visible datatype in the current scope.
    module worklib.testy:v
        errors: 1, warnings: 0
ncvlog: *F,NOTOPL: no top-level unit found, must have recursive instances.
irun: *E,VLGERR: An error occurred during parsing.  Review the log file for errors with the code *E and fix those identified problems to proceed.  Exiting with code (status 2).

我认为生成是静态确定的,但我在编译它时遇到了问题——因为参数不能在包中被覆盖,并且在设计中想不出一种方法来实现这一点,需要合成并且不想添加接口或类。有没有更好的方法来做到这一点。如果我包含所有组合并仅使用我想要的内容,我的结构有超过 100 个条目,但我认为使用生成我可以根据一组参数将其修剪为我想要的内容。

谢谢

4

1 回答 1

0

您的问题是语句typedef中块的本地范围。generate如果您需要做的只是更改数据类型的大小,则可以使用静态确定的常量函数调用。但是,您在解压后的结构声明中遇到了另一个问题——它仍然是模块的本地文件,您将无法使用匹配的数据类型将另一个结构连接到它。接口将是更好的解决方案并且是可综合的。

另一种可能性是传递类型参数。

于 2018-09-03T03:32:19.320 回答