I\'m trying to create a reusable barrel shifter; it takes an input array of bits and shifts them a certain number of positions (determined by another input). I want to parameter
You can create a log2-function in a library, like this:
function f_log2 (x : positive) return natural is
variable i : natural;
begin
i := 0;
while (2**i < x) and i < 31 loop
i := i + 1;
end loop;
return i;
end function;
If the library is imported you may then specify the port like this:
shift_cnt : in std_logic_vector(f_log2(NUMBITS)-1 downto 0)
It is a somewhat ugly solution, but it doesn't use any resources (since the function is pure and all the inputs are known at compile time).
I usually do this, but you may prefer specifying the log value as the generic like you're mentioning.