1 -- The Potato Processor - A simple processor for FPGAs
2 -- (c) Kristian Klomsten Skordal 2014 <kristian.skordal@wafflemail.net>
5 use ieee.std_logic_1164.all;
7 package pp_utilities is
9 --! Converts a boolean to an std_logic.
10 function to_std_logic(input : in boolean) return std_logic;
12 -- Checks if a number is 2^n:
13 function is_pow2(input : in natural) return boolean;
15 --! Calculates log2 with integers.
16 function log2(input : in natural) return natural;
18 -- Gets the value of the sel signals to the wishbone interconnect for the specified
19 -- operand size and address.
20 function wb_get_data_sel(size : in std_logic_vector(1 downto 0); address : in std_logic_vector)
21 return std_logic_vector;
23 end package pp_utilities;
25 package body pp_utilities is
27 function to_std_logic(input : in boolean) return std_logic is
34 end function to_std_logic;
36 function is_pow2(input : in natural) return boolean is
37 variable c : natural := 1;
50 function log2(input : in natural) return natural is
51 variable retval : natural := 0;
52 variable temp : natural := input;
62 function wb_get_data_sel(size : in std_logic_vector(1 downto 0); address : in std_logic_vector)
63 return std_logic_vector is
67 case address(1 downto 0) is
80 if address(1) = '0' then
88 end function wb_get_data_sel;
90 end package body pp_utilities;