Forum Discussion
Altera_Forum
Honored Contributor
12 years agoJudging from your code you assume S1/S2 are inputs each 24 bits. However I doubt it.
More likely you enter (n) elements each 24 bits wide into two rom tables (e.g. from a file). Once you have these two roms then you read rom1 output and check each output against rom2 output until you find a match then the distance is address2 - address1 then you perform your computation circuitry of adding all results * (n^2-1)/2 The divide by 2 is easiest(just discard 1 LSB from final result). for n^2-1 use multiplier subtractor directly(multiply n * n) then subtract 1 for final division you will need a divider