From 70d4dc5acf76cb516e541ae5e7c0814bdd0d3316 Mon Sep 17 00:00:00 2001
From: Eric Kooistra <kooistra@astron.nl>
Date: Thu, 18 Mar 2021 12:07:38 +0100
Subject: [PATCH] Added peripherals for statistics offload Tx hdr_dat.

---
 .../lofar2_unb2b_beamformer.fpga.yaml         |  10 +-
 .../lofar2/libraries/sdp/sdp.peripheral.yaml  | 224 +++++++++++++++++-
 2 files changed, 228 insertions(+), 6 deletions(-)

diff --git a/applications/lofar2/designs/lofar2_unb2b_beamformer/lofar2_unb2b_beamformer.fpga.yaml b/applications/lofar2/designs/lofar2_unb2b_beamformer/lofar2_unb2b_beamformer.fpga.yaml
index 37d1bbd33a..cb7b1d7945 100644
--- a/applications/lofar2/designs/lofar2_unb2b_beamformer/lofar2_unb2b_beamformer.fpga.yaml
+++ b/applications/lofar2/designs/lofar2_unb2b_beamformer/lofar2_unb2b_beamformer.fpga.yaml
@@ -190,7 +190,10 @@ peripherals:
     slave_port_names:
       - RAM_ST_SST
       
-      
+  - peripheral_name: sdp/sdp_statistics_offload_hdr_dat_sst
+    slave_port_names:
+      - REG_STAT_HDR_INFO
+
   #############################################################################
   # BF = Beamformer (from node_sdp_beamformer.vhd)
   #############################################################################
@@ -240,3 +243,8 @@ peripherals:
   - peripheral_name: st/st_bst_for_sdp
     slave_port_names:
       - RAM_ST_BST
+
+  #- peripheral_name: sdp/sdp_statistics_offload_hdr_dat_bst
+  #  slave_port_names:
+  #    - REG_STAT_HDR_INFO_BST
+
diff --git a/applications/lofar2/libraries/sdp/sdp.peripheral.yaml b/applications/lofar2/libraries/sdp/sdp.peripheral.yaml
index 2c25ab9b39..af6d759782 100644
--- a/applications/lofar2/libraries/sdp/sdp.peripheral.yaml
+++ b/applications/lofar2/libraries/sdp/sdp.peripheral.yaml
@@ -144,18 +144,18 @@ peripherals:
               address_offset: 0x4
 
 
-  - peripheral_name: sdp_beamformer_output_hdr_dat
+  - peripheral_name: sdp_beamformer_output_hdr_dat  #  pi_dp_offload_tx_hdr_dat_lofar2_beamformer_output.py
     peripheral_description: "SDP BF beamlet data output header."
-    parameters:
-      # Parameters fixed in sdp_beamformer_output.vhd / dp_offload_tx_v3.vhd / sdp_pkg.vhd
-      - { name: g_gain_w, value: 16 }
-      - { name: g_lsb_w, value: 15 }
     slave_ports:
       # MM port for sdp_beamformer_output.vhd / dp_offload_tx_v3.vhd
       - slave_name: REG_DP_OFFLOAD_TX_HDR_DAT
         slave_description: |
           "The ETH/IP/UDP/application header fields for the beamlet data output offload UDP packets.
 
+           The header fields are described in ICD STAT-CEP [1].
+
+           https://plm.astron.nl/polarion/#/project/LOFAR2System/wiki/L1%20Interface%20Control%20Documents/STAT%20to%20CEP%20ICD
+
            From tb_dp_offload_tx_v3.vhd simulation it follows that:
            . the header fields are stored in reversed address order due to that the array in VHDL has
              range (h downto 0) where the first header field (eth_destination_mac) is at index h.
@@ -219,3 +219,217 @@ peripherals:
           - - { field_name: nof_beamlets_per_block, width: 16,                 access_mode: RW, address_offset: 0xC }
           - - { field_name: block_period,           width: 16,                 access_mode: RW, address_offset: 0x8 }
           - - { field_name: BSN,                    width: 32,                 access_mode: RW, address_offset: 0x0, radix_width: 64 }
