From ab3d30c5dbb77b780ee4d505509f6aa6b8d427e7 Mon Sep 17 00:00:00 2001
From: Eric Kooistra <kooistra@astron.nl>
Date: Fri, 5 Mar 2021 20:45:35 +0100
Subject: [PATCH] Added dp_shiftram, dp_bsn_source, dp_bsn_source_v2,
 dp_bsn_scheduler, dp_bsn_monitor.

---
 libraries/base/dp/dp.peripheral.yaml | 240 ++++++++++++++++++++++++++-
 1 file changed, 239 insertions(+), 1 deletion(-)

diff --git a/libraries/base/dp/dp.peripheral.yaml b/libraries/base/dp/dp.peripheral.yaml
index ecc421c8c3..30d8efd01b 100644
--- a/libraries/base/dp/dp.peripheral.yaml
+++ b/libraries/base/dp/dp.peripheral.yaml
@@ -50,9 +50,247 @@ peripherals:
       # MM port for mms_dp_fifo_from_mm.vhd / dp_fifo_from_mm.vhd
       - slave_name: REG_MMDP_DATA   # Use REG_, instead of preferred FIFO_, to match slave_port_name in pi_mmdp.py
         slave_type: FIFO
-        slave_description: "MMDP = write word to the MM to DP write FIFO"
+        slave_description: "MMDP = write word to the MM to DP write FIFO."
         fields:
           - - field_name: data
               field_description: "Write data to the FIFO."
               access_mode: WO
               address_offset: 0x0
