library IEEE; use IEEE.STD_LOGIC_1164.all; use IEEE.NUMERIC_STD.all; package OSSS_PKG is function FOSSY_TO_STD_LOGIC(ARG: BOOLEAN) return STD_LOGIC; function FOSSY_TO_STD_LOGIC_VECTOR(ARG: BOOLEAN) return STD_LOGIC_VECTOR; function FOSSY_RANGE_S34_32 ( obj : in SIGNED ( 33 downto 0 ) ; l : in INTEGER ) return STD_LOGIC_VECTOR ; function FOSSY_SUB_U32_U32 ( lhs : in UNSIGNED ( 31 downto 0 ) ; rhs : in UNSIGNED ( 31 downto 0 ) ) return SIGNED ; function FOSSY_GT_U32_U32 ( lhs : in UNSIGNED ( 31 downto 0 ) ; rhs : in UNSIGNED ( 31 downto 0 ) ) return BOOLEAN ; function FOSSY_LOG_AND_B1_B1 ( lhs : in BOOLEAN ; rhs : in BOOLEAN ) return BOOLEAN ; function FOSSY_NEQ_U32_U32 ( lhs : in UNSIGNED ( 31 downto 0 ) ; rhs : in UNSIGNED ( 31 downto 0 ) ) return BOOLEAN ; function FOSSY_EQ_B1_B1 ( lhs : in BOOLEAN ; rhs : in BOOLEAN ) return BOOLEAN ; end package OSSS_PKG ; package body OSSS_PKG is function FOSSY_RANGE_S34_32 ( obj : in SIGNED ( 33 downto 0 ) ; l : in INTEGER ) return STD_LOGIC_VECTOR is variable result : STD_LOGIC_VECTOR(31 downto 0); begin case l is when 31 => result := STD_LOGIC_VECTOR(obj(31 downto 0)); when 32 => result := STD_LOGIC_VECTOR(obj(32 downto 1)); when 33 => result := STD_LOGIC_VECTOR(obj(33 downto 2)); when others => null; end case; return result; end; function FOSSY_SUB_U32_U32 ( lhs : in UNSIGNED ( 31 downto 0 ) ; rhs : in UNSIGNED ( 31 downto 0 ) ) return SIGNED is variable signed_lhs : SIGNED(32 downto 0); variable signed_rhs : SIGNED(32 downto 0); variable extended_lhs : SIGNED(33 downto 0); variable result : SIGNED(33 downto 0); begin signed_lhs := "000000000000000000000000000000000"; signed_rhs := "000000000000000000000000000000000"; extended_lhs := "0000000000000000000000000000000000"; result := "0000000000000000000000000000000000"; signed_lhs(31 downto 0) := SIGNED(lhs(31 downto 0)); extended_lhs := (others => signed_lhs(32)); extended_lhs(31 downto 0) := signed_lhs(31 downto 0); signed_rhs(31 downto 0) := SIGNED(rhs(31 downto 0)); result := extended_lhs - signed_rhs; return result; end; function FOSSY_GT_U32_U32 ( lhs : in UNSIGNED ( 31 downto 0 ) ; rhs : in UNSIGNED ( 31 downto 0 ) ) return BOOLEAN is variable extended_lhs : UNSIGNED(31 downto 0); variable extended_rhs : UNSIGNED(31 downto 0); variable result : BOOLEAN; begin extended_lhs := "00000000000000000000000000000000"; extended_rhs := "00000000000000000000000000000000"; result := FALSE; extended_lhs(31 downto 0) := lhs(31 downto 0); extended_rhs(31 downto 0) := rhs(31 downto 0); result := extended_lhs > extended_rhs; return result; end; function FOSSY_LOG_AND_B1_B1 ( lhs : in BOOLEAN ; rhs : in BOOLEAN ) return BOOLEAN is begin return lhs and rhs; end; function FOSSY_NEQ_U32_U32 ( lhs : in UNSIGNED ( 31 downto 0 ) ; rhs : in UNSIGNED ( 31 downto 0 ) ) return BOOLEAN is variable extended_lhs : UNSIGNED(31 downto 0); variable extended_rhs : UNSIGNED(31 downto 0); variable result : BOOLEAN; begin extended_lhs := "00000000000000000000000000000000"; extended_rhs := "00000000000000000000000000000000"; result := FALSE; extended_lhs(31 downto 0) := lhs(31 downto 0); extended_rhs(31 downto 0) := rhs(31 downto 0); result := extended_lhs /= extended_rhs; return result; end; function FOSSY_EQ_B1_B1 ( lhs : in BOOLEAN ; rhs : in BOOLEAN ) return BOOLEAN is begin return lhs = rhs; end; function FOSSY_TO_STD_LOGIC (ARG: BOOLEAN) return STD_LOGIC is variable result : STD_LOGIC; begin if arg then result := '1'; else result := '0'; end if; return result; end; function FOSSY_TO_STD_LOGIC_VECTOR (ARG: BOOLEAN) return STD_LOGIC_VECTOR is variable result : STD_LOGIC_VECTOR(0 downto 0); begin result := ( 0 => FOSSY_TO_STD_LOGIC( arg ) ); return result; end; end package body OSSS_PKG ;