From aa3cb9af066cb1b90a6f3ab0e2e342ec05b037a9 Mon Sep 17 00:00:00 2001
From: Eric Kooistra <kooistra@astron.nl>
Date: Tue, 9 Mar 2021 14:44:20 +0100
Subject: [PATCH] Added ADUH_MON, but kept reg and ram in seperate
 peripheral_names.

---
 .../lofar2_unb2b_adc.fpga.yaml                | 37 ++++++++----
 libraries/base/diag/diag.peripheral.yaml      |  8 +--
 libraries/io/aduh/aduh.peripheral.yaml        | 59 +++++++++++++++++++
 3 files changed, 86 insertions(+), 18 deletions(-)
 create mode 100644 libraries/io/aduh/aduh.peripheral.yaml

diff --git a/applications/lofar2/designs/lofar2_unb2b_adc/lofar2_unb2b_adc.fpga.yaml b/applications/lofar2/designs/lofar2_unb2b_adc/lofar2_unb2b_adc.fpga.yaml
index 97e25dd6ea..96164e10b8 100644
--- a/applications/lofar2/designs/lofar2_unb2b_adc/lofar2_unb2b_adc.fpga.yaml
+++ b/applications/lofar2/designs/lofar2_unb2b_adc/lofar2_unb2b_adc.fpga.yaml
@@ -82,14 +82,15 @@ peripherals:
       - { name: g_nof_block_per_sync, value: 195313 }  # 390625 = 2 * 195312, to have integer number of blocks in 2 s sync interval
     slave_port_names:
       - REG_BSN_SOURCE
-
-#  - peripheral_name: dp/dp_bsn_source_v2
-#    parameter_overrides:
-#      - { name: g_nof_clk_per_sync, value: 200000000 }  # = f_adc
-#      - { name: g_block_size, value: 1024 }       # = N_fft
-#      - { name: g_bsn_time_offset_w, value: 10 }  # note: g_bsn_time_offset_w = ceil_log2(g_block_size)
-#    slave_port_names:
-#      - REG_BSN_SOURCE_V2
+      
+  # TODO: Use REG_BSN_SOURCE_V2 instead of REG_BSN_SOURCE
+  #peripheral_name: dp/dp_bsn_source_v2
+  #parameter_overrides:
+  #  - { name: g_nof_clk_per_sync, value: 200000000 }  # = f_adc
+  #  - { name: g_block_size, value: 1024 }       # = N_fft
+  #  - { name: g_bsn_time_offset_w, value: 10 }  # note: g_bsn_time_offset_w = ceil_log2(g_block_size)
+  #slave_port_names:
+  #  - REG_BSN_SOURCE_V2
       
   - peripheral_name: dp/dp_bsn_scheduler
     slave_port_names:
@@ -107,10 +108,22 @@ peripherals:
       - REG_DIAG_WG
       - RAM_DIAG_WG
       
-#  - peripheral_name: aduh/aduh_monitor
-#    slave_port_names:
-#      - REG_ADUH_MONITOR
-#      - RAM_ADUH_MONITOR
+  - peripheral_name: aduh/aduh_mon_dc_power
+    parameter_overrides:
+      - { name: g_nof_streams, value: 12 }  # = S_pn
+    slave_port_names:
+      - REG_ADUH_MON
+
+  # Commented RAM_ADUH_MON, because use RAM_DIAG_DATA_BUF_BSN instead
+  #- peripheral_name: aduh/aduh_mon_data_buffer
+  #  parameter_overrides:
+  #    - { name: g_nof_streams, value: 12 }  # = S_pn
+  #    - { name: g_symbol_w, value: 16 }
+  #    - { name: g_nof_symbols_per_data, value: 1 }
+  #    - { name: g_buffer_nof_symbols, value: 512 }
+  #    - { name: g_buffer_use_sync, value: true }
+  #  slave_port_names:
+  #    - RAM_ADUH_MON
 
   - peripheral_name: diag/diag_data_buffer
     peripheral_group: bsn
diff --git a/libraries/base/diag/diag.peripheral.yaml b/libraries/base/diag/diag.peripheral.yaml
index 8de8766776..f14f4ef25e 100644
--- a/libraries/base/diag/diag.peripheral.yaml
+++ b/libraries/base/diag/diag.peripheral.yaml
@@ -60,10 +60,6 @@ peripherals:
               address_offset: 0x0
               number_of_fields: 1024  # = 2**c_wg_buf_addr_w in node_adc_input_and_timing.vhd
 
-    g_data_w      : NATURAL := 32;
-    g_nof_data    : NATURAL := 1024;
-    g_use_in_sync : BOOLEAN := FALSE   -- when TRUE start filling the buffer at the in_sync, else after the last word was read
-              
   - peripheral_name: diag_data_buffer    # pi_diag_data_buffer.py
     peripheral_description: "Data buffer (DB)"
     parameters:
@@ -71,7 +67,7 @@ peripherals:
       - { name: g_nof_streams, value: 1 }
       - { name: g_data_w, value: 16 }
       - { name: g_nof_data, value: 1024 }
-      - { name: g_use_in_sync, value: true }  # when true the starts filling at the sync, else after the last word was read
+      - { name: g_use_in_sync, value: true }
     slave_ports:                            
       # MM port for mms_diag_data_buffer.vhd
       - slave_name: REG_DIAG_DB
@@ -89,7 +85,7 @@ peripherals:
               address_offset: 0x4
       # MM port for mms_diag_data_buffer.vhd
       - slave_name: RAM_DIAG_DB
-        slave_description: "Data buffer memory."
+        slave_description: "Data buffer memory, gets filled after the sync when g_use_in_sync = true, else after the last word was read."
         slave_type: RAM
         number_of_slaves: g_nof_streams
         fields:
diff --git a/libraries/io/aduh/aduh.peripheral.yaml b/libraries/io/aduh/aduh.peripheral.yaml
new file mode 100644
index 0000000000..6d8ab929cf
--- /dev/null
+++ b/libraries/io/aduh/aduh.peripheral.yaml
@@ -0,0 +1,59 @@
+schema_name: args
+schema_version: 1.0
+schema_type: peripheral
+
+hdl_library_name: aduh
+hdl_library_description: "ADC Unit Handler (ADUH) of APERTIF."
+
+peripherals:
+  - peripheral_name: aduh_mon_dc_power    # pi_aduh_monitor.py
+    peripheral_description: "Determine mean sum and power sum of samples during a sync interval"
+    parameters:
+      # Parameters of mms_aduh_monitor_arr.vhd
+      - { name: g_nof_streams, value: 1 }
+    slave_ports:
+      # MM port for mms_aduh_monitor_arr.vhd / aduh_monitor_reg.vhd
+      - slave_name: REG_ADUH_MON
+        slave_type: REG
+        slave_description: "Sum of samples and sample powers during a sync interval."
+        number_of_slaves: g_nof_streams
+        fields:
+          - - field_name: mean_sum_lo
+              field_description: "Mean sum[31:0] of samples during a sync interval."
+              access_mode: RO
+              address_offset: 0x0
+          - - field_name: mean_sum_hi
+              field_description: "Mean sum[63:32] of samples during a sync interval."
+              access_mode: RO
+              address_offset: 0x4
+          - - field_name: power_sum_lo
+              field_description: "Power sum[31:0] of sample powers during a sync interval."
+              access_mode: RO
+              address_offset: 0x8
+          - - field_name: power_sum_hi
+              field_description: "Power sum[63:32] of sample powers during a sync interval."
+              access_mode: RO
+              address_offset: 0xC
+      
+  - peripheral_name: aduh_mon_data_buffer    # pi_aduh_monitor.py
+    peripheral_description: "Data buffer to capture samples (= diag_data_buffer)"
+    parameters:
+      # Parameters of mms_aduh_monitor_arr.vhd
+      - { name: g_nof_streams, value: 1 }
+      - { name: g_symbol_w, value: 16 }
+      - { name: g_nof_symbols_per_data, value: 1 }
+      - { name: g_buffer_nof_symbols, value: 512 }
+      - { name: g_buffer_use_sync, value: true }
+    slave_ports:
+      # MM port for mms_aduh_monitor_arr.vhd
+      - slave_name: RAM_ADUH_MON
+        slave_type: RAM
+        slave_description: "Data buffer memory, gets filled after the sync when g_buffer_use_sync = true, else after the last word was read."
+        number_of_slaves: g_nof_streams
+        fields:
+          - - field_name: data
+              field_description: ""
+              width: g_symbol_w * g_nof_symbols_per_data
+              address_offset: 0x0
+              number_of_fields: g_buffer_nof_symbols / g_nof_symbols_per_data
+        
-- 
GitLab