From 6f2404a43b29a0206ee367fe585c7eeb95f2e233 Mon Sep 17 00:00:00 2001
From: Eric Kooistra <kooistra@astron.nl>
Date: Mon, 25 Jan 2021 14:42:39 +0100
Subject: [PATCH] Clarified SNR of the WG sine output.

---
 libraries/base/diag/src/vhdl/diag_wg.vhd      | 21 ++++++++++++++++++-
 .../diag/src/vhdl/mms_diag_wg_wideband.vhd    |  3 ++-
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/libraries/base/diag/src/vhdl/diag_wg.vhd b/libraries/base/diag/src/vhdl/diag_wg.vhd
index 9b43ac5482..53ab3a2a5d 100644
--- a/libraries/base/diag/src/vhdl/diag_wg.vhd
+++ b/libraries/base/diag/src/vhdl/diag_wg.vhd
@@ -19,7 +19,26 @@
 --
 -------------------------------------------------------------------------------
 
--- Based on diag_waveproc from LOFAR
+-- Purpose: Sine waveform generator
+-- Description:
+-- . Based on diag_waveproc from LOFAR.
+-- Remarks:
+-- . For WG sine periods that integer fit in the WG buffer size the carrier
+--   wWave (CW) frequency is exact. For fractional WG frequencies, for which
+--   the CW period does not fit the WG buffer size, the WG frequency is exact
+--   only on average.
+-- . The signal to noise ratio (SNR) of the carrier wave (CW) sine is:
+--     SNR = g_calc_dat_w * 6.02 dB + 1.76 dB,
+--   provided that the CW period fits the buffer size.
+---. For fractional WG frequencies the effective number of bits of the WG is
+--   g_buf_addr_w - 1, because the WG buffer contains a full sine period. The
+--   -1 bit or factor 1/2 comes from that the rising slope and falling slope
+--   of the WG buffer sine map the period resolution to the amplitude
+--   resolution. Hence for fraction WG frequencies the effective SNR of the 
+--   CW becomes:
+--     SNR = (g_buf_addr_w-1) * 6.02 dB + 1.76 dB.
+--   Hence for g_buf_addr_w = 10, the effective SNR of the generated
+--   CW with fractional frequency is SNR ~= 56 dB, even if g_calc_dat_w > 9.
 
 LIBRARY IEEE, common_lib, common_mult_lib, technology_lib;
 USE IEEE.STD_LOGIC_1164.ALL;
diff --git a/libraries/base/diag/src/vhdl/mms_diag_wg_wideband.vhd b/libraries/base/diag/src/vhdl/mms_diag_wg_wideband.vhd
index 19a4f52c38..6c6b912bde 100644
--- a/libraries/base/diag/src/vhdl/mms_diag_wg_wideband.vhd
+++ b/libraries/base/diag/src/vhdl/mms_diag_wg_wideband.vhd
@@ -21,10 +21,11 @@
 
 -- Purpose: Provides a wideband WG by using multiple diag_wg
 -- Description:
--- Remarks:
+-- . See diag.wg.vhd.
 -- Remarks:
 -- . For g_wideband_factor=1 this diag_wg_wideband defaults to diag_wg. Hence
 --   no need to make a mms_diag_wg.vhd.
+--   
 
 LIBRARY IEEE, common_lib, technology_lib;
 USE IEEE.STD_LOGIC_1164.ALL;
-- 
GitLab