shaiko
Advanced Member level 5
Hello,
I have an input array of 128 unsigned vectors - 0 to 127.
I need to compare all cells and return the POSITION of the cell with the highest result.
To achieve higher throughput - I used a pipelined tree topology as follows:
Do you see a way how this can be written more generically for any even input size ?
I have an input array of 128 unsigned vectors - 0 to 127.
I need to compare all cells and return the POSITION of the cell with the highest result.
To achieve higher throughput - I used a pipelined tree topology as follows:
Code:
comparison_tree : process ( IN_CLOCK , IN_RESET_ASYNCHRONOUS ) is
begin
if IN_RESET_ASYNCHRONOUS = '1' then
stage_0_vote <= ( others => 0 ) ;
stage_1_vote <= ( others => 0 ) ;
stage_2_vote <= ( others => 0 ) ;
stage_3_vote <= ( others => 0 ) ;
stage_4_vote <= ( others => 0 ) ;
stage_5_vote <= ( others => 0 ) ;
stage_6_vote <= ( others => 0 ) ;
stage_7_vote <= 0 ;
elsif rising_edge ( IN_CLOCK ) then
if IN_RESET_SYNCHRONOUS = '1' then
stage_0_vote <= ( others => 0 ) ;
stage_1_vote <= ( others => 0 ) ;
stage_2_vote <= ( others => 0 ) ;
stage_3_vote <= ( others => 0 ) ;
stage_4_vote <= ( others => 0 ) ;
stage_5_vote <= ( others => 0 ) ;
stage_6_vote <= ( others => 0 ) ;
stage_7_vote <= 0 ;
else
for index in 0 to 63
loop
if input ( 2 * index ) > input ( 2 * index + 1 ) then
stage_0_vote ( index ) <= 2 * index ;
else
stage_0_vote ( index ) <= ( 2 * index + 1 ) ;
end if ;
end loop ;
for index in 0 to 31
loop
if stage_0_vote ( 2 * index ) > stage_0_vote ( 2 * index + 1 ) then
stage_1_vote ( index ) <= stage_0_vote ( 2 * index ) ;
else
stage_1_vote ( index ) <= stage_0_vote ( 2 * index + 1 ) ;
end if ;
end loop ;
for index in 0 to 15
loop
if stage_1_vote ( 2 * index ) > stage_1_vote ( 2 * index + 1 ) then
stage_2_vote ( index ) <= stage_1_vote ( 2 * index ) ;
else
stage_2_vote ( index ) <= stage_1_vote ( 2 * index + 1 ) ;
end if ;
end loop ;
for index in 0 to 7
loop
if stage_2_vote ( 2 * index ) > stage_2_vote ( 2 * index + 1 ) then
stage_3_vote ( index ) <= stage_2_vote ( 2 * index ) ;
else
stage_3_vote ( index ) <= stage_2_vote ( 2 * index + 1 ) ;
end if ;
end loop ;
for index in 0 to 3
loop
if stage_3_vote ( 2 * index ) > stage_3_vote ( 2 * index + 1 ) then
stage_4_vote ( index ) <= stage_3_vote ( 2 * index ) ;
else
stage_4_vote ( index ) <= stage_3_vote ( 2 * index + 1 ) ;
end if ;
end loop ;
for index in 0 to 1
loop
if stage_4_vote ( 2 * index ) > stage_4_vote ( 2 * index + 1 ) then
stage_5_vote ( index ) <= stage_4_vote ( 2 * index ) ;
else
stage_5_vote ( index ) <= stage_4_vote ( 2 * index + 1 ) ;
end if ;
end loop ;
for index in 0 to 1
loop
if stage_5_vote ( 2 * index ) > stage_5_vote ( 2 * index + 1 ) then
stage_6_vote ( index ) <= stage_5_vote ( 2 * index ) ;
else
stage_6_vote ( index ) <= stage_5_vote ( 2 * index + 1 ) ;
end if ;
end loop ;
if stage_6_vote ( 0 ) > stage_6_vote ( 1 ) then
stage_7_vote <= stage_6_vote ( 0 ) ;
else
stage_7_vote <= stage_6_vote ( 1 ) ;
end if ;
end if ;
end if ;
end process comparison_tree ;
Do you see a way how this can be written more generically for any even input size ?