Forum Discussion
Altera_Forum
Honored Contributor
12 years agoLet me suggest an easier way.
assume S1,S2 are inputs (8 bits wide each). Use two shift registers with (n) stages. Let the data S1,S2 shift through till the end and freeze the shift register then you can compare each value with others for equality and distance becomes index difference. For example if s1_shift(0) = s2_shift(3) then distance is 3-0 = 3 and so on. To code for shift register do this in a clocked process.
s1_shift(0) <= s1;
for i in 1 to n-1 loop -- n declared somewhere
s1_shift(i) <= s1_shift(i-1);
end loop;
the code for checking equality can also be done in a loop to check say index(0) of s1 with indices 0 to n-1 of s2 then index(1) of s1 with indices 0 to n-1 of s2 and so on.