Line 17... |
Line 17... |
function is_pow2(input : in natural) return boolean;
|
function is_pow2(input : in natural) return boolean;
|
|
|
--! Calculates log2 with integers.
|
--! Calculates log2 with integers.
|
function log2(input : in natural) return natural;
|
function log2(input : in natural) return natural;
|
|
|
|
-- Gets the value of the sel signals to the wishbone interconnect for the specified
|
|
-- operand size and address.
|
|
function wb_get_data_sel(size : in std_logic_vector(1 downto 0); address : in std_logic_vector)
|
|
return std_logic_vector;
|
|
|
end package pp_utilities;
|
end package pp_utilities;
|
|
|
package body pp_utilities is
|
package body pp_utilities is
|
|
|
function to_std_logic(input : in boolean) return std_logic is
|
function to_std_logic(input : in boolean) return std_logic is
|
Line 33... |
Line 38... |
end function to_std_logic;
|
end function to_std_logic;
|
|
|
function is_pow2(input : in natural) return boolean is
|
function is_pow2(input : in natural) return boolean is
|
variable c : natural := 1;
|
variable c : natural := 1;
|
begin
|
begin
|
for i in 0 to 31 loop
|
for i in 0 to 30 loop -- FIXME: Simulator complains about 2^31 being out of range!
|
if input = i then
|
if input = i then
|
return true;
|
return true;
|
end if;
|
end if;
|
|
|
c := c * 2;
|
c := c * 2;
|
Line 56... |
Line 61... |
end loop;
|
end loop;
|
|
|
return retval;
|
return retval;
|
end function log2;
|
end function log2;
|
|
|
|
function wb_get_data_sel(size : in std_logic_vector(1 downto 0); address : in std_logic_vector)
|
|
return std_logic_vector is
|
|
begin
|
|
case size is
|
|
when b"01" =>
|
|
case address(1 downto 0) is
|
|
when b"00" =>
|
|
return b"0001";
|
|
when b"01" =>
|
|
return b"0010";
|
|
when b"10" =>
|
|
return b"0100";
|
|
when b"11" =>
|
|
return b"1000";
|
|
when others =>
|
|
return b"0001";
|
|
end case;
|
|
when b"10" =>
|
|
if address(1) = '0' then
|
|
return b"0011";
|
|
else
|
|
return b"1100";
|
|
end if;
|
|
when others =>
|
|
return b"1111";
|
|
end case;
|
|
end function wb_get_data_sel;
|
|
|
end package body pp_utilities;
|
end package body pp_utilities;
|
|
|
No newline at end of file
|
No newline at end of file
|