Question: Execute the code implementing the Structure with enum data type and access all the elements of the enum using inbuilt methods of enum ( NOTE:

Execute the code implementing the Structure with enum data type and
access all the elements of the enum using inbuilt methods of enum
(NOTE: execute the code without Typedef
module eg_struct;
enum {RED, GREEN, BLACK, PURPLE, WHITE, GREY} color;
struct {
enum color; // Member of the enum type
} s_name;
initial begin
s_name.color = RED;-)))))
// Display the color names using built-in enum methods
$display("First Colour name: %s", s_name.color.name);
$display("Last Color name: %s", color.name(color.last));
$display("Next Color name: %s", color.name(color.next(s_name.color)));
$display("Second Next color name: %s", color.name(color.next(color.next(s_name.color)))));
$display("Previous Color name: %s", color.name(color.prev(s_name.color)));
$display("Second Previous Color name: %s", color.name(color.prev(color.prev(s_name.color)))));
end
endmodule

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!