0

Does SystemVerilog enables aliases for module instances and enumerations? Eg, how could I code this:

enum logic {foo, bar} myEnum
enum logic {baz, qux} myEnum

ie, baz and qux are aliases of foo and bar respectively.

2 Answers 2

2

The let construct can do this for any expression

enum logic {foo, bar} myEnum
let baz = foo;
let qux = bar;

You cannot alias an instance name.

Sign up to request clarification or add additional context in comments.

Comments

0

They cannot be aliased, but the can be casted/converted. Refer to IEEE Std 1800-2012 § 6.19.4 Enumerated types in numerical expressions. Example for the 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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.