Skip to content
Snippets Groups Projects
Select Git revision
  • 3d1bebb53fa9918f7910e3348a38c9cca43f92a5
  • master default protected
  • control-single-hba-and-lba
  • L2SS-1957-remove-pcon-control
  • stabilise-landing-page
  • all-stations-lofar2
  • L2SS-2357-fix-ruff
  • v0.39.7-backports
  • Move-sdptr-to-v1.5.0
  • fix-build-ubuntu
  • tokens-in-env-files
  • fix-build
  • L2SS-2214-deploy-cdb
  • fix-missing-init
  • add-power-hardware-apply
  • L2SS-2129-Add-Subrack-Routine
  • Also-listen-internal-to-rpc
  • fix-build-dind
  • L2SS-2153--Improve-Error-Handling
  • L2SS-2153-Add-Grpc-Gateway-support
  • L2SS-1970-apsct-lol
  • v0.52.3 protected
  • v0.52.3dev0 protected
  • 0.53.1dev0
  • v0.52.2-rc3 protected
  • v0.52.2-rc2 protected
  • v0.52.2-rc1 protected
  • v0.52.1.1 protected
  • v0.52.1 protected
  • v0.52.1-rc1 protected
  • v0.51.9-6 protected
  • v0.51.9-5 protected
  • v0.51.9-4 protected
  • v0.51.9-3 protected
  • v0.51.9-2 protected
  • v0.51.9-1 protected
  • v0.51.9 protected
  • v0.51.8 protected
  • v0.39.15-wsrttwo protected
  • v0.39.15-wsrt protected
  • v0.39.14-wsrt protected
41 results

