From 90d15c3684881f3dbe0ecaeb7444f6ac7e549caf Mon Sep 17 00:00:00 2001
From: Eric Kooistra <kooistra@astron.nl>
Date: Thu, 24 Sep 2020 17:50:51 +0200
Subject: [PATCH] Weekly commit.

---
 .../doc/prestudy/desp_howtools_erko.txt       |  13 +-
 .../station2_sdp_firmware_planning.txt        |   5 +
 .../lofar2/doc/prestudy/station2_sdp_icd.txt  | 183 +++++++++---------
 .../lofar2/doc/prestudy/station2_sdp_ring.txt |   2 +-
 4 files changed, 112 insertions(+), 91 deletions(-)

diff --git a/applications/lofar2/doc/prestudy/desp_howtools_erko.txt b/applications/lofar2/doc/prestudy/desp_howtools_erko.txt
index 31fc55ec01..53687f6236 100755
--- a/applications/lofar2/doc/prestudy/desp_howtools_erko.txt
+++ b/applications/lofar2/doc/prestudy/desp_howtools_erko.txt
@@ -294,7 +294,12 @@ Note:
   branch because the reviewer does not need to compile and run the code and
   because typically only one coder works on a branch.
 
-
+We hebben nog geen regel over sub-branches wel of niet. Als er geen duidelijk voordeel is dan zou
+ik alleen vanaf de master branchen, omdat je de branches dan onafhankelijk houdt van elkaar en
+alle branches dan dezelfde referentie hebben. Voordat je een merge request van je branch naar een
+bovenliggende branch doet, moet je eerst die bovenliggende branch mergen naar je branch.
+  
+  
 *******************************************************************************
 * Confluence:
 *******************************************************************************
@@ -654,8 +659,14 @@ https://linuxize.com/
 dop466 = SSD
 dop466_0 = HDD
 
+> tar -cvf filename.tar dir_name/   # create tar
+> tar -xvf filename.tar             # extract tar
+> gzip filename        # zip file
+> unzip filename.gz    # unzip file
+
 > grep -rl 'search text in files' .  # -r for recursive, -l for only list filename
 
+
 > sudo -s   # to become root
 > sudo pip install numpy      # to run Python2 library installer as root
 > sudo pip3 install numpy     # to run Python3 library installer as root
diff --git a/applications/lofar2/doc/prestudy/station2_sdp_firmware_planning.txt b/applications/lofar2/doc/prestudy/station2_sdp_firmware_planning.txt
index 164144b741..dfc516cc98 100755
--- a/applications/lofar2/doc/prestudy/station2_sdp_firmware_planning.txt
+++ b/applications/lofar2/doc/prestudy/station2_sdp_firmware_planning.txt
@@ -803,3 +803,8 @@ TB DDR4 access R/W via M&C
 BF full (ring)
 TB one node --> output via 10GbE --> full (ring)
 
+
+
+
+
+https://bits-chips.nl/artikel/cracking-the-code-to-craftsmanship/?utm_source=Bits%26Chips+newsletter&utm_campaign=a67ee91488-EMAIL_CAMPAIGN_2020_09_08_13%3A00&utm_medium=email&utm_term=0_cea2018fda-a67ee91488-322493781
diff --git a/applications/lofar2/doc/prestudy/station2_sdp_icd.txt b/applications/lofar2/doc/prestudy/station2_sdp_icd.txt
index d51c651115..0716805b5e 100755
--- a/applications/lofar2/doc/prestudy/station2_sdp_icd.txt
+++ b/applications/lofar2/doc/prestudy/station2_sdp_icd.txt
@@ -323,8 +323,8 @@ The total number of streams to CEP then becomes NOF_BEAMSETS * NOF_LANES.
       beamlet.
     Try use same fields as for statistics
       
