【发布时间】:2015-07-17 11:51:07
【问题描述】:
SystemVerilog 是否为模块实例和枚举启用别名?例如,我该如何编码:
enum logic {foo, bar} myEnum
enum logic {baz, qux} myEnum
即baz和qux分别是foo和bar的别名。
【问题讨论】:
标签: system-verilog
SystemVerilog 是否为模块实例和枚举启用别名?例如,我该如何编码:
enum logic {foo, bar} myEnum
enum logic {baz, qux} myEnum
即baz和qux分别是foo和bar的别名。
【问题讨论】:
标签: system-verilog
let 构造可以对任何表达式执行此操作
enum logic {foo, bar} myEnum
let baz = foo;
let qux = bar;
您不能为实例名称设置别名。
【讨论】:
它们不能别名,但可以转换/转换。请参阅IEEE Std 1800-2012 § 6.19.4 数值表达式中的枚举类型。 LRM 示例:
typedef enum {Red, Green, Blue} Colors; typedef enum {Mo,Tu,We,Th,Fr,Sa,Su} Week; Colors C; Week W; int I; C = Colors'(C+1); // C is converted to an integer, then added to // one, then converted back to a Colors type C = C + 1; C++; C+=2; C = I; // Illegal because they would all be // assignments of expressions without a cast C = Colors'(Su); // Legal; puts an out of range value into C I = C + W; // Legal; C and W are automatically cast to int
【讨论】: