Altera_Forum
Honored Contributor
9 years agoverilog HDL error :constant expression cannot contain a hierarchical identifier
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?