-  . 1b antenna_band: 0 = LB, 1 = HB [LOFAR2-3098, 6996]
-  . 2b nyquist_zone_index: Nyquist sampling zone index, 0 for LB, 1 or 2 for HB, 0 = first zone from 0-f_adc/2 Hz, 1 = second zone from f_adc/2:f_adc Hz, 2 = third zone from f_adc-f_adc*3/2 Hz
+  . 1b antenna_band_id: 0 = LB, 1 = HB [LOFAR2-3098, 6996]
+  . 2b nyquist_zone_id: Nyquist sampling zone index, 0 for LB, 1 or 2 for HB, 0 = first zone from 0-f_adc/2 Hz, 1 = second zone from f_adc/2:f_adc Hz, 2 = third zone from f_adc-f_adc*3/2 Hz
   . 1b f_adc, sample clock frequency of the ADC, 0 = 160 MHz, 1 = 200 MHz [LOFAR2-3578]
   . 1b fsub_type: 0 = critically sampled PFB , 1 = oversampled PFB [LOFAR2-2278]
        - rather than transporting p, q for R_os = p/q
@@ -358,8 +358,8 @@ The internal beamlet data in SDPFW is scaled by the beamlet_scale factor, before
       
         
 - 2 Byte, BEAMLET_INDEX of first beamlet in the payload
-  . sdp_beamset_index * nof_beamlets_per_set
-  . beamset_index = 0 in range(nof_beamsets).
+  . sdp_beamset_id * nof_beamlets_per_set
+  . beamset_id = 0 in range(nof_beamsets).
   . global beamlet index of first beamlet in block
     -   0: 487 for beamset 0
     - 488: 975 for beamset 1, etc
@@ -399,8 +399,8 @@ Obsolete fields:
   . NOF_LANES 8b
   . LANE_INDEX 8b in range(NOF_LANES)
   . BEAMLET_STEP = NOF_LANES
-  . BEAMLET_INDEX = beamset_index * nof_beamlets_per_set + bl * NOF_LANES + LANE_INDEX
-  . stream index = beamset_index * NOF_LANES + LANE_INDEX
+  . BEAMLET_INDEX = beamset_id * nof_beamlets_per_set + bl * NOF_LANES + LANE_INDEX
+  . stream index = beamset_id * NOF_LANES + LANE_INDEX
     - Separate destination address per stream
     - No need to have an stream index field, because the CEP only needs to know the beamlet index.
     - The beamlet index for each sample follows from BEAMLET_INDEX, BEAMLET_STEP, NOF_BEAMLETS_PER_BLOCK
@@ -493,7 +493,7 @@ Pre conditions:
 
 Remarks:
 
-Do not define a field for the subband RF frequency. For SST this can be derived from subband index and antenna_band and RCU2 mode. For BST each beamlet can have any subband RF frequency, so this is not possible to convey with a single field of only a few bytes.
+Do not define a field for the subband RF frequency. For SST this can be derived from subband index and antenna_band_id and RCU2 mode. For BST each beamlet can have any subband RF frequency, so this is not possible to convey with a single field of only a few bytes.
 Do not support more than one block per packet, because for SST and BST the payload is sufficiently large. For XST is convenient to have only one crosslet per packet, because then its subband index can be set in the header. Furthermore the number of statistics packets per second is relatively low.
 
 Statistics packet fields format: See ICD SC-SDP in Polarion
@@ -524,8 +524,8 @@ List of products with M&C in SDP
 Path                Product name
 
 /sdptr              SDP Translator
+/band[0:1]/sdpfw    SDPFW
 /band[0:1]/bsp      SDPFW Board Support Package
-/band[0:1]/general  SDPFW
 /band[0:1]/ait      SDPFW ADC Input and Timing
 /band[0:1]/fsub     SDPFW Subband Filterbank
 /band[0:1]/bf       SDPFW Beamformer
@@ -539,10 +539,8 @@ List of control points per antenna band and per product in SDP
 
 Path               Point
 /sdptr             /sdp_info
-/band[0:1]/bsp     /pn_image
-/band[0:1]/general /sdp_info
-                   /data_flags
-                   /signal_input_range
+/band[0:1]/sdpfw   /sdp_info
+/band[0:1]/bsp     /pn_image_name
 /band[0:1]/ait     /processing_enable
                    /si_sample_delay
                    /si_waveform_generator
@@ -567,19 +565,19 @@ Path               Point
 List of monitor points per antenna band and per product in SDP
 
 Path                Point
-/sdptr              /tr_info
-                    /tr_timing
-                    /tr_network
+/sdptr              /translator_info
+                    /translator_timing
+                    /translator_network
+/band[0:1]/sdpfw    /sdp_info
 /band[0:1]/bsp      /pn_info
                     /pps_timing
                     /mc_network
