It should be illegal, but it isn't The LRM says: Enumerated variables are type-checked in assignments, arguments, and relational operators. Enumerated variables are auto-cast into integral values, but assignment of arbitrary expressions to an enumerated variable requires an explicit cast. The LRM does not explain what "type-checked" means, but I take it to mean if it can proceed to auto-cast it to an integral expression, it will. -----Original Message----- From: owner-sv-bc@eda.org [mailto:owner-sv-bc@eda.org] On Behalf Of Neil Korpusik Sent: Thursday, March 20, 2014 5:25 PM To: sv-bc@eda.org Subject: [sv-bc] enumerated variable used with an equality operator Is the following legal? Should it be? Neil module top(); typedef enum {A,B,C,D} f_t; typedef enum {X,Y,Z } b_t; initial begin f_t f; b_t b; f = A; if (f == X) $display("matched"); // legal? end endmodule -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.Received on Thu Mar 20 17:37:52 2014
This archive was generated by hypermail 2.1.8 : Thu Mar 20 2014 - 17:37:56 PDT