23 lines
		
	
	
		
			615 B
		
	
	
	
		
			VHDL
		
	
	
	
	
	
			
		
		
	
	
			23 lines
		
	
	
		
			615 B
		
	
	
	
		
			VHDL
		
	
	
	
	
	
-- This package should cover all non-project specific maths functions that can be called
 | 
						|
-- Some of these are only suitable for use pre-synthesis, as they will not function properly
 | 
						|
-- during normal operation. These will be marked appropriately during creation
 | 
						|
 | 
						|
library ieee;
 | 
						|
use ieee.std_logic_1164.all;
 | 
						|
use ieee.numeric_std.all;
 | 
						|
use ieee.math_real.all;
 | 
						|
 | 
						|
package maths_pkg is
 | 
						|
 | 
						|
  function log_ceil(input : natural) return natural;
 | 
						|
 | 
						|
end package;
 | 
						|
 | 
						|
package body maths_pkg is
 | 
						|
 | 
						|
  function log_ceil(input : natural) return natural is
 | 
						|
  begin
 | 
						|
    return natural(ceil(log2(real(input))));
 | 
						|
  end function;
 | 
						|
 | 
						|
end package body; |