I'm attempting to implement an array of buffers in Verilog where data will ripple through the buffers upon a positive edge of a clock signal (CLK) while an input signal (data_valid) is active. However, I'm encountering a problem where my data_in wire isn't connecting to the first buffer, resulting in my output being stuck in a high-impedance state.
module convolution_ip(input [7:0] data_in,
input reset, input wire init_valid, clk,
output [9:0] final_output );
integer j ;
reg [7:0] input_fm_buff[24:0] ;
wire input_load;
/////////////////////////////////////////
assign input_load = clk & init_valid;
/////////////////////////////////////////
always@(posedge input_load or posedge reset)begin
if (reset) begin
// Reset buffer
for (int j = 0; j <=24; j = j + 1) begin
input_fm_buff[j] <= 8'h00;
end
end else begin
for (int j = 0; j<=24; j = j+1) begin
if (j==24)begin input_fm_buff[j] <= data_in;
end
input_fm_buff[j] <= input_fm_buff[j+1];
end
end
end
assign final_output = input_fm_buff[1];
endmodule
schematic is looking like this

I tried for loop and nonblocking assignments to synchronize the data flow through each buffer. I want the data to ripple through the buffers when init_valid is HIGH and there is a positive edge of a clk.
I see a couple of issues here (apart from your question):
posedge input_loadin sensitivity list because this way you are trying to feed clock to your logic via anANDgate. It is not recommended in FPGA because clock routes are different than the data routes i.e. clock signal travels on separate dedicates routes. With theANDgate you are bringing theCLKsignal on to normal data routes. So the simple solution is you should use an extraelse ifin the always block.output [7:0] final_outputbut you have defined it as 10-bit.Now, to the main issue of as to why
data_inwire isn't connecting to the first buffer? You have defined your logic in the else block, as below, in a way that ifj==24then the if statement is correct and your value get assigned to the buffer address 24 i.e.input_fm_buff[24] <= data_i. But then, followed by the if statement, you are reassigning a new value toinput_fm_buff[j]outside the if statement and that happens to beinput_fm_buff[j+1], i.e. 25, which is a non-existing memory.In other words, when
j==24then both the statementsinput_fm_buff[j] <= data_in;andinput_fm_buff[j] <= input_fm_buff[j+1];are executed, resulting in the implementation of later i.e.input_fm_buff[j] <= input_fm_buff[j+1];.The solution is to wrap your logic in if else statement.