diff --git a/libraries/base/ring/src/vhdl/ring_lane_info.vhd b/libraries/base/ring/src/vhdl/ring_lane_info.vhd new file mode 100644 index 0000000000000000000000000000000000000000..869ce43cb9d03ca03c07c94ca6a22876ade6ff8b --- /dev/null +++ b/libraries/base/ring/src/vhdl/ring_lane_info.vhd @@ -0,0 +1,85 @@ +------------------------------------------------------------------------------- +-- +-- 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: +-- . Ring lane info register +-- Description: +-- +-- Remark: +-- . +------------------------------------------------------------------------------- + +LIBRARY IEEE, common_lib, mm_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; + +ENTITY ring_lane_info IS + PORT ( + -- Clocks and reset + mm_rst : IN STD_LOGIC; -- reset synchronous with mm_clk + mm_clk : IN STD_LOGIC; -- memory-mapped bus clock + + dp_clk : IN STD_LOGIC; + dp_rst : IN STD_LOGIC; + + reg_mosi : IN t_mem_mosi; + reg_miso : OUT t_mem_miso; + + -- inputs from other blocks + lane_direction : IN STD_LOGIC; + + -- sdp info + lane_info : OUT t_lane_info + ); +END ring_lane_info; + + +ARCHITECTURE str OF ring_lane_info IS + + SIGNAL lane_info_ro: t_lane_info; -- ro = read only + +BEGIN + + u_mm_fields: ENTITY work.ring_lane_info_reg + PORT MAP ( + + mm_clk => mm_clk, + mm_rst => mm_rst, + + dp_clk => dp_clk, + dp_rst => dp_rst, + + reg_mosi => reg_mosi, + reg_miso => reg_miso, + + lane_info_ro => lane_info_ro, + lane_info => lane_info + ); + + + lane_info_ro.lane_direction <= lane_direction; + +END str; diff --git a/libraries/base/ring/src/vhdl/ring_lane_info_reg.vhd b/libraries/base/ring/src/vhdl/ring_lane_info_reg.vhd new file mode 100644 index 0000000000000000000000000000000000000000..1ed8937b5aafd3907b6feb3131b70d88620d9e74 --- /dev/null +++ b/libraries/base/ring/src/vhdl/ring_lane_info_reg.vhd @@ -0,0 +1,110 @@ +------------------------------------------------------------------------------- +-- +-- 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. Donker + +-- Purpose: +-- . Ring lane info register +-- Description: +-- +-- Remark: +-- . +------------------------------------------------------------------------------- + +LIBRARY IEEE, common_lib, mm_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 work.ring_pkg.ALL; + +ENTITY ring_lane_info_reg IS + PORT ( + -- Clocks and reset + mm_rst : IN STD_LOGIC; -- reset synchronous with mm_clk + mm_clk : IN STD_LOGIC; -- memory-mapped bus clock + + dp_clk : IN STD_LOGIC; + dp_rst : IN STD_LOGIC; + + reg_mosi : IN t_mem_mosi; + reg_miso : OUT t_mem_miso; + + -- sdp info + lane_info_ro : IN t_lane_info; -- ro = read only + lane_info : OUT t_lane_info + ); +END ring_lane_info_reg; + + +ARCHITECTURE str OF lane_info_reg IS + + SIGNAL mm_fields_in : STD_LOGIC_VECTOR(field_slv_in_len(c_lane_info_field_arr)-1 DOWNTO 0); + SIGNAL mm_fields_out : STD_LOGIC_VECTOR(field_slv_out_len(c_lane_info_field_arr)-1 DOWNTO 0); + + SIGNAL lane_info_rd : t_lane_info; + SIGNAL lane_info_wr : t_lane_info; + +BEGIN + + lane_info <= lane_info_rd; + + p_lane_info_rd : PROCESS(lane_info_wr, lane_info_ro) + BEGIN + -- default write assign all fields + lane_info_rd <= lane_info_wr; + + -- overrule the read only fields + lane_info_rd.lane_direction <= lane_info_ro.lane_direction; + END PROCESS; + + + u_mm_fields: ENTITY mm_lib.mm_fields + GENERIC MAP( + g_use_slv_in_val => FALSE, -- use FALSE to save logic when always slv_in_val='1' + g_field_arr => c_lane_info_field_arr + ) + PORT MAP ( + mm_clk => mm_clk, + mm_rst => mm_rst, + + mm_mosi => reg_mosi, + mm_miso => reg_miso, + + slv_clk => dp_clk, + slv_rst => dp_rst, + + slv_in => mm_fields_in, + slv_in_val => '1', + + slv_out => mm_fields_out + ); + + -- add "RO" fields to mm_fields + mm_fields_in(field_hi(c_lane_info_field_arr, "lane_direction") DOWNTO field_lo(c_lane_info_field_arr, "lane_direction")) <= slv(lane_info_rd.lane_direction); + + -- get "RW" fields from mm_fields + lane_info_wr.transport_nof_hops <= mm_fields_out(field_hi(c_lane_info_field_arr, "transport_nof_hops") DOWNTO field_lo(c_lane_info_field_arr, "transport_nof_hops")); + lane_info_wr.tx_select <= mm_fields_out(field_hi(c_lane_info_field_arr, "tx_select") DOWNTO field_lo(c_lane_info_field_arr, "tx_select")); + lane_info_wr.rx_select <= mm_fields_out(field_hi(c_lane_info_field_arr, "rx_select") DOWNTO field_lo(c_lane_info_field_arr, "rx_select")); + +END str; diff --git a/libraries/base/ring/src/vhdl/ring_pkg.vhd b/libraries/base/ring/src/vhdl/ring_pkg.vhd new file mode 100644 index 0000000000000000000000000000000000000000..c3e01e265639b8e75b3c10f8cd0dc24e44eca613 --- /dev/null +++ b/libraries/base/ring/src/vhdl/ring_pkg.vhd @@ -0,0 +1,87 @@ +------------------------------------------------------------------------------- +-- +-- 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; + +PACKAGE sdp_pkg is +-- lane info, see https://support.astron.nl/confluence/x/jyu7Ag +-- +====================+========+==============================================================================+===========================+ +-- | Field | Access | Description | Remark | +-- +====================+========+==============================================================================+===========================+ +-- | transport_nof_hops | RW | Number of hops (N_transport_hops) to transport a packet. The RN will remove | Same setting for all RN | +-- | | | packets that have traveled N_transport_hops hops. If | | +-- | | | N_transport_hops >= N_rn, then the ring cannot remove the packet, because | | +-- | | | then it cannot distinguish between a packet that just starts or that has | | +-- | | | has already been transported along the entire ring, so then the application | | +-- | | | has to take care of removing the packet from the ring (or let it cycle along | | +-- | | | the ring 'forever'). | | +-- +--------------------+--------+------------------------------------------------------------------------------+---------------------------+ +-- | lane_direction | RO | 1 = transport in positive RN index direction on lanes with even lane index. 0| Same setting for all RN | +-- | | | = transport in negative RN index direction on lanes with odd lane index. | | +-- | | | Hence for N_lanes = 8, lanes 0, 2, 4, and 6 will transport in positive | | +-- | | | direction, and lanes 1, 3, 5, 7 will transport in opposite (= negative) | | +-- | | | direction. The lane direction is fixed per lane and therefore read only. | | +-- +--------------------+--------+------------------------------------------------------------------------------+---------------------------+ +-- | tx_select | RW | 0 = transmit via on board port, 1 = transmit via cable (QSFP) port. Default | Individual setting per RN | +-- | | | in firmware assume cable between RN on different UniBoard2 and assume cable | | +-- | | | to close the ring defined by ring_info. The programmable tx_select allows | | +-- | | | using cables between other RN in the ring. | | +-- +--------------------+--------+------------------------------------------------------------------------------+---------------------------+ +-- | rx_select | RW | 0 = receive via on board port, 1 = receive via cable (QSFP) port. Default in | Individual setting per RN | +-- | | | firmware assume cable between RN on different UniBoard2 and assume cable to | | +-- | | | close the ring defined by ring_info. The programmable rx_select allows using | | +-- | | | cables between other RN in the ring. | | +-- +--------------------+--------+------------------------------------------------------------------------------+---------------------------+ + + TYPE t_lane_info IS RECORD + transport_nof_hops : STD_LOGIC_VECTOR(c_word_w-1 DOWNTO 0); + lane_direction : STD_LOGIC; + tx_select : STD_LOGIC; + rx_select : STD_LOGIC; + END RECORD; + + CONSTANT c_lane_info_rst : t_lane_info := + ( (OTHERS => '0'), '0', '0', '0' ); + + CONSTANT c_lane_info_field_arr : t_common_field_arr(3 DOWNTO 0) := + ( (field_name_pad("transport_nof_hops"), "RW", 32, field_default(0)), + (field_name_pad("lane_direction"), "RO", 1, field_default(0)), + (field_name_pad("tx_select"), "RW", 1, field_default(0)), + (field_name_pad("rx_select"), "RW", 1, field_default(0)) ); + + END PACKAGE sdp_pkg; + +PACKAGE BODY sdp_pkg IS + + +END sdp_pkg; +