I copied the following section of code:
1 | // https://www.chipverify.com/systemverilog/systemverilog-enumeration
|
2 |
|
3 | module tb;
|
4 | // "e_true_false" is a new data-type with two valid values: TRUE and FALSE
|
5 | typedef enum {TRUE, FALSE} e_true_false;
|
6 |
|
7 | initial begin
|
8 | // Declare a variable of type "e_true_false" that can store TRUE or FALSE
|
9 | e_true_false answer;
|
10 |
|
11 | // Assign TRUE/FALSE to the enumerated variable
|
12 | answer = TRUE;
|
13 |
|
14 | // Display string value of the variable
|
15 | $display ("answer = %s", answer.name);
|
16 | end
|
17 | endmodule
|
verbatim from
"https://www.chipverify.com/systemverilog/systemverilog-enumeration",
fourth code listing, except I added that initial comment and a blank
line. I'm currently using Icarus as my tool to simulate Verilog. When I
execute the following:
1 | D:\Hf\Verilog\Common>\Icarus\bin\iverilog tb.sv
|
2 | tb.sv:5: syntax error
|
3 | tb.sv:5: error: Invalid module instantiation
|
4 | tb.sv:9: syntax error
|
5 | tb.sv:9: error: malformed statement
|
6 |
|
7 | D:\Hf\Verilog\Common>
|
I get those error messages. It would appear Icarus can't handle
enumerations. In addition to not being able to use enumerations in
Verilog with Icarus, it looks like I cannot use a struct either. My code
uses the example from
"http://www.testbench.in/SV_07_STRUCTURES_AND_UNIOUNS.html" like so:
1 | module Se;
|
2 |
|
3 | struct packed {
|
4 | integer a;
|
5 | byte b;
|
6 | bit[0:7] c;
|
7 | } my_data;
|
8 |
|
9 | my_data.b = 8'b10;
|
10 | $display( "%d", my_data.a);
|
11 |
|
12 | endmodule
|
This example is precisely the example on that page, sandwiched between a
"module Se;" and an "endmodule". When I execute my simulator on it I
get:
1 | D:\Hf\Verilog\Common>\Icarus\bin\iverilog Se.sv
|
2 | Se.sv:3: syntax error
|
3 | Se.sv:3: error: Invalid module instantiation
|
4 | Se.sv:5: syntax error
|
5 | Se.sv:5: error: Invalid module instantiation
|
6 | Se.sv:6: error: Invalid module instantiation
|
7 | Se.sv:7: error: invalid module item.
|
8 | Se.sv:9: syntax error
|
9 | Se.sv:9: error: Invalid module instantiation
|
10 | Se.sv:10: error: invalid module item.
|
11 |
|
12 | D:\Hf\Verilog\Common>
|
What do I have to do to get Icarus to recognize enums and/or structs? Or
if I can't do it with Icarus, is there a free simulator that does
recognize enums and structs?