---------------------------------------------------------------------------------------
-- Title          : Wishbone slave core for WR Switch Hardware Info Unit
---------------------------------------------------------------------------------------
-- File           : hwiu_wbgen2_pkg.vhd
-- Author         : auto-generated by wbgen2 from wrsw_hwiu.wb
-- Created        : Wed Feb  5 16:15:53 2014
-- Standard       : VHDL'87
---------------------------------------------------------------------------------------
-- THIS FILE WAS GENERATED BY wbgen2 FROM SOURCE FILE wrsw_hwiu.wb
-- DO NOT HAND-EDIT UNLESS IT'S ABSOLUTELY NECESSARY!
---------------------------------------------------------------------------------------

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

package hwiu_wbgen2_pkg is
  
  
  -- Input registers (user design -> WB slave)
  
  type t_hwiu_in_registers is record
    cr_rd_err_i                              : std_logic;
    cr_rd_en_i                               : std_logic;
    reg_val_i                                : std_logic_vector(31 downto 0);
    end record;
  
  constant c_hwiu_in_registers_init_value: t_hwiu_in_registers := (
    cr_rd_err_i => '0',
    cr_rd_en_i => '0',
    reg_val_i => (others => '0')
    );
    
    -- Output registers (WB slave -> user design)
    
    type t_hwiu_out_registers is record
      cr_adr_o                                 : std_logic_vector(15 downto 0);
      cr_rd_en_o                               : std_logic;
      cr_rd_en_load_o                          : std_logic;
      chps_id_o                                : std_logic_vector(7 downto 0);
      end record;
    
    constant c_hwiu_out_registers_init_value: t_hwiu_out_registers := (
      cr_adr_o => (others => '0'),
      cr_rd_en_o => '0',
      cr_rd_en_load_o => '0',
      chps_id_o => (others => '0')
      );
    function "or" (left, right: t_hwiu_in_registers) return t_hwiu_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 hwiu_wbgen2_pkg is
function f_x_to_zero (x:std_logic) return std_logic is
begin
if(x = 'X' or x = 'U') then
return '0';
else
return x;
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_hwiu_in_registers) return t_hwiu_in_registers is
variable tmp: t_hwiu_in_registers;
begin
tmp.cr_rd_err_i := f_x_to_zero(left.cr_rd_err_i) or f_x_to_zero(right.cr_rd_err_i);
tmp.cr_rd_en_i := f_x_to_zero(left.cr_rd_en_i) or f_x_to_zero(right.cr_rd_en_i);
tmp.reg_val_i := f_x_to_zero(left.reg_val_i) or f_x_to_zero(right.reg_val_i);
return tmp;
end function;
end package body;
