Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
16593 Discussions

verilog HDL error :constant expression cannot contain a hierarchical identifier

Altera_Forum
Honored Contributor II
3,336 Views

Hello everyone! 

I got an error message while synthesizing my code in Quartus Prime, it said: 

verilog HDL error : constant expression cannot contain a hierarchical identifier. 

The example code is : 

interface m_if#( parameter LEFTPARA_BITW, parameter RIGHTPARA_BITW, parameter RESULT_BITW ) ( input bit clk, input wire rst ); logic leftpara; logic rightpara; logic res; modport port(input clk, rst, leftpara, rightpara, output res); endinterface module tb_m( m_if.port p ); localparam tmp_resbitw = p.LEFTPARA_BITW > p.RIGHTPARA_BITW ? p.LEFTPARA_BITW : p.RIGHTPARA_BITW;// synthesizer reports error message like above. wire tmpres = (tmp_resbitw)'(p.leftpara) + (tmp_resbitw)'(p.rightpara); always_comb begin if (p.RESULT_BITW > tmp_resbitw) p.res = (p.RESULT_BITW)'(tmpres);// synthesizer reports error message like above. else p.res = tmpres; end endmodule  

For I want to use the parameter in module 'tb_m' which is defined in interface 'm_if', how can I work around it?
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
2,063 Views

This is legal and works in simulation. I suspect it is not yet supported in Quartus Synthesis tools. 

 

I suspect you are writing this from VHDL. But all you have to do is write 

module tb_m( m_if.port p ); always_comb begin p.res = {pleftpa + p.rightpa}; endmodule 

 

Putting the addition + inside a concatenation {} makes the intermediate result with of addition self-determined, so its length is MAX(L(leftpa), L(rightpa)). See table 11-21 in the 1800-2012 LRM. There's no need to truncate the intermediate result width if it is larger than the final result. Verilog does that silently for you.
0 Kudos
Altera_Forum
Honored Contributor II
2,063 Views

 

--- Quote Start ---  

This is legal and works in simulation. I suspect it is not yet supported in Quartus Synthesis tools. 

 

I suspect you are writing this from VHDL. But all you have to do is write 

module tb_m( m_if.port p ); always_comb begin p.res = {pleftpa + p.rightpa}; endmodule 

 

Putting the addition + inside a concatenation {} makes the intermediate result with of addition self-determined, so its length is MAX(L(leftpa), L(rightpa)). See table 11-21 in the 1800-2012 LRM. There's no need to truncate the intermediate result width if it is larger than the final result. Verilog does that silently for you. 

--- Quote End ---  

 

 

Hi, Mr.dave_59! 

Thank you for replying. 

Does Altera provide any way for us to commit these deficiency?
0 Kudos
Altera_Forum
Honored Contributor II
2,063 Views

 

--- Quote Start ---  

Hi, Mr.dave_59! 

Thank you for replying. 

Does Altera provide any way for us to commit these deficiency? 

--- Quote End ---  

 

 

Yes. Open a service request. You'll need an Altera account to do that.
0 Kudos
Reply