module top();
// create a data-type called on_off_e which is derived from enum type
typedef enum bit {OFF, ON} on_off_e;
// create a variable of enum
enum bit {CLOSE, OPEN} switch_e;
// create a variable of data-type on_off_e
on_off_e on_off;
// If you try to define variable of switch_e then tool will give compilation error because switch_e it self is a variable
//switch_e switch_val;
initial
begin
$display("on_off=%s, on_off=%b", on_off.name, on_off);
$display("switch_e=%s, switch_e=%b", switch_e.name, switch_e);
end
endmodule : top
Output:
on_off=OFF, on_off=0
switch_e=CLOSE, switch_e=0
switch_e=CLOSE, switch_e=0
No comments:
Post a Comment