+
+
+  - peripheral_name: sdp_statistics_offload_hdr_dat_sst  #  pi_dp_offload_tx_hdr_dat_lofar2_sdp_statistics_offload.py
+    peripheral_description: "SDP statistics offload header for the subband statistics (SST)."
+    slave_ports:
+      # MM port for sdp_statistics_offload.vhd / dp_offload_tx_v3.vhd
+      - slave_name: REG_DP_OFFLOAD_TX_HDR_DAT
+        slave_description: |
+          "The ETH/IP/UDP/application header fields for the SST offload UDP packets.
+
+           The Subband statistics (SST) are integrated auto power values of the subbands per signal input.
+           The SST specific settings are defined by data_id_sst.
+
+           The statistics offload header fields are described in ICD SC-SDP [1].
+
+           [1] https://plm.astron.nl/polarion/#/project/LOFAR2System/wiki/L2%20Interface%20Control%20Documents/SC%20to%20SDP%20ICD
+          "
+        slave_type: REG
+        fields:
+          # eth field group
+          - - { field_name: eth_destination_mac,       width: 32,                 access_mode: RW, address_offset: 0x84, radix_width: 48 }
+          - - { field_name: eth_source_mac,            width: 32,                 access_mode: RO, address_offset: 0x7C, radix_width: 48 }
+          - - { field_name: eth_type,                  width: 16,                 access_mode: RO, address_offset: 0x78 }
+          # ip field group
+          - - { field_name: ip_version,                width:  4,                 access_mode: RW, address_offset: 0x74 }
+          - - { field_name: ip_header_length,          width:  4,                 access_mode: RW, address_offset: 0x70 }
+          - - { field_name: ip_services,               width:  8,                 access_mode: RW, address_offset: 0x6C }
+          - - { field_name: ip_total_length,           width: 16,                 access_mode: RW, address_offset: 0x68 }
+          - - { field_name: ip_identification,         width: 16,                 access_mode: RW, address_offset: 0x64 }
+          - - { field_name: ip_flags,                  width:  3,                 access_mode: RW, address_offset: 0x60 }
+          - - { field_name: ip_fragment_offset,        width: 13,                 access_mode: RW, address_offset: 0x5C }
+          - - { field_name: ip_time_to_live,           width:  8,                 access_mode: RW, address_offset: 0x58 }
+          - - { field_name: ip_protocol,               width:  8,                 access_mode: RW, address_offset: 0x54 }
+          - - { field_name: ip_header_checksum,        width: 16,                 access_mode: RW, address_offset: 0x50 }
+          - - { field_name: ip_source_address,         width: 32,                 access_mode: RW, address_offset: 0x4C }
+          - - { field_name: ip_destination_address,    width: 32,                 access_mode: RW, address_offset: 0x48 }
+          # udp field group
+          - - { field_name: udp_source_port,           width: 16,                 access_mode: RW, address_offset: 0x44 }
+          - - { field_name: udp_destination_port,      width: 16,                 access_mode: RW, address_offset: 0x40 }
+          - - { field_name: udp_length,                width: 16,                 access_mode: RW, address_offset: 0x3C }
+          - - { field_name: udp_checksum,              width: 16,                 access_mode: RW, address_offset: 0x38 }
+          # application field group
+          - - { field_name: marker,                    width:  8,                 access_mode: RO, address_offset: 0x34 }
+          - - { field_name: version_id,                width:  8,                 access_mode: RO, address_offset: 0x30 }
+          - - { field_name: observation_id,            width: 32,                 access_mode: RW, address_offset: 0x2C }
+          - - { field_name: station_id,                width: 16,                 access_mode: RW, address_offset: 0x28 }
+          - - { field_name: source_info,               width: 16,                 access_mode: RW, address_offset: 0x24 }
+          - "source_info":
+            - { field_name: antenna_band_index,        width:  1, bit_offset: 15, access_mode: RW, address_offset: 0x24 }
+            - { field_name: nyquist_zone_index,        width:  2, bit_offset: 13, access_mode: RW, address_offset: 0x24 }
+            - { field_name: f_adc,                     width:  1, bit_offset: 12, access_mode: RW, address_offset: 0x24 }
+            - { field_name: fsub_type,                 width:  1, bit_offset: 11, access_mode: RW, address_offset: 0x24 }
+            - { field_name: payload_error,             width:  1, bit_offset: 10, access_mode: RW, address_offset: 0x24 }
+            - { field_name: beam_repositioning_flag,   width:  1, bit_offset:  9, access_mode: RW, address_offset: 0x24 }
+            - { field_name: subband_calibrated_flag,   width:  1, bit_offset:  8, access_mode: RW, address_offset: 0x24 }
+            - { field_name: reserved,                  width:  3, bit_offset:  5, access_mode: RW, address_offset: 0x24 }
+            - { field_name: gn_index,                  width:  5, bit_offset:  0, access_mode: RW, address_offset: 0x24 }
+
+          - - { field_name: reserved,                  width:  8,                 access_mode: RW, address_offset: 0x20 }
+          - - { field_name: integration_interval,      width: 24,                 access_mode: RW, address_offset: 0x1C }
+          - - { field_name: data_id,                   width: 32,                 access_mode: RW, address_offset: 0x18 }
+          - "data_id_sst":
+            - { field_name: reserved,                  width: 24, bit_offset:  8, access_mode: RW, address_offset: 0x18 }
+            - { field_name: signal_input_index,        width:  8, bit_offset:  0, access_mode: RW, address_offset: 0x18 }
+
+          - - { field_name: nof_signal_inputs,         width:  8,                 access_mode: RW, address_offset: 0x14 }
+          - - { field_name: nof_bytes_per_statistic,   width:  8,                 access_mode: RW, address_offset: 0x10 }
+          - - { field_name: nof_statistics_per_packet, width: 16,                 access_mode: RW, address_offset: 0xC }
+          - - { field_name: block_period,              width: 16,                 access_mode: RW, address_offset: 0x8 }
+          - - { field_name: BSN,                       width: 32,                 access_mode: RW, address_offset: 0x0, radix_width: 64 }
+
+
+  - peripheral_name: sdp_statistics_offload_hdr_dat_bst  #  pi_dp_offload_tx_hdr_dat_lofar2_sdp_statistics_offload.py
+    peripheral_description: "SDP statistics offload header for the beamlet statistics (BST)."
+    slave_ports:
+      # MM port for sdp_statistics_offload.vhd / dp_offload_tx_v3.vhd
+      - slave_name: REG_DP_OFFLOAD_TX_HDR_DAT
+        slave_description: |
+          "The ETH/IP/UDP/application header fields for the BST offload UDP packets.
+
+           The beamlet statistics (BST) are integrated auto power values of the beamlets per beamset
+           The BST specific settings are defined by data_id_bst.
+
+           The statistics offload header fields are described in ICD SC-SDP [1].
+
+           [1] https://plm.astron.nl/polarion/#/project/LOFAR2System/wiki/L2%20Interface%20Control%20Documents/SC%20to%20SDP%20ICD
+          "
+        slave_type: REG
+        fields:
+          # eth field group
+          - - { field_name: eth_destination_mac,       width: 32,                 access_mode: RW, address_offset: 0x84, radix_width: 48 }
+          - - { field_name: eth_source_mac,            width: 32,                 access_mode: RO, address_offset: 0x7C, radix_width: 48 }
+          - - { field_name: eth_type,                  width: 16,                 access_mode: RO, address_offset: 0x78 }
+          # ip field group
+          - - { field_name: ip_version,                width:  4,                 access_mode: RW, address_offset: 0x74 }
+          - - { field_name: ip_header_length,          width:  4,                 access_mode: RW, address_offset: 0x70 }
+          - - { field_name: ip_services,               width:  8,                 access_mode: RW, address_offset: 0x6C }
+          - - { field_name: ip_total_length,           width: 16,                 access_mode: RW, address_offset: 0x68 }
+          - - { field_name: ip_identification,         width: 16,                 access_mode: RW, address_offset: 0x64 }
+          - - { field_name: ip_flags,                  width:  3,                 access_mode: RW, address_offset: 0x60 }
+          - - { field_name: ip_fragment_offset,        width: 13,                 access_mode: RW, address_offset: 0x5C }
+          - - { field_name: ip_time_to_live,           width:  8,                 access_mode: RW, address_offset: 0x58 }
+          - - { field_name: ip_protocol,               width:  8,                 access_mode: RW, address_offset: 0x54 }
+          - - { field_name: ip_header_checksum,        width: 16,                 access_mode: RW, address_offset: 0x50 }
+          - - { field_name: ip_source_address,         width: 32,                 access_mode: RW, address_offset: 0x4C }
+          - - { field_name: ip_destination_address,    width: 32,                 access_mode: RW, address_offset: 0x48 }
+          # udp field group
+          - - { field_name: udp_source_port,           width: 16,                 access_mode: RW, address_offset: 0x44 }
+          - - { field_name: udp_destination_port,      width: 16,                 access_mode: RW, address_offset: 0x40 }
+          - - { field_name: udp_length,                width: 16,                 access_mode: RW, address_offset: 0x3C }
+          - - { field_name: udp_checksum,              width: 16,                 access_mode: RW, address_offset: 0x38 }
+          # application field group
+          - - { field_name: marker,                    width:  8,                 access_mode: RO, address_offset: 0x34 }
+          - - { field_name: version_id,                width:  8,                 access_mode: RO, address_offset: 0x30 }
+          - - { field_name: observation_id,            width: 32,                 access_mode: RW, address_offset: 0x2C }
+          - - { field_name: station_id,                width: 16,                 access_mode: RW, address_offset: 0x28 }
+          - - { field_name: source_info,               width: 16,                 access_mode: RW, address_offset: 0x24 }
+          - "source_info":
+            - { field_name: antenna_band_index,        width:  1, bit_offset: 15, access_mode: RW, address_offset: 0x24 }
+            - { field_name: nyquist_zone_index,        width:  2, bit_offset: 13, access_mode: RW, address_offset: 0x24 }
+            - { field_name: f_adc,                     width:  1, bit_offset: 12, access_mode: RW, address_offset: 0x24 }
+            - { field_name: fsub_type,                 width:  1, bit_offset: 11, access_mode: RW, address_offset: 0x24 }
+            - { field_name: payload_error,             width:  1, bit_offset: 10, access_mode: RW, address_offset: 0x24 }
+            - { field_name: beam_repositioning_flag,   width:  1, bit_offset:  9, access_mode: RW, address_offset: 0x24 }
+            - { field_name: subband_calibrated_flag,   width:  1, bit_offset:  8, access_mode: RW, address_offset: 0x24 }
+            - { field_name: reserved,                  width:  3, bit_offset:  5, access_mode: RW, address_offset: 0x24 }
+            - { field_name: gn_index,                  width:  5, bit_offset:  0, access_mode: RW, address_offset: 0x24 }
+
+          - - { field_name: reserved,                  width:  8,                 access_mode: RW, address_offset: 0x20 }
+          - - { field_name: integration_interval,      width: 24,                 access_mode: RW, address_offset: 0x1C }
+          - - { field_name: data_id,                   width: 32,                 access_mode: RW, address_offset: 0x18 }
+          - "data_id_bst":
+            - { field_name: reserved,                  width: 16, bit_offset: 16, access_mode: RW, address_offset: 0x18 }
+            - { field_name: beamlet_index,             width: 16, bit_offset:  0, access_mode: RW, address_offset: 0x18 }
+
+          - - { field_name: nof_signal_inputs,         width:  8,                 access_mode: RW, address_offset: 0x14 }
+          - - { field_name: nof_bytes_per_statistic,   width:  8,                 access_mode: RW, address_offset: 0x10 }
+          - - { field_name: nof_statistics_per_packet, width: 16,                 access_mode: RW, address_offset: 0xC }
+          - - { field_name: block_period,              width: 16,                 access_mode: RW, address_offset: 0x8 }
+          - - { field_name: BSN,                       width: 32,                 access_mode: RW, address_offset: 0x0, radix_width: 64 }
+
+
+  - peripheral_name: sdp_statistics_offload_hdr_dat_xst  #  pi_dp_offload_tx_hdr_dat_lofar2_sdp_statistics_offload.py
+    peripheral_description: "SDP statistics offload header for the cross-subband statistics (XST)."
+    slave_ports:
+      # MM port for sdp_statistics_offload.vhd / dp_offload_tx_v3.vhd
+      - slave_name: REG_DP_OFFLOAD_TX_HDR_DAT
+        slave_description: |
+          "The ETH/IP/UDP/application header fields for the XST offload UDP packets.
+
+           The crosslet statistics (XST) are integrated cross power values of the subbands from all
+           pairs of signal inputs per suband.
+           The XST specific settings are defined by data_id_xst.
+
+           The statistics offload header fields are described in ICD SC-SDP [1].
+
+           [1] https://plm.astron.nl/polarion/#/project/LOFAR2System/wiki/L2%20Interface%20Control%20Documents/SC%20to%20SDP%20ICD
+          "
+        slave_type: REG
+        fields:
+          # eth field group
+          - - { field_name: eth_destination_mac,       width: 32,                 access_mode: RW, address_offset: 0x84, radix_width: 48 }
+          - - { field_name: eth_source_mac,            width: 32,                 access_mode: RO, address_offset: 0x7C, radix_width: 48 }
+          - - { field_name: eth_type,                  width: 16,                 access_mode: RO, address_offset: 0x78 }
+          # ip field group
+          - - { field_name: ip_version,                width:  4,                 access_mode: RW, address_offset: 0x74 }
+          - - { field_name: ip_header_length,          width:  4,                 access_mode: RW, address_offset: 0x70 }
+          - - { field_name: ip_services,               width:  8,                 access_mode: RW, address_offset: 0x6C }
+          - - { field_name: ip_total_length,           width: 16,                 access_mode: RW, address_offset: 0x68 }
+          - - { field_name: ip_identification,         width: 16,                 access_mode: RW, address_offset: 0x64 }
+          - - { field_name: ip_flags,                  width:  3,                 access_mode: RW, address_offset: 0x60 }
+          - - { field_name: ip_fragment_offset,        width: 13,                 access_mode: RW, address_offset: 0x5C }
+          - - { field_name: ip_time_to_live,           width:  8,                 access_mode: RW, address_offset: 0x58 }
+          - - { field_name: ip_protocol,               width:  8,                 access_mode: RW, address_offset: 0x54 }
+          - - { field_name: ip_header_checksum,        width: 16,                 access_mode: RW, address_offset: 0x50 }
+          - - { field_name: ip_source_address,         width: 32,                 access_mode: RW, address_offset: 0x4C }
+          - - { field_name: ip_destination_address,    width: 32,                 access_mode: RW, address_offset: 0x48 }
+          # udp field group
+          - - { field_name: udp_source_port,           width: 16,                 access_mode: RW, address_offset: 0x44 }
+          - - { field_name: udp_destination_port,      width: 16,                 access_mode: RW, address_offset: 0x40 }
+          - - { field_name: udp_length,                width: 16,                 access_mode: RW, address_offset: 0x3C }
+          - - { field_name: udp_checksum,              width: 16,                 access_mode: RW, address_offset: 0x38 }
+          # application field group
+          - - { field_name: marker,                    width:  8,                 access_mode: RO, address_offset: 0x34 }
+          - - { field_name: version_id,                width:  8,                 access_mode: RO, address_offset: 0x30 }
+          - - { field_name: observation_id,            width: 32,                 access_mode: RW, address_offset: 0x2C }
+          - - { field_name: station_id,                width: 16,                 access_mode: RW, address_offset: 0x28 }
+          - - { field_name: source_info,               width: 16,                 access_mode: RW, address_offset: 0x24 }
+          - "source_info":
+            - { field_name: antenna_band_index,        width:  1, bit_offset: 15, access_mode: RW, address_offset: 0x24 }
+            - { field_name: nyquist_zone_index,        width:  2, bit_offset: 13, access_mode: RW, address_offset: 0x24 }
+            - { field_name: f_adc,                     width:  1, bit_offset: 12, access_mode: RW, address_offset: 0x24 }
+            - { field_name: fsub_type,                 width:  1, bit_offset: 11, access_mode: RW, address_offset: 0x24 }
+            - { field_name: payload_error,             width:  1, bit_offset: 10, access_mode: RW, address_offset: 0x24 }
+            - { field_name: beam_repositioning_flag,   width:  1, bit_offset:  9, access_mode: RW, address_offset: 0x24 }
+            - { field_name: subband_calibrated_flag,   width:  1, bit_offset:  8, access_mode: RW, address_offset: 0x24 }
+            - { field_name: reserved,                  width:  3, bit_offset:  5, access_mode: RW, address_offset: 0x24 }
+            - { field_name: gn_index,                  width:  5, bit_offset:  0, access_mode: RW, address_offset: 0x24 }
+
+          - - { field_name: reserved,                  width:  8,                 access_mode: RW, address_offset: 0x20 }
+          - - { field_name: integration_interval,      width: 24,                 access_mode: RW, address_offset: 0x1C }
+          - - { field_name: data_id,                   width: 32,                 access_mode: RW, address_offset: 0x18 }
+          - "data_id_xst":
+            - { field_name: reserved,                  width:  7, bit_offset: 25, access_mode: RW, address_offset: 0x18 }
+            - { field_name: subband_index,             width:  9, bit_offset: 16, access_mode: RW, address_offset: 0x18 }
+            - { field_name: signal_input_A_index,      width:  8, bit_offset:  8, access_mode: RW, address_offset: 0x18 }
+            - { field_name: signal_input_B_index,      width:  8, bit_offset:  0, access_mode: RW, address_offset: 0x18 }
+
+          - - { field_name: nof_signal_inputs,         width:  8,                 access_mode: RW, address_offset: 0x14 }
+          - - { field_name: nof_bytes_per_statistic,   width:  8,                 access_mode: RW, address_offset: 0x10 }
+          - - { field_name: nof_statistics_per_packet, width: 16,                 access_mode: RW, address_offset: 0xC }
+          - - { field_name: block_period,              width: 16,                 access_mode: RW, address_offset: 0x8 }
+          - - { field_name: BSN,                       width: 32,                 access_mode: RW, address_offset: 0x0, radix_width: 64 }
+
-- 
GitLab