Electronic – HDLCompiler:251 – Cannot access memory directly Error

verilog

I'm giving a 2d array to a VHDL module.This 2d array is valued in a verilog module.
The error that ISE is giving is that the 2d array is assumed a memory and can not be accessed.
I've googled the error but there were no answers to this specific case.
Please help me on this.
Here's the definition of the 2d array.

wire [IN_FIFO_DEPTH_BIT:0]  depth_of_fifo[NUM_QUEUES-1:0];//storing the depth of all FIFOs  
wire [IN_FIFO_DEPTH_BIT - 1:0] packet_size_temp[NUM_QUEUES-1:0];

Here's the part of my verilog code that is the source of the error.

Deficit_Round_Robbin_algorithem
#(
.Quantom(),
.Num_queues(NUM_QUEUES),
.IN_FIFO_DEPTH_BIT(IN_FIFO_DEPTH_BIT)
 )
algorithem_module(
.clk(axi_aclk),
.axi_resetn(axi_resetn),
.m_axis_tready(m_axis_tready),
.packet_size(packet_size_temp),  //Line 247
.fifo_out_tlast(fifo_out_tlast),
.empty(empty),
.rd_en(rd_en),
.pkt_fwd(pkt_fwd)
 );

And here is the error message

ERROR:HDLCompiler:251 - "K:/final project/codes/v3/input_arbiter.v" Line 247: Cannot access memory packet_size_temp directly
ERROR:HDLCompiler:598 - "K:/final project/codes/v3/input_arbiter.v" Line 46: Module <input_arbiter> ignored due to previous errors.

Best Answer

Verilog does not support two dimensional arrays or unpacked arrays as ports; SystemVerilog does. Verilog does support a packed array (also referred to as a vector) as a port.

For verilog, you need to pass the index. Examples: .packet_size(packet_size_temp[0]), or .packet_size(packet_size_temp[reg_or_wire_of_index]),.
If you need to pass the whole array, then you will need to flatten it to one big vector and slice it on the other side:

...
reg [NUM_QUEUES*IN_FIFO_DEPTH_BIT - 1:0] packet_size_temp__packed;
always @* begin
   for(idx=0; idx<NUM_QUEUES; idx=idx+1) begin
     packet_size_temp__packed[idx*IN_FIFO_DEPTH_BIT +: IN_FIFO_DEPTH_BIT] = packet_size_temp[idx];
   end
end
...
Deficit_Round_Robbin_algorithem
  #(
    ...
  )
  algorithem_module(
    ...
    .packet_size(packet_size_temp_packed),
    ...
  );
...

Review on +: stackoverflow: Indexing vectors and arrays with +: and What is +: and -:?

Enabling SystemVerilog is alternative, it does support arrayed ports. To do so, it is recommend the change the file extension from .v to .sv. Most simulators and synthesizers will properly parse the file with only the correct extinction. Another approach is to set a compiler flag which is tool dependent (usually -sv or -sverilog), but this will typically force all Verilog files to be treated as SystemVerilog which may have naming conflicts with SystemVerilog keywords.