module my_delay_mod(
input [11:0]audio,
input delay_clk,
output [11:0]delay_out
);
integer i;
reg [11:0]memory[0:4999];
always @ (posedge delay_clk) begin
memory[0]<=audio;
for (i=0; i<4999; i=i+1) begin
memory[i+1]<=memory[i];
end
end
assign delay_out = memory[4999];
endmodule
答案 0 :(得分:1)
Your code will be hard to synthesis. If you want a synthesisable code, I suggest that, you use a RAM based shift register. You can either use the IP's available with the vendor(I know Xilinx have one in Coregen) or make your own(not so complicated).
In a RAM based shift register you don't really shift all the data in every clock cycle. But you have different read and write pointers. The values of these pointers are separated by the delay value(in terms of number of clock cycles).
the steps would be,
答案 1 :(得分:0)
假设您的delay_clk为20Khz,这与您的mic_i N 的采样率相同,则 U 可以尝试下面的代码 S 。
integer ee;
reg [11:0] memory[0:2020];
always @ (posedge delay_clk) begin
memory[0]<=audio;
for (ee = 0; ee < 2020; ee = ee+1) begin
memory[ee+1]<=memory[ee];
end
delay_out <= memory[2020];
end
这是一些可能对您有帮助的示例代码,但值可能不正确。这应该指向正确的方向。