Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
Announcements
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.
15479 Discussions

ModelSim-Altera show error on compilation while Quartus not.

Altera_Forum
Honored Contributor II
1,021 Views

Quartus compile this code without any errors. 

code.sv 

`timescale 1 ns/ 1 nsmodule test013_LITERAL ( input A, input B, output C ); struct{enum{IDLE, SOME_STAGE_1} FSM; logic some_register; } first_machine; struct{enum{IDLE, SOME_STAGE_2} FSM; logic some_register; } second_machine; assign C = A ^ B; endmodule 

 

testbench.vt 

`timescale 1 ns/ 1 nsmodule testbench(); reg test_A; reg test_B; wire test_C; test013_LITERAL DUT (.A(test_A), .B(test_B), .C(test_C)); initial begin # 100 test_A = 0; test_B = 0; # 100 test_A = 1; test_B = 0; # 100 test_A = 0; test_B = 1; # 100 test_A = 1; test_B = 1; end endmodule 

 

But modelsim-Altera show error: "enum literal name 'idle' already exists.

Emm... Syntaxis of SV allowed me to use enum in struct but literal scope in struct is still common while registers scope in struct is privat. 

 

Can I write on SystemVerilog two structs in one module and then make enum in each struct with same literal ("IDLE" for example)? Is another struct means another scope? 

If not can anyone describe what structs are used for? 

If yes can anyone describe to me how to win ModelSim-Altera?
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
87 Views

Hi, 

--- Quote Start ---  

Can I write on SystemVerilog two structs in one module and then make enum in each struct with the same literal ("IDLE" for example)? Is another struct means another scope? 

If not can anyone describe what structs are used for? 

If yes can anyone describe to me how to win ModelSim-Altera? 

--- Quote End ---  

You can use two structs in one module but you can`t use the same enumeration constants between two different enumeration types (since two structs have individual scope) inside two different structs. 

No two enum types can use the same enumeration constants between them 

If you want to use the same enumeration constants between two different enumeration types, you'll have to create unique prefixes or suffixes for them (for example IDLE_1) 

 

 

Best Regards 

Vikas Jathar  

(This message was posted on behalf of Intel Corporation)
Reply