---------------------------------------------------------------------------------------
-- Title          : Wishbone slave core for SiTime 5359 interface
---------------------------------------------------------------------------------------
-- File           : sit5359_regs_pkg.vhd
-- Author         : auto-generated by wbgen2 from sit5359_if_wb.wb
-- Created        : 01/11/22 17:31:58
-- Standard       : VHDL'87
---------------------------------------------------------------------------------------
-- THIS FILE WAS GENERATED BY wbgen2 FROM SOURCE FILE sit5359_if_wb.wb
-- DO NOT HAND-EDIT UNLESS IT'S ABSOLUTELY NECESSARY!
---------------------------------------------------------------------------------------

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

package sit5359_wbgen2_pkg is
  
  
  -- Input registers (user design -> WB slave)
  
  type t_sit5359_in_registers is record
    gpsr_scl_i                               : std_logic;
    gpsr_sda_i                               : std_logic;
    end record;
  
  constant c_sit5359_in_registers_init_value: t_sit5359_in_registers := (
    gpsr_scl_i => '0',
    gpsr_sda_i => '0'
    );
    
    -- Output registers (WB slave -> user design)
    
    type t_sit5359_out_registers is record
      cr_i2c_addr_o                            : std_logic_vector(7 downto 0);
      cr_clk_div_o                             : std_logic_vector(7 downto 0);
      cr_spll_en_o                             : std_logic;
      cr_osc_oe_o                              : std_logic;
      gpsr_scl_o                               : std_logic;
      gpsr_scl_load_o                          : std_logic;
      gpsr_sda_o                               : std_logic;
      gpsr_sda_load_o                          : std_logic;
      gpcr_scl_o                               : std_logic;
      gpcr_sda_o                               : std_logic;
      end record;
    
    constant c_sit5359_out_registers_init_value: t_sit5359_out_registers := (
      cr_i2c_addr_o => (others => '0'),
      cr_clk_div_o => (others => '0'),
      cr_spll_en_o => '0',
      cr_osc_oe_o => '0',
      gpsr_scl_o => '0',
      gpsr_scl_load_o => '0',
      gpsr_sda_o => '0',
      gpsr_sda_load_o => '0',
      gpcr_scl_o => '0',
      gpcr_sda_o => '0'
      );
    function "or" (left, right: t_sit5359_in_registers) return t_sit5359_in_registers;
    function f_x_to_zero (x:std_logic) return std_logic;
    function f_x_to_zero (x:std_logic_vector) return std_logic_vector;
end package;

package body sit5359_wbgen2_pkg is
function f_x_to_zero (x:std_logic) return std_logic is
begin
if x = '1' then
return '1';
else
return '0';
end if;
end function;
function f_x_to_zero (x:std_logic_vector) return std_logic_vector is
variable tmp: std_logic_vector(x'length-1 downto 0);
begin
for i in 0 to x'length-1 loop
if(x(i) = 'X' or x(i) = 'U') then
tmp(i):= '0';
else
tmp(i):=x(i);
end if; 
end loop; 
return tmp;
end function;
function "or" (left, right: t_sit5359_in_registers) return t_sit5359_in_registers is
variable tmp: t_sit5359_in_registers;
begin
tmp.gpsr_scl_i := f_x_to_zero(left.gpsr_scl_i) or f_x_to_zero(right.gpsr_scl_i);
tmp.gpsr_sda_i := f_x_to_zero(left.gpsr_sda_i) or f_x_to_zero(right.gpsr_sda_i);
return tmp;
end function;
end package body;