VERSION

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    ring_pkg.vhd 6.01 KiB
    -------------------------------------------------------------------------------
    --
    -- Copyright 2021
    -- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
    -- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
    --
    -- Licensed under the Apache License, Version 2.0 (the "License");
    -- you may not use this file except in compliance with the License.
    -- You may obtain a copy of the License at
    --
    --     http://www.apache.org/licenses/LICENSE-2.0
    --
    -- Unless required by applicable law or agreed to in writing, software
    -- distributed under the License is distributed on an "AS IS" BASIS,
    -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    -- See the License for the specific language governing permissions and
    -- limitations under the License.
    --
    -------------------------------------------------------------------------------
    
    -------------------------------------------------------------------------------
    --
    -- Author: R. van der Walle
    -- Purpose: 
    -- . This package contains ring specific constants.
    -- Description:
    -- Remark:
    -------------------------------------------------------------------------------
    LIBRARY ieee, common_lib;
    USE IEEE.std_logic_1164.ALL;
    USE common_lib.common_pkg.ALL;
    USE common_lib.common_mem_pkg.ALL;
    USE common_lib.common_field_pkg.ALL;
    USE common_lib.common_network_layers_pkg.ALL;
    
    PACKAGE ring_pkg is
    -- lane info, see https://support.astron.nl/confluence/x/jyu7Ag
      TYPE t_ring_lane_info IS RECORD
        transport_nof_hops : STD_LOGIC_VECTOR(c_word_w-1 DOWNTO 0);
        lane_direction     : STD_LOGIC; 
      END RECORD;   
    
      CONSTANT c_ring_lane_info_rst : t_ring_lane_info :=
          ( (OTHERS => '0'), '0' );  
    
      CONSTANT c_ring_lane_info_field_arr : t_common_field_arr(1 DOWNTO 0) :=
          ( (field_name_pad("transport_nof_hops"), "RW", 32, field_default(0)),
            (field_name_pad("lane_direction"),     "RO",  1, field_default(0)) );
    
    -- ring info, see https://support.astron.nl/confluence/x/jyu7Ag
      TYPE t_ring_info IS RECORD
        O_rn                     : STD_LOGIC_VECTOR(c_byte_w-1 DOWNTO 0);
        N_rn                     : STD_LOGIC_VECTOR(c_byte_w-1 DOWNTO 0); 
        use_cable_to_next_rn     : STD_LOGIC;   
        use_cable_to_previous_rn : STD_LOGIC;  
      END RECORD;   
    
      CONSTANT c_ring_info_rst : t_ring_info := 
          ( (OTHERS => '0'), (OTHERS => '0'), '0', '0' );  
    
      CONSTANT c_ring_info_field_arr : t_common_field_arr(3 DOWNTO 0) := 
          ( (field_name_pad("O_rn"),                     "RW", 8, field_default( 0)),
            (field_name_pad("N_rn"),                     "RW", 8, field_default(16)),
            (field_name_pad("use_cable_to_next_rn"),     "RW", 1, field_default( 0)),
            (field_name_pad("use_cable_to_previous_rn"), "RW", 1, field_default( 0)) );
    
      CONSTANT c_ring_eth_dst_mac : STD_LOGIC_VECTOR(c_network_eth_mac_addr_w-1 DOWNTO 0) := x"FFFFFFFFFFFF";
      CONSTANT c_ring_eth_src_mac : STD_LOGIC_VECTOR(c_network_eth_mac_addr_w-1 DOWNTO 0) := x"002286080000";
      CONSTANT c_ring_pkt_type_bf : STD_LOGIC_VECTOR(c_halfword_w-1 DOWNTO 0) := x"10FB";
      CONSTANT c_ring_pkt_type_xc : STD_LOGIC_VECTOR(c_halfword_w-1 DOWNTO 0) := x"10FC";
      CONSTANT c_ring_pkt_type_so : STD_LOGIC_VECTOR(c_halfword_w-1 DOWNTO 0) := x"10FD";
      CONSTANT c_ring_pkt_type_tb : STD_LOGIC_VECTOR(c_halfword_w-1 DOWNTO 0) := x"10FE";
    
      CONSTANT c_ring_eth_nof_hdr_fields : NATURAL := 3;
      CONSTANT c_ring_eth_hdr_field_sel  : STD_LOGIC_VECTOR(c_ring_eth_nof_hdr_fields-1 DOWNTO 0) := "000";
      CONSTANT c_ring_eth_hdr_field_arr : t_common_field_arr(c_ring_eth_nof_hdr_fields-1 DOWNTO 0) := (
          ( field_name_pad("eth_dst_mac"  ), "RW", 48, field_default(c_ring_eth_dst_mac) ), 
          ( field_name_pad("eth_src_mac"  ), "RW", 48, field_default(c_ring_eth_src_mac) ),
          ( field_name_pad("eth_type"     ), "RW", 16, field_default(0) )
      );
      CONSTANT c_ring_eth_hdr_field_size : NATURAL := ceil_div(field_slv_len(c_ring_eth_hdr_field_arr), c_longword_w);  -- = 14/8 = 2 longwords
    
      CONSTANT c_ring_dp_nof_hdr_fields : NATURAL := 6;
      CONSTANT c_ring_dp_hdr_field_sel  : STD_LOGIC_VECTOR(c_ring_dp_nof_hdr_fields-1 DOWNTO 0) := "000"&"000";
      CONSTANT c_ring_dp_hdr_field_arr : t_common_field_arr(c_ring_dp_nof_hdr_fields-1 DOWNTO 0) := (
          ( field_name_pad("eth_dst_mac"  ), "RW", 48, field_default(c_ring_eth_dst_mac) ),  
          ( field_name_pad("eth_src_mac"  ), "RW", 48, field_default(c_ring_eth_src_mac) ),
          ( field_name_pad("eth_type"     ), "RW", 16, field_default(0) ),
          ( field_name_pad("dp_channel"   ), "RW", 16, field_default(0) ),
          ( field_name_pad("dp_sync"      ), "RW",  1, field_default(0) ),
          ( field_name_pad("dp_bsn"       ), "RW", 63, field_default(0) )
      );
      CONSTANT c_ring_dp_hdr_field_size : NATURAL := ceil_div(field_slv_len(c_ring_dp_hdr_field_arr), c_longword_w);  -- = 24/8 = 3 longwords
    
      FUNCTION func_ring_nof_hops_to_source_rn(hops, this_rn, N_rn, lane_dir : NATURAL) RETURN NATURAL;
      FUNCTION func_ring_nof_hops_to_source_rn(hops, this_rn, N_rn : STD_LOGIC_VECTOR; lane_dir : NATURAL) RETURN STD_LOGIC_VECTOR; -- return vector length is same as hops vector length
    
     END PACKAGE ring_pkg;
    
    PACKAGE BODY ring_pkg IS
    
      FUNCTION func_ring_nof_hops_to_source_rn(hops, this_rn, N_rn, lane_dir : NATURAL) RETURN NATURAL IS
        VARIABLE v_source_rn     : INTEGER;
        VARIABLE v_source_rn_nat : NATURAL;
      BEGIN
    
        IF lane_dir > 0 THEN --transport in positive direction (even lanes)
          v_source_rn := this_rn - hops;
        ELSE                 --transport in negative direction (odd lanes)
          v_source_rn := this_rn + hops;
        END IF;
    
        IF v_source_rn < 0 THEN -- Cannot use MOD as N_rn is not a constant.
          v_source_rn := v_source_rn + N_rn;
        END IF;
    
        IF v_source_rn >= N_rn THEN
          v_source_rn := v_source_rn - N_rn;
        END IF;
    
        v_source_rn_nat := v_source_rn;
        RETURN v_source_rn_nat;
      END;
    
      FUNCTION func_ring_nof_hops_to_source_rn(hops, this_rn, N_rn : STD_LOGIC_VECTOR; lane_dir : NATURAL) RETURN STD_LOGIC_VECTOR IS
      BEGIN
        RETURN TO_UVEC(func_ring_nof_hops_to_source_rn(TO_UINT(hops), TO_UINT(this_rn), TO_UINT(N_rn), lane_dir),hops'LENGTH);
      END;
      
    END ring_pkg;