From 3fc5b2a4edc5b4d99412d0e7b0c51ba471be8872 Mon Sep 17 00:00:00 2001
From: Eric Kooistra <kooistra@astron.nl>
Date: Wed, 20 Sep 2023 15:17:18 +0200
Subject: [PATCH] Connect destinations_info register.

---
 .../sdp/src/vhdl/sdp_beamformer_output.vhd    | 61 ++++++++++++-------
 1 file changed, 40 insertions(+), 21 deletions(-)

diff --git a/applications/lofar2/libraries/sdp/src/vhdl/sdp_beamformer_output.vhd b/applications/lofar2/libraries/sdp/src/vhdl/sdp_beamformer_output.vhd
index f91da36273..3d12337c51 100644
--- a/applications/lofar2/libraries/sdp/src/vhdl/sdp_beamformer_output.vhd
+++ b/applications/lofar2/libraries/sdp/src/vhdl/sdp_beamformer_output.vhd
@@ -57,24 +57,27 @@ entity sdp_beamformer_output is
     mm_clk   : in  std_logic;
     mm_rst   : in  std_logic;
 
-    reg_hdr_dat_mosi   : in  t_mem_mosi := c_mem_mosi_rst;
-    reg_hdr_dat_miso   : out t_mem_miso;
+    reg_hdr_dat_mosi      : in  t_mem_mosi := c_mem_mosi_rst;
+    reg_hdr_dat_miso      : out t_mem_miso;
 
-    reg_dp_xonoff_mosi : in  t_mem_mosi := c_mem_mosi_rst;
-    reg_dp_xonoff_miso : out t_mem_miso;
+    reg_destinations_copi : in  t_mem_copi := c_mem_mosi_rst;
+    reg_destinations_cipo : out t_mem_cipo;
 
-    in_sosi  : in  t_dp_sosi;
-    out_sosi : out t_dp_sosi;
-    out_siso : in t_dp_siso;
+    reg_dp_xonoff_mosi    : in  t_mem_mosi := c_mem_mosi_rst;
+    reg_dp_xonoff_miso    : out t_mem_miso;
 
-    sdp_info      : in t_sdp_info;
-    beamlet_scale : in std_logic_vector(c_sdp_W_beamlet_scale-1 downto 0);
-    gn_id         : in std_logic_vector(c_sdp_W_gn_id - 1 downto 0);
+    in_sosi        : in  t_dp_sosi;
+    out_sosi       : out t_dp_sosi;
+    out_siso       : in t_dp_siso;
+
+    sdp_info       : in t_sdp_info;
+    beamlet_scale  : in std_logic_vector(c_sdp_W_beamlet_scale-1 downto 0);
+    gn_id          : in std_logic_vector(c_sdp_W_gn_id - 1 downto 0);
 
     -- Source MAC/IP/UDP are not used, c_sdp_cep_hdr_field_sel selects MM programmable instead
-    eth_src_mac  : in std_logic_vector(c_network_eth_mac_addr_w - 1 downto 0);
-    ip_src_addr  : in std_logic_vector(c_network_ip_addr_w - 1 downto 0);
-    udp_src_port : in std_logic_vector(c_network_udp_port_w - 1 downto 0);
+    eth_src_mac    : in std_logic_vector(c_network_eth_mac_addr_w - 1 downto 0);
+    ip_src_addr    : in std_logic_vector(c_network_ip_addr_w - 1 downto 0);
+    udp_src_port   : in std_logic_vector(c_network_udp_port_w - 1 downto 0);
 
     hdr_fields_out : out std_logic_vector(1023 downto 0)
   );
@@ -131,6 +134,7 @@ architecture str of sdp_beamformer_output is
   signal station_info       : std_logic_vector(15 downto 0) := (others => '0');
 
   -- Multiple destinations
+  signal destinations_info  : t_sdp_bdo_destinations_info;
   signal eth_dst_mac        : std_logic_vector(c_network_eth_mac_addr_w - 1 downto 0);
   signal ip_dst_addr        : std_logic_vector(c_network_ip_addr_w - 1 downto 0);
   signal udp_dst_port       : std_logic_vector(c_network_udp_port_w - 1 downto 0);
@@ -245,10 +249,6 @@ begin
         snk_in   => dp_repack_beamlet_src_out,
         src_out  => dp_packet_reorder_src_out
       );
-
-    -- Use constant defaults for beamlet data output to one destination.
-    nof_blocks_per_packet  <= c_sdp_cep_nof_blocks_per_packet;  -- = 4;
-    nof_beamlets_per_block <= c_sdp_S_sub_bf;  -- = 488 dual pol beamlets;
   end generate;
 
   gen_multiple_destinations : if g_use_multiple_destinations = true generate
@@ -267,16 +267,20 @@ begin
         g_use_transpose => g_use_transpose
       )
       port map (
+        mm_clk   => mm_clk,
+        mm_rst   => mm_rst,
+
         dp_clk   => dp_clk,
         dp_rst   => dp_rst,
 
+        reg_destinations_copi => reg_destinations_copi,
+        reg_destinations_cipo => reg_destinations_cipo,
+
+        destinations_info => destinations_info,
+
         snk_in   => dp_repack_beamlet_src_out,
         src_out  => dp_packet_reorder_src_out
       );
-
-    -- Use dynamic sizes for beamlet data output to multiple destination.
-    nof_blocks_per_packet  <= c_sdp_cep_nof_blocks_per_packet;  -- = 4;
-    nof_beamlets_per_block <= c_sdp_S_sub_bf;  -- = 488 dual pol beamlets;
   end generate;
 
   -- Debug signals for view in Wave window
@@ -425,6 +429,21 @@ begin
   --
   --        DP    dp_bsn
 
+  p_assemble_offload_info : process(destinations_info)
+  begin
+    if g_use_multiple_destinations = false then
+      -- Use constant defaults for beamlet data output to one destination.
+      nof_blocks_per_packet  <= c_sdp_cep_nof_blocks_per_packet;  -- = 4;
+      nof_beamlets_per_block <= c_sdp_S_sub_bf;  -- = 488 dual pol beamlets;
+    else
+      -- Use dynamic sizes for beamlet data output to multiple destination.
+      nof_blocks_per_packet  <= destinations_info.nof_blocks_per_packet_act;
+      nof_beamlets_per_block <= c_sdp_S_sub_bf;  -- = 488 dual pol beamlets;
+
+      -- TODO check channel field to set destination addresses in dp_offload_tx_hdr_fields
+    end if;
+  end process;
+
   station_info <= sdp_info.antenna_field_index & sdp_info.station_id;
 
   -- Use MM programmable source MAC/IP/UDP instead of source MAC/IP/UDP based
-- 
GitLab