Forum Discussion
Altera_Forum
Honored Contributor
12 years agoHow to find largest value and its position in memory array?
As attachment... the memory array contains continuous input at every positive edge clock... these inputs are the outputs from the Altera FFT core... then i need to find the peak and its location... p...
Altera_Forum
Honored Contributor
12 years ago --- Quote Start --- is it like this? reg [26:0] peak_value [0:10]; reg [14:0] peak_location [0:10]; reg [3:0] i; always @ (posedge clk) begin if (data_en) begin if (abs_source_real > peak_value_temp) begin peak_value <= abs_source_real;
peak_location <= Q-3; end Q <= Q + 1; i <= i + 1; end end --- Quote End --- No, I said increment counter i only when a peak occurs. So put inside your test construct, not outside as it will keep going up and becomes same as Q