---------------------------------------------------------------------------------------
-- Title          : Wishbone slave core for Carrier control and status registers
---------------------------------------------------------------------------------------
-- File           : ../carrier_csr_wbgen2_pkg.vhd
-- Author         : auto-generated by wbgen2 from carrier_csr.wb
-- Created        : Wed Jan 30 13:16:24 2019
-- Standard       : VHDL'87
---------------------------------------------------------------------------------------
-- THIS FILE WAS GENERATED BY wbgen2 FROM SOURCE FILE carrier_csr.wb
-- DO NOT HAND-EDIT UNLESS IT'S ABSOLUTELY NECESSARY!
---------------------------------------------------------------------------------------

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

package carrier_csr_wbgen2_pkg is
  
  
  -- Input registers (user design -> WB slave)
  
  type t_carrier_csr_in_registers is record
    carrier_pcb_rev_i                        : std_logic_vector(3 downto 0);
    carrier_reserved_i                       : std_logic_vector(11 downto 0);
    carrier_type_i                           : std_logic_vector(15 downto 0);
    stat_fmc_pres_i                          : std_logic;
    stat_p2l_pll_lck_i                       : std_logic;
    stat_sys_pll_lck_i                       : std_logic;
    stat_ddr3_cal_done_i                     : std_logic;
    end record;
  
  constant c_carrier_csr_in_registers_init_value: t_carrier_csr_in_registers := (
    carrier_pcb_rev_i => (others => '0'),
    carrier_reserved_i => (others => '0'),
    carrier_type_i => (others => '0'),
    stat_fmc_pres_i => '0',
    stat_p2l_pll_lck_i => '0',
    stat_sys_pll_lck_i => '0',
    stat_ddr3_cal_done_i => '0'
    );
    
    -- Output registers (WB slave -> user design)
    
    type t_carrier_csr_out_registers is record
      ctrl_led_green_o                         : std_logic;
      ctrl_led_red_o                           : std_logic;
      ctrl_dac_clr_n_o                         : std_logic;
      rst_fmc0_o                               : std_logic;
      end record;
    
    constant c_carrier_csr_out_registers_init_value: t_carrier_csr_out_registers := (
      ctrl_led_green_o => '0',
      ctrl_led_red_o => '0',
      ctrl_dac_clr_n_o => '0',
      rst_fmc0_o => '0'
      );
    function "or" (left, right: t_carrier_csr_in_registers) return t_carrier_csr_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 carrier_csr_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) = '1') then
tmp(i):= '1';
else
tmp(i):= '0';
end if; 
end loop; 
return tmp;
end function;
function "or" (left, right: t_carrier_csr_in_registers) return t_carrier_csr_in_registers is
variable tmp: t_carrier_csr_in_registers;
begin
tmp.carrier_pcb_rev_i := f_x_to_zero(left.carrier_pcb_rev_i) or f_x_to_zero(right.carrier_pcb_rev_i);
tmp.carrier_reserved_i := f_x_to_zero(left.carrier_reserved_i) or f_x_to_zero(right.carrier_reserved_i);
tmp.carrier_type_i := f_x_to_zero(left.carrier_type_i) or f_x_to_zero(right.carrier_type_i);
tmp.stat_fmc_pres_i := f_x_to_zero(left.stat_fmc_pres_i) or f_x_to_zero(right.stat_fmc_pres_i);
tmp.stat_p2l_pll_lck_i := f_x_to_zero(left.stat_p2l_pll_lck_i) or f_x_to_zero(right.stat_p2l_pll_lck_i);
tmp.stat_sys_pll_lck_i := f_x_to_zero(left.stat_sys_pll_lck_i) or f_x_to_zero(right.stat_sys_pll_lck_i);
tmp.stat_ddr3_cal_done_i := f_x_to_zero(left.stat_ddr3_cal_done_i) or f_x_to_zero(right.stat_ddr3_cal_done_i);
return tmp;
end function;
end package body;