-/band[0:1]/general  /sdp_info
-/band[0:1]/ait      /sdp_status
+/band[0:1]/ait      /processing_status
                     /si_timing
-                    /si_mean
-                    /si_sigma
+                    /si_data_mean
+                    /si_data_sigma
                     /si_data_buffer
-                    /si_histogram
+                    /si_data_histogram
 /band[0:1]/fsub     -                If sst_offload_enable = off, then the SST can be read via direct monitoring.
 /band[0:1]/bf       -                If bst_offload_enable = off, then the BST can be read via direct monitoring.
 /band[0:1]/ri/
@@ -592,61 +590,66 @@ Path                Point
 For the SDP Firmware the 
 
 /sdptr/
-    Control:
-    - sdp_info:
-      . station_id
-    Monitor:
-    - tr_info:
-      . software name and version
-      . temperature ? (or via EC2 ?)
-    - tr_timing:
-      . NTP status
-      . PPS status : Locked, not locked, unknown
-        - Not locked = NTP time at SDPTR does not coincide within +- 1 ms with PPS top of second at SDPFW
-        - Locked = NTP time at SDPTR is aligned within +- 1 ms with the PPS top of second at SDPFW → based on the offset_cnt information from the PPSH in one of the PN in the SDPHW / SDPFW
-        - Unknown when the PPS information in SDPFW is not stable or not available
-    - tr_network:
-      . SC-SDPTR link status at SDPTR : nof tx pkts, nof rx pkts, nof crc errors, nof retransmissions, nof timeouts
-      . SDPTR-SDPFW link status at SDPTR : nof tx pkts, nof rx pkts, nof crc errors, nof retransmissions, nof timeouts
-    
+    DONE Control:
+    DONE - sdp_info:
+    DONE   . station_id
+    DONE Monitor:
+    DONE - translator_info:
+    DONE   . software name and version
+    DONE   . temperature ? (or via EC2 ?)
+    DONE - translator_timing:
+    DONE   . NTP status
+    DONE   . NTP time
+    DONE   . PPS status : synchronized, not synchronized, indeterminate
+    DONE     - Not synchronized = NTP time at SDPTR does not coincide within +- 1 ms with PPS top of second at SDPFW
+    DONE     - Synchronized = NTP time at SDPTR is aligned within +- 1 ms with the PPS top of second at SDPFW → based on the offset_cnt information from the PPSH in one of the PN in the SDPHW / SDPFW
+    DONE     - Indeterminate when the PPS information in SDPFW is not stable or not available
+    DONE - translator_network:
+    DONE   . SC-SDPTR link status at SDPTR : nof tx pkts, nof rx pkts, nof crc errors, nof retransmissions, nof timeouts
+    DONE   . SDPTR-SDPFW link status at SDPTR : nof tx pkts, nof rx pkts, nof crc errors, nof retransmissions, nof timeouts
     
-/band[0:1]/bsp/
-    Control for all allocated PN
-    - pn_image : design name
     
-    Monitor per allocated PN
-    - pn_info : unb_hw_version, gn_id, rn_id, fw_image (design_name with date, time and revision stamp, design note), f_adc, fsub_type
-    - pn_regmap : mmap
-    - pps_timing :
-      . STF-SDPFW PPS status at SDPFW:
-        'not active' = measured PPS count >> f_adc = 200M and clipped at 2**28 - 1
-        'asynchronous' = measured PPS count != expected count -1, +0, or +1
-        'active' = measured PPS count = expected count -1, +0, or +1
-        'active and stable' → measured PPS count has been equal to expected count -1, +0, or +1 since last time it was monitored.
-    - eth1g :
-      . SDPTR-SDPFW link status at SDPFW : nof tx pkts, nof rx pkts, nof crc errors, nof retransmissions, nof timeouts
-
-band[0:1]/general
-    Control
-    - sdp_info: observation_id, nyquist_zone_index
-    - data_flags : beam repositioning flag, calibrated subbands flag
-    - signal_input_range : R_ant = (O_si, N_si) → this will allocate N_pn = N_si / S_pn PN starting with PN with rn_id = O_si / S_pn
+band[0:1]/sdpfw
+    DONE Control
+    DONE - sdp_info:
+    DONE   . antenna_band_id, observation_id, nyquist_zone_id
+    DONE   . repositioning_flag, calibrated_flag
+    DONE   . signal_input_range : R_si = (O_si, N_si) → this will allocate N_pn = N_si / S_pn PN starting with PN with rn_id = O_si / S_pn
+    DONE 
+    DONE Monitor per allocated PN
+    DONE - sdp_info:
+    DONE   . f_adc, fsub_type
+    DONE   . ring_node_range  : R_rn = (O_rn, N_rn)
+    DONE   . sample_period
+    DONE   . block_period
+    DONE - eth10g
     
