module Delay_Module (
input wire clk,
input wire [3:0] data_in,
input wire [7:0] delay_cycles,
output reg [3:0] output_data
);
reg [4:0] counter = 0;
reg [3:0] memory [0:47];
integer i;
integer j;
reg flag;
initial begin
for(j=0; j<48;j = j+1)begin
memory[j]<=4'b0000;
end
output_data <=0;
flag <= 1;
end
always @(posedge clk ) begin
if (flag == 1) begin
for(i = delay_cycles-1; i >= 0; i = i - 1 )begin
memory[i+1] <= memory[i];
output_data <= memory[delay_cycles-2];
memory[0]<=data_in;
end
end
end
endmodule
I have to design a delay module, that stores data for delay_cycles time gpio inputs in memory and then outputs the stored data. The maximum value for delay_cycles is 48, same as memory size.
For synthesis, Vivado likely expects the loop to execute a constant number of times, but your
forloop uses a variabledelay_cyclesin the start condition.You declared a
countervariable, but did not use it. You could implement a counter instead of using theforloop.