wait until Flag = '0';
if count_max = 0
then
if (max_left >= peak_left)
AND (max_left > twelve_db)
then
count_peak_l <= 0;
peak_left <= max_left;
end if;
if (max_right >= peak_right)
AND (max_right > twelve_db)
then
count_peak_r <= 0;
peak_right <= max_right;
end if;
end if;
wait for 5 ns;
if count_max = 0
then
MAX_L <= max_left;
MAX_R <= max_right;
max_left <= LOG_L;
max_right <= LOG_R;
PEAK_L <= peak_left;
PEAK_R <= peak_right;
else
if LOG_L > max_left
then
max_left <= LOG_L;
end if;
if LOG_R > max_right
then
max_right <= LOG_R;
end if;
end if;
wait until FLAG = '1';
if count_max = 2204
then
count_max <= 0;
count_peak_l <= count_peak_l + 1;
count_peak_r <= count_peak_r + 1;
if count_peak_l = 39
then
peak_left <= "0000";
count_peak_l <= 0;
else
count_peak_l <= count_peak_l + 1;
end if;
if count_peak_r = 39
then
peak_right <= "0000";
count_peak_r <= 0;
else
count_peak_r <= count_peak_r + 1;
end if;
else
count_max <= count_max + 1;
end if;