nic_wbgen2_pkg.vhd 4.45 KB
Newer Older
1 2 3 4 5
---------------------------------------------------------------------------------------
-- Title          : Wishbone slave core for White Rabbit Switch NIC's spec
---------------------------------------------------------------------------------------
-- File           : nic_wbgen2_pkg.vhd
-- Author         : auto-generated by wbgen2 from wr_nic.wb
6
-- Created        : Mon Aug  1 16:26:56 2016
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
-- Standard       : VHDL'87
---------------------------------------------------------------------------------------
-- THIS FILE WAS GENERATED BY wbgen2 FROM SOURCE FILE wr_nic.wb
-- DO NOT HAND-EDIT UNLESS IT'S ABSOLUTELY NECESSARY!
---------------------------------------------------------------------------------------

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

package nic_wbgen2_pkg is
  
  
  -- Input registers (user design -> WB slave)
  
  type t_nic_in_registers is record
    sr_bna_i                                 : std_logic;
    sr_rec_i                                 : std_logic;
    sr_tx_done_i                             : std_logic;
    sr_tx_error_i                            : std_logic;
    sr_cur_tx_desc_i                         : std_logic_vector(2 downto 0);
    sr_cur_rx_desc_i                         : std_logic_vector(2 downto 0);
30 31
    rxbw_i                                   : std_logic_vector(31 downto 0);
    maxrxbw_i                                : std_logic_vector(15 downto 0);
32 33 34 35 36 37 38 39
    end record;
  
  constant c_nic_in_registers_init_value: t_nic_in_registers := (
    sr_bna_i => '0',
    sr_rec_i => '0',
    sr_tx_done_i => '0',
    sr_tx_error_i => '0',
    sr_cur_tx_desc_i => (others => '0'),
40
    sr_cur_rx_desc_i => (others => '0'),
41 42
    rxbw_i => (others => '0'),
    maxrxbw_i => (others => '0')
43 44 45 46 47 48 49
    );
    
    -- Output registers (WB slave -> user design)
    
    type t_nic_out_registers is record
      cr_rx_en_o                               : std_logic;
      cr_tx_en_o                               : std_logic;
50
      cr_rxthr_en_o                            : std_logic;
51
      cr_sw_rst_o                              : std_logic;
52 53 54 55 56 57
      sr_rec_o                                 : std_logic;
      sr_rec_load_o                            : std_logic;
      sr_tx_done_o                             : std_logic;
      sr_tx_done_load_o                        : std_logic;
      sr_tx_error_o                            : std_logic;
      sr_tx_error_load_o                       : std_logic;
58 59
      maxrxbw_o                                : std_logic_vector(15 downto 0);
      maxrxbw_load_o                           : std_logic;
60 61 62 63 64
      end record;
    
    constant c_nic_out_registers_init_value: t_nic_out_registers := (
      cr_rx_en_o => '0',
      cr_tx_en_o => '0',
65
      cr_rxthr_en_o => '0',
66
      cr_sw_rst_o => '0',
67 68 69 70 71
      sr_rec_o => '0',
      sr_rec_load_o => '0',
      sr_tx_done_o => '0',
      sr_tx_done_load_o => '0',
      sr_tx_error_o => '0',
72 73 74
      sr_tx_error_load_o => '0',
      maxrxbw_o => (others => '0'),
      maxrxbw_load_o => '0'
75 76 77
      );
    function "or" (left, right: t_nic_in_registers) return t_nic_in_registers;
    function f_x_to_zero (x:std_logic) return std_logic;
78
    function f_x_to_zero (x:std_logic_vector) return std_logic_vector;
79 80 81 82 83
end package;

package body nic_wbgen2_pkg is
function f_x_to_zero (x:std_logic) return std_logic is
begin
84 85
if x = '1' then
return '1';
86
else
87 88
return '0';
end if;
89
end function;
90 91 92 93
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
94 95
if x(i) = '1' then
tmp(i):= '1';
96
else
97
tmp(i):= '0';
98 99 100 101
end if; 
end loop; 
return tmp;
end function;
102 103 104
function "or" (left, right: t_nic_in_registers) return t_nic_in_registers is
variable tmp: t_nic_in_registers;
begin
105 106 107 108 109 110
tmp.sr_bna_i := f_x_to_zero(left.sr_bna_i) or f_x_to_zero(right.sr_bna_i);
tmp.sr_rec_i := f_x_to_zero(left.sr_rec_i) or f_x_to_zero(right.sr_rec_i);
tmp.sr_tx_done_i := f_x_to_zero(left.sr_tx_done_i) or f_x_to_zero(right.sr_tx_done_i);
tmp.sr_tx_error_i := f_x_to_zero(left.sr_tx_error_i) or f_x_to_zero(right.sr_tx_error_i);
tmp.sr_cur_tx_desc_i := f_x_to_zero(left.sr_cur_tx_desc_i) or f_x_to_zero(right.sr_cur_tx_desc_i);
tmp.sr_cur_rx_desc_i := f_x_to_zero(left.sr_cur_rx_desc_i) or f_x_to_zero(right.sr_cur_rx_desc_i);
111 112
tmp.rxbw_i := f_x_to_zero(left.rxbw_i) or f_x_to_zero(right.rxbw_i);
tmp.maxrxbw_i := f_x_to_zero(left.maxrxbw_i) or f_x_to_zero(right.maxrxbw_i);
113 114 115
return tmp;
end function;
end package body;