-    Both the offset and the amount are a multiple of S_pn = 12 signals inputs, because there are S_pn = 12 signal inputs per FPGA processing node (PN) in the SDP Hardware and because the PN are interconnected in a fixed sequence.
+/band[0:1]/bsp/
+    DONE Control for all allocated PN
+    DONE - pn_image_name : design name
     
     Monitor per allocated PN
-    - sdp_info : f_adc, fsub_type
-    - eth10g
-    
+    DONE - pn_info : unb_hw_version, gn_id, rn_id, fw_image (design_name with date, time and revision stamp, design note)
+    DONE - pps_timing :
+    DONE   . STF-SDPFW PPS status at SDPFW:
+    DONE     'not active' = measured PPS count >> f_adc = 200M and clipped at 2**28 - 1
+    DONE     'not synchronous' = measured PPS count != expected count -1, +0, or +1
+    DONE     'synchronous' = measured PPS count = expected count -1, +0, or +1
+    DONE     'synchronous and stable' → measured PPS count has been equal to expected count -1, +0, or +1 since last time it was monitored.
+    DONE - eth1g :
+    DONE   . SDPTR-SDPFW link status at SDPFW : nof tx pkts, nof rx pkts, nof crc errors, nof retransmissions, nof timeouts
+
 /band[0:1]/ait/    (AIT = adc input and timing)
-    Control:
-    - processing_enable : Start, stop
-    - si_sample_delay, Sample delay buffer : (unit16)ait_sample_delay[R_ant]
-    - si_waveform_generator (WG) : start at BSN, stop, freq[R_ant], ampl[R_ant], phs[R_ant]
-    
+    DONE Control:
+    DONE - processing_enable : Start, stop --> SDPTR zorgt voor BSN offset en BSN
+    DONE - si_sample_delay, Sample delay buffer : (unit16)ait_sample_delay[N_si]
+    DONE - si_waveform_generator (WG) :
+    DONE   . freq[N_si], ampl[N_si], phs[N_si]
+    DONE   . enable[N_si] --> start, continue, stop --> SDPTR zorgt voor start at PPS
+      
     Monitor:
-    - sdp_status : 'stopped', 'running' or running and stable' → based on read BSN from BSN source being equal and incrementing correctly at all PN
-    - si_timing : (enum)ait_timing[R_ant]
+    DONE - processing_status : 'stopped', 'running' or running and stable' → based on read BSN from BSN source being equal and incrementing correctly at all PN
+    - si_timing : (enum)si_timing[N_si]
       'not active' = no data
       'active' = there is data
       'active and stable and not aligned' = there is a stable flow of data since last time it was monitored, but the recovered LMFC is not aligned with the local FPGA_SYSREF
@@ -654,32 +657,32 @@ band[0:1]/general
       'aligned and stable' = there is a stable flow of data and it is aligned since the last time it was monitored    
 
     Monitor on request:
-    - si_mean : (float)ait_mean[R_ant]
-    - si_sigma : (float)ait_sigma[R_ant]
-    - si_data_buffer : (sint16)ait_data_buffer[R_ant][N]  (N = 1k samples)
-    - si_histogram : (uint32)ait_histogram[R_ant][N]  (N = 1k bins)
+    - si_data_mean : (float)ait_mean[N_si]
+    - si_data_sigma : (float)ait_sigma[N_si]
+    - si_data_buffer : (sint16)ait_data_buffer[N_si][N]  (N = 1k samples)
+    - si_data_histogram : (uint32)ait_histogram[N_si][N]  (N = 1k bins)
 
 /band[0:1]/fsub/  (Fsub = subband filterbank)
