-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathenum_data.sv
executable file
·41 lines (31 loc) · 916 Bytes
/
enum_data.sv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
module enum_data();
enum integer {IDLE=0, GNT0=1, GNT1=2} state;
enum {RED,GREEN,ORANGE} color;
enum {BRONZE=3, SILVER, GOLD} medal;
enum {US, CHINA, INDIA} country;
// a=0, b=7, c=8
enum {a, b=7, c} alphabet;
// Width declaration
enum bit [3:0] {bronze='h1, silver, gold='h5} newMedal;
// Using enum in typedef
typedef enum { red, green, blue, yellow, white, black } Colors;
Colors Lcolors;
initial begin
state = IDLE;
color = RED;
medal = BRONZE;
alphabet = c;
newMedal = silver;
Lcolors = yellow;
country = CHINA;
$display (" state = %0d", state);
$display (" state = %s", state.name());
$display (" color = %s", color.name());
$display (" medal = %s", medal.name());
$display (" alphabet = %s", alphabet.name());
$display (" newMedal = %s", newMedal.name());
$display (" Lcolors = %s", Lcolors.name());
$display (" country = %s", country.name());
$finish;
end
endmodule