0

I'm trying to design a fifo that accepts a maximum of N=4 words and has a M=2 bit width of each word. I first designed a 1 bit width word fifo and I'm trying to use it for the wider one. I'm having an issue debugging the line

single_fifo fArr[M-1:0]({M*{clk}},{M*{reset}},in,{M*{push}},{M*{pop}},out,full_string);

While getting the following error:

ncelab: *E,PCAVDM (./fifo.v,85|27): Vector length of port connection expression (32) in array of instances does not match product of number of instances (2) and port length (1). single_fifo fArrM-1:0;

My code has nothing that's 32 bits long so I'm quite confused by this error.

My code:

 module fifo(clk, reset, in, push, pop, out, full);
   parameter N=4; // determines the maximum number of words in queue.
   parameter M=2; // determines the bit-width of each word, stored in the queue.

   input clk, reset, push, pop;
   input [M-1:0] in;
   output [M-1:0] out;

   wire [M-1:0] full_string;
   output full;
   wire full;

   single_fifo fArr[M-1:0]({M*{clk}},{M*{reset}},in,{M*{push}},{M*{pop}},out,full_string);

   assign full=|full_string;

endmodule

I'll also add the list of ports for single_fifo in case it's required:

module single_fifo(clk,reset,in_bit,push,pop,out_bit,full);
   parameter N=4; // determines the maximum number of words in queue.
   input clk, reset, push, pop;
   input in_bit;
   output out_bit;

   reg [N-1:0] bit_list;
   reg [N-1:0] n; 
   reg out_bit;
   output full;
   reg full;

Sorry if my question seems noobish, I'm still new to verilog. Help will be appriciated!

2
  • 2
    {M*{clk} means multiplication of M by clk and the 32-bit wide result. you probably meant this {M{clk}} which is the replication operator with a 2-bit result. Commented Jan 4, 2020 at 20:24
  • Second time you help me today, you're a life saver! Thank you! Commented Jan 4, 2020 at 20:29

1 Answer 1

2

Although you probably meant to use replication {M{clk}} instead of multiplication {M*{clk}}, there is no need for any of this with an array of instances. Verilog automatically replicates the signals you connect to an array of instances so you can just write

single_fifo fArr[M-1:0](clk,reset,in,push,pop,out,full_string);

P.S. I should know because I was responsible for added this feature to Verilog way back in 1990. See section 23.3.3.5 Unpacked array ports and arrays of instances in the IEEE 1800-2017 LRM

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.