-    Control:
-    - pfir_coefficients: FIR filter coefficients: (sint16)pfir_coefficients[N_taps*N_fft]
-    - subband_weights : (cint16)subband_weights[R_ant][N_sub]
-    - sst_input_select : (bool)sst_input_select, select calibrated or not calibrated for SST
-    - sst_offload_destination : SST UDP offload header
-      . Destination : (tuple)sst_offload_destination = (MAC address, IPv4 address, UDP port)
-    - sst_offload_enable : SST UDP offload : (bool)sst_offload_enable = on, off
-
-    Monitor: None, if sst_offload = off, then the SST can be read via direct monitoring.
+    DONE Control:
+    DONE - pfir_coefficients: FIR filter coefficients: (int16)pfir_coefficients[N_taps*N_fft]
+    DONE - subband_weights : (cint16)subband_weights[N_si][N_sub]
+    DONE - sst_input_select : (bool)sst_input_select, select calibrated or not calibrated for SST
+    DONE - sst_offload_destination : SST UDP offload header
+    DONE   . Destination : (tuple)sst_offload_destination = (MAC address, IPv4 address, UDP port)
+    DONE - sst_offload_enable : SST UDP offload : (bool)sst_offload_enable = on, off
+    DONE 
+    DONE Monitor: None, if sst_offload = off, then the SST can be read via direct monitoring.
 
 /band[0:1]/bf/ (BF = beamformer)
     Control: 
-    - Subband select per beam: (uint16)beamlet_subband_select[N_beamlets]
-    - Beamformer weights for X polarization beams: (cint16)beamlet_weights_xx[N_ant][N_beamlets]
-    - Beamformer weights for Y polarization beams: (cint16)beamlet_weights_yy[N_ant][N_beamlets]
-    - BST UDP offload header
-      . Destination : (tuple)bst_offload_destination[N_beamsets] = (MAC address, IPv4 address, UDP port)
-    - BST UDP offload : (bool)bst_offload[N_beamsets] = on, off
-
-    Monitor: None, if bst_offload = off, then the BST can be read via direct monitoring.
+    DONE - Subband select per beam: (uint16)beamlet_subband_select[N_beamlets]
+    DONE - Beamformer weights for X polarization beams: (cint16)beamlet_weights_xx[N_ant][N_beamlets]
+    DONE - Beamformer weights for Y polarization beams: (cint16)beamlet_weights_yy[N_ant][N_beamlets]
+    DONE - BST UDP offload header
+    DONE   . Destination : (tuple)bst_offload_destination[N_beamsets] = (MAC address, IPv4 address, UDP port)
+    DONE - BST UDP offload : (bool)bst_offload[N_beamsets] = on, off
+    DONE 
+    DONE Monitor: None, if bst_offload = off, then the BST can be read via direct monitoring.
 
 /band[0:1]/ri/ (RI = ring)
 
@@ -692,6 +695,8 @@ band[0:1]/general
 
 De SDP Translator is valt ook onder beheer EC2.
 
+Enianess:
+The Nios II architecture uses little-endian byte ordering. Words and halfwords are stored inmemory with the more-significant bytes at higher addresses.
 
 
 ###################################################################################################
diff --git a/applications/lofar2/doc/prestudy/station2_sdp_ring.txt b/applications/lofar2/doc/prestudy/station2_sdp_ring.txt
index 36ad9f70b8..99ea252384 100755
--- a/applications/lofar2/doc/prestudy/station2_sdp_ring.txt
+++ b/applications/lofar2/doc/prestudy/station2_sdp_ring.txt
@@ -657,7 +657,7 @@ Design decision:
   
 Maximum number of crosslets per correlator cell:
 An X_pn correlator cell can correlate N_clk / X_sq = 1024 / 144 = 7 different crosslets frequencies.
-With N = 16 for LBA, there need to be N/2 + 1 = 9 of these X_pn correlator cells in parallel. One
+With N = 16 for LBA, there need to be P_xc = N/2 + 1 = 9 of these X_pn correlator cells in parallel. One
 X_pn correlates the local-local crosslets and the other N/2 = 8 X_pn correlate the local-remote
 crosslets. These 9 X_pn in parallel can correlate up to 7 different crosslets. The link can
 transport maximum 11 crosslets. Hence the processing capacity of 9 X_pn is less than the IO 
-- 
GitLab