+              
+  - peripheral_name: dp_shiftram    # pi_dp_shiftram.py
+    peripheral_description: "Sample delay buffer with programmable delay for streaming data."
+    parameters:
+      # Parameters of dp_shiftram.vhd
+      - { name: g_nof_streams, value: 1 }
+      - { name: g_nof_words, value: 1024 }
+      - { name: g_data_w, value: 16 }
+    slave_ports:                            
+      # MM port for dp_shiftram.vhd
+      - slave_name: REG_DP_SHIFTRAM
+        slave_type: REG
+        slave_description: ""
+        number_of_slaves: g_nof_streams
+        fields:
+          - - field_name: shift
+              field_description: "Fill level of the sample delay buffer in number of data samples."
+              width: ceil_log2(g_nof_words)
+              access_mode: RW
+              address_offset: 0x0
+
+  - peripheral_name: dp_bsn_source    # pi_dp_bsn_source.py
+    peripheral_description: "Block Sequence Number (BSN) source for timestamping blocks of data samples."
+    parameters:
+      # Parameters of dp_bsn_source_reg.vhd
+      - { name: g_nof_block_per_sync, value: 20 }
+    slave_ports:                            
+      # MM port for dp_bsn_source_reg.vhd
+      - slave_name: REG_DP_BSN_SOURCE
+        slave_type: REG
+        slave_description: ""
+        fields:
+          - - field_name: dp_on
+              field_description: |
+                "When 1 then enable BSN source, else when 0 disable BSN source. If dp_on_pps is 0,
+                 then dp_on = 1 enables the BSN source immediately. To enable the BSN source at
+                 the next PPS, then first set dp_on_pps = 1. Clearing dp_on stops the BSN source."
+              width: 1
+              access_mode: RW
+              address_offset: 0x0
+          - - field_name: dp_on_pps
+              field_description: "When 1 and dp_on = 1 then enable BSN source at next PPS."
+              width: 1
+              bit_offset: 1
+              access_mode: RW
+              address_offset: 0x0
+          - - field_name: nof_block_per_sync
+              field_description: "Number of blocks per sync interval."
+              access_mode: RW
+              address_offset: 0x4
+          - - field_name: bsn_lo
+              field_description: "Initial BSN[31:0]"
+              access_mode: RW
+              address_offset: 0x8
+          - - field_name: bsn_hi
+              field_description: "Initial BSN[63:32]"
+              access_mode: RW
+              address_offset: 0xC
+
+  - peripheral_name: dp_bsn_source_v2    # pi_dp_bsn_source_v2.py
+    peripheral_description: "Block Sequence Number (BSN) source with block time offset, for timestamping blocks of data samples."
+    parameters:
+      # Parameters of dp_bsn_source_reg_v2.vhd
+      - { name: g_nof_clk_per_sync, value: 200000000 }
+      - { name: g_block_size, value: 256 }
+      - { name: g_bsn_time_offset_w, value: 8 }  # note: g_bsn_time_offset_w = ceil_log2(g_block_size)
+    slave_ports:                            
+      # MM port for dp_bsn_source_reg_v2.vhd
+      - slave_name: REG_DP_BSN_SOURCE_V2
+        slave_type: REG
+        slave_description: ""
+        fields:
+          - - field_name: dp_on
+              field_description: |
+                "When 1 then enable BSN source, else when 0 disable BSN source. If dp_on_pps is 0,
+                 then dp_on = 1 enables the BSN source immediately. To enable the BSN source at
+                 the next PPS, then first set dp_on_pps = 1. Clearing dp_on stops the BSN source."
+              width: 1
+              access_mode: RW
+              address_offset: 0x0
+          - - field_name: dp_on_pps
+              field_description: "When 1 and dp_on = 1, then enable BSN source at next PPS."
+              width: 1
+              bit_offset: 1
+              access_mode: RW
+              address_offset: 0x0
+          - - field_name: nof_block_per_sync
+              field_description: "Number of clock cycles per sync interval."
+              access_mode: RW
+              address_offset: 0x4
+          - - field_name: bsn_init_lo
+              field_description: "Initial BSN[31:0]"
+              access_mode: RW
+              address_offset: 0x8
+          - - field_name: bsn_init_hi
+              field_description: "Initial BSN[63:32]"
+              access_mode: RW
+              address_offset: 0xC
+          - - field_name: bsn_time_offset
+              field_description: "The BSN block time offset in number of clock cycles, with respect to the PPS."
+              width: g_bsn_time_offset_w
+              access_mode: RW
+              address_offset: 0x10
+              
+  - peripheral_name: dp_bsn_scheduler    # pi_dp_bsn_scheduler.py
+    peripheral_description: "Schedule a trigger at a certain Block Sequence Number (BSN) instant."
+    slave_ports:                            
+      # MM port for dp_bsn_scheduler_reg.vhd
+      - slave_name: REG_DP_BSN_SCHEDULER
+        slave_type: REG
+        slave_description: ""
+        fields:
+          - - field_name: scheduled_bsn_lo
+              field_description: "Write scheduled BSN lo, read current BSN lo. First access lo, then hi."
+              access_mode: RW
+              address_offset: 0x0
+          - - field_name: scheduled_bsn_hi
+              field_description: "Write scheduled BSN hi, read current BSN hi. First access lo, then hi."
+              access_mode: RW
+              address_offset: 0x4
+              
+  - peripheral_name: dp_bsn_monitor    # pi_dp_bsn_monitor.py
+    peripheral_description: "Monitor the Block Sequence Number (BSN) status of streaming data."
+    parameters:
+      # Parameters of mms_dp_bsn_monitor.vhd
+      - { name: g_nof_streams, value: 1 }
+    slave_ports:                            
+      # MM port for dp_bsn_monitor_reg.vhd
+      - slave_name: REG_DP_BSN_MONITOR
+        slave_type: REG
+        slave_description: ""
+        number_of_slaves: g_nof_streams
+        fields:
+          - - field_name: xon_stable
+              field_description: "Data block flow control xon signal was active and stable during last sync interval."
+              width: 1
+              bit_offset: 0
+              access_mode: RO
+              address_offset: 0x0
+          - - field_name: ready_stable
+              field_description: "Clock cycle flow control ready signal was active and stable during last sync interval."
+              width: 1
+              bit_offset: 1
+              access_mode: RO
+              address_offset: 0x0
+          - - field_name: sync_timeout
+              field_description: "Data stream sync did not occur during last sync interval."
+              width: 1
+              bit_offset: 2      # EK TODO: using 1 cause gen_doc.py to fail without clear error, because fields then overlap
+              access_mode: RO
+              address_offset: 0x0
+          - - field_name: bsn_at_sync_lo
+              field_description: "Data stream BSN lo at sync."
+              access_mode: RO
+              address_offset: 0x4
+          - - field_name: bsn_at_sync_hi
+              field_description: "Data stream BSN hi at sync."
+              access_mode: RO
+              address_offset: 0x8
+          - - field_name: nof_sop
+              field_description: "Number data blocks (sop = start of packet) during last sync interval."
+              access_mode: RO
+              address_offset: 0xC
+          - - field_name: nof_valid
+              field_description: "Number valid samples of the data blocks during last sync interval (= nof_sop * block size)."
+              access_mode: RO
+              address_offset: 0x10
+          - - field_name: nof_err
+              field_description: "Number data blocks with error indication during last sync interval."
+              access_mode: RO
+              address_offset: 0x14
+          - - field_name: bsn_first_lo
+              field_description: "First data stream BSN lo ever."
+              access_mode: RO
+              address_offset: 0x18
+          - - field_name: bsn_first_hi
+              field_description: "First data stream BSN hi ever."
+              access_mode: RO
+              address_offset: 0x1C
+          - - field_name: bsn_first_cycle_cnt
+              field_description: "Arrival latency of first data stream BSN ever, relative to local sync."
+              access_mode: RO
+              address_offset: 0x20
+
+  - peripheral_name: dp_bsn_monitor_v2    # pi_dp_bsn_monitor_v2.py
+    peripheral_description: "Monitor the Block Sequence Number (BSN) status and latency of streaming data."
+    parameters:
+      # Parameters of mms_dp_bsn_monitor_v2.vhd
+      - { name: g_nof_streams, value: 1 }
+    slave_ports:                            
+      # MM port for dp_bsn_monitor_reg_v2.vhd
+      - slave_name: REG_DP_BSN_MONITOR_V2
+        slave_type: REG
+        slave_description: ""
+        number_of_slaves: g_nof_streams
+        fields:
+          - - field_name: xon_stable
+              field_description: "Data block flow control xon signal was active and stable during last sync interval."
+              width: 1
+              bit_offset: 0
+              access_mode: RO
+              address_offset: 0x0
+          - - field_name: ready_stable
+              field_description: "Clock cycle flow control ready signal was active and stable during last sync interval."
+              width: 1
+              bit_offset: 1
+              access_mode: RO
+              address_offset: 0x0
+          - - field_name: sync_timeout
+              field_description: "Data stream sync did not occur during last sync interval."
+              width: 1
+              bit_offset: 1
+              access_mode: RO
+              address_offset: 0x0
+          - - field_name: bsn_at_sync_lo
+              field_description: "Data stream BSN lo at sync."
+              access_mode: RO
+              address_offset: 0x4
+          - - field_name: bsn_at_sync_hi
+              field_description: "Data stream BSN hi at sync."
+              access_mode: RO
+              address_offset: 0x8
+          - - field_name: nof_sop
+              field_description: "Number data blocks (sop = start of packet) during last sync interval."
+              access_mode: RO
+              address_offset: 0xC
+          - - field_name: nof_valid
+              field_description: "Number valid samples of the data blocks during last sync interval (= nof_sop * block size)."
+              access_mode: RO
+              address_offset: 0x10
+          - - field_name: nof_err
+              field_description: "Number data blocks with error indication during last sync interval."
+              access_mode: RO
+              address_offset: 0x14
+          - - field_name: latency
+              field_description: "Arrival latency of data stream BSN at sync, relative to local sync."
+              access_mode: RO
+              address_offset: 0x20
-- 
GitLab