Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
-- fold begin
fold : block
-- given a level and a depth, calculate the corresponding index into the
-- intermediate array
function depth2index (levels,depth : in natural) return natural is
begin
return (2 ** levels - 2 ** depth);
end function;
signal intermediate : main_types.array_of_boolean(0 to (2*10)-2);
constant levels : natural := natural (ceil (log2 (real (10))));
begin
-- put input array into the first half of the intermediate array
intermediate(0 to 10-1) <= app_arg;
-- Create the tree of instantiated components
make_tree : if levels /= 0 generate
tree_depth : for d_0 in levels-1 downto 0 generate
tree_depth_loop : for i_0 in 0 to (natural(2**d_0) - 1) generate
intermediate(depth2index(levels+1,d_0+1)+i_0) <= intermediate(depth2index(levels+1,d_0+2)+(2*i_0)) and intermediate(depth2index(levels+1,d_0+2)+(2*i_0)+1);
end generate;
end generate;
end generate;
-- The last element of the intermediate array holds the result
case_alt <= intermediate((2*10)-2);
end block;
-- fold end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.