diff --git a/applications/lofar1/pfb2/hdllib.cfg b/applications/lofar1/pfb2/hdllib.cfg
new file mode 100644
index 0000000000000000000000000000000000000000..e6aff635245a72dbd483a934f68c04d07bb2ee75
--- /dev/null
+++ b/applications/lofar1/pfb2/hdllib.cfg
@@ -0,0 +1,17 @@
+hdl_lib_name = pfb2
+hdl_library_clause_name = pfb2_lib
+hdl_lib_uses_synth = common dp pfs pft2 st
+hdl_lib_uses_sim = 
+hdl_lib_technology = 
+
+synth_files =
+    src/vhdl/pfb2.vhd
+    src/vhdl/pfb2_unit.vhd
+    
+test_bench_files = 
+
+regression_test_vhdl = 
+    
+[modelsim_project_file]
+
+[ise_project_file]
diff --git a/applications/lofar1/pfb2/src/vhdl/pfb2.vhd b/applications/lofar1/pfb2/src/vhdl/pfb2.vhd
new file mode 100644
index 0000000000000000000000000000000000000000..62d2a5e3e91132b0e44dd76cdc4c9fba4381bb8a
--- /dev/null
+++ b/applications/lofar1/pfb2/src/vhdl/pfb2.vhd
@@ -0,0 +1,143 @@
+-------------------------------------------------------------------------------
+--
+-- Copyright 2020
+-- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
+-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-------------------------------------------------------------------------------
+--
+-- Author: E. Kooistra
+-- Purpose: Combine LOFAR1 pfs + pft2 into pfb2 with statistics and streaming
+--          interfaces, similar as wpfb_unit_dev
+-- Description:
+--
+-- Remark:
+-- . Convert between LOFAR1 sync timing 1 clk before sop and streaming data path
+--   (DP) sync timing at sop.
+-- . g_switch_en = '1' decorrelates rounding crosstalk between the X and Y output
+--   that can occur due to PFT_MODE_REAL2.
+
+LIBRARY IEEE, common_lib, dp_lib, pfs_lib, pft2_lib;
+USE IEEE.std_logic_1164.ALL;
+USE common_lib.common_pkg.ALL;
+USE dp_lib.dp_stream_pkg.ALL;
+USE pft2_lib.pft_pkg.ALL;
+
+ENTITY pfb2 IS
+  GENERIC (
+    g_nof_points     : NATURAL := 1024;
+
+    -- pfs
+    g_pfs_nof_taps   : NATURAL := 16;
+    g_pfs_in_dat_w   : NATURAL := 12;
+    g_pfs_out_dat_w  : NATURAL := 18;
+    g_pfs_coef_dat_w : NATURAL := 16;
+  
+  -- pft2
+    g_pft_mode       : PFT_MODE_TYPE := PFT_MODE_REAL2;
+    g_pft_switch_en  : STD_LOGIC := '1';
+    g_pft_out_dat_w  : NATURAL := 18
+  );
+  PORT (
+    dp_rst        : IN  STD_LOGIC;
+    dp_clk        : IN  STD_LOGIC;
+    in_sosi       : IN  t_dp_sosi;
+    fil_sosi      : OUT t_dp_sosi;
+    out_sosi      : OUT t_dp_sosi
+  );
+END pfb2;
+
+ARCHITECTURE str OF pfb2 IS
+  
+  CONSTANT c_nof_coeffs     : NATURAL := g_pfs_nof_taps*g_nof_points;
+  
+  SIGNAL pfs_in_dat_x       : STD_LOGIC_VECTOR(g_pfs_in_dat_w-1 DOWNTO 0);
+  SIGNAL pfs_in_dat_y       : STD_LOGIC_VECTOR(g_pfs_in_dat_w-1 DOWNTO 0);
+  SIGNAL pfs_in_val         : STD_LOGIC;
+  SIGNAL pfs_in_sync        : STD_LOGIC;
+    
+  SIGNAL fil_out_dat_x      : STD_LOGIC_VECTOR(g_pfs_out_dat_w-1 DOWNTO 0);
+  SIGNAL fil_out_dat_y      : STD_LOGIC_VECTOR(g_pfs_out_dat_w-1 DOWNTO 0);
+  SIGNAL fil_out_val        : STD_LOGIC;
+  SIGNAL fil_out_sync       : STD_LOGIC;
+    
+  SIGNAL pft_out_dat_re     : STD_LOGIC_VECTOR(g_pft_out_dat_w-1 DOWNTO 0);
+  SIGNAL pft_out_dat_im     : STD_LOGIC_VECTOR(g_pft_out_dat_w-1 DOWNTO 0);
+  SIGNAL pft_out_val        : STD_LOGIC;
+  SIGNAL pft_out_sync       : STD_LOGIC;
+  
+BEGIN
+
+  -- Delay in_sosi data with respect to sync to fit LOFAR1 sync timing
+  pfs_in_dat_x <= in_sosi.re(g_pfs_in_dat_w-1 DOWNTO 0) WHEN rising_edge(dp_clk);
+  pfs_in_dat_y <= in_sosi.im(g_pfs_in_dat_w-1 DOWNTO 0) WHEN rising_edge(dp_clk);
+  pfs_in_val   <= in_sosi.valid                         WHEN rising_edge(dp_clk);
+  pfs_in_sync  <= in_sosi.sync;
+  
+  pfs : ENTITY pfs_lib.pfs
+  GENERIC MAP (
+    g_nof_bands              => g_nof_points,
+    g_nof_taps               => c_nof_coeffs,
+    g_in_dat_w               => g_pfs_in_dat_w,
+    g_out_dat_w              => g_pfs_out_dat_w,
+    g_coef_dat_w             => g_pfs_coef_dat_w
+  )
+  PORT MAP (
+    in_dat_x                 => pfs_in_dat_x,
+    in_dat_y                 => pfs_in_dat_y,
+    in_val                   => pfs_in_val,
+    in_sync                  => pfs_in_sync,
+    out_dat_x                => fil_out_dat_x,
+    out_dat_y                => fil_out_dat_y,
+    out_val                  => fil_out_val,
+    out_sync                 => fil_out_sync,
+    clk                      => dp_clk,
+    rst                      => dp_rst,
+    restart                  => '0'
+  );
+  
+  fil_sosi.re    <= RESIZE_DP_DSP_DATA(fil_out_dat_x);
+  fil_sosi.im    <= RESIZE_DP_DSP_DATA(fil_out_dat_y);
+  fil_sosi.valid <= fil_out_val;
+  fil_sosi.sync  <= fil_out_sync;
+  
+  pft : ENTITY pft2_lib.pft
+  GENERIC MAP (
+    g_fft_size_w             => ceil_log2(g_nof_points),
+    g_in_dat_w               => g_pfs_out_dat_w,
+    g_out_dat_w              => g_pft_out_dat_w,
+    g_mode                   => PFT_MODE_REAL2
+  )
+  PORT MAP (
+    in_re                    => fil_out_dat_x,
+    in_im                    => fil_out_dat_y,
+    in_val                   => fil_out_val,
+    in_sync                  => fil_out_sync,
+    switch_en                => g_pft_switch_en,
+    out_re                   => pft_out_dat_re,
+    out_im                   => pft_out_dat_im,
+    out_val                  => pft_out_val,
+    out_sync                 => pft_out_sync,
+    clk                      => dp_clk,
+    rst                      => dp_rst
+  );
+
+  -- Delay pft sync with respect pft data to fit DP sync timing
+  out_sosi.re    <= RESIZE_DP_DSP_DATA(pft_out_dat_re);
+  out_sosi.im    <= RESIZE_DP_DSP_DATA(pft_out_dat_im);
+  out_sosi.valid <= pft_out_val;
+  out_sosi.sync  <= pft_out_sync WHEN rising_edge(dp_clk);
+  
+END str;
diff --git a/applications/lofar1/pfb2/src/vhdl/pfb2_unit.vhd b/applications/lofar1/pfb2/src/vhdl/pfb2_unit.vhd
new file mode 100644
index 0000000000000000000000000000000000000000..c51c6277e87765c055725fe54d7d3b7dd14c0916
--- /dev/null
+++ b/applications/lofar1/pfb2/src/vhdl/pfb2_unit.vhd
@@ -0,0 +1,150 @@
+-------------------------------------------------------------------------------
+--
+-- Copyright 2020
+-- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
+-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-------------------------------------------------------------------------------
+--
+-- Author: E. Kooistra
+-- Purpose: Combine LOFAR1 pfb2 with subband statistics (SST), similar as wpfb_unit_dev
+-- Description:
+-- . support multiple complex input streams via g_nof_streams
+-- . 1 complex pfb2 per stream
+-- . 1 complex pfb2 can process two real inputs with PFT_MODE_REAL2
+-- . pass on in_sosi.bsn
+--
+-- Remark:
+
+LIBRARY IEEE, common_lib, dp_lib, pfs_lib, pft2_lib, st_lib;
+USE IEEE.std_logic_1164.ALL;
+USE common_lib.common_pkg.ALL;
+USE common_lib.common_mem_pkg.ALL;
+USE dp_lib.dp_stream_pkg.ALL;
+USE pft2_lib.pft_pkg.ALL;
+
+ENTITY pfb2_unit IS
+  GENERIC (
+    g_nof_streams    : NATURAL := 1;    -- number of pfb2 instances, 1 pfb2 per stream
+    g_nof_points     : NATURAL := 1024;
+
+    -- pfs
+    g_pfs_nof_taps   : NATURAL := 16;
+    g_pfs_in_dat_w   : NATURAL := 12;
+    g_pfs_out_dat_w  : NATURAL := 18;
+    g_pfs_coef_dat_w : NATURAL := 16;
+  
+    -- pft2
+    g_pft_mode       : PFT_MODE_TYPE := PFT_MODE_REAL2;
+    g_pft_switch_en  : STD_LOGIC := '1';
+    g_pft_out_dat_w  : NATURAL := 18;
+    
+    -- sst
+    g_sst_data_w     : NATURAL := 64;   -- nof bits for the SST power values
+    g_sst_data_sz    : NATURAL := 2     -- nof MM 32b words to fit g_sst_data_w
+  );
+  PORT (
+    dp_rst           : IN  STD_LOGIC;
+    dp_clk           : IN  STD_LOGIC;
+    mm_rst           : IN  STD_LOGIC;
+    mm_clk           : IN  STD_LOGIC;
+    ram_st_sst_mosi  : IN  t_mem_mosi := c_mem_mosi_rst;  -- Subband statistics registers
+    ram_st_sst_miso  : OUT t_mem_miso;
+    in_sosi_arr      : IN  t_dp_sosi_arr(g_nof_streams-1 DOWNTO 0);
+    fil_sosi_arr     : OUT t_dp_sosi_arr(g_nof_streams-1 DOWNTO 0);
+    out_sosi_arr     : OUT t_dp_sosi_arr(g_nof_streams-1 DOWNTO 0)
+  );
+END pfb2_unit;
+
+ARCHITECTURE str OF pfb2_unit IS
+
+  CONSTANT c_nof_stats       : NATURAL := g_nof_points;    -- SST X and SST Y are interleaved for PFT_MODE_REAL2
+  
+  SIGNAL ram_st_sst_mosi_arr : t_mem_mosi_arr(g_nof_streams-1 downto 0);
+  SIGNAL ram_st_sst_miso_arr : t_mem_miso_arr(g_nof_streams-1 downto 0) := (OTHERS => c_mem_miso_rst);
+
+  SIGNAL pft_sosi_arr        : t_dp_sosi_arr(g_nof_streams-1 DOWNTO 0);
+  
+BEGIN
+ 
+  ---------------------------------------------------------------
+  -- Polyphase Filterbanks
+  ---------------------------------------------------------------
+  gen_pfb2: FOR I IN 0 TO g_nof_streams-1 GENERATE
+    u_pfb2 : ENTITY work.pfb2
+    GENERIC MAP (
+      g_nof_points     => g_nof_points,
+  
+      -- pfs
+      g_pfs_nof_taps   => g_pfs_nof_taps,
+      g_pfs_in_dat_w   => g_pfs_in_dat_w,
+      g_pfs_out_dat_w  => g_pfs_out_dat_w,
+      g_pfs_coef_dat_w => g_pfs_coef_dat_w,
+    
+      -- pft2
+      g_pft_mode       => g_pft_mode,
+      g_pft_switch_en  => g_pft_switch_en,
+      g_pft_out_dat_w  => g_pft_out_dat_w
+    )
+    PORT MAP (
+      dp_rst        => dp_rst,
+      dp_clk        => dp_clk,
+      in_sosi       => in_sosi_arr(I),
+      fil_sosi      => fil_sosi_arr(I),
+      out_sosi      => pft_sosi_arr(I)
+    );
+  END GENERATE;
+
+  ---------------------------------------------------------------
+  -- Subband Statistics (SST)
+  ---------------------------------------------------------------
+  -- MM mux for SST
+  u_mem_mux_sst : ENTITY common_lib.common_mem_mux
+  GENERIC MAP (
+    g_nof_mosi    => g_nof_streams,
+    g_mult_addr_w => ceil_log2(g_sst_data_sz*c_nof_stats)
+  )
+  PORT MAP (
+    mosi     => ram_st_sst_mosi,
+    miso     => ram_st_sst_miso,
+    mosi_arr => ram_st_sst_mosi_arr,
+    miso_arr => ram_st_sst_miso_arr
+  );
+  
+  gen_sst: FOR I IN 0 TO g_nof_streams-1 GENERATE
+    u_sst : ENTITY st_lib.st_sst
+    GENERIC MAP (
+      g_nof_stat      => c_nof_stats,
+      g_in_data_w     => g_pft_out_dat_w,
+      g_stat_data_w   => g_sst_data_w,
+      g_stat_data_sz  => g_sst_data_sz
+    )
+    PORT MAP (
+      mm_rst          => mm_rst,
+      mm_clk          => mm_clk,
+      dp_rst          => dp_rst,
+      dp_clk          => dp_clk,
+      in_complex      => pft_sosi_arr(I),
+      ram_st_sst_mosi => ram_st_sst_mosi_arr(I),
+      ram_st_sst_miso => ram_st_sst_miso_arr(I)
+    );
+  END GENERATE;
+
+  out_sosi_arr <= pft_sosi_arr;
+
+end str;
+
+
+
diff --git a/applications/lofar1/pfb2/src/vhdl/wpfb_unit_dev.vhd b/applications/lofar1/pfb2/src/vhdl/wpfb_unit_dev.vhd
new file mode 100644
index 0000000000000000000000000000000000000000..8ce1683177a1d182ac838b7688556aefcd3723ff
--- /dev/null
+++ b/applications/lofar1/pfb2/src/vhdl/wpfb_unit_dev.vhd
@@ -0,0 +1,718 @@
+--------------------------------------------------------------------------------
+-- Author: Harm Jan Pepping : HJP at astron.nl: April 2012
+--------------------------------------------------------------------------------
+--
+-- Copyright (C) 2012
+-- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
+-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
+--
+-- This program is free software: you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation, either version 3 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program.  If not, see <http://www.gnu.org/licenses/>.
+--
+--------------------------------------------------------------------------------
+-- Purpose: Wideband polyphase filterbank with subband statistics and streaming interfaces.
+--
+-- Description:
+--
+-- This WPFB unit connects an incoming array of streaming interfaces to the
+-- wideband pft + fft.
+-- The output of the wideband fft is connected to a set of subband statistics
+-- units. The statistics can be read via the memory mapped interface.
+-- A control unit takes care of the correct composition of the control of the 
+-- output streams regarding sop, eop, sync, bsn, err.
+--
+-- The wpfb unit can handle a wideband factor >= 1 (g_wpfb.wb_factor) or
+-- a narrowband factor >= 1 (2**g_wpfb.nof_chan).
+-- . For wb_factor = 1 the wpfb_unit uses fft_r2_pipe
+-- . For wb_factor > 1 the wpfb_unit uses fft_r2_wide
+-- . For wb_factor >= 1 the wpfb_unit supports nof_chan >= 0, even though the
+--   concept of channels is typically not useful when wb_factor > 1.
+-- . The wpfb_unit does support use_reorder.
+-- . The wpfb_unit does support use_separate.
+-- . The wpfb_unit does support input flow control with invalid gaps in the
+--   input.
+--
+-- . g_coefs_file_prefix:
+--   The g_coefs_file_prefix points to the location where the files
+--   with the initial content for the coefficients memories are located and
+--   is described in fil_ppf_wide.vhd.
+--
+-- . fft_out_gain_w
+--   For two real input typically fft_out_gain_w = 1 is used to compensate for
+--   the divide by 2 in the separate function that is done because real input
+--   frequency bins have norm 0.5. For complex input typically fft_out_gain_w
+--   = 0, because the complex bins have norm 1.
+--
+-- . g_dont_flip_channels:
+--   True preserves channel interleaving, set by g_wpfb.nof_chan>0, of the FFT
+--   output when g_bit_flip=true to reorder the FFT output.
+--   The g_dont_flip_channels applies for both complex input and two_real
+--   input FFT. The g_dont_flip_channels is only implemented for the pipelined
+--   fft_r2_pipe, because for g_wpfb.wb_factor=1 using g_wpfb.nof_chan>0 makes
+--   sense, while for the fft_r2_wide with g_wpfb.wb_factor>1 using input
+--   multiplexing via g_wpfb.nof_chan>0 makes less sense.
+--
+-- The reordering to the fil_ppf_wide is done such that the FIR filter
+-- coefficients are reused. The same filter coefficients are used for all
+-- streams. The filter has real coefficients, because the filterbank
+-- channels are symmetrical in frequency. The real part and the imaginary
+-- part are filtered independently and also use the same real FIR
+-- coefficients.
+--
+-- Note that:
+-- . The same P of all streams are grouped the in filter and all P per
+--   stream are grouped in the FFT. Hence the WPFB input is grouped per
+--   P for all wideband streams to allow FIR coefficients reuse per P
+--   for all wideband streams. The WPFB output is grouped per wideband
+--   stream to have all P together.
+--
+-- . The wideband time index t is big-endian inside the prefilter and
+--   little-endian inside the FFT. 
+--   When g_big_endian_wb_in=true then the WPFB input must be in big-endian
+--   format, else in little-endian format.
+--   For little-endian time index t increments in the same direction as the
+--   wideband factor index P, so P = 0, 1, 2, 3 --> t0, t1, t2, t3.
+--   For big-endian the time index t increments in the opposite direction of
+--   the wideband factor index P, so P = 3, 2, 1, 0 --> t0, t1, t2, t3.
+--   The WPFB output is fixed little-endian, so with frequency bins in
+--   incrementing order. However the precise frequency bin order depends
+--   on the reorder generics.
+--
+-- When wb_factor = 4 and nof_wb_streams = 2 the mapping is as follows using 
+-- the array notation:
+--
+--   . I = array index
+--   . S = stream index of a wideband stream
+--   . P = wideband factor index
+--   . t = time index
+--
+--                    parallel                           serial   type
+--   in_sosi_arr      [nof_streams][wb_factor]           [t]      cint
+--                                               
+--   fil_in_arr       [wb_factor][nof_streams][complex]  [t]       int
+--   fil_out_arr      [wb_factor][nof_streams][complex]  [t]       int
+--                                               
+--   fil_sosi_arr     [nof_streams][wb_factor]           [t]      cint
+--   fft_in_re_arr    [nof_streams][wb_factor]           [t]       int
+--   fft_in_im_arr    [nof_streams][wb_factor]           [t]       int
+--   fft_out_re_arr   [nof_streams][wb_factor]           [bin]     int
+--   fft_out_im_arr   [nof_streams][wb_factor]           [bin]     int
+--   fft_out_sosi_arr [nof_streams][wb_factor]           [bin]    cint
+--   pfb_out_sosi_arr [nof_streams][wb_factor]           [bin]    cint with sync, BSN, sop, eop
+--   out_sosi_arr     [nof_streams][wb_factor]           [bin]    cint with sync, BSN, sop, eop
+-- 
+--   in_sosi_arr  | fil_in_arr  | fft_in_re_arr | fft_out_re_arr  
+--   fil_sosi_arr | fil_out_arr | fft_in_im_arr | fft_out_im_arr  
+--                |             |               | fft_out_sosi_arr
+--                |             |               | pfb_out_sosi_arr
+--                |             |               |     out_sosi_arr
+--                |             |               |
+--    I  S P t    |   I  P S    | I  S P t      | I  S P          
+--    7  1 3 0    |  15  3 1 IM | 7  1 3 3      | 7  1 3          
+--    6  1 2 1    |  14  3 1 RE | 6  1 2 2      | 6  1 2          
+--    5  1 1 2    |  13  3 0 IM | 5  1 1 1      | 5  1 1          
+--    4  1 0 3    |  12  3 0 RE | 4  1 0 0      | 4  1 0          
+--    3  0 3 0    |  11  2 1 IM | 3  0 3 3      | 3  0 3          
+--    2  0 2 1    |  10  2 1 RE | 2  0 2 2      | 2  0 2          
+--    1  0 1 2    |   9  2 0 IM | 1  0 1 1      | 1  0 1          
+--    0  0 0 3    |   8  2 0 RE | 0  0 0 0      | 0  0 0          
+--                |   7  1 1 IM |               |                 
+--           ^    |   6  1 1 RE |        ^      |                 
+--         big    |   5  1 0 IM |      little   |                 
+--         endian |   4  1 0 RE |      endian   |                 
+--                |   3  0 1 IM |               |                 
+--                |   2  0 1 RE |               |                 
+--                |   1  0 0 IM |               |                 
+--                |   0  0 0 RE |               |                 
+--
+-- The WPFB output are the frequency bins per transformed block:
+--   . subbands, in case ot two real input or
+--   . channels, in case of complex input
+--
+-- The order of the WPFB output depends on the g_fft fields:
+--   . wb_factor
+--   . use_reorder
+--   . use_fft_shift
+--   . use_separate
+-- 
+-- The frequency bin order at the output is obtained with reg_out_bin
+-- in the test bench tb_wpfb_unit_dev.vhd.
+--
+-- Output examples:
+--
+-- Frequency bins:
+--     fs = sample frequency
+--     Bb = fs/nof_points = bin bandwidth
+--
+--     0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
+--     ^                                           ^  ^  ^                                          ^
+--     <--------- negative bin frequencies ---------> 0 <---------- positive bin frequencies ------->
+--     -fs/2                                      -Bb 0 +Bb                                        +fs/2-Bb
+--
+-- I) Wideband wb_factor = 4
+-- 1) Two real inputs:
+-- 
+--   out_sosi_arr:
+--     I  S P    bin frequency order         . nof_streams   = 2            
+--     7  1 3    12 12 13 13 14 14 15 15     . wb_factor     = 4                 
+--     6  1 2     8  8  9  9 10 10 11 11     . nof_points    = 32               
+--     5  1 1     4  4  5  5  6  6  7  7     . use_reorder   = true            
+--     4  1 0     0  0  1  1  2  2  3  3     . use_fft_shift = false         
+--     3  0 3    12 12 13 13 14 14 15 15     . use_separate  = true           
+--     2  0 2     8  8  9  9 10 10 11 11       - input A via in_sosi_arr().re
+--     1  0 1     4  4  5  5  6  6  7  7       - input B via in_sosi_arr().im
+--     0  0 0     0  0  1  1  2  2  3  3
+--      input     A  B  A  B  A  B  A  B
+--
+--   when nof_chan=1 then:
+--     I  S P    bin frequency order    
+--     7  1 3    12 12 13 13 14 14 15 15 12 12 13 13 14 14 15 15
+--     6  1 2     8  8  9  9 10 10 11 11  8  8  9  9 10 10 11 11
+--     5  1 1     4  4  5  5  6  6  7  7  4  4  5  5  6  6  7  7
+--     4  1 0     0  0  1  1  2  2  3  3  0  0  1  1  2  2  3  3
+--     3  0 3    12 12 13 13 14 14 15 15 12 12 13 13 14 14 15 15
+--     2  0 2     8  8  9  9 10 10 11 11  8  8  9  9 10 10 11 11
+--     1  0 1     4  4  5  5  6  6  7  7  4  4  5  5  6  6  7  7
+--     0  0 0     0  0  1  1  2  2  3  3  0  0  1  1  2  2  3  3
+--      input     A  B  A  B  A  B  A  B  A  B  A  B  A  B  A  B
+--    channel     0....................0  1....................1
+--
+-- 2a) Complex input with fft_shift:
+-- 
+--   out_sosi_arr:
+--     I  S P    bin frequency order         . nof_streams   = 2                    
+--     7  1 3    24 25 26 27 28 29 30 31     . wb_factor     = 4                 
+--     6  1 2    16 17 18 19 20 21 22 23     . nof_points    = 32               
+--     5  1 1     8  9 10 11 12 13 14 15     . use_reorder   = true                         
+--     4  1 0     0  1  2  3  4  5  6  7     . use_fft_shift = true 
+--     3  0 3    24 25 26 27 28 29 30 31     . use_separate  = false                       
+--     2  0 2    16 17 18 19 20 21 22 23       - complex input via in_sosi_arr().re and im
+--     1  0 1     8  9 10 11 12 13 14 15
+--     0  0 0     0  1  2  3  4  5  6  7
+--
+--   when nof_chan=1 then:
+--     I  S P    bin frequency order    
+--     7  1 3    24 25 26 27 28 29 30 31 24 25 26 27 28 29 30 31
+--     6  1 2    16 17 18 19 20 21 22 23 16 17 18 19 20 21 22 23
+--     5  1 1     8  9 10 11 12 13 14 15  8  9 10 11 12 13 14 15 
+--     4  1 0     0  1  2  3  4  5  6  7  0  1  2  3  4  5  6  7
+--     3  0 3    24 25 26 27 28 29 30 31 24 25 26 27 28 29 30 31
+--     2  0 2    16 17 18 19 20 21 22 23 16 17 18 19 20 21 22 23
+--     1  0 1     8  9 10 11 12 13 14 15  8  9 10 11 12 13 14 15
+--     0  0 0     0  1  2  3  4  5  6  7  0  1  2  3  4  5  6  7
+--    channel     0....................0  1....................1
+--
+-- 2b) Complex input with reorder, but no fft_shift:
+-- 
+--   out_sosi_arr:
+--     I  S P    bin frequency order         . nof_streams   = 2                    
+--     7  1 3     8  9 10 11 12 13 14 15     . wb_factor     = 4                 
+--     6  1 2     0  1  2  3  4  5  6  7     . nof_points    = 32               
+--     5  1 1    24 25 26 27 28 29 30 31     . use_reorder   = true                         
+--     4  1 0    16 17 18 19 20 21 22 23     . use_fft_shift = false                      
+--     3  0 3     8  9 10 11 12 13 14 15     . use_separate  = false                       
+--     2  0 2     0  1  2  3  4  5  6  7       - complex input via in_sosi_arr().re and im
+--     1  0 1    24 25 26 27 28 29 30 31
+--     0  0 0    16 17 18 19 20 21 22 23
+-- 
+--   when nof_chan=1 then:
+--     I  S P    bin frequency order
+--     7  1 3     8  9 10 11 12 13 14 15  8  9 10 11 12 13 14 15
+--     6  1 2     0  1  2  3  4  5  6  7  0  1  2  3  4  5  6  7
+--     5  1 1    24 25 26 27 28 29 30 31 24 25 26 27 28 29 30 31  
+--     4  1 0    16 17 18 19 20 21 22 23 16 17 18 19 20 21 22 23
+--     3  0 3     8  9 10 11 12 13 14 15  8  9 10 11 12 13 14 15 
+--     2  0 2     0  1  2  3  4  5  6  7  0  1  2  3  4  5  6  7
+--     1  0 1    24 25 26 27 28 29 30 31 24 25 26 27 28 29 30 31
+--     0  0 0    16 17 18 19 20 21 22 23 16 17 18 19 20 21 22 23
+--    channel     0....................0  1....................1
+--
+-- 2c) Complex input without reorder (so bit flipped):
+-- 
+--   out_sosi_arr:
+--     I  S P    bin frequency order         . nof_streams   = 2                
+--     7  1 3     8 12 10 14  9 13 11 15     . wb_factor     = 4                
+--     6  1 2    24 28 26 30 25 29 27 31     . nof_points    = 32               
+--     5  1 1     0  4  2  6  1  5  3  7     . use_reorder   = false                        
+--     4  1 0    16 20 18 22 17 21 19 23     . use_fft_shift = false                      
+--     3  0 3     8 12 10 14  9 13 11 15     . use_separate  = false                       
+--     2  0 2    24 28 26 30 25 29 27 31       - complex input via in_sosi_arr().re and im
+--     1  0 1     0  4  2  6  1  5  3  7
+--     0  0 0    16 20 18 22 17 21 19 23
+--
+--   when nof_chan=1 then:
+--     I  S P    bin frequency order    
+--     7  1 3     8  8 12 12 10 10 14 14  9  9 13 13 11 11 15 15
+--     6  1 2    24 24 28 28 26 26 30 30 25 25 29 29 27 27 31 31
+--     5  1 1     0  0  4  4  2  2  6  6  1  1  5  5  3  3  7  7  
+--     4  1 0    16 16 20 20 18 18 22 22 17 17 21 21 19 19 23 23
+--     3  0 3     8  8 12 12 10 10 14 14  9  9 13 13 11 11 15 15 
+--     2  0 2    24 24 28 28 26 26 30 30 25 25 29 29 27 27 31 31
+--     1  0 1     0  0  4  4  2  2  6  6  1  1  5  5  3  3  7  7
+--     0  0 0    16 16 20 20 18 18 22 22 17 17 21 21 19 19 23 23
+--    channel     0  1  0  1  0  1  0  1  0  1  0  1  0  1  0  1
+--
+-- II) Narrowband wb_factor = 1
+--
+-- 1) Two real inputs:
+-- 
+--   . nof_streams   = 2
+--   . nof_chan      = 0
+--   . wb_factor     = 1
+--   . nof_points    = 32
+--   . use_reorder   = true
+--   . use_fft_shift = false
+--   . use_separate  = true
+--     - input A via in_sosi_arr().re
+--     - input B via in_sosi_arr().im
+--
+--   out_sosi_arr:
+--     I  S P    bin frequency order
+--     1  1 0     0  0  1  1  2  2  3  3  4  4  5  5  6  6  7  7  8  8  9  9 10 10 11 11 12 12 13 13 14 14 15 15
+--     0  0 0     0  0  1  1  2  2  3  3  4  4  5  5  6  6  7  7  8  8  9  9 10 10 11 11 12 12 13 13 14 14 15 15
+--      input     A  B  A  B  A  B  A  B  A  B  A  B  A  B  A  B  A  B  A  B  A  B  A  B  A  B  A  B  A  B  A  B
+--
+--   when nof_chan=1 then:
+--     I  S P    bin frequency order
+--     1  1 0     0  0  1  1  2  2  3  3  4  4  5  5  6  6  7  7  8  8  9  9 10 10 11 11 12 12 13 13 14 14 15 15  0  0  1  1  2  2  3  3  4  4  5  5  6  6  7  7  8  8  9  9 10 10 11 11 12 12 13 13 14 14 15 15
+--     0  0 0     0  0  1  1  2  2  3  3  4  4  5  5  6  6  7  7  8  8  9  9 10 10 11 11 12 12 13 13 14 14 15 15  0  0  1  1  2  2  3  3  4  4  5  5  6  6  7  7  8  8  9  9 10 10 11 11 12 12 13 13 14 14 15 15
+--      input     A  B  A  B  A  B  A  B  A  B  A  B  A  B  A  B  A  B  A  B  A  B  A  B  A  B  A  B  A  B  A  B  A  B  A  B  A  B  A  B  A  B  A  B  A  B  A  B  A  B  A  B  A  B  A  B  A  B  A  B  A  B  A  B
+--     channel:   0............................................................................................0  1............................................................................................1
+--
+-- 2) Complex input
+--   . nof_streams = 2
+--   . nof_chan = 0
+--   . wb_factor = 1
+--   . nof_points = 32
+--   . use_separate = false
+--     - complex input via in_sosi_arr().re and im
+
+-- 2a) Complex input with fft_shift (so use_reorder = true, use_fft_shift = true)
+-- 
+--   out_sosi_arr:
+--     I  S P    bin frequency order
+--     1  1 0     0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
+--     0  0 0     0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
+--
+--   when nof_chan=1 then:
+--     I  S P    bin frequency order
+--     1  1 0     0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
+--     0  0 0     0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
+--     channel:   0............................................................................................0  1............................................................................................1
+--
+-- 2b) Complex input with reorder but no fft_shift (so use_reorder = true, use_fft_shift = false)
+-- 
+--   out_sosi_arr:
+--     I  S P    bin frequency order
+--     1  1 0    16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15
+--     0  0 0    16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15
+--
+--   when nof_chan=1 then:
+--     I  S P    bin frequency order
+--     1  1 0    16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15
+--     0  0 0    16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15
+--     channel:   0............................................................................................0  1............................................................................................1
+--
+-- 2c) Complex input without reorder (so use_reorder = false, use_fft_shift = false)
+-- 
+--   out_sosi_arr:
+--     I  S P    bin frequency order
+--     1  1 0    16  0 24  8 20  4 28 12 18  2 26 10 22  6 30 14 17  1 25  9 21  5 29 13 19  3 27 11 23  7 31 15
+--     0  0 0    16  0 24  8 20  4 28 12 18  2 26 10 22  6 30 14 17  1 25  9 21  5 29 13 19  3 27 11 23  7 31 15
+--
+--   when nof_chan=1 then:
+--     I  S P    bin frequency order
+--     1  1 0    16 16  0  0 24 24  8  8 20 20  4  4 28 28 12 12 18 18  2  2 26 26 10 10 22 22  6  6 30 30 14 14 17 17  1  1 25 25  9  9 21 21  5  5 29 29 13 13 19 19  3  3 27 27 11 11 23 23  7  7 31 31 15 15
+--     0  0 0    16 16  0  0 24 24  8  8 20 20  4  4 28 28 12 12 18 18  2  2 26 26 10 10 22 22  6  6 30 30 14 14 17 17  1  1 25 25  9  9 21 21  5  5 29 29 13 13 19 19  3  3 27 27 11 11 23 23  7  7 31 31 15 15
+--     channel:   0  1  0  1  0  1  0  1  0  1  0  1  0  1  0  1  0  1  0  1  0  1  0  1  0  1  0  1  0  1  0  1  0  1  0  1  0  1  0  1  0  1  0  1  0  1  0  1  0  1  0  1  0  1  0  1  0  1  0  1  0  1  0  1
+--
+-- Remarks:
+-- . The unit can handle only one sync at a time. Therfor the
+--   sync interval should be larger than the total pipeline
+--   stages of the wideband fft.
+--
+
+library ieee, common_lib, dp_lib, rTwoSDF_lib, st_lib, filter_lib, fft_lib, diag_lib;
+use IEEE.std_logic_1164.all;
+use STD.textio.all;
+use common_lib.common_pkg.all;
+use common_lib.common_mem_pkg.all;
+use dp_lib.dp_stream_pkg.ALL;
+use rTwoSDF_lib.rTwoSDFPkg.all;
+use st_lib.all;
+use filter_lib.all;
+use filter_lib.fil_pkg.all;
+use fft_lib.all;
+use fft_lib.fft_pkg.all;
+use work.wpfb_pkg.all;
+
+entity wpfb_unit_dev is
+  generic (
+    g_big_endian_wb_in  : boolean           := true;
+    g_wpfb              : t_wpfb;
+    g_dont_flip_channels: boolean           := false;   -- True preserves channel interleaving for pipelined FFT
+    g_use_prefilter     : boolean           := TRUE;
+    g_stats_ena         : boolean           := TRUE;    -- Enables the statistics unit
+    g_use_bg            : boolean           := FALSE;
+    g_coefs_file_prefix : string            := "data/coefs_wide" -- File prefix for the coefficients files.
+   );
+  port (
+    dp_rst             : in  std_logic := '0';
+    dp_clk             : in  std_logic;
+    mm_rst             : in  std_logic;
+    mm_clk             : in  std_logic;
+    ram_fil_coefs_mosi : in  t_mem_mosi := c_mem_mosi_rst;
+    ram_fil_coefs_miso : out t_mem_miso;
+    ram_st_sst_mosi    : in  t_mem_mosi := c_mem_mosi_rst;  -- Subband statistics registers
+    ram_st_sst_miso    : out t_mem_miso;
+    reg_bg_ctrl_mosi   : in  t_mem_mosi := c_mem_mosi_rst;
+    reg_bg_ctrl_miso   : out t_mem_miso;
+    ram_bg_data_mosi   : in  t_mem_mosi := c_mem_mosi_rst;
+    ram_bg_data_miso   : out t_mem_miso;
+    in_sosi_arr        : in  t_dp_sosi_arr(g_wpfb.nof_wb_streams*g_wpfb.wb_factor-1 downto 0);
+    fil_sosi_arr       : out t_dp_sosi_arr(g_wpfb.nof_wb_streams*g_wpfb.wb_factor-1 downto 0);
+    out_sosi_arr       : out t_dp_sosi_arr(g_wpfb.nof_wb_streams*g_wpfb.wb_factor-1 downto 0)
+  );
+end entity wpfb_unit_dev;
+
+architecture str of wpfb_unit_dev is
+
+  constant c_nof_channels          : natural := 2**g_wpfb.nof_chan;
+  
+  constant c_nof_data_per_block    : natural := c_nof_channels * g_wpfb.nof_points;
+  constant c_nof_valid_per_block   : natural := c_nof_data_per_block / g_wpfb.wb_factor;
+  
+  constant c_nof_stats             : natural := c_nof_valid_per_block;
+  
+  constant c_fil_ppf         : t_fil_ppf := (g_wpfb.wb_factor,
+                                             g_wpfb.nof_chan,
+                                             g_wpfb.nof_points,
+                                             g_wpfb.nof_taps,
+                                             c_nof_complex*g_wpfb.nof_wb_streams,  -- Complex FFT always requires 2 filter streams: real and imaginary
+                                             g_wpfb.fil_backoff_w,
+                                             g_wpfb.fil_in_dat_w,
+                                             g_wpfb.fil_out_dat_w,
+                                             g_wpfb.coef_dat_w);
+
+  constant c_fft             : t_fft     := (g_wpfb.use_reorder,
+                                             g_wpfb.use_fft_shift,
+                                             g_wpfb.use_separate,
+                                             g_wpfb.nof_chan,
+                                             g_wpfb.wb_factor,
+                                             0,
+                                             g_wpfb.nof_points,
+                                             g_wpfb.fft_in_dat_w,
+                                             g_wpfb.fft_out_dat_w,
+                                             g_wpfb.fft_out_gain_w,
+                                             g_wpfb.stage_dat_w,
+                                             g_wpfb.guard_w,
+                                             g_wpfb.guard_enable,
+                                             g_wpfb.stat_data_w,
+                                             g_wpfb.stat_data_sz);
+
+  constant c_fft_r2_check           : boolean := fft_r2_parameter_asserts(c_fft);
+  
+  constant c_bg_buf_adr_w           : natural := ceil_log2(g_wpfb.nof_points/g_wpfb.wb_factor);
+  constant c_bg_data_file_index_arr : t_nat_natural_arr := array_init(0, g_wpfb.nof_wb_streams*g_wpfb.wb_factor, 1);
+  constant c_bg_data_file_prefix    : string  := "UNUSED";
+
+  signal ram_st_sst_mosi_arr : t_mem_mosi_arr(g_wpfb.nof_wb_streams*g_wpfb.wb_factor-1 downto 0);
+  signal ram_st_sst_miso_arr : t_mem_miso_arr(g_wpfb.nof_wb_streams*g_wpfb.wb_factor-1 downto 0) := (others => c_mem_miso_rst);
+
+  signal fil_in_arr          : t_fil_slv_arr(c_nof_complex*g_wpfb.nof_wb_streams*g_wpfb.wb_factor-1 downto 0);
+  signal fil_in_val          : std_logic;
+  signal fil_out_arr         : t_fil_slv_arr(c_nof_complex*g_wpfb.nof_wb_streams*g_wpfb.wb_factor-1 downto 0);
+  signal fil_out_val         : std_logic;
+  
+  signal fft_in_re_arr       : t_fft_slv_arr(g_wpfb.nof_wb_streams*g_wpfb.wb_factor-1 downto 0);
+  signal fft_in_im_arr       : t_fft_slv_arr(g_wpfb.nof_wb_streams*g_wpfb.wb_factor-1 downto 0);
+  signal fft_in_val          : std_logic;
+
+  signal fft_out_re_arr_i    : t_fft_slv_arr(g_wpfb.nof_wb_streams*g_wpfb.wb_factor-1 downto 0);
+  signal fft_out_im_arr_i    : t_fft_slv_arr(g_wpfb.nof_wb_streams*g_wpfb.wb_factor-1 downto 0);
+  signal fft_out_re_arr      : t_fft_slv_arr(g_wpfb.nof_wb_streams*g_wpfb.wb_factor-1 downto 0);
+  signal fft_out_im_arr      : t_fft_slv_arr(g_wpfb.nof_wb_streams*g_wpfb.wb_factor-1 downto 0);
+  signal fft_out_re_arr_pipe : t_fft_slv_arr(g_wpfb.nof_wb_streams*g_wpfb.wb_factor-1 downto 0);
+  signal fft_out_im_arr_pipe : t_fft_slv_arr(g_wpfb.nof_wb_streams*g_wpfb.wb_factor-1 downto 0);
+  signal fft_out_val_arr     : std_logic_vector(g_wpfb.nof_wb_streams*g_wpfb.wb_factor-1 downto 0);
+
+  signal fft_out_sosi        : t_dp_sosi;
+  signal fft_out_sosi_arr    : t_dp_sosi_arr(g_wpfb.nof_wb_streams*g_wpfb.wb_factor-1 downto 0) := (others => c_dp_sosi_rst);
+  
+  signal pfb_out_sosi_arr    : t_dp_sosi_arr(g_wpfb.nof_wb_streams*g_wpfb.wb_factor-1 downto 0) := (others => c_dp_sosi_rst);
+  
+  type reg_type is record
+    in_sosi_arr : t_dp_sosi_arr(g_wpfb.nof_wb_streams*g_wpfb.wb_factor-1 downto 0);
+  end record;
+
+  signal r, rin : reg_type;
+
+begin
+
+  -- The complete input sosi arry is registered.
+  comb : process(r, in_sosi_arr)
+    variable v : reg_type;
+  begin
+    v             := r;
+    v.in_sosi_arr := in_sosi_arr;
+    rin           <= v;
+  end process comb;
+
+  regs : process(dp_clk)
+  begin
+    if rising_edge(dp_clk) then
+      r <= rin;
+    end if;
+  end process;
+
+  ---------------------------------------------------------------
+  -- COMBINE MEMORY MAPPED INTERFACES
+  ---------------------------------------------------------------
+  -- Combine the internal array of mm interfaces for the subband
+  -- statistics to one array that is connected to the port of the
+  -- fft_wide_unit.
+  u_mem_mux_sst : entity common_lib.common_mem_mux
+  generic map (
+    g_nof_mosi    => g_wpfb.nof_wb_streams*g_wpfb.wb_factor,
+    g_mult_addr_w => ceil_log2(g_wpfb.stat_data_sz*c_nof_stats)
+  )
+  port map (
+    mosi     => ram_st_sst_mosi,
+    miso     => ram_st_sst_miso,
+    mosi_arr => ram_st_sst_mosi_arr,
+    miso_arr => ram_st_sst_miso_arr
+  );
+
+  gen_pfb : if g_use_bg = FALSE generate
+    ---------------------------------------------------------------
+    -- REWIRE THE DATA FOR WIDEBAND POLY PHASE FILTER
+    ---------------------------------------------------------------
+
+    -- Wire in_sosi_arr --> fil_in_arr
+    wire_fil_in_wideband: for P in 0 to g_wpfb.wb_factor-1 generate
+      wire_fil_in_streams: for S in 0 to g_wpfb.nof_wb_streams-1 generate
+        fil_in_arr(P*g_wpfb.nof_wb_streams*c_nof_complex+S*c_nof_complex)   <= RESIZE_SVEC_32(r.in_sosi_arr(S*g_wpfb.wb_factor+P).re(g_wpfb.fil_in_dat_w-1 downto 0));
+        fil_in_arr(P*g_wpfb.nof_wb_streams*c_nof_complex+S*c_nof_complex+1) <= RESIZE_SVEC_32(r.in_sosi_arr(S*g_wpfb.wb_factor+P).im(g_wpfb.fil_in_dat_w-1 downto 0));
+      end generate;
+    end generate;
+    fil_in_val <= r.in_sosi_arr(0).valid;
+
+    -- Wire fil_out_arr --> fil_sosi_arr
+    wire_fil_sosi_streams: for S in 0 to g_wpfb.nof_wb_streams-1 generate
+      wire_fil_sosi_wideband: for P in 0 to g_wpfb.wb_factor-1 generate
+        fil_sosi_arr(S*g_wpfb.wb_factor+P).valid <= fil_out_val;
+        fil_sosi_arr(S*g_wpfb.wb_factor+P).re    <= RESIZE_DP_DSP_DATA(fil_out_arr(P*g_wpfb.nof_wb_streams*c_nof_complex+S*c_nof_complex  ));
+        fil_sosi_arr(S*g_wpfb.wb_factor+P).im    <= RESIZE_DP_DSP_DATA(fil_out_arr(P*g_wpfb.nof_wb_streams*c_nof_complex+S*c_nof_complex+1));
+      end generate;
+    end generate; 
+    
+    -- Wire fil_out_arr --> fft_in_re_arr, fft_in_im_arr
+    wire_fft_in_streams: for S in 0 to g_wpfb.nof_wb_streams-1 generate
+      wire_fft_in_wideband: for P in 0 to g_wpfb.wb_factor-1 generate
+        fft_in_re_arr(S*g_wpfb.wb_factor + P) <= fil_out_arr(P*g_wpfb.nof_wb_streams*c_nof_complex+S*c_nof_complex);
+        fft_in_im_arr(S*g_wpfb.wb_factor + P) <= fil_out_arr(P*g_wpfb.nof_wb_streams*c_nof_complex+S*c_nof_complex+1);
+      end generate;
+    end generate;
+
+    ---------------------------------------------------------------
+    -- THE POLY PHASE FILTER
+    ---------------------------------------------------------------
+    gen_prefilter : IF g_use_prefilter = TRUE generate
+      u_filter : entity filter_lib.fil_ppf_wide
+      generic map (
+        g_big_endian_wb_in  => g_big_endian_wb_in,
+        g_big_endian_wb_out => false,  -- reverse wideband order from big-endian [3:0] = [t0,t1,t2,t3] in fil_ppf_wide to little-endian [3:0] = [t3,t2,t1,t0] in fft_r2_wide
+        g_fil_ppf           => c_fil_ppf,
+        g_fil_ppf_pipeline  => g_wpfb.fil_pipeline,
+        g_coefs_file_prefix => g_coefs_file_prefix
+      )
+      port map (
+        dp_clk         => dp_clk,
+        dp_rst         => dp_rst,
+        mm_clk         => mm_clk,
+        mm_rst         => mm_rst,
+        ram_coefs_mosi => ram_fil_coefs_mosi,
+        ram_coefs_miso => ram_fil_coefs_miso,
+        in_dat_arr     => fil_in_arr,
+        in_val         => fil_in_val,
+        out_dat_arr    => fil_out_arr,
+        out_val        => fil_out_val
+      );
+    end generate;
+
+    -- Bypass filter
+    no_prefilter : if g_use_prefilter = FALSE generate
+      fil_out_arr <= fil_in_arr;
+      fil_out_val <= fil_in_val;
+    end generate;
+
+    fft_in_val <= fil_out_val;
+
+    ---------------------------------------------------------------
+    -- THE WIDEBAND FFT
+    ---------------------------------------------------------------
+    gen_wideband_fft: if g_wpfb.wb_factor > 1  generate
+      gen_fft_r2_wide_streams: for S in 0 to g_wpfb.nof_wb_streams-1 generate
+        u_fft_r2_wide : entity fft_lib.fft_r2_wide
+        generic map(
+          g_fft          => c_fft,         -- generics for the WFFT
+          g_pft_pipeline => g_wpfb.pft_pipeline,
+          g_fft_pipeline => g_wpfb.fft_pipeline
+        )
+        port map(
+          clk        => dp_clk,
+          rst        => dp_rst,
+          in_re_arr  => fft_in_re_arr((S+1)*g_wpfb.wb_factor-1 downto S*g_wpfb.wb_factor),
+          in_im_arr  => fft_in_im_arr((S+1)*g_wpfb.wb_factor-1 downto S*g_wpfb.wb_factor),
+          in_val     => fft_in_val,
+          out_re_arr => fft_out_re_arr((S+1)*g_wpfb.wb_factor-1 downto S*g_wpfb.wb_factor),
+          out_im_arr => fft_out_im_arr((S+1)*g_wpfb.wb_factor-1 downto S*g_wpfb.wb_factor),
+          out_val    => fft_out_val_arr(S)
+        );
+      end generate;
+    end generate;
+
+    ---------------------------------------------------------------
+    -- THE PIPELINED FFT
+    ---------------------------------------------------------------
+    gen_pipeline_fft: if g_wpfb.wb_factor = 1  generate
+      gen_fft_r2_pipe_streams: for S in 0 to g_wpfb.nof_wb_streams-1 generate
+        u_fft_r2_pipe : entity fft_lib.fft_r2_pipe
+        generic map(
+          g_fft      => c_fft,
+          g_dont_flip_channels => g_dont_flip_channels,
+          g_pipeline => g_wpfb.fft_pipeline
+        )
+        port map(
+          clk       => dp_clk,
+          rst       => dp_rst,
+          in_re     => fft_in_re_arr(S)(c_fft.in_dat_w-1 downto 0),
+          in_im     => fft_in_im_arr(S)(c_fft.in_dat_w-1 downto 0),
+          in_val    => fft_in_val,
+          out_re    => fft_out_re_arr_i(S)(c_fft.out_dat_w-1 downto 0),
+          out_im    => fft_out_im_arr_i(S)(c_fft.out_dat_w-1 downto 0),
+          out_val   => fft_out_val_arr(S)
+        );
+        
+        fft_out_re_arr(S) <= RESIZE_SVEC_32(fft_out_re_arr_i(S)(c_fft.out_dat_w-1 downto 0));
+        fft_out_im_arr(S) <= RESIZE_SVEC_32(fft_out_im_arr_i(S)(c_fft.out_dat_w-1 downto 0));
+      end generate;
+    end generate;
+
+    ---------------------------------------------------------------
+    -- FFT CONTROL UNIT
+    ---------------------------------------------------------------
+    
+    -- Capture input BSN at input sync and pass the captured input BSN it on to PFB output sync.
+    -- The FFT output valid defines PFB output sync, sop, eop.
+
+    fft_out_sosi.sync  <= r.in_sosi_arr(0).sync;  
+    fft_out_sosi.bsn   <= r.in_sosi_arr(0).bsn;   
+    fft_out_sosi.valid <= fft_out_val_arr(0);     
+    
+    wire_fft_out_sosi_arr : for I in 0 to g_wpfb.nof_wb_streams*g_wpfb.wb_factor-1 generate
+      fft_out_sosi_arr(I).re    <= RESIZE_DP_DSP_DATA(fft_out_re_arr(I));
+      fft_out_sosi_arr(I).im    <= RESIZE_DP_DSP_DATA(fft_out_im_arr(I));
+      fft_out_sosi_arr(I).valid <=                    fft_out_val_arr(I);
+    end generate;
+    
+    u_dp_block_gen_valid_arr : ENTITY dp_lib.dp_block_gen_valid_arr
+    GENERIC MAP (
+      g_nof_streams         => g_wpfb.nof_wb_streams*g_wpfb.wb_factor,
+      g_nof_data_per_block  => c_nof_valid_per_block,
+      g_nof_blk_per_sync    => g_wpfb.nof_blk_per_sync,
+      g_check_input_sync    => false,
+      g_nof_pages_bsn       => 1,
+      g_restore_global_bsn  => true
+    )
+    PORT MAP (
+      rst         => dp_rst,
+      clk         => dp_clk,
+      -- Streaming sink
+      snk_in      => fft_out_sosi,
+      snk_in_arr  => fft_out_sosi_arr,
+      -- Streaming source
+      src_out_arr => pfb_out_sosi_arr,
+      -- Control
+      enable      => '1'
+    );
+  end generate;
+
+  ----------------------------------------------------------------------------
+  -- Source: block generator
+  ----------------------------------------------------------------------------
+  gen_bg : if g_use_bg = TRUE generate
+    u_bg : entity diag_lib.mms_diag_block_gen
+    generic map(
+      g_nof_streams      => g_wpfb.nof_wb_streams*g_wpfb.wb_factor,
+      g_buf_dat_w        => c_nof_complex*g_wpfb.fft_out_dat_w,
+      g_buf_addr_w       => c_bg_buf_adr_w,               -- Waveform buffer size 2**g_buf_addr_w nof samples
+      g_file_index_arr   => c_bg_data_file_index_arr,
+      g_file_name_prefix => c_bg_data_file_prefix
+    )
+    port map(
+      -- System
+      mm_rst           => mm_rst,
+      mm_clk           => mm_clk,
+      dp_rst           => dp_rst,
+      dp_clk           => dp_clk,
+      en_sync          => '0',
+      -- MM interface
+      reg_bg_ctrl_mosi => reg_bg_ctrl_mosi,
+      reg_bg_ctrl_miso => reg_bg_ctrl_miso,
+      ram_bg_data_mosi => ram_bg_data_mosi,
+      ram_bg_data_miso => ram_bg_data_miso,
+      -- ST interface
+      out_sosi_arr     => pfb_out_sosi_arr
+    );
+  end generate;
+
+ ---------------------------------------------------------------
+  -- SUBBAND STATISTICS
+  ---------------------------------------------------------------
+  -- For all "wb_factor"x"nof_wb_streams" output streams of the
+  -- wideband FFT a subband statistics unit is placed if the
+  -- g_stats_ena is TRUE.
+  -- Since the subband statistics module uses embedded DSP blocks
+  -- for multiplication, the incoming data cannot be wider
+  -- than 18 bit.
+  gen_stats : if g_stats_ena = TRUE generate
+    gen_stats_streams: for S in 0 to g_wpfb.nof_wb_streams-1 generate
+      gen_stats_wideband: for P in 0 to g_wpfb.wb_factor-1 generate
+        u_subband_stats : entity st_lib.st_sst
+        generic map(
+          g_nof_stat      => c_nof_stats,
+          g_in_data_w     => g_wpfb.fft_out_dat_w,
+          g_stat_data_w   => g_wpfb.stat_data_w,
+          g_stat_data_sz  => g_wpfb.stat_data_sz
+        )
+        port map (
+          mm_rst          => mm_rst,
+          mm_clk          => mm_clk,
+          dp_rst          => dp_rst,
+          dp_clk          => dp_clk,
+          in_complex      => pfb_out_sosi_arr(S*g_wpfb.wb_factor+P),
+          ram_st_sst_mosi => ram_st_sst_mosi_arr(S*g_wpfb.wb_factor+P),
+          ram_st_sst_miso => ram_st_sst_miso_arr(S*g_wpfb.wb_factor+P)
+        );
+      end generate;
+    end generate;
+  end generate;
+
+  -- Connect to the outside world
+  out_sosi_arr <= pfb_out_sosi_arr;
+
+end str;
+
+
+
diff --git a/applications/lofar1/pfs/tb/vhdl/tb_pfs.vhd b/applications/lofar1/pfs/tb/vhdl/tb_pfs.vhd
index 5e860b25337036c79cc48ad9cc80d6aa59f50df7..3d1420b1709690fe4e1a32cc92479cfb7129f71b 100644
--- a/applications/lofar1/pfs/tb/vhdl/tb_pfs.vhd
+++ b/applications/lofar1/pfs/tb/vhdl/tb_pfs.vhd
@@ -1,6 +1,7 @@
 -- Usage:
 -- > as 5
--- > run 100 us
+-- > run -a
+-- The tb is self stpping, but not self checking
 -- In Wave Window:
 -- . Copy pfs_dat_x
 -- . View pfs_dat_x in decimal radix and analog format (right click)
@@ -9,6 +10,7 @@ LIBRARY IEEE, pfs_lib, common_lib;
 USE IEEE.std_logic_1164.ALL;
 USE IEEE.numeric_std.ALL;
 USE common_lib.common_pkg.ALL;
+USE common_lib.tb_common_pkg.ALL;
 
 
 ENTITY tb_pfs IS
@@ -28,10 +30,11 @@ ARCHITECTURE tb OF tb_pfs IS
   SIGNAL pfs_sync       : STD_LOGIC;
   SIGNAL clk            : STD_LOGIC := '1';
   SIGNAL rst            : STD_LOGIC := '1';
+  SIGNAL tb_end         : STD_LOGIC := '0';
 
 BEGIN
 
-  clk <= NOT clk AFTER clk_period / 2;
+  clk <= (NOT clk) OR tb_end AFTER clk_period / 2;
   rst <= '0' AFTER 3*clk_period;
 
   pfs : ENTITY pfs_lib.pfs
@@ -66,17 +69,35 @@ BEGIN
     in_dat_x <= TO_UVEC(0, in_dat_x'LENGTH);
     WAIT FOR 1 us;
     WAIT UNTIL rising_edge(clk);
+    -- LOFAR1 sync is active one clk cycle before sync interval
+    -- create sync for first sync interval
+    in_sync <= '1';
+    WAIT UNTIL rising_edge(clk);
+    in_sync <= '0';
     in_val <= '1';
-    FOR j IN 1 TO 16 LOOP
-      FOR i IN 1 TO 1024 LOOP
-        IF j = 1 THEN
-          in_dat_x <= TO_UVEC(2**10, in_dat_x'LENGTH);
-        ELSE
-          in_dat_x <= TO_UVEC(0, in_dat_x'LENGTH);
-        END IF;
-        WAIT UNTIL rising_edge(clk);
+    FOR k IN 1 TO 2 LOOP
+    
+      -- issue impulse
+      FOR j IN 1 TO 16 LOOP
+        FOR i IN 1 TO 1024 LOOP
+          IF j = 1 THEN
+            in_dat_x <= TO_UVEC(2**10, in_dat_x'LENGTH);
+          ELSE
+            in_dat_x <= TO_UVEC(0, in_dat_x'LENGTH);
+          END IF;
+          WAIT UNTIL rising_edge(clk);
+        END LOOP;
       END LOOP;
+      
+      -- continue some more per sync interval
+      proc_common_wait_some_cycles(clk, 1024*4-1);  -- -1 to create sync for next sync interval
+      in_sync <= '1';
+      WAIT UNTIL rising_edge(clk);
+      in_sync <= '0';
     END LOOP;
+    -- continue some more to observe last pfs_sync
+    proc_common_wait_some_cycles(clk, 1024*1);      
+    tb_end <= '1';
     WAIT;
   END PROCESS;
 
diff --git a/applications/lofar1/pft2/hdllib.cfg b/applications/lofar1/pft2/hdllib.cfg
index e828e3bb9101fac6ded72227bd5d3b3d995762f5..73ad9896125c41cc3b3066ff43671c1be870d409 100644
--- a/applications/lofar1/pft2/hdllib.cfg
+++ b/applications/lofar1/pft2/hdllib.cfg
@@ -33,9 +33,10 @@ synth_files =
     
 test_bench_files = 
     tb/vhdl/tb_pft2.vhd
-    #tb/vhdl/syn_pft_bf.vhd
+    tb/vhdl/tb_tb_pft2.vhd
 
 regression_test_vhdl = 
+    tb/vhdl/tb_tb_pft2.vhd
     
 [modelsim_project_file]
 modelsim_copy_files =
diff --git a/applications/lofar1/pft2/tb/data/block_1.sig b/applications/lofar1/pft2/tb/data/block_1.sig
new file mode 100644
index 0000000000000000000000000000000000000000..5a52601c7913a8f8ead507e21fe064071cddea67
--- /dev/null
+++ b/applications/lofar1/pft2/tb/data/block_1.sig
@@ -0,0 +1,1024 @@
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
+-102000
diff --git a/applications/lofar1/pft2/tb/data/block_117.sig b/applications/lofar1/pft2/tb/data/block_117.sig
new file mode 100644
index 0000000000000000000000000000000000000000..33335edf2679ac59450c44527ce83ca3ae08082b
--- /dev/null
+++ b/applications/lofar1/pft2/tb/data/block_117.sig
@@ -0,0 +1,1024 @@
+-102000
+102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+102000
+102000
+102000
+102000
+-102000
+-102000
+-102000
+-102000
+-102000
+102000
diff --git a/applications/lofar1/pft2/tb/data/cosin_1.sig b/applications/lofar1/pft2/tb/data/cosin_1.sig
new file mode 100644
index 0000000000000000000000000000000000000000..393018d4cb43519351ef034ed1ba172b81a3596d
--- /dev/null
+++ b/applications/lofar1/pft2/tb/data/cosin_1.sig
@@ -0,0 +1,1024 @@
+131000
+130998
+130990
+130978
+130961
+130938
+130911
+130879
+130842
+130800
+130753
+130702
+130645
+130583
+130517
+130446
+130369
+130288
+130202
+130111
+130015
+129914
+129808
+129698
+129582
+129462
+129336
+129206
+129071
+128932
+128787
+128637
+128483
+128324
+128160
+127991
+127817
+127638
+127455
+127267
+127074
+126876
+126674
+126467
+126255
+126038
+125816
+125590
+125359
+125123
+124883
+124638
+124388
+124134
+123875
+123611
+123342
+123069
+122791
+122509
+122222
+121930
+121634
+121334
+121028
+120718
+120404
+120085
+119761
+119433
+119101
+118764
+118423
+118077
+117726
+117372
+117012
+116649
+116281
+115908
+115532
+115151
+114765
+114375
+113981
+113583
+113180
+112774
+112362
+111947
+111528
+111104
+110676
+110244
+109807
+109367
+108923
+108474
+108021
+107564
+107104
+106639
+106170
+105697
+105220
+104739
+104255
+103766
+103273
+102777
+102277
+101772
+101264
+100753
+100237
+99718
+99194
+98667
+98137
+97603
+97065
+96523
+95978
+95429
+94876
+94320
+93761
+93198
+92631
+92061
+91487
+90910
+90330
+89746
+89159
+88568
+87974
+87377
+86776
+86173
+85566
+84955
+84342
+83725
+83106
+82483
+81857
+81227
+80595
+79960
+79322
+78681
+78037
+77390
+76740
+76087
+75431
+74772
+74111
+73447
+72780
+72110
+71438
+70762
+70085
+69404
+68721
+68036
+67347
+66657
+65964
+65268
+64570
+63869
+63166
+62461
+61753
+61043
+60331
+59616
+58899
+58180
+57459
+56735
+56010
+55282
+54552
+53820
+53087
+52351
+51613
+50873
+50132
+49388
+48643
+47895
+47146
+46395
+45643
+44889
+44133
+43375
+42616
+41855
+41092
+40328
+39563
+38796
+38027
+37257
+36486
+35713
+34939
+34164
+33387
+32610
+31830
+31050
+30269
+29486
+28702
+27917
+27132
+26345
+25557
+24768
+23978
+23188
+22396
+21604
+20810
+20016
+19222
+18426
+17630
+16833
+16036
+15238
+14439
+13640
+12840
+12040
+11239
+10438
+9637
+8835
+8033
+7231
+6428
+5625
+4822
+4018
+3215
+2411
+1608
+804
+0
+-804
+-1608
+-2411
+-3215
+-4018
+-4822
+-5625
+-6428
+-7231
+-8033
+-8835
+-9637
+-10438
+-11239
+-12040
+-12840
+-13640
+-14439
+-15238
+-16036
+-16833
+-17630
+-18426
+-19222
+-20016
+-20810
+-21604
+-22396
+-23188
+-23978
+-24768
+-25557
+-26345
+-27132
+-27917
+-28702
+-29486
+-30269
+-31050
+-31830
+-32610
+-33387
+-34164
+-34939
+-35713
+-36486
+-37257
+-38027
+-38796
+-39563
+-40328
+-41092
+-41855
+-42616
+-43375
+-44133
+-44889
+-45643
+-46395
+-47146
+-47895
+-48643
+-49388
+-50132
+-50873
+-51613
+-52351
+-53087
+-53820
+-54552
+-55282
+-56010
+-56735
+-57459
+-58180
+-58899
+-59616
+-60331
+-61043
+-61753
+-62461
+-63166
+-63869
+-64570
+-65268
+-65964
+-66657
+-67347
+-68036
+-68721
+-69404
+-70085
+-70762
+-71438
+-72110
+-72780
+-73447
+-74111
+-74772
+-75431
+-76087
+-76740
+-77390
+-78037
+-78681
+-79322
+-79960
+-80595
+-81227
+-81857
+-82483
+-83106
+-83725
+-84342
+-84955
+-85566
+-86173
+-86776
+-87377
+-87974
+-88568
+-89159
+-89746
+-90330
+-90910
+-91487
+-92061
+-92631
+-93198
+-93761
+-94320
+-94876
+-95429
+-95978
+-96523
+-97065
+-97603
+-98137
+-98667
+-99194
+-99718
+-100237
+-100753
+-101264
+-101772
+-102277
+-102777
+-103273
+-103766
+-104255
+-104739
+-105220
+-105697
+-106170
+-106639
+-107104
+-107564
+-108021
+-108474
+-108923
+-109367
+-109807
+-110244
+-110676
+-111104
+-111528
+-111947
+-112362
+-112774
+-113180
+-113583
+-113981
+-114375
+-114765
+-115151
+-115532
+-115908
+-116281
+-116649
+-117012
+-117372
+-117726
+-118077
+-118423
+-118764
+-119101
+-119433
+-119761
+-120085
+-120404
+-120718
+-121028
+-121334
+-121634
+-121930
+-122222
+-122509
+-122791
+-123069
+-123342
+-123611
+-123875
+-124134
+-124388
+-124638
+-124883
+-125123
+-125359
+-125590
+-125816
+-126038
+-126255
+-126467
+-126674
+-126876
+-127074
+-127267
+-127455
+-127638
+-127817
+-127991
+-128160
+-128324
+-128483
+-128637
+-128787
+-128932
+-129071
+-129206
+-129336
+-129462
+-129582
+-129698
+-129808
+-129914
+-130015
+-130111
+-130202
+-130288
+-130369
+-130446
+-130517
+-130583
+-130645
+-130702
+-130753
+-130800
+-130842
+-130879
+-130911
+-130938
+-130961
+-130978
+-130990
+-130998
+-131000
+-130998
+-130990
+-130978
+-130961
+-130938
+-130911
+-130879
+-130842
+-130800
+-130753
+-130702
+-130645
+-130583
+-130517
+-130446
+-130369
+-130288
+-130202
+-130111
+-130015
+-129914
+-129808
+-129698
+-129582
+-129462
+-129336
+-129206
+-129071
+-128932
+-128787
+-128637
+-128483
+-128324
+-128160
+-127991
+-127817
+-127638
+-127455
+-127267
+-127074
+-126876
+-126674
+-126467
+-126255
+-126038
+-125816
+-125590
+-125359
+-125123
+-124883
+-124638
+-124388
+-124134
+-123875
+-123611
+-123342
+-123069
+-122791
+-122509
+-122222
+-121930
+-121634
+-121334
+-121028
+-120718
+-120404
+-120085
+-119761
+-119433
+-119101
+-118764
+-118423
+-118077
+-117726
+-117372
+-117012
+-116649
+-116281
+-115908
+-115532
+-115151
+-114765
+-114375
+-113981
+-113583
+-113180
+-112774
+-112362
+-111947
+-111528
+-111104
+-110676
+-110244
+-109807
+-109367
+-108923
+-108474
+-108021
+-107564
+-107104
+-106639
+-106170
+-105697
+-105220
+-104739
+-104255
+-103766
+-103273
+-102777
+-102277
+-101772
+-101264
+-100753
+-100237
+-99718
+-99194
+-98667
+-98137
+-97603
+-97065
+-96523
+-95978
+-95429
+-94876
+-94320
+-93761
+-93198
+-92631
+-92061
+-91487
+-90910
+-90330
+-89746
+-89159
+-88568
+-87974
+-87377
+-86776
+-86173
+-85566
+-84955
+-84342
+-83725
+-83106
+-82483
+-81857
+-81227
+-80595
+-79960
+-79322
+-78681
+-78037
+-77390
+-76740
+-76087
+-75431
+-74772
+-74111
+-73447
+-72780
+-72110
+-71438
+-70762
+-70085
+-69404
+-68721
+-68036
+-67347
+-66657
+-65964
+-65268
+-64570
+-63869
+-63166
+-62461
+-61753
+-61043
+-60331
+-59616
+-58899
+-58180
+-57459
+-56735
+-56010
+-55282
+-54552
+-53820
+-53087
+-52351
+-51613
+-50873
+-50132
+-49388
+-48643
+-47895
+-47146
+-46395
+-45643
+-44889
+-44133
+-43375
+-42616
+-41855
+-41092
+-40328
+-39563
+-38796
+-38027
+-37257
+-36486
+-35713
+-34939
+-34164
+-33387
+-32610
+-31830
+-31050
+-30269
+-29486
+-28702
+-27917
+-27132
+-26345
+-25557
+-24768
+-23978
+-23188
+-22396
+-21604
+-20810
+-20016
+-19222
+-18426
+-17630
+-16833
+-16036
+-15238
+-14439
+-13640
+-12840
+-12040
+-11239
+-10438
+-9637
+-8835
+-8033
+-7231
+-6428
+-5625
+-4822
+-4018
+-3215
+-2411
+-1608
+-804
+0
+804
+1608
+2411
+3215
+4018
+4822
+5625
+6428
+7231
+8033
+8835
+9637
+10438
+11239
+12040
+12840
+13640
+14439
+15238
+16036
+16833
+17630
+18426
+19222
+20016
+20810
+21604
+22396
+23188
+23978
+24768
+25557
+26345
+27132
+27917
+28702
+29486
+30269
+31050
+31830
+32610
+33387
+34164
+34939
+35713
+36486
+37257
+38027
+38796
+39563
+40328
+41092
+41855
+42616
+43375
+44133
+44889
+45643
+46395
+47146
+47895
+48643
+49388
+50132
+50873
+51613
+52351
+53087
+53820
+54552
+55282
+56010
+56735
+57459
+58180
+58899
+59616
+60331
+61043
+61753
+62461
+63166
+63869
+64570
+65268
+65964
+66657
+67347
+68036
+68721
+69404
+70085
+70762
+71438
+72110
+72780
+73447
+74111
+74772
+75431
+76087
+76740
+77390
+78037
+78681
+79322
+79960
+80595
+81227
+81857
+82483
+83106
+83725
+84342
+84955
+85566
+86173
+86776
+87377
+87974
+88568
+89159
+89746
+90330
+90910
+91487
+92061
+92631
+93198
+93761
+94320
+94876
+95429
+95978
+96523
+97065
+97603
+98137
+98667
+99194
+99718
+100237
+100753
+101264
+101772
+102277
+102777
+103273
+103766
+104255
+104739
+105220
+105697
+106170
+106639
+107104
+107564
+108021
+108474
+108923
+109367
+109807
+110244
+110676
+111104
+111528
+111947
+112362
+112774
+113180
+113583
+113981
+114375
+114765
+115151
+115532
+115908
+116281
+116649
+117012
+117372
+117726
+118077
+118423
+118764
+119101
+119433
+119761
+120085
+120404
+120718
+121028
+121334
+121634
+121930
+122222
+122509
+122791
+123069
+123342
+123611
+123875
+124134
+124388
+124638
+124883
+125123
+125359
+125590
+125816
+126038
+126255
+126467
+126674
+126876
+127074
+127267
+127455
+127638
+127817
+127991
+128160
+128324
+128483
+128637
+128787
+128932
+129071
+129206
+129336
+129462
+129582
+129698
+129808
+129914
+130015
+130111
+130202
+130288
+130369
+130446
+130517
+130583
+130645
+130702
+130753
+130800
+130842
+130879
+130911
+130938
+130961
+130978
+130990
+130998
diff --git a/applications/lofar1/pft2/tb/data/cosin_39.sig b/applications/lofar1/pft2/tb/data/cosin_39.sig
new file mode 100644
index 0000000000000000000000000000000000000000..93a3101eeac7449c022c4375aa3d3918533038fa
--- /dev/null
+++ b/applications/lofar1/pft2/tb/data/cosin_39.sig
@@ -0,0 +1,1024 @@
+57040
+34596
+10180
+-14816
+-38967
+-60898
+-79358
+-93295
+-101915
+-104726
+-101570
+-92624
+-78400
+-59707
+-37611
+-13373
+11629
+35967
+58256
+77224
+91791
+101127
+104700
+102305
+94080
+80493
+62318
+40592
+16552
+-8430
+-32933
+-55558
+-75018
+-90201
+-100244
+-104574
+-102944
+-95447
+-82510
+-64871
+-43534
+-19717
+5224
+29868
+52809
+72741
+88526
+99267
+104350
+103486
+96724
+84450
+67362
+46436
+22863
+-2013
+-26775
+-50010
+-70395
+-86768
+-98196
+-104028
+-103931
+-97910
+-86310
+-69790
+-49293
+-25987
+-1200
+23656
+47164
+67983
+84929
+97033
+103608
+104278
+99005
+88089
+72153
+52105
+29087
+4411
+-20516
+-44273
+-65508
+-83009
+-95779
+-103090
+-104527
+-100006
+-89785
+-74447
+-54867
+-32159
+-7619
+17356
+41341
+62970
+81011
+94434
+102476
+104677
+100912
+91397
+76672
+57577
+35201
+10819
+-14179
+-38370
+-60374
+-78937
+-93001
+-101765
+-104729
+-101724
+-92922
+-78824
+-60234
+-38211
+-14010
+10990
+35363
+57720
+76788
+91480
+100958
+104682
+102440
+94360
+80902
+62833
+41184
+17187
+-7790
+-32322
+-55013
+-74568
+-89873
+-100056
+-104537
+-103060
+-95710
+-82904
+-65374
+-44118
+-20348
+4582
+29251
+52253
+72277
+88181
+99060
+104294
+103583
+96969
+84828
+67853
+47011
+23489
+-1371
+-26153
+-49444
+-69918
+-86407
+-97971
+-103952
+-104008
+-98137
+-86672
+-70268
+-49859
+-26609
+-1842
+23030
+46589
+67493
+84551
+96790
+103512
+104335
+99212
+88435
+72617
+52661
+29704
+5053
+-19885
+-43690
+-65005
+-82615
+-95517
+-102975
+-104565
+-100194
+-90114
+-74898
+-55413
+-32770
+-8260
+16722
+40750
+62456
+80602
+94155
+102341
+104695
+101082
+91709
+77108
+58113
+35806
+11458
+-13542
+-37771
+-59848
+-78513
+-92704
+-101611
+-104728
+-101875
+-93217
+-79246
+-60758
+-38808
+-14646
+10351
+34757
+57183
+76350
+91166
+100785
+104661
+102572
+94637
+81309
+63346
+41774
+17820
+-7149
+-31710
+-54465
+-74115
+-89541
+-99865
+-104496
+-103172
+-95969
+-83295
+-65875
+-44700
+-20978
+3940
+28634
+51695
+71811
+87833
+98850
+104233
+103676
+97210
+85203
+68341
+47584
+24115
+-728
+-25530
+-48877
+-69438
+-86042
+-97742
+-103872
+-104081
+-98359
+-87031
+-70743
+-50424
+-27230
+-2485
+22403
+46013
+67001
+84170
+96542
+103413
+104389
+99416
+88777
+73079
+53215
+30319
+5695
+-19254
+-43105
+-64500
+-82219
+-95252
+-102856
+-104599
+-100380
+-90440
+-75346
+-55957
+-33380
+-8900
+16087
+40157
+61939
+80190
+93872
+102203
+104710
+101249
+92017
+77542
+58647
+36409
+12097
+-12905
+-37171
+-59319
+-78086
+-92403
+-101454
+-104722
+-102022
+-93508
+-79664
+-61281
+-39404
+-15282
+9711
+34150
+56644
+75909
+90848
+100609
+104636
+102700
+94911
+81712
+63857
+42362
+18453
+-6508
+-31097
+-53915
+-73660
+-89206
+-99669
+-104452
+-103281
+-96224
+-83683
+-66373
+-45280
+-21607
+3298
+28015
+51135
+71341
+87481
+98636
+104169
+103765
+97447
+85575
+68827
+48156
+24740
+-86
+-24906
+-48308
+-68956
+-85674
+-97510
+-103788
+-104151
+-98578
+-87387
+-71216
+-50986
+-27850
+-3127
+21774
+45435
+66506
+83786
+96292
+103309
+104439
+99616
+89117
+73538
+53768
+30934
+6337
+-18622
+-42519
+-63993
+-81819
+-94983
+-102733
+-104629
+-100561
+-90762
+-75791
+-56499
+-33988
+-9540
+15452
+39563
+61419
+79776
+93585
+102061
+104720
+101411
+92322
+77972
+59178
+37011
+12735
+-12267
+-36570
+-58788
+-77657
+-92099
+-101292
+-104713
+-102166
+-93796
+-80080
+-61801
+-39999
+-15918
+9071
+33542
+56102
+75465
+90526
+100428
+104607
+102824
+95181
+82113
+64365
+42949
+19085
+-5866
+-30483
+-53363
+-73202
+-88868
+-99470
+-104403
+-103385
+-96476
+-84068
+-66869
+-45859
+-22235
+2656
+27395
+50574
+70870
+87127
+98418
+104100
+103850
+97681
+85944
+69310
+48725
+25364
+557
+-24282
+-47737
+-68471
+-85303
+-97273
+-103700
+-104216
+-98793
+-87740
+-71686
+-51546
+-28469
+-3769
+21145
+44855
+66008
+83399
+96037
+103202
+104485
+99813
+89452
+73994
+54318
+31547
+6978
+-17989
+-41931
+-63483
+-81417
+-94710
+-102607
+-104655
+-100739
+-91081
+-76233
+-57040
+-34596
+-10180
+14816
+38967
+60898
+79358
+93295
+101915
+104726
+101570
+92624
+78400
+59707
+37611
+13373
+-11629
+-35967
+-58256
+-77224
+-91791
+-101127
+-104700
+-102305
+-94080
+-80493
+-62318
+-40592
+-16552
+8430
+32933
+55558
+75018
+90201
+100244
+104574
+102944
+95447
+82510
+64871
+43534
+19717
+-5224
+-29868
+-52809
+-72741
+-88526
+-99267
+-104350
+-103486
+-96724
+-84450
+-67362
+-46436
+-22863
+2013
+26775
+50010
+70395
+86768
+98196
+104028
+103931
+97910
+86310
+69790
+49293
+25987
+1200
+-23656
+-47164
+-67983
+-84929
+-97033
+-103608
+-104278
+-99005
+-88089
+-72153
+-52105
+-29087
+-4411
+20516
+44273
+65508
+83009
+95779
+103090
+104527
+100006
+89785
+74447
+54867
+32159
+7619
+-17356
+-41341
+-62970
+-81011
+-94434
+-102476
+-104677
+-100912
+-91397
+-76672
+-57577
+-35201
+-10819
+14179
+38370
+60374
+78937
+93001
+101765
+104729
+101724
+92922
+78824
+60234
+38211
+14010
+-10990
+-35363
+-57720
+-76788
+-91480
+-100958
+-104682
+-102440
+-94360
+-80902
+-62833
+-41184
+-17187
+7790
+32322
+55013
+74568
+89873
+100056
+104537
+103060
+95710
+82904
+65374
+44118
+20348
+-4582
+-29251
+-52253
+-72277
+-88181
+-99060
+-104294
+-103583
+-96969
+-84828
+-67853
+-47011
+-23489
+1371
+26153
+49444
+69918
+86407
+97971
+103952
+104008
+98137
+86672
+70268
+49859
+26609
+1842
+-23030
+-46589
+-67493
+-84551
+-96790
+-103512
+-104335
+-99212
+-88435
+-72617
+-52661
+-29704
+-5053
+19885
+43690
+65005
+82615
+95517
+102975
+104565
+100194
+90114
+74898
+55413
+32770
+8260
+-16722
+-40750
+-62456
+-80602
+-94155
+-102341
+-104695
+-101082
+-91709
+-77108
+-58113
+-35806
+-11458
+13542
+37771
+59848
+78513
+92704
+101611
+104728
+101875
+93217
+79246
+60758
+38808
+14646
+-10351
+-34757
+-57183
+-76350
+-91166
+-100785
+-104661
+-102572
+-94637
+-81309
+-63346
+-41774
+-17820
+7149
+31710
+54465
+74115
+89541
+99865
+104496
+103172
+95969
+83295
+65875
+44700
+20978
+-3940
+-28634
+-51695
+-71811
+-87833
+-98850
+-104233
+-103676
+-97210
+-85203
+-68341
+-47584
+-24115
+728
+25530
+48877
+69438
+86042
+97742
+103872
+104081
+98359
+87031
+70743
+50424
+27230
+2485
+-22403
+-46013
+-67001
+-84170
+-96542
+-103413
+-104389
+-99416
+-88777
+-73079
+-53215
+-30319
+-5695
+19254
+43105
+64500
+82219
+95252
+102856
+104599
+100380
+90440
+75346
+55957
+33380
+8900
+-16087
+-40157
+-61939
+-80190
+-93872
+-102203
+-104710
+-101249
+-92017
+-77542
+-58647
+-36409
+-12097
+12905
+37171
+59319
+78086
+92403
+101454
+104722
+102022
+93508
+79664
+61281
+39404
+15282
+-9711
+-34150
+-56644
+-75909
+-90848
+-100609
+-104636
+-102700
+-94911
+-81712
+-63857
+-42362
+-18453
+6508
+31097
+53915
+73660
+89206
+99669
+104452
+103281
+96224
+83683
+66373
+45280
+21607
+-3298
+-28015
+-51135
+-71341
+-87481
+-98636
+-104169
+-103765
+-97447
+-85575
+-68827
+-48156
+-24740
+86
+24906
+48308
+68956
+85674
+97510
+103788
+104151
+98578
+87387
+71216
+50986
+27850
+3127
+-21774
+-45435
+-66506
+-83786
+-96292
+-103309
+-104439
+-99616
+-89117
+-73538
+-53768
+-30934
+-6337
+18622
+42519
+63993
+81819
+94983
+102733
+104629
+100561
+90762
+75791
+56499
+33988
+9540
+-15452
+-39563
+-61419
+-79776
+-93585
+-102061
+-104720
+-101411
+-92322
+-77972
+-59178
+-37011
+-12735
+12267
+36570
+58788
+77657
+92099
+101292
+104713
+102166
+93796
+80080
+61801
+39999
+15918
+-9071
+-33542
+-56102
+-75465
+-90526
+-100428
+-104607
+-102824
+-95181
+-82113
+-64365
+-42949
+-19085
+5866
+30483
+53363
+73202
+88868
+99470
+104403
+103385
+96476
+84068
+66869
+45859
+22235
+-2656
+-27395
+-50574
+-70870
+-87127
+-98418
+-104100
+-103850
+-97681
+-85944
+-69310
+-48725
+-25364
+-557
+24282
+47737
+68471
+85303
+97273
+103700
+104216
+98793
+87740
+71686
+51546
+28469
+3769
+-21145
+-44855
+-66008
+-83399
+-96037
+-103202
+-104485
+-99813
+-89452
+-73994
+-54318
+-31547
+-6978
+17989
+41931
+63483
+81417
+94710
+102607
+104655
+100739
+91081
+76233
diff --git a/applications/lofar1/pft2/tb/data/cosin_N2.sig b/applications/lofar1/pft2/tb/data/cosin_N2.sig
new file mode 100644
index 0000000000000000000000000000000000000000..e487309587720861908be3efd4a28ec6b4fbc230
--- /dev/null
+++ b/applications/lofar1/pft2/tb/data/cosin_N2.sig
@@ -0,0 +1,1024 @@
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
+65000
+-65000
diff --git a/applications/lofar1/pft2/tb/data/dc.sig b/applications/lofar1/pft2/tb/data/dc.sig
new file mode 100644
index 0000000000000000000000000000000000000000..2b42834d494b7dc49627b89e88e988592c7f8ce7
--- /dev/null
+++ b/applications/lofar1/pft2/tb/data/dc.sig
@@ -0,0 +1,1024 @@
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
+65000
diff --git a/applications/lofar1/pft2/tb/data/impulse_0.sig b/applications/lofar1/pft2/tb/data/impulse_0.sig
new file mode 100644
index 0000000000000000000000000000000000000000..a885e607aa02c64dc7993d7fefaa84d4e961b978
--- /dev/null
+++ b/applications/lofar1/pft2/tb/data/impulse_0.sig
@@ -0,0 +1,1024 @@
+131000
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
diff --git a/applications/lofar1/pft2/tb/data/impulse_1.sig b/applications/lofar1/pft2/tb/data/impulse_1.sig
new file mode 100644
index 0000000000000000000000000000000000000000..9f6e827f7f153f263aa010149f27e3f1c89540d0
--- /dev/null
+++ b/applications/lofar1/pft2/tb/data/impulse_1.sig
@@ -0,0 +1,1024 @@
+0
+131000
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
diff --git a/applications/lofar1/pft2/tb/data/sinus_1.sig b/applications/lofar1/pft2/tb/data/sinus_1.sig
new file mode 100644
index 0000000000000000000000000000000000000000..8d62a2a02512f856288319400e4ee3aa38b46245
--- /dev/null
+++ b/applications/lofar1/pft2/tb/data/sinus_1.sig
@@ -0,0 +1,1024 @@
+0
+804
+1608
+2411
+3215
+4018
+4822
+5625
+6428
+7231
+8033
+8835
+9637
+10438
+11239
+12040
+12840
+13640
+14439
+15238
+16036
+16833
+17630
+18426
+19222
+20016
+20810
+21604
+22396
+23188
+23978
+24768
+25557
+26345
+27132
+27917
+28702
+29486
+30269
+31050
+31830
+32610
+33387
+34164
+34939
+35713
+36486
+37257
+38027
+38796
+39563
+40328
+41092
+41855
+42616
+43375
+44133
+44889
+45643
+46395
+47146
+47895
+48643
+49388
+50132
+50873
+51613
+52351
+53087
+53820
+54552
+55282
+56010
+56735
+57459
+58180
+58899
+59616
+60331
+61043
+61753
+62461
+63166
+63869
+64570
+65268
+65964
+66657
+67347
+68036
+68721
+69404
+70085
+70762
+71438
+72110
+72780
+73447
+74111
+74772
+75431
+76087
+76740
+77390
+78037
+78681
+79322
+79960
+80595
+81227
+81857
+82483
+83106
+83725
+84342
+84955
+85566
+86173
+86776
+87377
+87974
+88568
+89159
+89746
+90330
+90910
+91487
+92061
+92631
+93198
+93761
+94320
+94876
+95429
+95978
+96523
+97065
+97603
+98137
+98667
+99194
+99718
+100237
+100753
+101264
+101772
+102277
+102777
+103273
+103766
+104255
+104739
+105220
+105697
+106170
+106639
+107104
+107564
+108021
+108474
+108923
+109367
+109807
+110244
+110676
+111104
+111528
+111947
+112362
+112774
+113180
+113583
+113981
+114375
+114765
+115151
+115532
+115908
+116281
+116649
+117012
+117372
+117726
+118077
+118423
+118764
+119101
+119433
+119761
+120085
+120404
+120718
+121028
+121334
+121634
+121930
+122222
+122509
+122791
+123069
+123342
+123611
+123875
+124134
+124388
+124638
+124883
+125123
+125359
+125590
+125816
+126038
+126255
+126467
+126674
+126876
+127074
+127267
+127455
+127638
+127817
+127991
+128160
+128324
+128483
+128637
+128787
+128932
+129071
+129206
+129336
+129462
+129582
+129698
+129808
+129914
+130015
+130111
+130202
+130288
+130369
+130446
+130517
+130583
+130645
+130702
+130753
+130800
+130842
+130879
+130911
+130938
+130961
+130978
+130990
+130998
+131000
+130998
+130990
+130978
+130961
+130938
+130911
+130879
+130842
+130800
+130753
+130702
+130645
+130583
+130517
+130446
+130369
+130288
+130202
+130111
+130015
+129914
+129808
+129698
+129582
+129462
+129336
+129206
+129071
+128932
+128787
+128637
+128483
+128324
+128160
+127991
+127817
+127638
+127455
+127267
+127074
+126876
+126674
+126467
+126255
+126038
+125816
+125590
+125359
+125123
+124883
+124638
+124388
+124134
+123875
+123611
+123342
+123069
+122791
+122509
+122222
+121930
+121634
+121334
+121028
+120718
+120404
+120085
+119761
+119433
+119101
+118764
+118423
+118077
+117726
+117372
+117012
+116649
+116281
+115908
+115532
+115151
+114765
+114375
+113981
+113583
+113180
+112774
+112362
+111947
+111528
+111104
+110676
+110244
+109807
+109367
+108923
+108474
+108021
+107564
+107104
+106639
+106170
+105697
+105220
+104739
+104255
+103766
+103273
+102777
+102277
+101772
+101264
+100753
+100237
+99718
+99194
+98667
+98137
+97603
+97065
+96523
+95978
+95429
+94876
+94320
+93761
+93198
+92631
+92061
+91487
+90910
+90330
+89746
+89159
+88568
+87974
+87377
+86776
+86173
+85566
+84955
+84342
+83725
+83106
+82483
+81857
+81227
+80595
+79960
+79322
+78681
+78037
+77390
+76740
+76087
+75431
+74772
+74111
+73447
+72780
+72110
+71438
+70762
+70085
+69404
+68721
+68036
+67347
+66657
+65964
+65268
+64570
+63869
+63166
+62461
+61753
+61043
+60331
+59616
+58899
+58180
+57459
+56735
+56010
+55282
+54552
+53820
+53087
+52351
+51613
+50873
+50132
+49388
+48643
+47895
+47146
+46395
+45643
+44889
+44133
+43375
+42616
+41855
+41092
+40328
+39563
+38796
+38027
+37257
+36486
+35713
+34939
+34164
+33387
+32610
+31830
+31050
+30269
+29486
+28702
+27917
+27132
+26345
+25557
+24768
+23978
+23188
+22396
+21604
+20810
+20016
+19222
+18426
+17630
+16833
+16036
+15238
+14439
+13640
+12840
+12040
+11239
+10438
+9637
+8835
+8033
+7231
+6428
+5625
+4822
+4018
+3215
+2411
+1608
+804
+0
+-804
+-1608
+-2411
+-3215
+-4018
+-4822
+-5625
+-6428
+-7231
+-8033
+-8835
+-9637
+-10438
+-11239
+-12040
+-12840
+-13640
+-14439
+-15238
+-16036
+-16833
+-17630
+-18426
+-19222
+-20016
+-20810
+-21604
+-22396
+-23188
+-23978
+-24768
+-25557
+-26345
+-27132
+-27917
+-28702
+-29486
+-30269
+-31050
+-31830
+-32610
+-33387
+-34164
+-34939
+-35713
+-36486
+-37257
+-38027
+-38796
+-39563
+-40328
+-41092
+-41855
+-42616
+-43375
+-44133
+-44889
+-45643
+-46395
+-47146
+-47895
+-48643
+-49388
+-50132
+-50873
+-51613
+-52351
+-53087
+-53820
+-54552
+-55282
+-56010
+-56735
+-57459
+-58180
+-58899
+-59616
+-60331
+-61043
+-61753
+-62461
+-63166
+-63869
+-64570
+-65268
+-65964
+-66657
+-67347
+-68036
+-68721
+-69404
+-70085
+-70762
+-71438
+-72110
+-72780
+-73447
+-74111
+-74772
+-75431
+-76087
+-76740
+-77390
+-78037
+-78681
+-79322
+-79960
+-80595
+-81227
+-81857
+-82483
+-83106
+-83725
+-84342
+-84955
+-85566
+-86173
+-86776
+-87377
+-87974
+-88568
+-89159
+-89746
+-90330
+-90910
+-91487
+-92061
+-92631
+-93198
+-93761
+-94320
+-94876
+-95429
+-95978
+-96523
+-97065
+-97603
+-98137
+-98667
+-99194
+-99718
+-100237
+-100753
+-101264
+-101772
+-102277
+-102777
+-103273
+-103766
+-104255
+-104739
+-105220
+-105697
+-106170
+-106639
+-107104
+-107564
+-108021
+-108474
+-108923
+-109367
+-109807
+-110244
+-110676
+-111104
+-111528
+-111947
+-112362
+-112774
+-113180
+-113583
+-113981
+-114375
+-114765
+-115151
+-115532
+-115908
+-116281
+-116649
+-117012
+-117372
+-117726
+-118077
+-118423
+-118764
+-119101
+-119433
+-119761
+-120085
+-120404
+-120718
+-121028
+-121334
+-121634
+-121930
+-122222
+-122509
+-122791
+-123069
+-123342
+-123611
+-123875
+-124134
+-124388
+-124638
+-124883
+-125123
+-125359
+-125590
+-125816
+-126038
+-126255
+-126467
+-126674
+-126876
+-127074
+-127267
+-127455
+-127638
+-127817
+-127991
+-128160
+-128324
+-128483
+-128637
+-128787
+-128932
+-129071
+-129206
+-129336
+-129462
+-129582
+-129698
+-129808
+-129914
+-130015
+-130111
+-130202
+-130288
+-130369
+-130446
+-130517
+-130583
+-130645
+-130702
+-130753
+-130800
+-130842
+-130879
+-130911
+-130938
+-130961
+-130978
+-130990
+-130998
+-131000
+-130998
+-130990
+-130978
+-130961
+-130938
+-130911
+-130879
+-130842
+-130800
+-130753
+-130702
+-130645
+-130583
+-130517
+-130446
+-130369
+-130288
+-130202
+-130111
+-130015
+-129914
+-129808
+-129698
+-129582
+-129462
+-129336
+-129206
+-129071
+-128932
+-128787
+-128637
+-128483
+-128324
+-128160
+-127991
+-127817
+-127638
+-127455
+-127267
+-127074
+-126876
+-126674
+-126467
+-126255
+-126038
+-125816
+-125590
+-125359
+-125123
+-124883
+-124638
+-124388
+-124134
+-123875
+-123611
+-123342
+-123069
+-122791
+-122509
+-122222
+-121930
+-121634
+-121334
+-121028
+-120718
+-120404
+-120085
+-119761
+-119433
+-119101
+-118764
+-118423
+-118077
+-117726
+-117372
+-117012
+-116649
+-116281
+-115908
+-115532
+-115151
+-114765
+-114375
+-113981
+-113583
+-113180
+-112774
+-112362
+-111947
+-111528
+-111104
+-110676
+-110244
+-109807
+-109367
+-108923
+-108474
+-108021
+-107564
+-107104
+-106639
+-106170
+-105697
+-105220
+-104739
+-104255
+-103766
+-103273
+-102777
+-102277
+-101772
+-101264
+-100753
+-100237
+-99718
+-99194
+-98667
+-98137
+-97603
+-97065
+-96523
+-95978
+-95429
+-94876
+-94320
+-93761
+-93198
+-92631
+-92061
+-91487
+-90910
+-90330
+-89746
+-89159
+-88568
+-87974
+-87377
+-86776
+-86173
+-85566
+-84955
+-84342
+-83725
+-83106
+-82483
+-81857
+-81227
+-80595
+-79960
+-79322
+-78681
+-78037
+-77390
+-76740
+-76087
+-75431
+-74772
+-74111
+-73447
+-72780
+-72110
+-71438
+-70762
+-70085
+-69404
+-68721
+-68036
+-67347
+-66657
+-65964
+-65268
+-64570
+-63869
+-63166
+-62461
+-61753
+-61043
+-60331
+-59616
+-58899
+-58180
+-57459
+-56735
+-56010
+-55282
+-54552
+-53820
+-53087
+-52351
+-51613
+-50873
+-50132
+-49388
+-48643
+-47895
+-47146
+-46395
+-45643
+-44889
+-44133
+-43375
+-42616
+-41855
+-41092
+-40328
+-39563
+-38796
+-38027
+-37257
+-36486
+-35713
+-34939
+-34164
+-33387
+-32610
+-31830
+-31050
+-30269
+-29486
+-28702
+-27917
+-27132
+-26345
+-25557
+-24768
+-23978
+-23188
+-22396
+-21604
+-20810
+-20016
+-19222
+-18426
+-17630
+-16833
+-16036
+-15238
+-14439
+-13640
+-12840
+-12040
+-11239
+-10438
+-9637
+-8835
+-8033
+-7231
+-6428
+-5625
+-4822
+-4018
+-3215
+-2411
+-1608
+-804
diff --git a/applications/lofar1/pft2/tb/data/sinus_13.sig b/applications/lofar1/pft2/tb/data/sinus_13.sig
new file mode 100644
index 0000000000000000000000000000000000000000..8089cbdc8c0017fa3db7b84278acc1437ead03e3
--- /dev/null
+++ b/applications/lofar1/pft2/tb/data/sinus_13.sig
@@ -0,0 +1,1024 @@
+65500
+74332
+82691
+90524
+97781
+104417
+110388
+115658
+120192
+123961
+126943
+129117
+130470
+130993
+130683
+129543
+127578
+124802
+121232
+116892
+111808
+106013
+99544
+92441
+84751
+76522
+67807
+58660
+49140
+39307
+29225
+18957
+8568
+-1875
+-12307
+-22660
+-32869
+-42869
+-52596
+-61989
+-70988
+-79535
+-87576
+-95061
+-101941
+-108173
+-113716
+-118537
+-122604
+-125891
+-128377
+-130047
+-130890
+-130901
+-130079
+-128430
+-125965
+-122698
+-118651
+-113849
+-108323
+-102109
+-95245
+-87776
+-79748
+-71213
+-62225
+-52842
+-43122
+-33128
+-22924
+-12574
+-2143
+8300
+18691
+28964
+39052
+48891
+58420
+67577
+76305
+84547
+92251
+99369
+105855
+111668
+116770
+121130
+124720
+127517
+129502
+130664
+130996
+130494
+129162
+127009
+124048
+120298
+115783
+110532
+104578
+97959
+90717
+82898
+74552
+65732
+56494
+46896
+37000
+26869
+16568
+6160
+-4286
+-14705
+-25031
+-35198
+-45140
+-54796
+-64103
+-73002
+-81438
+-89355
+-96704
+-103438
+-109514
+-114894
+-119543
+-123432
+-126536
+-128836
+-130316
+-130967
+-130785
+-129772
+-127933
+-125281
+-121832
+-117609
+-112637
+-106949
+-100581
+-93573
+-85971
+-77821
+-69177
+-60093
+-50626
+-40838
+-30790
+-20546
+-10171
+268
+10705
+21075
+31310
+41347
+51120
+60568
+69631
+78252
+86374
+93948
+100924
+107258
+112910
+117844
+122028
+125437
+128048
+129844
+130815
+130954
+130260
+128738
+126397
+123252
+119323
+114636
+109219
+103108
+96342
+88962
+81017
+72557
+63635
+54309
+44637
+34681
+24505
+14173
+3751
+-6695
+-17099
+-27394
+-37514
+-47396
+-56977
+-66195
+-74992
+-83312
+-91103
+-98314
+-104900
+-110819
+-116033
+-120509
+-124219
+-127139
+-129250
+-130540
+-130999
+-130625
+-129421
+-127393
+-124555
+-120925
+-116527
+-111387
+-105539
+-99019
+-91870
+-84137
+-75868
+-67118
+-57940
+-48394
+-38540
+-28441
+-18161
+-7766
+2679
+13107
+23451
+33646
+43628
+53331
+62696
+71662
+80172
+88173
+95612
+102444
+108624
+114113
+118877
+122885
+126111
+128535
+130142
+130921
+130867
+129982
+128269
+125742
+122414
+118308
+113449
+107869
+101603
+94691
+87177
+79109
+70537
+61517
+52105
+42362
+32350
+22132
+11773
+1340
+-9102
+-19487
+-29747
+-39818
+-49636
+-59138
+-68264
+-76957
+-85159
+-92820
+-99891
+-106327
+-112086
+-117133
+-121434
+-124964
+-127699
+-129621
+-130720
+-130987
+-130421
+-129025
+-126809
+-123787
+-119978
+-115405
+-110099
+-104092
+-97424
+-90136
+-82274
+-73890
+-65035
+-55767
+-46145
+-36229
+-26082
+-15770
+-5357
+5089
+15504
+25820
+35971
+45894
+55525
+64803
+73668
+82066
+89941
+97244
+103929
+109953
+115278
+119870
+123699
+126742
+128979
+130395
+130982
+130737
+129660
+127758
+125044
+121535
+117252
+112224
+106483
+100064
+93009
+85363
+77173
+68493
+59377
+49884
+40073
+30008
+19752
+9370
+-1072
+-11506
+-21868
+-32090
+-42109
+-51859
+-61280
+-70311
+-78895
+-86977
+-94506
+-101434
+-107717
+-113315
+-118192
+-122318
+-125666
+-128215
+-129948
+-130855
+-130930
+-130172
+-128586
+-126183
+-122977
+-118989
+-114245
+-108773
+-102611
+-95795
+-88371
+-80384
+-71886
+-62931
+-53576
+-43880
+-33905
+-23715
+-13373
+-2947
+7498
+17896
+28179
+38284
+48145
+57699
+66887
+75650
+83931
+91679
+98844
+105380
+111245
+116404
+120822
+124472
+127330
+129379
+130605
+131000
+130562
+129294
+127203
+124304
+120614
+116157
+110962
+105060
+98491
+91295
+83519
+75212
+66426
+57218
+47646
+37771
+27656
+17365
+6963
+-3483
+-13906
+-24242
+-34423
+-44385
+-54065
+-63401
+-72334
+-80806
+-88765
+-96160
+-102943
+-109071
+-114506
+-119212
+-123161
+-126326
+-128688
+-130231
+-130946
+-130829
+-129879
+-128104
+-125514
+-122125
+-117960
+-113045
+-107411
+-101094
+-94134
+-86576
+-78466
+-69858
+-60806
+-51367
+-41601
+-31570
+-21339
+-10972
+-536
+9904
+20281
+30529
+40583
+50379
+59854
+68949
+77606
+85768
+93386
+100409
+106794
+112500
+117490
+121734
+125203
+127875
+129735
+130770
+130973
+130343
+128884
+126605
+123522
+119653
+115023
+109661
+103602
+96884
+89551
+81647
+73225
+64336
+55039
+45392
+35456
+25294
+14972
+4554
+-5893
+-16302
+-26607
+-36743
+-46646
+-56252
+-65500
+-74332
+-82691
+-90524
+-97781
+-104417
+-110388
+-115658
+-120192
+-123961
+-126943
+-129117
+-130470
+-130993
+-130683
+-129543
+-127578
+-124802
+-121232
+-116892
+-111808
+-106013
+-99544
+-92441
+-84751
+-76522
+-67807
+-58660
+-49140
+-39307
+-29225
+-18957
+-8568
+1875
+12307
+22660
+32869
+42869
+52596
+61989
+70988
+79535
+87576
+95061
+101941
+108173
+113716
+118537
+122604
+125891
+128377
+130047
+130890
+130901
+130079
+128430
+125965
+122698
+118651
+113849
+108323
+102109
+95245
+87776
+79748
+71213
+62225
+52842
+43122
+33128
+22924
+12574
+2143
+-8300
+-18691
+-28964
+-39052
+-48891
+-58420
+-67577
+-76305
+-84547
+-92251
+-99369
+-105855
+-111668
+-116770
+-121130
+-124720
+-127517
+-129502
+-130664
+-130996
+-130494
+-129162
+-127009
+-124048
+-120298
+-115783
+-110532
+-104578
+-97959
+-90717
+-82898
+-74552
+-65732
+-56494
+-46896
+-37000
+-26869
+-16568
+-6160
+4286
+14705
+25031
+35198
+45140
+54796
+64103
+73002
+81438
+89355
+96704
+103438
+109514
+114894
+119543
+123432
+126536
+128836
+130316
+130967
+130785
+129772
+127933
+125281
+121832
+117609
+112637
+106949
+100581
+93573
+85971
+77821
+69177
+60093
+50626
+40838
+30790
+20546
+10171
+-268
+-10705
+-21075
+-31310
+-41347
+-51120
+-60568
+-69631
+-78252
+-86374
+-93948
+-100924
+-107258
+-112910
+-117844
+-122028
+-125437
+-128048
+-129844
+-130815
+-130954
+-130260
+-128738
+-126397
+-123252
+-119323
+-114636
+-109219
+-103108
+-96342
+-88962
+-81017
+-72557
+-63635
+-54309
+-44637
+-34681
+-24505
+-14173
+-3751
+6695
+17099
+27394
+37514
+47396
+56977
+66195
+74992
+83312
+91103
+98314
+104900
+110819
+116033
+120509
+124219
+127139
+129250
+130540
+130999
+130625
+129421
+127393
+124555
+120925
+116527
+111387
+105539
+99019
+91870
+84137
+75868
+67118
+57940
+48394
+38540
+28441
+18161
+7766
+-2679
+-13107
+-23451
+-33646
+-43628
+-53331
+-62696
+-71662
+-80172
+-88173
+-95612
+-102444
+-108624
+-114113
+-118877
+-122885
+-126111
+-128535
+-130142
+-130921
+-130867
+-129982
+-128269
+-125742
+-122414
+-118308
+-113449
+-107869
+-101603
+-94691
+-87177
+-79109
+-70537
+-61517
+-52105
+-42362
+-32350
+-22132
+-11773
+-1340
+9102
+19487
+29747
+39818
+49636
+59138
+68264
+76957
+85159
+92820
+99891
+106327
+112086
+117133
+121434
+124964
+127699
+129621
+130720
+130987
+130421
+129025
+126809
+123787
+119978
+115405
+110099
+104092
+97424
+90136
+82274
+73890
+65035
+55767
+46145
+36229
+26082
+15770
+5357
+-5089
+-15504
+-25820
+-35971
+-45894
+-55525
+-64803
+-73668
+-82066
+-89941
+-97244
+-103929
+-109953
+-115278
+-119870
+-123699
+-126742
+-128979
+-130395
+-130982
+-130737
+-129660
+-127758
+-125044
+-121535
+-117252
+-112224
+-106483
+-100064
+-93009
+-85363
+-77173
+-68493
+-59377
+-49884
+-40073
+-30008
+-19752
+-9370
+1072
+11506
+21868
+32090
+42109
+51859
+61280
+70311
+78895
+86977
+94506
+101434
+107717
+113315
+118192
+122318
+125666
+128215
+129948
+130855
+130930
+130172
+128586
+126183
+122977
+118989
+114245
+108773
+102611
+95795
+88371
+80384
+71886
+62931
+53576
+43880
+33905
+23715
+13373
+2947
+-7498
+-17896
+-28179
+-38284
+-48145
+-57699
+-66887
+-75650
+-83931
+-91679
+-98844
+-105380
+-111245
+-116404
+-120822
+-124472
+-127330
+-129379
+-130605
+-131000
+-130562
+-129294
+-127203
+-124304
+-120614
+-116157
+-110962
+-105060
+-98491
+-91295
+-83519
+-75212
+-66426
+-57218
+-47646
+-37771
+-27656
+-17365
+-6963
+3483
+13906
+24242
+34423
+44385
+54065
+63401
+72334
+80806
+88765
+96160
+102943
+109071
+114506
+119212
+123161
+126326
+128688
+130231
+130946
+130829
+129879
+128104
+125514
+122125
+117960
+113045
+107411
+101094
+94134
+86576
+78466
+69858
+60806
+51367
+41601
+31570
+21339
+10972
+536
+-9904
+-20281
+-30529
+-40583
+-50379
+-59854
+-68949
+-77606
+-85768
+-93386
+-100409
+-106794
+-112500
+-117490
+-121734
+-125203
+-127875
+-129735
+-130770
+-130973
+-130343
+-128884
+-126605
+-123522
+-119653
+-115023
+-109661
+-103602
+-96884
+-89551
+-81647
+-73225
+-64336
+-55039
+-45392
+-35456
+-25294
+-14972
+-4554
+5893
+16302
+26607
+36743
+46646
+56252
diff --git a/applications/lofar1/pft2/tb/data/sinus_13s.sig b/applications/lofar1/pft2/tb/data/sinus_13s.sig
new file mode 100644
index 0000000000000000000000000000000000000000..8e57aec2636058a759563bfb4623310e2e2bab92
--- /dev/null
+++ b/applications/lofar1/pft2/tb/data/sinus_13s.sig
@@ -0,0 +1,1024 @@
+10
+11
+12
+13
+14
+15
+16
+17
+17
+18
+18
+19
+19
+19
+19
+19
+19
+18
+18
+17
+16
+15
+14
+13
+12
+11
+10
+9
+7
+6
+4
+3
+1
+0
+-2
+-3
+-5
+-6
+-8
+-9
+-10
+-12
+-13
+-14
+-15
+-16
+-16
+-17
+-18
+-18
+-19
+-19
+-19
+-19
+-19
+-19
+-18
+-18
+-17
+-17
+-16
+-15
+-14
+-13
+-12
+-10
+-9
+-8
+-6
+-5
+-3
+-2
+0
+1
+3
+4
+6
+7
+8
+10
+11
+12
+13
+14
+15
+16
+17
+18
+18
+18
+19
+19
+19
+19
+19
+18
+18
+17
+17
+16
+15
+14
+13
+12
+11
+10
+8
+7
+5
+4
+2
+1
+-1
+-2
+-4
+-5
+-7
+-8
+-9
+-11
+-12
+-13
+-14
+-15
+-16
+-17
+-17
+-18
+-18
+-19
+-19
+-19
+-19
+-19
+-19
+-18
+-18
+-17
+-16
+-16
+-15
+-14
+-12
+-11
+-10
+-9
+-7
+-6
+-4
+-3
+-1
+0
+2
+3
+5
+6
+7
+9
+10
+11
+13
+14
+15
+16
+16
+17
+18
+18
+19
+19
+19
+19
+19
+19
+18
+18
+17
+17
+16
+15
+14
+13
+12
+11
+9
+8
+6
+5
+4
+2
+1
+-1
+-2
+-4
+-5
+-7
+-8
+-10
+-11
+-12
+-13
+-14
+-15
+-16
+-17
+-17
+-18
+-18
+-19
+-19
+-19
+-19
+-19
+-18
+-18
+-18
+-17
+-16
+-15
+-14
+-13
+-12
+-11
+-10
+-8
+-7
+-6
+-4
+-3
+-1
+0
+2
+3
+5
+6
+8
+9
+10
+12
+13
+14
+15
+16
+17
+17
+18
+18
+19
+19
+19
+19
+19
+19
+18
+18
+17
+16
+16
+15
+14
+13
+11
+10
+9
+8
+6
+5
+3
+2
+0
+-1
+-3
+-4
+-6
+-7
+-9
+-10
+-11
+-12
+-13
+-14
+-15
+-16
+-17
+-18
+-18
+-19
+-19
+-19
+-19
+-19
+-19
+-18
+-18
+-17
+-17
+-16
+-15
+-14
+-13
+-12
+-11
+-9
+-8
+-7
+-5
+-4
+-2
+-1
+1
+2
+4
+5
+7
+8
+9
+11
+12
+13
+14
+15
+16
+17
+17
+18
+18
+19
+19
+19
+19
+19
+19
+18
+18
+17
+16
+15
+15
+13
+12
+11
+10
+9
+7
+6
+4
+3
+1
+0
+-2
+-3
+-5
+-6
+-8
+-9
+-10
+-11
+-13
+-14
+-15
+-16
+-16
+-17
+-18
+-18
+-19
+-19
+-19
+-19
+-19
+-19
+-18
+-18
+-17
+-17
+-16
+-15
+-14
+-13
+-12
+-10
+-9
+-8
+-6
+-5
+-3
+-2
+0
+1
+3
+4
+6
+7
+8
+10
+11
+12
+13
+14
+15
+16
+17
+18
+18
+18
+19
+19
+19
+19
+19
+18
+18
+17
+17
+16
+15
+14
+13
+12
+11
+10
+8
+7
+5
+4
+3
+1
+-1
+-2
+-4
+-5
+-6
+-8
+-9
+-10
+-12
+-13
+-14
+-15
+-16
+-17
+-17
+-18
+-18
+-19
+-19
+-19
+-19
+-19
+-19
+-18
+-18
+-17
+-16
+-16
+-15
+-14
+-13
+-11
+-10
+-9
+-7
+-6
+-5
+-3
+-2
+0
+1
+3
+4
+6
+7
+9
+10
+11
+12
+14
+15
+15
+16
+17
+18
+18
+19
+19
+19
+19
+19
+19
+18
+18
+17
+17
+16
+15
+14
+13
+12
+11
+9
+8
+7
+5
+4
+2
+1
+-1
+-2
+-4
+-5
+-7
+-8
+-9
+-11
+-12
+-13
+-14
+-15
+-16
+-17
+-17
+-18
+-18
+-19
+-19
+-19
+-19
+-19
+-19
+-18
+-18
+-17
+-16
+-15
+-14
+-13
+-12
+-11
+-10
+-9
+-7
+-6
+-4
+-3
+-1
+0
+2
+3
+5
+6
+8
+9
+10
+12
+13
+14
+15
+16
+16
+17
+18
+18
+19
+19
+19
+19
+19
+19
+18
+18
+17
+17
+16
+15
+14
+13
+12
+10
+9
+8
+6
+5
+3
+2
+0
+-1
+-3
+-4
+-6
+-7
+-8
+-10
+-11
+-12
+-13
+-14
+-15
+-16
+-17
+-18
+-18
+-18
+-19
+-19
+-19
+-19
+-19
+-18
+-18
+-17
+-17
+-16
+-15
+-14
+-13
+-12
+-11
+-10
+-8
+-7
+-5
+-4
+-2
+-1
+1
+2
+4
+5
+7
+8
+9
+11
+12
+13
+14
+15
+16
+17
+17
+18
+18
+19
+19
+19
+19
+19
+19
+18
+18
+17
+16
+16
+15
+14
+12
+11
+10
+9
+7
+6
+4
+3
+1
+0
+-2
+-3
+-5
+-6
+-7
+-9
+-10
+-11
+-13
+-14
+-15
+-16
+-16
+-17
+-18
+-18
+-19
+-19
+-19
+-19
+-19
+-19
+-18
+-18
+-17
+-17
+-16
+-15
+-14
+-13
+-12
+-11
+-9
+-8
+-6
+-5
+-4
+-2
+-1
+1
+2
+4
+5
+7
+8
+10
+11
+12
+13
+14
+15
+16
+17
+17
+18
+18
+19
+19
+19
+19
+19
+18
+18
+18
+17
+16
+15
+14
+13
+12
+11
+10
+8
+7
+6
+4
+3
+1
+0
+-2
+-3
+-5
+-6
+-8
+-9
+-10
+-12
+-13
+-14
+-15
+-16
+-17
+-17
+-18
+-18
+-19
+-19
+-19
+-19
+-19
+-19
+-18
+-18
+-17
+-16
+-16
+-15
+-14
+-13
+-11
+-10
+-9
+-8
+-6
+-5
+-3
+-2
+0
+1
+3
+4
+6
+7
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+18
+19
+19
+19
+19
+19
+19
+18
+18
+17
+17
+16
+15
+14
+13
+12
+11
+9
+8
+7
+5
+4
+2
+1
+-1
+-2
+-4
+-5
+-7
+-8
+-9
+-11
+-12
+-13
+-14
+-15
+-16
+-17
+-17
+-18
+-18
+-19
+-19
+-19
+-19
+-19
+-19
+-18
+-18
+-17
+-16
+-15
+-15
+-13
+-12
+-11
+-10
+-9
+-7
+-6
+-4
+-3
+-1
+0
+2
+3
+5
+6
+8
+9
+10
+11
+13
+14
+15
+16
+16
+17
+18
+18
+19
+19
+19
+19
+19
+19
+18
+18
+17
+17
+16
+15
+14
+13
+12
+10
+9
+8
+6
+5
+3
+2
+0
+-1
+-3
+-4
+-6
+-7
+-8
+-10
+-11
+-12
+-13
+-14
+-15
+-16
+-17
+-18
+-18
+-18
+-19
+-19
+-19
+-19
+-19
+-18
+-18
+-17
+-17
+-16
+-15
+-14
+-13
+-12
+-11
+-10
+-8
+-7
+-5
+-4
+-3
+-1
+1
+2
+4
+5
+6
+8
+9
+10
+12
+13
+14
+15
+16
+17
+17
+18
+18
+19
+19
+19
+19
+19
+19
+18
+18
+17
+16
+16
+15
+14
+13
+11
+10
+9
+7
+6
+5
+3
+2
+0
+-1
+-3
+-4
+-6
+-7
+-9
+-10
+-11
+-12
+-14
+-15
+-15
+-16
+-17
+-18
+-18
+-19
+-19
+-19
+-19
+-19
+-19
+-18
+-18
+-17
+-17
+-16
+-15
+-14
+-13
+-12
+-11
+-9
+-8
+-7
+-5
+-4
+-2
+-1
+1
+2
+4
+5
+7
+8
diff --git a/applications/lofar1/pft2/tb/data/tc_sig.tcl b/applications/lofar1/pft2/tb/data/tc_sig.tcl
new file mode 100644
index 0000000000000000000000000000000000000000..5fe010b7946a0492d3223027e39c11c021193ed3
--- /dev/null
+++ b/applications/lofar1/pft2/tb/data/tc_sig.tcl
@@ -0,0 +1,283 @@
+###############################################################################
+#
+# Copyright (C) 2012
+# ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
+# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+###############################################################################
+
+#
+# This test verifies the PFT output for several input signals agains golden results. The
+# expected results are read from files that can be generated by means of MATLAB program
+# tc.m.
+#
+# Features:
+# - Several signals can be applied per slice, e.g. noise, sinus, block, impulse.
+# - Subband 0 should reflect DC or fs/2:
+#   . f = 0 (DC) --> subband 0 real
+#   . f = fs/2   --> subband 0 imag
+# - Some quatization error per subband is accepted and the threshold can be set via c_diff_max.
+# - When both X and Y are zero then the PFT output must be exactly zero.
+# - Quantization crosstalk between X and Y is shown by keeping one signal zero.
+# - The simulation is rerun as often as necessary to get all subbands in the result buffer via SS.
+#
+
+source "../../../tcl/constants.tcl"
+source "../../../tcl/wg.tcl"
+
+set dir_tc "./"
+
+
+#############################################################################
+# - Initializations
+#############################################################################
+
+set c_slice_size [expr $c_cpx * $c_rsp_nof_subbands]
+
+#############################################################################
+# - Prepare waveform signals.
+#############################################################################
+
+set pi            [expr 4*atan(1)]
+set n             $c_slice_size                    ;# One FFT-slice
+set a_max         [expr int(pow(2,$c_diag_reg_wave_dat_w-1)-1)]     ;# WG maximum amplitude
+set a_large       [expr int(1000*floor(0.001 * $a_max))]            ;# Large amplitude intended for impulse and sinusoids
+set a_large_prime 104729
+set a_large_2     [expr int(1000*floor(0.001 * $a_max/2))]          ;# Large amplitude intended for DC and Fs/2
+set a_large_pi4   [expr int(1000*floor(0.001 * $a_max * $pi/4))]    ;# Large amplitude intended for square wave
+set a_medium      [expr int($a_max/2)]
+set a_small_n     [expr 19*$c_slice_size]                           ;# Small amplitude intended for impulse
+set a_small       19                                                ;# Small amplitude intended for DC and sinusoids
+
+# >>> Cosinus
+set amp         $a_large_2
+set ofs         0
+set phs         0
+set nof_per     [expr $n/2]                     ;# N/2 periods per slice, so freq is N/2 * (2/N * fs/2) = fs/2
+set per         [expr $n/$nof_per]
+set cosin_N2    [wg_adc [wg_calculate_analogue_waveform cosin $amp $ofs $phs $per 0 $n] $c_diag_reg_wave_dat_w]
+set f           {}
+append f        "$dir_tc" "cosin_N2"
+wg_write_file   $f $cosin_N2
+
+set amp         $a_large
+set ofs         0
+set phs         0
+set nof_per     1                               ;# n periods per slice, so freq is n * fs/N
+set per         [expr $n/$nof_per]
+set cosin_1     [wg_adc [wg_calculate_analogue_waveform cosin $amp $ofs $phs $per 0 $n] $c_diag_reg_wave_dat_w]
+set f           {}
+append f        "$dir_tc" "cosin_1"
+wg_write_file   $f $cosin_1
+
+set amp         $a_large_prime
+set ofs         0
+set nof_per     39.0                            ;# n periods per slice, so freq is n * fs/N
+set per         [expr $n/$nof_per]
+set phs         57                              ;# degrees
+set phs         [expr $phs * $per/360]
+set cosin_39    [wg_adc [wg_calculate_analogue_waveform cosin $amp $ofs $phs $per 0 $n] $c_diag_reg_wave_dat_w]
+set f           {}
+append f        "$dir_tc" "cosin_39"
+wg_write_file   $f $cosin_39
+
+# >>> Sinus
+set amp         $a_large
+set ofs         0
+set phs         0
+set nof_per     1                               ;# n periods per slice, so freq is n * fs/N
+set per         [expr $n/$nof_per]
+set sinus_1     [wg_adc [wg_calculate_analogue_waveform sinus $amp $ofs $phs $per 0 $n] $c_diag_reg_wave_dat_w]
+set f           {}
+append f        "$dir_tc" "sinus_1"
+wg_write_file   $f $sinus_1
+
+set amp         $a_large
+set ofs         0
+set nof_per     13.0                            ;# n periods per slice, so freq is n * fs/N
+set per         [expr $n/$nof_per]
+set phs         30                              ;# degrees
+set phs         [expr $phs * $per/360]
+set sinus_13    [wg_adc [wg_calculate_analogue_waveform sinus $amp $ofs $phs $per 0 $n] $c_diag_reg_wave_dat_w]
+set f           {}
+append f        "$dir_tc" "sinus_13"
+wg_write_file   $f $sinus_13
+
+set amp         $a_small
+set ofs         0
+set nof_per     13.0                            ;# n periods per slice, so freq is n * fs/N
+set per         [expr $n/$nof_per]
+set phs         30                              ;# degrees
+set phs         [expr $phs * $per/360]
+set sinus_13s   [wg_adc [wg_calculate_analogue_waveform sinus $amp $ofs $phs $per 0 $n] $c_diag_reg_wave_dat_w]
+set f           {}
+append f        "$dir_tc" "sinus_13s"
+wg_write_file   $f $sinus_13s
+
+# >>> Impulse
+# [1 0 0 0 ... 0]
+set amp         $a_large
+set ofs         0
+set phs         0
+set impulse_0   [wg_adc [wg_calculate_analogue_waveform block $amp $ofs $phs $n 1 $n] $c_diag_reg_wave_dat_w]
+set f           {}
+append f        "$dir_tc" "impulse_0"
+wg_write_file   $f $impulse_0
+
+# [0 1 0 0 ... 0]
+set amp         $a_large
+set ofs         0
+set phs         -1
+set impulse_1   [wg_adc [wg_calculate_analogue_waveform block $amp $ofs $phs $n 1 $n] $c_diag_reg_wave_dat_w]
+set f           {}
+append f        "$dir_tc" "impulse_1"
+wg_write_file   $f $impulse_1
+
+# >>> Zeros
+set amp         0
+set ofs         0
+set zeros       [wg_adc [wg_calculate_analogue_waveform block $amp $ofs 0 1 1 $n] $c_diag_reg_wave_dat_w]
+set f           {}
+append f        "$dir_tc" "zeros"
+wg_write_file   $f $zeros
+
+# >>> DC
+set amp         $a_large_2
+set ofs         0
+set dc          [wg_adc [wg_calculate_analogue_waveform block $amp $ofs 0 1 1 $n] $c_diag_reg_wave_dat_w]
+set f           {}
+append f        "$dir_tc" "dc"
+wg_write_file   $f $dc
+
+# >>> Block
+# [1 1 1 ... 1 0 0 0 ... 0]
+set amp         [expr 2*$a_large_pi4]
+set ofs         -$a_large_pi4
+set phs         0
+set nof_per     1                               ;# n periods per slice, so freq is n * fs/N
+set per         [expr $n/$nof_per]
+set duty        [expr 0.5*$per]
+set block_1     [wg_adc [wg_calculate_analogue_waveform block $amp $ofs $phs $per $duty $n] $c_diag_reg_wave_dat_w]
+set f           {}
+append f        "$dir_tc" "block_1"
+wg_write_file   $f $block_1
+
+# [0 1 1 ... 1 1 0 0 ... 0]
+set amp         [expr 2*$a_large_pi4]
+set ofs         -$a_large_pi4
+set nof_per     117.3                           ;# n periods per slice, so freq is n * fs/N
+set per         [expr $n/$nof_per]
+set duty        [expr 0.5*$per]
+set phs         30                              ;# degrees
+set phs         [expr -$phs * $per/360]
+set block_117   [wg_adc [wg_calculate_analogue_waveform block $amp $ofs $phs $per $duty $n] $c_diag_reg_wave_dat_w]
+set f           {}
+append f        "$dir_tc" "block_117"
+wg_write_file   $f $block_117
+
+# >>> Noise (uniform)
+set amp         $a_medium
+set ofs         0
+set phs         0
+set u_noise     [wg_adc [wg_calculate_analogue_waveform uniform $amp $ofs $phs 1 1 $n] $c_diag_reg_wave_dat_w]
+set f           {}
+append f        "$dir_tc" "u_noise"
+wg_write_file   $f $u_noise
+
+
+#############################################################################
+# List of waveforms
+#############################################################################
+
+# X input                           # Y input
+set i 0
+set waveform_x($i) $impulse_0     ; set waveform_y($i) $impulse_1
+set wavename_x($i)  impulse_0     ; set wavename_y($i)  impulse_1    ; incr i
+
+set waveform_x($i) $impulse_0     ; set waveform_y($i) $zeros
+set wavename_x($i)  impulse_0     ; set wavename_y($i)  zeros        ; incr i
+
+set waveform_x($i) $cosin_39      ; set waveform_y($i) $zeros
+set wavename_x($i)  cosin_39      ; set wavename_y($i)  zeros        ; incr i
+
+set waveform_x($i) $zeros         ; set waveform_y($i) $zeros
+set wavename_x($i)  zeros         ; set wavename_y($i)  zeros        ; incr i
+
+set waveform_x($i) $dc            ; set waveform_y($i) $cosin_N2
+set wavename_x($i)  dc            ; set wavename_y($i)  cosin_N2     ; incr i
+
+set waveform_x($i) $dc            ; set waveform_y($i) $sinus_13
+set wavename_x($i)  dc            ; set wavename_y($i)  sinus_13     ; incr i
+
+set waveform_x($i) $block_117     ; set waveform_y($i) $u_noise
+set wavename_x($i)  block_117     ; set wavename_y($i)  u_noise      ; incr i
+
+set waveform_x($i) $u_noise       ; set waveform_y($i) $u_noise
+set wavename_x($i)  u_noise       ; set wavename_y($i)  u_noise      ; incr i
+set nof_waveforms $i
+
+
+#############################################################################
+# - Derive expected results from golden results
+#############################################################################
+
+for {set k 0} {$k < $nof_waveforms} {incr k} {
+  # Read the golden FFT results (generated by MATLAB: tc.m)
+  set f {}; append f "$dir_tc" "$wavename_x($k).re"; set fft_x_re($k) [wg_read_file $f]
+  set f {}; append f "$dir_tc" "$wavename_x($k).im"; set fft_x_im($k) [wg_read_file $f]
+  set f {}; append f "$dir_tc" "$wavename_y($k).re"; set fft_y_re($k) [wg_read_file $f]
+  set f {}; append f "$dir_tc" "$wavename_y($k).im"; set fft_y_im($k) [wg_read_file $f]
+
+  # Scale and round the golden FFT results
+  # - The PFT stages scale the output by the FFT size N so by 1/N = 1/$c_slice_size.
+  # - PFT seperate does not divide by 2 in Xa(m) = [X*(N-m) + X(m)]/2, Xb(m)=j[X*(N-m) - X(m)]/2
+  # - PFT seperate result for m=N is same as for m=0
+  # - PFT seperate puts real result for m=N/2 in imag of m=0
+  set N $c_slice_size
+
+  set f [expr round (2*[lindex $fft_x_re($k) [expr $N/2]]/$N)]
+  for {set i 1} {$i < $N/2} {incr i} {
+    set lo [lindex $fft_x_im($k) $i]
+    set hi [lindex $fft_x_im($k) [expr $N - $i]]
+    lappend f [expr round ((-$hi + $lo)/$N)]
+  }
+  set fft_x_im($k) $f
+
+  set f [expr round (2*[lindex $fft_x_re($k) 0]/$N)]
+  for {set i 1} {$i < $N/2} {incr i} {
+    set lo [lindex $fft_x_re($k) $i]
+    set hi [lindex $fft_x_re($k) [expr $N - $i]]
+    lappend f [expr round (($hi + $lo)/$N)]
+  }
+  set fft_x_re($k) $f
+
+  set f [expr round (2*[lindex $fft_y_re($k) [expr $N/2]]/$N)]
+  for {set i 1} {$i < $N/2} {incr i} {
+    set lo [lindex $fft_y_im($k) $i]
+    set hi [lindex $fft_y_im($k) [expr $N - $i]]
+    lappend f [expr round ((-$hi + $lo)/$N)]
+  }
+  set fft_y_im($k) $f
+
+  set f [expr round (2*[lindex $fft_y_re($k) 0]/$N)]
+  for {set i 1} {$i < $N/2} {incr i} {
+    set lo [lindex $fft_y_re($k) $i]
+    set hi [lindex $fft_y_re($k) [expr $N - $i]]
+    lappend f [expr round (($hi + $lo)/$N)]
+  }
+  set fft_y_re($k) $f
+}
+
diff --git a/applications/lofar1/pft2/tb/data/u_noise.sig b/applications/lofar1/pft2/tb/data/u_noise.sig
new file mode 100644
index 0000000000000000000000000000000000000000..82f6125d31fc542a70c50cd5f125399238e932a6
--- /dev/null
+++ b/applications/lofar1/pft2/tb/data/u_noise.sig
@@ -0,0 +1,1024 @@
+63770
+15317
+11186
+56653
+-64634
+2057
+-34778
+61363
+61480
+-56706
+-50839
+-11971
+2781
+-43693
+41112
+-30887
+50455
+-26038
+18926
+-18127
+-53504
+27000
+30805
+16057
+-5455
+64318
+-65465
+63844
+-44891
+-46198
+4324
+58509
+-62487
+39746
+-46788
+46633
+-39408
+-30067
+-63673
+41496
+31
+3950
+-61733
+6453
+52980
+-62138
+14387
+-23680
+62039
+35226
+4097
+52695
+11087
+-38835
+24064
+-36508
+-43056
+1686
+17164
+-13480
+62355
+-40777
+18901
+-40122
+29507
+-47161
+-59115
+-36343
+-23702
+-43933
+-60440
+-26925
+55868
+-4831
+-59923
+10739
+10646
+15516
+-44161
+34070
+-29650
+8964
+50240
+36187
+24957
+33449
+16117
+-40309
+24282
+-36074
+28398
+-65056
+-17415
+-13226
+-1243
+-43794
+39394
+60819
+-30147
+39595
+27106
+-35434
+37388
+25006
+57584
+-7548
+10890
+50338
+-24319
+-60286
+-51522
+47692
+-65247
+61869
+46128
+-3011
+-18525
+-64112
+-10241
+-23662
+-22934
+18082
+-54356
+-3981
+-54736
+28428
+38143
+3694
+-40183
+44342
+-1874
+-41040
+57124
+2671
+59858
+-52810
+26935
+-24344
+56880
+-42102
+33715
+24870
+976
+18851
+25167
+13503
+56240
+-50661
+-24121
+-3700
+-52798
+-24445
+57236
+45594
+62420
+10624
+42625
+-33128
+1269
+-32472
+22377
+50124
+50052
+16386
+16126
+-29982
+63637
+15465
+1245
+-42935
+55093
+-55569
+50063
+-57442
+39849
+-29637
+-46905
+51951
+-44421
+-8534
+-40684
+12194
+-57012
+44449
+-41425
+8947
+33016
+-43322
+-12611
+-19107
+-14178
+594
+25640
+-33505
+-43071
+5826
+8107
+-52091
+49945
+52560
+-36797
+-65212
+-5219
+-26063
+-8032
+15101
+53401
+-56280
+40285
+-44728
+-61521
+23796
+48758
+27736
+-53730
+28960
+60055
+-33489
+-40501
+-48004
+-62067
+24433
+4221
+33679
+-42394
+-13057
+-31941
+22588
+54633
+-59131
+-42346
+-3555
+24798
+-19263
+-3738
+-37499
+-59308
+-2007
+-41845
+38393
+7711
+-33707
+-32842
+-44738
+32826
+37024
+65304
+-14125
+-27851
+-48637
+36205
+63572
+-23684
+6210
+42550
+27734
+48314
+29844
+-19662
+-28788
+-64323
+-4637
+46136
+3982
+-44419
+24480
+13339
+64843
+-31343
+-10499
+-43725
+19947
+-21765
+19006
+7857
+63580
+-27741
+-27101
+-17770
+46351
+-59976
+41448
+-23556
+59227
+-48283
+-30197
+-24611
+16612
+16820
+-21449
+-50527
+-11369
+17735
+12309
+55763
+55620
+14723
+-4102
+-3944
+35518
+62966
+7945
+-29718
+38234
+-32665
+43679
+-9847
+37847
+4771
+-35288
+-129
+56642
+22351
+9162
+-15531
+54629
+-519
+-64846
+-27401
+57295
+-21073
+-27609
+-37036
+-8096
+-15327
+-46131
+-49325
+10930
+-64800
+-32977
+51914
+-16083
+-46435
+-34490
+42957
+50601
+-64602
+11231
+15710
+57343
+6432
+-37953
+35591
+-25859
+14827
+33076
+35192
+-45781
+-52767
+-39836
+-14881
+-21424
+-31256
+6173
+-56492
+8370
+43018
+29744
+4559
+-59697
+17101
+-14077
+-4355
+-65493
+-9866
+-7237
+-655
+-5349
+15611
+-29410
+-30138
+51842
+-50559
+-18294
+27850
+21896
+-43885
+-47207
+-48443
+31917
+-48714
+50108
+40250
+25467
+-47066
+-38799
+-22892
+-52458
+50810
+36471
+-54452
+-49815
+28077
+31808
+-35541
+-47416
+-18905
+-24155
+-50190
+17082
+56852
+10771
+25981
+-62975
+-26480
+64570
+-37107
+-26649
+-22634
+-48564
+-48452
+-3203
+42311
+-62959
+-18630
+14016
+36973
+6914
+-48308
+61388
+-35877
+64248
+59969
+-32089
+28987
+-3061
+-61574
+52123
+-41901
+3873
+-55965
+-46518
+9620
+-56983
+14699
+-17332
+-53261
+46222
+-5278
+20562
+-47146
+60561
+-40878
+29951
+-46607
+-48546
+-5358
+-4562
+-3189
+10087
+62747
+-7138
+-34477
+172
+4202
+-15414
+59499
+61289
+1707
+-9350
+13749
+-3005
+-35717
+6143
+-40487
+53112
+58603
+-42851
+25731
+59940
+-841
+28054
+51201
+-63266
+62960
+42806
+-3191
+-23049
+54205
+-48913
+-5014
+2784
+-856
+26235
+11403
+20421
+-48705
+-44425
+52143
+39780
+-7260
+9918
+-28080
+34951
+-29804
+25860
+-1112
+53460
+22893
+-65332
+-65463
+-27754
+13114
+-54430
+56546
+-26618
+-19165
+-61205
+-42143
+287
+-33124
+-59369
+17929
+4214
+39384
+23644
+-17990
+27050
+-49451
+-3048
+17330
+34359
+-26145
+-65404
+38946
+7578
+-29226
+55146
+43430
+-5149
+-28260
+32518
+-32857
+-22820
+-17988
+50295
+35257
+-872
+18902
+-30442
+54485
+-61340
+48709
+-11223
+-10742
+-55336
+40152
+-47780
+24696
+-40796
+-32020
+9298
+39800
+-54739
+-11259
+29560
+54246
+-2822
+13980
+-42763
+-55347
+-21128
+-36473
+16153
+37382
+-64817
+-52953
+-16570
+39528
+-41098
+11957
+22586
+23030
+17391
+-1553
+-15779
+-39826
+20765
+-49683
+32729
+-28332
+-4463
+-32932
+14854
+-42146
+-46497
+-38878
+-45204
+62943
+15303
+29998
+-50255
+-15780
+-60922
+10985
+-52756
+14384
+55783
+9212
+36203
+34134
+-6834
+-41176
+-2208
+-18688
+-42220
+18520
+-27479
+43529
+-40301
+29097
+18475
+-1719
+-64136
+-7239
+-30720
+-19700
+-21191
+-44885
+56080
+18310
+-22197
+-40198
+51565
+24596
+-1797
+-54421
+-39578
+536
+-29526
+-9302
+34201
+-55592
+64881
+-40411
+19190
+-43893
+-44537
+5959
+16427
+51290
+-12164
+24344
+-49847
+18913
+22657
+41361
+-46565
+5290
+45334
+25359
+-22665
+-47053
+62163
+19251
+-65373
+27904
+12620
+36263
+-9969
+-39621
+48823
+-62503
+35934
+-31265
+-19249
+-40607
+-8083
+65363
+50889
+65161
+-51632
+32077
+19675
+-5592
+-5585
+-20883
+25617
+-24627
+8650
+23122
+-11773
+47914
+4916
+56343
+-17025
+-11197
+32286
+-618
+-25731
+63413
+58671
+48118
+24171
+62227
+37969
+-31881
+-9820
+-22414
+-14183
+37624
+61457
+-48960
+-10414
+-51385
+-2825
+-27868
+60048
+-12714
+-33027
+-6617
+60852
+6953
+-60228
+2598
+18638
+-6445
+-55557
+3796
+-30343
+20296
+63385
+-29113
+-23014
+-16874
+34406
+-17939
+-43236
+-14062
+-15897
+-62353
+-62007
+-15891
+48137
+-53265
+-15254
+4145
+63638
+25761
+33328
+-41544
+-14194
+-5139
+9871
+-32956
+9069
+-16789
+20281
+-51548
+5664
+43786
+-40648
+-40964
+21740
+-43844
+-6470
+53889
+19325
+-3119
+5439
+54104
+-41559
+-2410
+-2653
+-26741
+7342
+56359
+-11554
+64584
+-57306
+-46962
+15804
+-58150
+58603
+-53155
+4033
+20637
+40850
+13095
+21571
+156
+-4831
+62060
+-10458
+-9269
+51840
+53855
+-36770
+6891
+-41323
+23035
+-30616
+16909
+34730
+56613
+59336
+-49531
+-47125
+22993
+41040
+-56190
+-24831
+-13139
+30564
+19065
+-44885
+55532
+-30542
+-54813
+41351
+47571
+5832
+-23931
+51402
+35974
+-7420
+-52281
+5410
+-40045
+10457
+-14019
+39594
+10680
+-59428
+-61232
+37338
+-30103
+-4205
+-25599
+52717
+-10433
+31116
+-3716
+61461
+11151
+-12662
+42497
+54726
+54358
+32439
+-43192
+-60087
+5190
+-61173
+-14249
+-23530
+-31701
+4365
+-32875
+62620
+-37785
+-16448
+-9363
+48741
+5046
+2436
+41098
+-11710
+52002
+22225
+-7425
+-16255
+-43176
+-53141
+-30263
+53764
+10039
+33640
+-40110
+-41557
+24114
+19968
+63280
+48820
+25225
+-60353
+-9780
+-4225
+27377
+62231
+-30204
+-492
+-17641
+-5003
+-63575
+-30204
+1249
+28387
+-2665
+39698
+53520
+-25922
+12889
+-40375
+-33007
+-63324
+-1473
+8825
+-43107
+59193
+38629
+55008
+-42075
+-33733
+64406
+-27152
+40746
+-23717
+-22940
+48831
+-54496
+4710
+-3219
+23511
+-34148
+26981
+-31364
+24603
+-22995
+43805
+9554
+13424
+53476
+27467
+15164
+54781
+-55777
+-29047
+37607
+41143
+-39780
+-645
+38552
+-62962
+49207
+-36298
+-65114
+63264
+34159
+21920
+-32113
+30466
+-53845
+63043
+340
+-53316
+43697
+35266
+18972
+-36630
+-11596
+13867
+23912
+27420
+3175
+18017
+40166
+59742
+-40095
+-41124
+-46066
+-8460
+31426
+-34511
+-34411
+59749
+-56461
+14440
+-41935
+-34791
+-34146
+-61084
+28757
+56312
+-24374
+-60934
+65386
+46381
+59443
+46239
+32239
+-3205
+8784
+44379
+-45414
+-54260
+41641
+-53646
+3302
+59500
+-52094
+-1629
+9913
+19722
+-6582
+2856
+24922
+-42394
+-21778
+55315
+2082
+-3486
+-5006
+11261
+-59
+63094
+62257
+27850
+23493
+61539
+15377
+-32943
+-31182
+-59272
+-48395
+39249
+-18506
+-5538
+-24023
+-58111
+54108
+28367
+-63173
+42959
diff --git a/applications/lofar1/pft2/tb/data/zeros.sig b/applications/lofar1/pft2/tb/data/zeros.sig
new file mode 100644
index 0000000000000000000000000000000000000000..69e7556d8ed2e61110dd2b687941e7a1bfbf0a82
--- /dev/null
+++ b/applications/lofar1/pft2/tb/data/zeros.sig
@@ -0,0 +1,1024 @@
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
diff --git a/applications/lofar1/pft2/tb/vhdl/tb_pft2.vhd b/applications/lofar1/pft2/tb/vhdl/tb_pft2.vhd
index fe065916f283cd4bdb7fb8ec03238b1d9735ca63..639aec03827a49f61bf2058c75f959043e0e2cb7 100644
--- a/applications/lofar1/pft2/tb/vhdl/tb_pft2.vhd
+++ b/applications/lofar1/pft2/tb/vhdl/tb_pft2.vhd
@@ -19,132 +19,146 @@
 --
 -------------------------------------------------------------------------------
 
-LIBRARY IEEE, pft2_lib, tst_lib, common_lib;
+-- Usage:
+-- > as 3
+-- > run -a
+-- - View PFT in and out signals in Wave Window with decimal radix and in analog format:
+--   . Input: in_dat_x, in_dat_y
+--   . Output:
+--     - PFT_MODE_BITREV, PFT_MODE_COMPLEX: out_fft_re, out_fft_im
+--     - PFT_MODE_REAL2: out_x_re, out_x_im, out_y_re, out_y_im
+--   . Copy these signals in Wave Window to view them in both literal format and analog format
+-- - The tb works OK for all three PFT modes.
+
+LIBRARY IEEE, tst_lib, common_lib;
 USE IEEE.std_logic_1164.ALL;
 USE IEEE.numeric_std.ALL;
-USE pft2_lib.pft_pkg.ALL;
+USE work.pft_pkg.ALL;
 USE common_lib.common_pkg.ALL;
+USE common_lib.tb_common_pkg.ALL;
 
 ENTITY tb_pft2 IS
   GENERIC (
-    g_clk_period         : TIME    := 10 ns;
-    g_rst_period         : NATURAL := 20;
-    g_fft_size_w         : NATURAL := 10;
-    g_in_dat_w           : NATURAL := 18;
-    g_out_dat_w          : NATURAL := 18;
-    g_tst_data_dir       : STRING  := "data/"
+    -- The PFT has 3 modes:
+    -- . PFT_MODE_BITREV   --> DIT output
+    -- . PFT_MODE_COMPLEX  --> DIF output
+    -- . PFT_MODE_REAL2    --> DIT output of two real inputs (default for LOFAR)
+    --g_pft_mode : pft_mode_type := PFT_MODE_BITREV;
+    --g_pft_mode : pft_mode_type := PFT_MODE_COMPLEX;
+    g_pft_mode : pft_mode_type := PFT_MODE_REAL2;
+  
+    -- . For PFT_MODE_REAL2 select any signal pair for X and Y input.
+    -- . For PFT_MODE_BITREV and PFT_MODE_COMPLEX select zeros for Y input.
+  
+    -- Select one input signal for X (used as real input to the PFT)
+    --g_name_x   : STRING  := "cosin_N2";
+    --g_name_x   : STRING  := "cosin_1";
+    --g_name_x   : STRING  := "cosin_39";
+    --g_name_x   : STRING  := "sinus_1";
+    --g_name_x   : STRING  := "sinus_13";
+    --g_name_x   : STRING  := "sinus_13s";
+    --g_name_x   : STRING  := "impulse_0";
+    --g_name_x   : STRING  := "impulse_1";
+    --g_name_x   : STRING  := "zeros";
+    --g_name_x   : STRING  := "dc";
+    g_name_x   : STRING  := "block_1";
+    --g_name_x   : STRING  := "block_117";
+    --g_name_x   : STRING  := "u_noise";
+  
+    -- Select one input signal for Y (used as imag input to the PFT)
+    --g_name_y   : STRING  := "cosin_N2";
+    --g_name_y   : STRING  := "cosin_1";
+    --g_name_y   : STRING  := "cosin_39";
+    --g_name_y   : STRING  := "sinus_1";
+    --g_name_y   : STRING  := "sinus_13";
+    --g_name_y   : STRING  := "sinus_13s";
+    --g_name_y   : STRING  := "impulse_0";
+    --g_name_y   : STRING  := "impulse_1";
+    g_name_y   : STRING  := "zeros";  -- For PFT_MODE_BITREV and PFT_MODE_COMPLEX select zeros for Y input.
+    --g_name_y   : STRING  := "dc";
+    --g_name_y   : STRING  := "block_1";
+    --g_name_y   : STRING  := "block_117";
+    --g_name_y   : STRING  := "u_noise";
+    g_repeat   : NATURAL := 2  -- minimal 2 due to PFT latency
+    --g_repeat   : NATURAL := 10  -- > c_nof_block_per_sync to view multiple in_sync and out_sync intervals
   );
 END tb_pft2;
 
 ARCHITECTURE tb OF tb_pft2 IS
   
-  -- Usage:
-  -- - Typically run 50 us when c_repeat=2.
-  -- - The tb works OK for all three PFT modes.
-
-  CONSTANT c_repeat             : NATURAL := 2;  -- minimal 2 due to PFT latency
+  CONSTANT c_clk_period         : TIME    := 10 ns;
+  CONSTANT c_rst_period         : NATURAL := 20;
+  CONSTANT c_fft_size_w         : NATURAL := 10;
+  CONSTANT c_in_dat_w           : NATURAL := 18;
+  CONSTANT c_out_dat_w          : NATURAL := 18;
   
-  -- Maximum quantization error in PFT output
-  CONSTANT c_diff_max           : NATURAL := 10;  -- value per subband
-  --CONSTANT c_pdiff_max          : NATURAL := 5;  -- average power diff over all subbands from TC 5.19
-
-  -- The input stimuli signals are located in g_tst_data_dir and have been
+  CONSTANT c_nof_block_per_sync : NATURAL := 2;
+  
+  -- The input stimuli signals are located in c_tst_data_dir and have been
   -- generated with TC 5.2 and are used in the PFT continuous test TC 5.19.
+  CONSTANT c_tst_data_dir       : STRING  := "data/";
   
-  -- The PFT has 3 modes:
-  -- . PFT_MODE_BITREV   --> DIT output
-  -- . PFT_MODE_COMPLEX  --> DIF output
-  -- . PFT_MODE_REAL2    --> DIT output of two real inputs (default for LOFAR)
-  --CONSTANT c_pft_mode           : pft_mode_type := PFT_MODE_BITREV;
-  --CONSTANT c_pft_mode           : pft_mode_type := PFT_MODE_COMPLEX;
-  CONSTANT c_pft_mode           : pft_mode_type := PFT_MODE_REAL2;
-
-  -- . For PFT_MODE_REAL2 select any signal pair for X and Y input.
-  -- . For PFT_MODE_BITREV and PFT_MODE_COMPLEX select zeros for Y input.
-
-  -- Select one input signal for X (used as real input to the PFT)
---   CONSTANT c_name_x             : STRING  := "cosin_N2";
---   CONSTANT c_name_x             : STRING  := "cosin_1";
---   CONSTANT c_name_x             : STRING  := "cosin_39";
---   CONSTANT c_name_x             : STRING  := "sinus_1";
---   CONSTANT c_name_x             : STRING  := "sinus_13";
---   CONSTANT c_name_x             : STRING  := "sinus_13s";
-  CONSTANT c_name_x             : STRING  := "impulse_0";
---   CONSTANT c_name_x             : STRING  := "impulse_1";
---   CONSTANT c_name_x             : STRING  := "zeros";
---   CONSTANT c_name_x             : STRING  := "dc";
---   CONSTANT c_name_x             : STRING  := "block_1";
---   CONSTANT c_name_x             : STRING  := "block_117";
---   CONSTANT c_name_x             : STRING  := "u_noise";
+  -- Maximum quantization error in PFT output
+  CONSTANT c_diff_max           : NATURAL := 20;  -- Maximum quantization error in PFT output, as used in tc.tcl
+  --CONSTANT c_diff_max           : NATURAL := 10;  -- value per subband
+  --CONSTANT c_pdiff_max          : NATURAL := 5;  -- average power diff over all subbands from TC 5.19
 
-  -- Select one input signal for Y (used as imag input to the PFT)
---   CONSTANT c_name_y             : STRING  := "cosin_N2";
---   CONSTANT c_name_y             : STRING  := "cosin_1";
---   CONSTANT c_name_y             : STRING  := "cosin_39";
---   CONSTANT c_name_y             : STRING  := "sinus_1";
---   CONSTANT c_name_y             : STRING  := "sinus_13";
---   CONSTANT c_name_y             : STRING  := "sinus_13s";
---   CONSTANT c_name_y             : STRING  := "impulse_0";
-  CONSTANT c_name_y             : STRING  := "impulse_1";
---   CONSTANT c_name_y             : STRING  := "zeros";  -- For PFT_MODE_BITREV and PFT_MODE_COMPLEX select zeros for Y input.
---   CONSTANT c_name_y             : STRING  := "dc";
---   CONSTANT c_name_y             : STRING  := "block_1";
---   CONSTANT c_name_y             : STRING  := "block_117";
---   CONSTANT c_name_y             : STRING  := "u_noise";
-  
-  CONSTANT c_file_pft_in_x      : STRING  := g_tst_data_dir & c_name_x & ".sig";
-  CONSTANT c_file_pft_in_y      : STRING  := g_tst_data_dir & c_name_y & ".sig";
+  -- Input signal for X and Y (used as real and imag input to the PFT)
+  CONSTANT c_file_pft_in_x      : STRING  := c_tst_data_dir & g_name_x & ".sig";
+  CONSTANT c_file_pft_in_y      : STRING  := c_tst_data_dir & g_name_y & ".sig";
   
   -- The reference FFT ouput results have been generated with MATLAB.
-  CONSTANT c_file_pft_ref_x_re  : STRING  := g_tst_data_dir & c_name_x & ".re";
-  CONSTANT c_file_pft_ref_x_im  : STRING  := g_tst_data_dir & c_name_x & ".im";
-  CONSTANT c_file_pft_ref_y_re  : STRING  := g_tst_data_dir & c_name_y & ".re";
-  CONSTANT c_file_pft_ref_y_im  : STRING  := g_tst_data_dir & c_name_y & ".im";
+  CONSTANT c_file_pft_ref_x_re  : STRING  := c_tst_data_dir & g_name_x & ".re";
+  CONSTANT c_file_pft_ref_x_im  : STRING  := c_tst_data_dir & g_name_x & ".im";
+  CONSTANT c_file_pft_ref_y_re  : STRING  := c_tst_data_dir & g_name_y & ".re";
+  CONSTANT c_file_pft_ref_y_im  : STRING  := c_tst_data_dir & g_name_y & ".im";
   CONSTANT c_file_pft_dat_w     : NATURAL := 32;
   
-  CONSTANT c_fft_size           : NATURAL := 2**g_fft_size_w;
+  CONSTANT c_fft_size           : NATURAL := 2**c_fft_size_w;
   
   TYPE t_ref_dat       IS ARRAY (0 TO c_fft_size    ) OF INTEGER;  -- one extra dummy
   TYPE t_ref_fft_dat   IS ARRAY (0 TO c_fft_size-1)   OF INTEGER;  -- PFT_MODE_BITREV, PFT_MODE_COMPLEX scaled and rounded
   TYPE t_ref_real2_dat IS ARRAY (0 TO c_fft_size/2-1) OF INTEGER;  -- PFT_MODE_REAL2 scaled and rounded
 
   -- Signals
+  SIGNAL tb_end             : STD_LOGIC := '0';
   SIGNAL clk                : STD_LOGIC := '1';
   SIGNAL rst                : STD_LOGIC := '1';
+  SIGNAL rst_sync           : STD_LOGIC := '1';
 
   -- PFT input stimuli from file
   SIGNAL in_en              : STD_LOGIC;
   SIGNAL in_sync            : STD_LOGIC;
-  SIGNAL in_dat_x           : STD_LOGIC_VECTOR(g_in_dat_w-1 DOWNTO 0);
-  SIGNAL in_dat_y           : STD_LOGIC_VECTOR(g_in_dat_w-1 DOWNTO 0);
+  SIGNAL in_dat_x           : STD_LOGIC_VECTOR(c_in_dat_w-1 DOWNTO 0);
+  SIGNAL in_dat_y           : STD_LOGIC_VECTOR(c_in_dat_w-1 DOWNTO 0);
   SIGNAL in_val_x           : STD_LOGIC;
   SIGNAL in_val_y           : STD_LOGIC;
   SIGNAL in_val             : STD_LOGIC;
   
   -- PFT output
-  SIGNAL out_re             : STD_LOGIC_VECTOR(g_out_dat_w-1 DOWNTO 0);
-  SIGNAL out_im             : STD_LOGIC_VECTOR(g_out_dat_w-1 DOWNTO 0);
+  SIGNAL out_re             : STD_LOGIC_VECTOR(c_out_dat_w-1 DOWNTO 0);
+  SIGNAL out_im             : STD_LOGIC_VECTOR(c_out_dat_w-1 DOWNTO 0);
   SIGNAL out_val            : STD_LOGIC;
   SIGNAL toggle             : STD_LOGIC;
   SIGNAL nxt_toggle         : STD_LOGIC;
   SIGNAL toggle_dly         : STD_LOGIC;
-  SIGNAL out_re_dly         : STD_LOGIC_VECTOR(g_out_dat_w-1 DOWNTO 0);
-  SIGNAL out_im_dly         : STD_LOGIC_VECTOR(g_out_dat_w-1 DOWNTO 0);
+  SIGNAL out_re_dly         : STD_LOGIC_VECTOR(c_out_dat_w-1 DOWNTO 0);
+  SIGNAL out_im_dly         : STD_LOGIC_VECTOR(c_out_dat_w-1 DOWNTO 0);
   SIGNAL out_val_dly        : STD_LOGIC;
   -- For PFT_MODE_BITREV, PFT_MODE_COMPLEX
-  SIGNAL out_fft_re         : INTEGER;
   SIGNAL nxt_out_fft_re     : INTEGER;
-  SIGNAL out_fft_im         : INTEGER;
   SIGNAL nxt_out_fft_im     : INTEGER;
+  SIGNAL out_fft_re         : INTEGER;
+  SIGNAL out_fft_im         : INTEGER;
   -- For PFT_MODE_REAL2
-  SIGNAL out_x_re           : INTEGER;
   SIGNAL nxt_out_x_re       : INTEGER;
-  SIGNAL out_x_im           : INTEGER;
   SIGNAL nxt_out_x_im       : INTEGER;
-  SIGNAL out_y_re           : INTEGER;
   SIGNAL nxt_out_y_re       : INTEGER;
-  SIGNAL out_y_im           : INTEGER;
   SIGNAL nxt_out_y_im       : INTEGER;
+  SIGNAL out_x_re           : INTEGER := 0;  -- init at 0 to fit automatic analog scaling in Wave Window
+  SIGNAL out_x_im           : INTEGER := 0;  -- init at 0 to fit automatic analog scaling in Wave Window
+  SIGNAL out_y_re           : INTEGER := 0;  -- init at 0 to fit automatic analog scaling in Wave Window
+  SIGNAL out_y_im           : INTEGER := 0;  -- init at 0 to fit automatic analog scaling in Wave Window
   SIGNAL out_sync           : STD_LOGIC;
   
   -- Reference FFT output data from MATLAB generated files
@@ -220,7 +234,7 @@ ARCHITECTURE tb OF tb_pft2 IS
                             ref       : IN  t_ref_dat;
                             SIGNAL sr : OUT t_ref_fft_dat) IS
     CONSTANT N : NATURAL := c_fft_size;
-    CONSTANT w : NATURAL := g_fft_size_w;
+    CONSTANT w : NATURAL := c_fft_size_w;
     VARIABLE r : NATURAL;
   BEGIN
     IF en='1' THEN
@@ -287,13 +301,23 @@ ARCHITECTURE tb OF tb_pft2 IS
     
 BEGIN
 
-  rst <= '0' AFTER g_clk_period*g_rst_period;
+  p_tb_end : PROCESS
+  BEGIN
+    proc_common_wait_until_hi_lo(clk, out_val);  -- end of test
+    proc_common_wait_some_cycles(clk, 100);
+    tb_end <= '1';
+    WAIT;
+  END PROCESS;
+
+  rst <= '0' AFTER c_clk_period*c_rst_period;
     
-  clk <= NOT clk AFTER g_clk_period / 2;
-  
-  in_sync <= '0', '1' AFTER g_clk_period*g_rst_period*2, '0' AFTER g_clk_period*(g_rst_period*2+1);
-  in_en   <= '0', '1' AFTER g_clk_period*g_rst_period*2;
-  in_val  <= in_val_x;
+  clk <= (NOT clk) OR tb_end AFTER c_clk_period / 2;
+
+  in_en  <= '0', '1' AFTER c_clk_period*c_rst_period*2;
+  in_val <= in_val_x;
+
+  rst_sync <= '1', '0' AFTER c_clk_period*(c_rst_period*2 - 1);    -- start in_sync pulse interval 1 clk cycle before first in_val = '1'
+  proc_common_gen_pulse(1, c_nof_block_per_sync*c_fft_size, '1', rst_sync, clk, in_sync);
   
   
   -----------------------------------------------------------------------------
@@ -303,9 +327,9 @@ BEGIN
   u_in_x: ENTITY tst_lib.tst_input
   GENERIC MAP (
     g_file_name   => c_file_pft_in_x,
-    g_file_repeat => c_repeat,
+    g_file_repeat => g_repeat,
     g_nof_data    => 1,
-    g_data_width  => g_in_dat_w,
+    g_data_width  => c_in_dat_w,
     g_data_type   => "SIGNED"
   )
   PORT MAP (
@@ -319,9 +343,9 @@ BEGIN
   u_in_y: ENTITY tst_lib.tst_input
   GENERIC MAP (
     g_file_name   => c_file_pft_in_y,
-    g_file_repeat => c_repeat,
+    g_file_repeat => g_repeat,
     g_nof_data    => 1,
-    g_data_width  => g_in_dat_w,
+    g_data_width  => c_in_dat_w,
     g_data_type   => "SIGNED"
   )
   PORT MAP (
@@ -332,7 +356,7 @@ BEGIN
     out_val   => in_val_y
   );
 
-    
+
   -----------------------------------------------------------------------------
   -- Read expected Xre, Xim, Yre, Yim data
   -----------------------------------------------------------------------------
@@ -422,19 +446,19 @@ BEGIN
 
   -- Adapt the reference results to the PFT mode
   
-  gen_fft_bitrev : IF c_pft_mode=PFT_MODE_BITREV GENERATE
+  gen_fft_bitrev : IF g_pft_mode=PFT_MODE_BITREV GENERATE
     -- Support only real input test signal to the PFT, so imag input is zeros
     proc_fft_bitrev(ref_rdy, rd_dat_x_re, ref_fft_dat_re);
     proc_fft_bitrev(ref_rdy, rd_dat_x_im, ref_fft_dat_im);
   END GENERATE;
   
-  gen_fft_complex : IF c_pft_mode=PFT_MODE_COMPLEX GENERATE
+  gen_fft_complex : IF g_pft_mode=PFT_MODE_COMPLEX GENERATE
     -- Support only real input test signal to the PFT, so imag input is zeros
     proc_fft_complex(ref_rdy, rd_dat_x_re, ref_fft_dat_re);
     proc_fft_complex(ref_rdy, rd_dat_x_im, ref_fft_dat_im);
   END GENERATE;
   
-  gen_fft_real2 : IF c_pft_mode=PFT_MODE_REAL2 GENERATE
+  gen_fft_real2 : IF g_pft_mode=PFT_MODE_REAL2 GENERATE
     -- Scale and round the reference FFT outputs for the two real inputs X and Y
     proc_fft_real2_re(ref_rdy, rd_dat_x_re,              ref_real2_dat_x_re);
     proc_fft_real2_re(ref_rdy, rd_dat_y_re,              ref_real2_dat_y_re);
@@ -456,7 +480,7 @@ BEGIN
   END PROCESS;
   
   
-  gen_diff_fft : IF c_pft_mode=PFT_MODE_BITREV OR c_pft_mode=PFT_MODE_COMPLEX GENERATE
+  gen_diff_fft : IF g_pft_mode=PFT_MODE_BITREV OR g_pft_mode=PFT_MODE_COMPLEX GENERATE
     nxt_diff_cnt <= diff_cnt + 1 WHEN out_val_dly = '1' AND diff_cnt < c_fft_size-1 ELSE
                     0            WHEN out_val_dly = '1' AND diff_cnt = c_fft_size-1 ELSE
                     diff_cnt;
@@ -474,15 +498,15 @@ BEGIN
     p_report : PROCESS(diff_rdy)
     BEGIN
       IF diff_rdy='1' THEN
-        IF diff_max_fft_re <= c_diff_max THEN REPORT "FFT real output for re " & c_name_x & " and im " & c_name_y & " is OK"    SEVERITY NOTE;
-                                         ELSE REPORT "FFT real output for re " & c_name_x & " and im " & c_name_y & " is wrong" SEVERITY NOTE; END IF;
-        IF diff_max_fft_im <= c_diff_max THEN REPORT "FFT imag output for im " & c_name_x & " and im " & c_name_y & " is OK"    SEVERITY NOTE;
-                                         ELSE REPORT "FFT imag output for im " & c_name_x & " and im " & c_name_y & " is wrong" SEVERITY NOTE; END IF;
+        IF diff_max_fft_re <= c_diff_max THEN REPORT "FFT real output for re " & g_name_x & " and im " & g_name_y & " is OK"    SEVERITY NOTE;
+                                         ELSE REPORT "FFT real output for re " & g_name_x & " and im " & g_name_y & " is wrong" SEVERITY ERROR; END IF;
+        IF diff_max_fft_im <= c_diff_max THEN REPORT "FFT imag output for im " & g_name_x & " and im " & g_name_y & " is OK"    SEVERITY NOTE;
+                                         ELSE REPORT "FFT imag output for im " & g_name_x & " and im " & g_name_y & " is wrong" SEVERITY ERROR; END IF;
       END IF;
     END PROCESS;
   END GENERATE;
   
-  gen_diff_real2 : IF c_pft_mode=PFT_MODE_REAL2 GENERATE
+  gen_diff_real2 : IF g_pft_mode=PFT_MODE_REAL2 GENERATE
     nxt_diff_cnt <= diff_cnt + 1 WHEN out_val_dly = '1' AND toggle_dly='1' AND diff_cnt < c_fft_size/2-1 ELSE
                     0            WHEN out_val_dly = '1' AND toggle_dly='1' AND diff_cnt = c_fft_size/2-1 ELSE
                     diff_cnt;
@@ -498,40 +522,39 @@ BEGIN
     diff_max_y_re <= largest(abs(diff_y_re), diff_max_y_re);
     diff_max_y_im <= largest(abs(diff_y_im), diff_max_y_im);
     
-    ASSERT diff_max_x_re <= c_diff_max REPORT "FFT X re output differs to much from reference data" SEVERITY ERROR;
-    ASSERT diff_max_x_im <= c_diff_max REPORT "FFT X im output differs to much from reference data" SEVERITY ERROR;
-    ASSERT diff_max_y_re <= c_diff_max REPORT "FFT Y re output differs to much from reference data" SEVERITY ERROR;
-    ASSERT diff_max_y_im <= c_diff_max REPORT "FFT Y im output differs to much from reference data" SEVERITY ERROR;
+    ASSERT diff_max_x_re <= c_diff_max REPORT "FFT X re output differs too much from reference data" SEVERITY ERROR;
+    ASSERT diff_max_x_im <= c_diff_max REPORT "FFT X im output differs too much from reference data" SEVERITY ERROR;
+    ASSERT diff_max_y_re <= c_diff_max REPORT "FFT Y re output differs too much from reference data" SEVERITY ERROR;
+    ASSERT diff_max_y_im <= c_diff_max REPORT "FFT Y im output differs too much from reference data" SEVERITY ERROR;
     
     p_report : PROCESS(diff_rdy)
     BEGIN
       IF diff_rdy='1' THEN
-        IF diff_max_x_re <= c_diff_max THEN REPORT "FFT X real output for " & c_name_x & " is OK"    SEVERITY NOTE;
-                                       ELSE REPORT "FFT X real output for " & c_name_x & " is wrong" SEVERITY NOTE; END IF;
-        IF diff_max_x_im <= c_diff_max THEN REPORT "FFT X imag output for " & c_name_x & " is OK"    SEVERITY NOTE;
-                                       ELSE REPORT "FFT X imag output for " & c_name_x & " is wrong" SEVERITY NOTE; END IF;
-        IF diff_max_y_re <= c_diff_max THEN REPORT "FFT Y real output for " & c_name_y & " is OK"    SEVERITY NOTE;
-                                       ELSE REPORT "FFT Y real output for " & c_name_y & " is wrong" SEVERITY NOTE; END IF;
-        IF diff_max_y_im <= c_diff_max THEN REPORT "FFT Y imag output for " & c_name_y & " is OK"    SEVERITY NOTE;
-                                       ELSE REPORT "FFT Y imag output for " & c_name_y & " is wrong" SEVERITY NOTE; END IF;
+        IF diff_max_x_re <= c_diff_max THEN REPORT "FFT X real output for " & g_name_x & " is OK"    SEVERITY NOTE;
+                                       ELSE REPORT "FFT X real output for " & g_name_x & " is wrong" SEVERITY ERROR; END IF;
+        IF diff_max_x_im <= c_diff_max THEN REPORT "FFT X imag output for " & g_name_x & " is OK"    SEVERITY NOTE;
+                                       ELSE REPORT "FFT X imag output for " & g_name_x & " is wrong" SEVERITY ERROR; END IF;
+        IF diff_max_y_re <= c_diff_max THEN REPORT "FFT Y real output for " & g_name_y & " is OK"    SEVERITY NOTE;
+                                       ELSE REPORT "FFT Y real output for " & g_name_y & " is wrong" SEVERITY ERROR; END IF;
+        IF diff_max_y_im <= c_diff_max THEN REPORT "FFT Y imag output for " & g_name_y & " is OK"    SEVERITY NOTE;
+                                       ELSE REPORT "FFT Y imag output for " & g_name_y & " is wrong" SEVERITY ERROR; END IF;
       END IF;
     END PROCESS;
   END GENERATE;
   
   diff_val <= out_val_dly;  
   
-  
     
   -----------------------------------------------------------------------------
   -- PFT
   -----------------------------------------------------------------------------
   
-  u_pft : ENTITY pft2_lib.pft
+  u_pft : ENTITY work.pft
   GENERIC MAP (
-    g_fft_size_w   => g_fft_size_w,
-    g_in_dat_w     => g_in_dat_w,
-    g_out_dat_w    => g_out_dat_w,
-    g_mode         => c_pft_mode
+    g_fft_size_w   => c_fft_size_w,
+    g_in_dat_w     => c_in_dat_w,
+    g_out_dat_w    => c_out_dat_w,
+    g_mode         => g_pft_mode
   )
   PORT MAP (
     in_re          => in_dat_x,
@@ -567,12 +590,12 @@ BEGIN
   
   nxt_toggle <= '0' WHEN out_val='0' ELSE NOT toggle;
   
-  gen_out_fft : IF c_pft_mode=PFT_MODE_BITREV OR c_pft_mode=PFT_MODE_COMPLEX GENERATE
+  gen_out_fft : IF g_pft_mode=PFT_MODE_BITREV OR g_pft_mode=PFT_MODE_COMPLEX GENERATE
     nxt_out_fft_re <= 0 WHEN out_val='0' ELSE TO_INTEGER(SIGNED(out_re));
     nxt_out_fft_im <= 0 WHEN out_val='0' ELSE TO_INTEGER(SIGNED(out_im));
   END GENERATE;
   
-  gen_out_real2 : IF c_pft_mode=PFT_MODE_REAL2 GENERATE
+  gen_out_real2 : IF g_pft_mode=PFT_MODE_REAL2 GENERATE
     nxt_out_x_re <= 0 WHEN out_val='0' ELSE TO_INTEGER(SIGNED(out_re)) WHEN toggle='0' ELSE out_x_re;
     nxt_out_y_re <= 0 WHEN out_val='0' ELSE TO_INTEGER(SIGNED(out_re)) WHEN toggle='1' ELSE out_y_re;
     nxt_out_x_im <= 0 WHEN out_val='0' ELSE TO_INTEGER(SIGNED(out_im)) WHEN toggle='0' ELSE out_x_im;
diff --git a/applications/lofar1/pft2/tb/vhdl/tb_tb_pft2.vhd b/applications/lofar1/pft2/tb/vhdl/tb_tb_pft2.vhd
new file mode 100644
index 0000000000000000000000000000000000000000..398c87d757559208ec380a4c1a5a75a20b7604fa
--- /dev/null
+++ b/applications/lofar1/pft2/tb/vhdl/tb_tb_pft2.vhd
@@ -0,0 +1,103 @@
+-------------------------------------------------------------------------------
+--
+-- Copyright 2020
+-- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
+-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-------------------------------------------------------------------------------
+
+-------------------------------------------------------------------------------
+--
+-- Author: E. Kooistra
+-- Purpose: Multi testbench for pft2.vhd
+-- Description:
+
+LIBRARY IEEE;
+USE IEEE.std_logic_1164.ALL;
+
+ENTITY tb_tb_pft2 IS
+END tb_tb_pft2;
+USE work.pft_pkg.ALL;
+
+ARCHITECTURE tb OF tb_tb_pft2 IS
+  SIGNAL tb_end : STD_LOGIC := '0';  -- declare tb_end to avoid 'No objects found' error on 'when -label tb_end'
+BEGIN
+
+  -- The PFT has 3 modes:
+  -- . PFT_MODE_BITREV   --> DIT output
+  -- . PFT_MODE_COMPLEX  --> DIF output
+  -- . PFT_MODE_REAL2    --> DIT output of two real inputs (default for LOFAR)
+  --g_pft_mode : pft_mode_type := PFT_MODE_BITREV;
+  --g_pft_mode : pft_mode_type := PFT_MODE_COMPLEX;
+  --g_pft_mode : pft_mode_type := PFT_MODE_REAL2;
+  --
+  -- . For PFT_MODE_REAL2 select any signal pair for X and Y input.
+  -- . For PFT_MODE_BITREV and PFT_MODE_COMPLEX select zeros for Y input.
+  --
+  -- Select one input signal for X (used as real input to the PFT)
+  --g_name_x   : STRING  := "cosin_N2";
+  --g_name_x   : STRING  := "cosin_1";
+  --g_name_x   : STRING  := "cosin_39";
+  --g_name_x   : STRING  := "sinus_1";
+  --g_name_x   : STRING  := "sinus_13";
+  --g_name_x   : STRING  := "sinus_13s";
+  --g_name_x   : STRING  := "impulse_0";
+  --g_name_x   : STRING  := "impulse_1";
+  --g_name_x   : STRING  := "zeros";
+  --g_name_x   : STRING  := "dc";
+  --g_name_x   : STRING  := "block_1";
+  --g_name_x   : STRING  := "block_117";
+  --g_name_x   : STRING  := "u_noise";
+  --
+  -- Select one input signal for Y (used as imag input to the PFT)
+  --g_name_y   : STRING  := "cosin_N2"
+  --g_name_y   : STRING  := "cosin_1"
+  --g_name_y   : STRING  := "cosin_39"
+  --g_name_y   : STRING  := "sinus_1"
+  --g_name_y   : STRING  := "sinus_13"
+  --g_name_y   : STRING  := "sinus_13s"
+  --g_name_y   : STRING  := "impulse_0"
+  --g_name_y   : STRING  := "impulse_1"
+  --g_name_y   : STRING  := "zeros"  -- For PFT_MODE_BITREV and PFT_MODE_COMPLEX select zeros for Y input.
+  --g_name_y   : STRING  := "dc"
+  --g_name_y   : STRING  := "block_1"
+  --g_name_y   : STRING  := "block_117"
+  --g_name_y   : STRING  := "u_noise"
+  --
+  --g_repeat   : NATURAL := 2  -- minimal 2 due to PFT latency
+  --g_repeat   : NATURAL := 10  -- > c_nof_block_per_sync to view multiple in_sync and out_sync intervals
+    
+  u_cosin_N2  : ENTITY work.tb_pft2 GENERIC MAP(PFT_MODE_REAL2, "cosin_N2" , "zeros", 2);
+  u_cosin_1   : ENTITY work.tb_pft2 GENERIC MAP(PFT_MODE_REAL2, "cosin_1"  , "zeros", 2);
+  u_cosin_39  : ENTITY work.tb_pft2 GENERIC MAP(PFT_MODE_REAL2, "cosin_39" , "zeros", 2);
+  u_sinus_1   : ENTITY work.tb_pft2 GENERIC MAP(PFT_MODE_REAL2, "sinus_1"  , "zeros", 2);
+  u_sinus_13  : ENTITY work.tb_pft2 GENERIC MAP(PFT_MODE_REAL2, "sinus_13" , "zeros", 2);
+  u_sinus_13s : ENTITY work.tb_pft2 GENERIC MAP(PFT_MODE_REAL2, "sinus_13s", "zeros", 2);
+  u_impulse_0 : ENTITY work.tb_pft2 GENERIC MAP(PFT_MODE_REAL2, "impulse_0", "zeros", 2);
+  u_impulse_1 : ENTITY work.tb_pft2 GENERIC MAP(PFT_MODE_REAL2, "impulse_1", "zeros", 2);
+  u_zeros     : ENTITY work.tb_pft2 GENERIC MAP(PFT_MODE_REAL2, "zeros"    , "zeros", 2);
+  u_dc        : ENTITY work.tb_pft2 GENERIC MAP(PFT_MODE_REAL2, "dc"       , "zeros", 2);
+  u_block_1   : ENTITY work.tb_pft2 GENERIC MAP(PFT_MODE_REAL2, "block_1"  , "zeros", 2);
+  u_block_117 : ENTITY work.tb_pft2 GENERIC MAP(PFT_MODE_REAL2, "block_117", "zeros", 2);
+  u_u_noise   : ENTITY work.tb_pft2 GENERIC MAP(PFT_MODE_REAL2, "u_noise"  , "zeros", 2);
+
+  u_impulse_0_impulse_1 : ENTITY work.tb_pft2 GENERIC MAP(PFT_MODE_REAL2, "impulse_0", "impulse_1", 2);
+  u_dc_cosin_N2         : ENTITY work.tb_pft2 GENERIC MAP(PFT_MODE_REAL2,        "dc",  "cosin_N2", 2);
+  u_dc_sinus_13         : ENTITY work.tb_pft2 GENERIC MAP(PFT_MODE_REAL2,        "dc",  "sinus_13", 2);
+  u_block_117_u_noise   : ENTITY work.tb_pft2 GENERIC MAP(PFT_MODE_REAL2, "block_117",   "u_noise", 2);
+  u_u_noise_u_noise     : ENTITY work.tb_pft2 GENERIC MAP(PFT_MODE_REAL2,   "u_noise",   "u_noise", 2);
+
+
+END tb;
diff --git a/applications/lofar1/readme_lofar1.txt b/applications/lofar1/readme_lofar1.txt
new file mode 100644
index 0000000000000000000000000000000000000000..64324e75cfc400b87c2aa9d802f1f1b52ca35611
--- /dev/null
+++ b/applications/lofar1/readme_lofar1.txt
@@ -0,0 +1,103 @@
+-------------------------------------------------------------------------------
+--
+-- Copyright 2020
+-- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
+-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-------------------------------------------------------------------------------
+--
+-- Author: E. Kooistra
+
+This readme describes how the PFB (= pfs + pft2) code of LOFAR1/RSP was ported to git for LOFAR2
+
+Contents
+1) Comparison of LOFAR1 and APERTIF polyphase filterbank (PFB)
+2) Porting LOFAR1 PFB code to LOFAR2.0
+  a) pfs
+  b) pft2
+  c) Simulating tb/vhdl/tb_pft2.vhd
+3) Create pfb2_unit.vhd that can replace wpfb_unit_dev.vhd
+
+
+References:
+[1] LOFAR1 RSP firmware SVN repository https://svn.astron.nl/Station/trunk/RSP/
+[2] LOFAR1 pft2 reference files https://svn.astron.nl/Station/trunk/RSP/rsp/tb/tc/5.%20Datapath/5.2%20PFT/
+[3] LOFAR1 firmware ported to LOFAR2.0 GIT repository https://git.astron.nl/desp/hdl/-/tree/master/applications/lofar1
+[4] APERTIF DSP firmware (rTwoSDF, filter, fft, wpfb) in LOFAR2.0 GIT repository https://git.astron.nl/desp/hdl/-/tree/master/libraries/dsp
+[5] APERTIF PFB MATLAB code in APERTIF firmware SVN repository https://svn.astron.nl/UniBoard_FP7/RadioHDL/trunk/applications/apertif/matlab/apertif_matlab_readme.txt
+
+
+
+1) Comparison of LOFAR1 and APERTIF polyphase filterbank (PFB)
+- Advantages of LOFAR1 PFB (= pfs + pft2) are:
+  . used in LOFAR1
+  . pft2 uses multipliers 100% whereas fft_r2_pipe in wpfb_unit_dev achieves 50%
+  . pft2 has pft_switch to decorrelate the fft_separate crosstalk between the two real signal inputs
+- Advantages of Apertif PFB (= wpfb_unit_dev) are:
+  . used in APERTIF
+  . already available in LOFAR2.0 SDP
+
+
+  
+2) Porting LOFAR1 PFB code to LOFAR2.0
+- Porting from [1] to [3]
+
+a) pfs
+  * hdllib.cfg : copy simulation files to data/
+  * src/vhdl/
+    - pfs_coefsbuf(str).vhd :
+      . use c_coefs_rom : t_c_mem for common_rom from common_lib.
+      . use g_init_file => "data/pfs_coefsbuf_1024.hex"
+    - pfs_filter(rtl).vhd : use ported common_mult_add.vhd from common_mult_lib
+  * tb/vhdl/tb_pfs.vhd : ==> simulates OK
+    . added usage comment
+    
+b) pft2
+  * hdllib.cfg : copy simulation files to data/
+  * src/vhdl/
+    - pft_bf(rtl).vhd :
+      . use common_complex_add_sub from common_lib instead of common_caddsub
+      . use common_fifo_sc from common_lib
+    - pft_bf_fw(rtl).vhd : use common_add_sub from common_lib instead of common_caddsub
+    - pft_buffer(rtl).vhd : use common_ram_r_w from common_lib instead of common_dpram
+    - pft_separate(rtl).vhd : use common_add_sub from common_lib instead of common_caddsub
+    - pft_stage(str).vhd : use common_complex_round from common_lib instead of common_cround
+    - pft_tmult(rtl).vhd :
+      . use c_twid_file = "data/twiddle_" & NATURAL'IMAGE(c_coeff_w) & "_" & NATURAL'IMAGE(g_index) & ".hex"
+      . use c_twid_rom : t_c_mem for common_rom from common_lib.
+      . use common_complex_round from common_lib instead of common_cround
+      . use common_complex_mult from common_lib instead of common_cmult
+    - pft_top(str).vhd : removed option c_use_coregen_pfft
+  * tb/data
+    . copied stimuli and expected results files from [2] to data/,
+      the tc.tcl can create *.sig files that tc.m can use to created expected *.re and *.im files
+  * tb/vhdl/tb_pft2.vhd : ==> compiles OK, input *.sig files not recreated yet.
+    . g_tst_data_dir = "data/"
+
+c) Simulating tb/vhdl/tb_pft2.vhd
+  * Derived tc_sig.tcl from tc.tcl and copied constants.tcl and wg.tcl to tcl/ to generate the *sig files
+  * Made tb_pft2.vhd self stopping and changed generics to g_pft_mode, g_name_x, g_name_y
+  * Added multi tb_tb_pft2.vhd to verify ptf2 with all available *sig files.
+  ==> tb_tb_pft2.vhd simulates OK using c_diff_max = 20 like in data/tc.tcl
+
+  
+  
+3) Create pfb2_unit.vhd that can replace wpfb_unit_dev.vhd
+  * pfb2.vhd = pfs + pft2
+  * pfb2_unit.vhd = multiple instances of pfb2 + sst, similar as wpfb_unit_dev.vhd for wideband factor wb = 1.
+
+
+
+
diff --git a/applications/lofar1/tcl/constants.tcl b/applications/lofar1/tcl/constants.tcl
new file mode 100644
index 0000000000000000000000000000000000000000..71bd31f525672f95874ae8b40fef166f92ddc5c3
--- /dev/null
+++ b/applications/lofar1/tcl/constants.tcl
@@ -0,0 +1,297 @@
+#
+# From common(pkg).vhd
+#
+set c_complex                     2          ;# factor 2 accounting for Re part and Im part of complex number
+set c_cpx                         $c_complex
+set c_phs                         $c_complex
+set c_pol                         2          ;# factor 2 accounting for X and Y polarization
+set c_pol_phs                     4          ;# factor 4 accounting for dual polarization and complex
+
+set c_long                        4          ;# factor 4 accounting for 4 bytes
+
+set c_rcu_version                 1          ;# ctrlreg[23:20] = "0001" in RCU i2cslave(rtl).vhd
+
+set c_rsp_ext_clk_freq            200000000
+set c_rsp_rcu_clk_freq            $c_rsp_ext_clk_freq
+set c_rsp_ext_sync_idelay         0
+set c_rsp_rcu_clock_idelay        0
+
+set c_rsp_nof_bp                  1
+set c_rsp_nof_ap                  4
+set c_rsp_nof_blp_per_ap          1
+set c_rsp_nof_blp                 [expr $c_rsp_nof_ap*$c_rsp_nof_blp_per_ap]
+
+set c_rsp_nof_rcu_per_ap          $c_pol                                      ;# = 2, nof RCU per AP (and 1 BLP per AP)
+set c_rsp_nof_rcu                 [expr $c_rsp_nof_ap*$c_rsp_nof_rcu_per_ap]  ;# = 8, nof RCU per RSP (and 1 BLP per AP)
+set c_rsp_nof_sp                  $c_rsp_nof_rcu;                             ;# = 8, nof signal paths (SP) per RSP (each RCU receives one SP)
+  
+set c_rsp_nof_subbands          512
+set c_rsp_slice_size              [expr $c_complex*$c_rsp_nof_subbands]       ;# = 1024
+
+set c_rsp_nof_lanes                   4
+set c_rsp_nof_beamlets              248
+set c_rsp_nof_beamlets_per_lane       [expr $c_rsp_nof_beamlets/$c_rsp_nof_lanes]
+set c_rsp_nof_antennas               96
+set c_rsp_nof_crosslets_per_antenna   1
+set c_rsp_nof_crosslets               [expr $c_rsp_nof_crosslets_per_antenna*$c_rsp_nof_antennas]
+set c_rsp_nof_crosslets_per_lane      [expr $c_rsp_nof_crosslets/$c_rsp_nof_lanes]
+set c_rsp_nof_reflets                 $c_rsp_nof_crosslets_per_antenna
+set c_rsp_nof_reflets_ap              [expr $c_rsp_nof_crosslets_per_antenna*$c_rsp_nof_ap]
+set c_rsp_nof_beamlets_ap             [expr $c_rsp_nof_reflets_ap+$c_rsp_nof_beamlets]
+set c_rsp_nof_let_types               2
+
+set c_rsp_rcu_dat_w              12
+set c_blp_out_dat_w              18
+
+set c_rsp_sst_acc_w              54
+set c_rsp_bst_acc_w              54
+set c_rsp_xst_acc_w              54
+
+set c_diag_reg_wave_dat_w        18
+set c_diag_reg_wave_size_small_w 11
+set c_diag_wave_factor            2
+set c_diag_wave_size              [expr $c_diag_wave_factor*$c_rsp_slice_size]  ;# = 2**c_diag_reg_wave_size_small_w
+
+set c_diag_reg_res_word_w         4
+set c_diag_reg_res_size           [expr $c_rsp_nof_beamlets_ap*$c_pol_phs]
+
+set c_bf_reg_coef_w              16
+set c_rsp_beam_data_dat_w        24
+
+set c_rsp_ring_dat_w             14
+
+set c_tdsh_protocol_adr_w        11
+set c_tdsh_result_adr_w          10
+set c_rcuh_protocol_adr_w         9
+set c_rcuh_result_adr_w           9
+
+set c_rad_nof_rx_latency          [expr 1+$c_rsp_nof_let_types*$c_rsp_nof_lanes]                   ;# = 1 + 2*4     = 9
+set c_rad_nof_rx_status           [expr 1+$c_rsp_nof_let_types*$c_rsp_nof_lanes+$c_rsp_nof_lanes]  ;# = 1 + 2*4 + 4 = 13
+
+set c_ei_status_rsp_tvolt_offset  0
+set c_ei_status_rsp_tvolt_size    9
+set c_ei_status_rsp_clk_offset    [expr $c_ei_status_rsp_tvolt_offset +                $c_ei_status_rsp_tvolt_size]
+set c_ei_status_rsp_clk_size      1
+set c_ei_status_rsp_offset        0 ;# = $c_ei_status_rsp_tvolt_offset
+set c_ei_status_rsp_size         12 ;# = $c_ei_status_rsp_tvolt_size + $c_ei_status_rsp_clk_size rounded to factor of 4
+set c_ei_status_eth_offset        [expr $c_ei_status_rsp_offset       +                $c_ei_status_rsp_size]
+set c_ei_status_eth_size         12
+set c_ei_status_mep_offset        [expr $c_ei_status_eth_offset       +                $c_ei_status_eth_size]
+set c_ei_status_mep_size          4
+set c_ei_status_diag_offset       [expr $c_ei_status_mep_offset       +                $c_ei_status_mep_size]
+set c_ei_status_diag_size        24
+set c_ei_status_bs_offset         [expr $c_ei_status_diag_offset      +                $c_ei_status_diag_size]
+set c_ei_status_bs_size          16 ;# For each AP
+set c_ei_status_rcuh_offset       [expr $c_ei_status_bs_offset        + $c_rsp_nof_blp*$c_ei_status_bs_size]
+set c_ei_status_rcuh_size        12 ;# For each AP
+set c_ei_status_rsu_offset        [expr $c_ei_status_rcuh_offset      + $c_rsp_nof_blp*$c_ei_status_rcuh_size]
+set c_ei_status_rsu_size          4
+set c_ei_status_ado_offset        [expr $c_ei_status_rsu_offset       +                $c_ei_status_rsu_size]
+set c_ei_status_ado_size          8
+set c_ei_status_rad_offset        [expr $c_ei_status_ado_offset       + $c_rsp_nof_blp*$c_ei_status_ado_size]
+set c_ei_status_rad_size          4 ;# For each link
+set c_ei_status_rcuh_test_offset  [expr $c_ei_status_rad_offset       + $c_rad_nof_rx_status *$c_ei_status_rad_size]
+set c_ei_status_rcuh_test_size    4 ;# For each AP
+set c_ei_status_rsr_offset        0 ;# = $c_ei_status_rsp_tvolt_offset
+set c_ei_status_rsr_size          [expr $c_ei_status_rcuh_test_offset + $c_rsp_nof_blp*$c_ei_status_rcuh_test_size]
+
+set c_ei_eth_err_noerr            0
+set c_ei_eth_err_preamblevalue    1
+set c_ei_eth_err_framedelimiter   2
+set c_ei_eth_err_preamblelength   3
+set c_ei_eth_err_headerlength     4
+set c_ei_eth_err_crc              5
+set c_ei_eth_err_oddnibblelength  6
+set c_ei_eth_err_framelength      7
+
+set c_ei_mep_err_noerr            0
+set c_ei_mep_err_type             1
+set c_ei_mep_err_addr_blp         2
+set c_ei_mep_err_pid              3
+set c_ei_mep_err_regid            4
+set c_ei_mep_err_offset           5
+set c_ei_mep_err_size             6
+set c_ei_mep_err_ringcrc          7
+set c_ei_mep_err_timeout          8
+
+#
+# CEP data output Ethernet frame constants
+#
+
+set c_eth_preamble_len            8     ;# ETH preamble (8 octets)
+set c_eth_header_len             14     ;# ETH header (14 octets)
+set c_ip_header_len              28     ;# IP header (28 octets)
+set c_epa_header_len             16     ;# EPA header (16 octets)
+set c_phy_header_len              [expr $c_eth_preamble_len + $c_eth_header_len]
+set c_cdo_header_len              [expr $c_ip_header_len + $c_epa_header_len]
+set c_cep_header_len              [expr $c_phy_header_len + $c_cdo_header_len]
+set c_cep_nof_octets              2     ;# two octets per beamlet data halfword to CEP
+  
+#
+# SDO = Subband Data Output constants from common(pkg) and sdo_pkg, see also description in sdo_frame.vhd.
+#
+set c_ss_sel_zero                      [expr 0x8000]
+
+set c_rsp_sdo_nof_subbands            36      ;# Number of SDO subbands per SP
+set c_rsp_sdo_nof_subbands_per_lane    [expr $c_rsp_sdo_nof_subbands/$c_rsp_nof_lanes]
+
+# Define 4 dat (real) = 2 bands (complex) ^= 1 let (dual pol and complex)
+set c_sdo_ss_nof_subbands_ap           [expr $c_rsp_sdo_nof_subbands*$c_pol]         ;# = 72
+set c_sdo_ss_nof_subbands_rsp          [expr $c_rsp_sdo_nof_subbands*$c_rsp_nof_sp]  ;# = 288
+set c_sdo_ss_nof_bands               316      ;# = c_sdo_len_ap_frame_payload/c_rsp_nof_pol
+
+
+#
+# Derived constants
+#
+
+# - Calculate ADO scale factor based on word widths in ado(rtl).vhd and nof samples per sync interval for 200 MHz
+set dat_in_w    $c_rsp_rcu_dat_w
+set nof_acc_w   [expr ceil(log($c_rsp_rcu_clk_freq)/log(2))]
+set result_w    32
+set acc_w       [expr $dat_in_w + $nof_acc_w]
+set c_ado_scale [expr round(pow(2, $acc_w - $result_w))]
+
+#
+# RSR status
+#
+set c_rsr_ok         0
+set c_rsr_error      1
+set c_rsr_undefined  2
+
+set c_cp_bp              1
+set c_cp_statusRdy       0
+set c_cp_statusVersion0  1
+set c_cp_statusFpgaType  2
+set c_cp_statusImageType 3
+set c_cp_statusTrigLo    4
+set c_cp_statusTrigHi    6
+set c_cp_statusVersion1  7
+set c_cp_version_w       2
+set c_cp_trig_w          [expr $c_cp_statusTrigHi-$c_cp_statusTrigLo+1]
+set c_cp_trig_mask       [expr (1 << $c_cp_trig_w) - 1]
+set c_cp_trig_ButtonRst  0
+set c_cp_trig_TempRst    1
+set c_cp_trig_UserRst    2
+set c_cp_trig_WdRst      4
+
+
+#
+# From diag(pkg).vhd
+#
+set c_diag_dev_ri            0
+set c_diag_dev_rcux          1
+set c_diag_dev_rcuy          2
+set c_diag_dev_lcu           3
+set c_diag_dev_cep           4
+set c_diag_dev_serdes        5
+
+set c_diag_mode_no_tst           0
+set c_diag_mode_loop_local       1
+set c_diag_mode_loop_line        2
+set c_diag_mode_loop_remote      3
+set c_diag_mode_tx               4
+set c_diag_mode_rx               5
+set c_diag_mode_tx_rx            6
+# RI specific modes
+set c_diag_mode_bus              $c_diag_mode_tx_rx
+set c_diag_mode_lane_all         7
+set c_diag_mode_lane_single      8
+# Serdes specific loopback mode variants
+set c_diag_mode_loop_sys_diag    9
+set c_diag_mode_loop_par_diag    $c_diag_mode_loop_local
+set c_diag_mode_loop_serial     10
+set c_diag_mode_loop_metal_line  $c_diag_mode_loop_line
+set c_diag_mode_loop_par_line   11
+
+set c_diag_duration_debug    0
+set c_diag_duration_quick    1
+set c_diag_duration_normal   2
+set c_diag_duration_extra    3
+
+set c_diag_res_ok            0
+set c_diag_res_none          1
+set c_diag_res_sync_timeout  2
+set c_diag_res_data_timeout  3
+set c_diag_res_word_err      4
+set c_diag_res_illegal       5
+
+#
+# RCU I2C bus
+#
+set c_rcuh_i2c_addr_rcu      1
+set c_rcuh_i2c_addr_hba      2
+
+# I2C handler time resolution
+set c_msec                   [expr round(200e6 * 1e-3)]
+
+#
+# HBA control
+#
+#   In the client the registers are stored in order: SPEED, TBM, LED, DUMMY, VREF, STAT.
+#   - TBM = measured bit time
+#   - STAT = bit 0 contains the comparator state: 0 is high line input level, 1 for low line input level
+#   Reading 2 bytes from the SPEED register yields SPEED and TBM. Similar reading 2 bytes from VREF yields
+#   VREF and STAT. In fact note that reading 6 bytes from SPEED yields them all.
+#
+#   In the server the measured bit time is also stored after YDELAY, so via get word from c_hba_sreg_ydelay
+#   one gets ydelay and the measured bit time.
+#
+set c_hba_nof_servers      16       ;# HBA nof servers
+
+set c_hba_cmd_request       0       ;# HBA client REQUEST register
+set c_hba_cmd_response      1       ;# HBA client RESPONSE register
+set c_hba_cmd_led           2       ;# HBA client LED register
+set c_hba_cmd_vref        124       ;# HBA client VREF register
+set c_hba_cmd_speed       125       ;# HBA client SPEED register
+set c_hba_cmd_version     126       ;# HBA client VERSION register
+set c_hba_reg_request_sz   38       ;# register size in octets
+set c_hba_reg_response_sz   4
+set c_hba_reg_led_sz        1
+set c_hba_reg_vref_sz       1
+set c_hba_reg_speed_sz      1
+set c_hba_reg_version_sz    1
+
+set c_hba_f_set_byte        2       ;# HBA server function codes
+set c_hba_f_get_byte        3
+set c_hba_f_set_word        4
+set c_hba_f_get_word        5
+set c_hba_bc_server         0       ;# HBA server broadcast address
+set c_hba_sreg_xdelay       0       ;# HBA server xdelay register address
+set c_hba_sreg_ydelay       1       ;# HBA server ydelay register address
+set c_hba_sreg_version    254       ;# HBA server version register address
+set c_hba_sreg_address    255       ;# HBA server address register address
+
+# - Modem time (modem speed = 40 = 10 kbps, modem prescaler = 1): 
+#   . Broadcast request: 38 msec seems minimum for set_word broadcast 16 servers
+#   . Unicast request  : 11 msec seems minimum for set_word or get word
+# - For modem prescaler = 2 the uc_wait = 20 just works at modem speed = 40 = 5.5 kbps,
+#   hence to be safe double the wait times.
+# - Use hba_gap_wait as minimal wait after every I2C access to the client, before issueing a new I2C access
+set hba_prescaler  1
+set hba_prescaler  2
+set hba_bc_wait   [expr 40*$hba_prescaler]      ;# used with PROTOCOL_C_WAIT and WG_WAIT
+set hba_uc_wait   [expr 16*$hba_prescaler]      ;# used with PROTOCOL_C_WAIT and WG_WAIT
+set hba_gap_wait   2                            ;# used with PROTOCOL_C_WAIT and WG_WAIT
+set hba_bc_i2c    40       ;# used with WG_WAIT, I2C signalling time +30 is enough at 200 M
+set hba_uc_i2c    25       ;# used with WG_WAIT, I2C signalling time +20 is enough at 200 M
+set hba_reg_i2c    5       ;# used with WG_WAIT, I2C signalling time  +4 is enough at 50 kbps and 327 us comma per byte,
+                           ;# so addr, cmd, 4 bytes = 6 bytes * 9 = 54 bits @ 50 kbps = 1.1 ms, 6 bytes * 327 us = 1.9 ms
+
+set c_hba_vref_default   [expr 0xEC]  ;# Reference default mid level setting
+set c_hba_speed_default  40
+ 
+#
+# TDS timing distribution clock board
+#
+set c_tds_clksel_10MHz_sma     1
+set c_tds_clksel_10MHz_infini  [expr !$c_tds_clksel_10MHz_sma]
+set c_tds_clksel_160MHz        0
+set c_tds_clksel_200MHz        [expr !$c_tds_clksel_160MHz]
+set c_tds_clksel_pps_sma       0
+set c_tds_clksel_pps_infini    [expr !$c_tds_clksel_pps_sma]
+
+#
+# From tb_rsp.vhd
+#
+set c_sim_nof_slices_psync   20
diff --git a/applications/lofar1/tcl/wg.tcl b/applications/lofar1/tcl/wg.tcl
new file mode 100644
index 0000000000000000000000000000000000000000..ee24e3fcfabc3d2494b1781dc6e3119a1000290c
--- /dev/null
+++ b/applications/lofar1/tcl/wg.tcl
@@ -0,0 +1,3719 @@
+###############################################################################
+#
+# Copyright (C) 2012
+# ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
+# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+###############################################################################
+
+###############################################################################
+#
+# Procedures for generating test cases
+#
+# - wg_i2bb
+# - wg_i2bbbb
+#
+# - wg_wait_for_interrupt
+#
+# - wg_overwrite_rsr
+# - wg_read_rsr
+# - wg_write_rsr_timestamp
+# - wg_read_rsr_timestamp
+# - wg_write_rsr_beam_mode_settings
+# - wg_read_rsr_beam_mode_settings
+# - wg_write_rsr_sdo_mode_settings
+# - wg_read_rsr_sdo_mode_settings
+#
+# - wg_write_cr_softclear
+# - wg_write_cr_softsync
+# - wg_write_cr_sync_on
+# - wg_write_cr_sync_off
+# - wg_read_cr_sync_off
+# - wg_write_cr_sync_delay
+# - wg_read_cr_sync_delay
+#
+# - wg_write_serdes_rx_delay
+# - wg_write_serdes_tx_delay
+# - wg_read_serdes_rx_delay
+# - wg_read_serdes_tx_delay
+#
+# - wg_write_rsu_altsync
+#
+# - wg_write_rd_smbh_protocol_list
+# - wg_overwrite_rd_smbh_protocol_results
+#
+# - wg_write_rcuh_settings
+# - wg_read_rcuh_settings
+# - wg_write_rcuh_settings_test
+# - wg_read_rcuh_settings_test
+# - wg_write_rcuh_clock_control
+# - wg_read_rcuh_clock_control
+# - wg_write_rcuh_control_list
+# - wg_read_rcuh_control_result
+#
+# - wg_write_tbbi_settings
+# - wg_read_tbbi_settings
+# - wg_write_tbbi_bandsel
+# - wg_read_tbbi_bandsel
+# - wg_write_tbbi_test
+# - wg_read_tbbi_test
+#
+# - wg_write_diag_bypass
+# - wg_read_diag_bypass
+# - wg_setup_diag_waveform_generator
+# - wg_read_diag_waveform_generator
+# - wg_write_diag_waveform
+# - wg_read_diag_waveform
+# - wg_read_diag_result_buffer
+#
+# - wg_write_bs_nof_samples_psync
+# - wg_read_bs_nof_samples_psync
+#
+# - wg_write_ss
+# - wg_read_ss
+# - wg_write_sdo_ss
+# - wg_read_sdo_ss
+#
+# - wg_write_bf
+# - wg_read_bf
+#
+# - wg_overwrite_subband_power_statistics
+# - wg_read_subband_power_statistics
+# - wg_read_beamlet_power_statistics
+# - wg_read_crosslet_power_statistics
+#
+# - wg_write_rad_settings
+# - wg_read_rad_settings
+# - wg_read_rad_latency
+#
+# - wg_write_cdo_settings
+# - wg_read_cdo_settings
+# - wg_write_cdo_transport_header
+# - wg_read_cdo_transport_header
+#
+# - wg_adc
+# - wg_calculate_analogue_waveform
+# - wg_calculate_next_sequence_value
+#
+# - wg_sdo_ss_generate_map
+#
+# - wg_write_file
+# - wg_read_file
+#
+# - wg_flip
+# - wg_transpose
+#
+# - wg_clip
+# - wg_wrap
+# - wg_round
+# - wg_truncate
+#
+# - wg_wait
+#
+###############################################################################
+
+
+###############################################################################
+#
+# WG_I2BB : Convert list of integers into list of byte-bytes
+#
+# Input:
+#
+# - s   = List of integers
+#
+# Return:
+#
+# - ret = List of two bytes, LSByte first per pair
+#
+proc wg_i2bb {s} {
+  set ret {}
+  foreach i $s {
+    lappend ret [expr $i%256] [expr ($i/256)%256]
+  }
+  return $ret
+}
+
+
+###############################################################################
+#
+# WG_I2BBBB : Convert list of integers into list of byte-bytes-byte-bytes
+#
+# Input:
+#
+# - s   = List of integers
+#
+# Return:
+#
+# - ret = List of four bytes, LSByte first per four
+#
+proc wg_i2bbbb {s} {
+  set ret {}
+  foreach i $s {
+    lappend ret [expr $i%256] [expr ($i/256)%256] [expr ($i/(256*256))%256] [expr ($i/(256*256*256))%256]
+  }
+  return $ret
+}
+
+
+###############################################################################
+#
+# WG_WAIT_FOR_INTERRUPT : Wait for MEP interrupt message from board
+#
+# Input:
+# - repeat = nof MEP timeout periods to wait for MEP interrupt
+# - applev = Append log level
+#
+# Return: 1 when interrupt message was received, else 0.
+#
+#   tc appendlog messages are reported.
+#
+proc wg_wait_for_interrupt {{repeat 10} {applev 21}} {
+
+  set mep_interrupt 0
+  set rep           1
+  while {$mep_interrupt==0} {
+    puts                 "Rep-$rep: Wait for MEP interrupt"      ;# useful for simulation
+    tc appendLog $applev "Rep-$rep: Wait for MEP interrupt"
+    set mep_interrupt [expr ![rsp interruptMsg [msg interruptMepMsg]]]
+    if {$rep >= $repeat} {
+      tc appendLog 21 "Timeout for MEP interrupt, break to continue."
+      tc setResult FAILED
+      break
+    }
+    incr rep
+    #after 10
+  }
+    
+  return $mep_interrupt
+}
+
+
+###############################################################################
+#
+# WG_OVERWRITE_RSR : Overwrite the selected process fields of the RSP status register
+#
+# Input:
+#
+# - procid   = Process ID : 'rsp', 'eth', 'mep', 'diag', 'bs', 'rcuh', 'rsu', 'ado', 'rad', 'rcuh_test' or 'all'
+# - value    = Byte value to use for overwrite
+# - rspId    = RSP ID: 'rsp#'
+#
+# Return:
+#
+# - ret      = void
+#
+proc wg_overwrite_rsr {{procid "all"} {value 255} {rspId rsp0}} {
+
+  global env
+  source "$env(RSP)/rsp/tb/tc/5. Datapath/constants.tcl"
+
+  switch $procid {
+    "rsp"        {set offset $c_ei_status_rsp_offset;       set size                      $c_ei_status_rsp_size}
+    "eth"        {set offset $c_ei_status_eth_offset;       set size                      $c_ei_status_eth_size}
+    "mep"        {set offset $c_ei_status_mep_offset;       set size                      $c_ei_status_mep_size}
+    "diag"       {set offset $c_ei_status_diag_offset;      set size                      $c_ei_status_diag_size}
+    "bs"         {set offset $c_ei_status_bs_offset;        set size [expr $c_rsp_nof_blp*$c_ei_status_bs_size]}
+    "rcuh"       {set offset $c_ei_status_rcuh_offset;      set size [expr $c_rsp_nof_blp*$c_ei_status_rcuh_size]}
+    "rsu"        {set offset $c_ei_status_rsu_offset;       set size                      $c_ei_status_rsu_size}
+    "ado"        {set offset $c_ei_status_ado_offset;       set size [expr $c_rsp_nof_blp*$c_ei_status_ado_size]}
+    "rad"        {set offset $c_ei_status_rad_offset;       set size [expr $c_rad_nof_rx_status *$c_ei_status_rad_size]}
+    "rcuh_test"  {set offset $c_ei_status_rcuh_test_offset; set size [expr $c_rsp_nof_blp*$c_ei_status_rcuh_test_size]}
+    default      {set offset $c_ei_status_rsr_offset;       set size                      $c_ei_status_rsr_size}
+  }
+
+  set status {}
+  for {set i 0} {$i < $size} {incr i} {
+    lappend status [expr $value]
+  }
+
+  foreach ri $rspId {
+    if {[rsp writeMsg [msg writeMepMsg "rsr status rsp \"offset $offset\"" $status] $ri] == 0} {
+      tc setResult PASSED
+    } else {
+      tc setResult FAILED
+    }
+  }
+}
+
+
+###############################################################################
+#
+# WG_READ_RSR : Read the selected process fields from the RSP status register
+#
+# Input:
+#
+# - procid   = Process ID : 'rsp', 'eth', 'mep', 'diag', 'bs', 'rcuh', 'rsu', 'ado', 'rad', 'rcuh_test' or 'all'
+# - rspId    = RSP ID: 'rsp#'
+# - applev   = Append log level
+#
+# Return:
+#
+# - ret      = List of read process status fields, list structure: {{first RSP} {last RSP}},
+#              where the data structure per RSP depends on the procid.
+# - retb     = Boolean telling wither the status is OK or ERROR
+#
+proc wg_read_rsr {{procid "all"} {rspId rsp0} {applev 11}} {
+
+  global env
+  source "$env(RSP)/rsp/tb/tc/5. Datapath/constants.tcl"
+
+  set ret_rsp {}      ;# Declare return result
+
+  # Read all RSR fields
+  foreach ri $rspId {
+    set ret {}
+    set retb {}
+    if {[rsp readMsg [msg readMepMsg "rsr status rsp \"offset $c_ei_status_rsr_offset\"" $c_ei_status_rsr_size] $ri] == 0} {
+      msg setOffset 0
+      # RSP status
+      set rsp_volt_1v2         [msg readUnsigned 1]
+      set rsp_volt_2v5         [msg readUnsigned 1]
+      set rsp_volt_3v3         [msg readUnsigned 1]
+      set rsp_pcb_temp         [msg readSigned   1]
+      set rsp_bp_temp          [msg readSigned   1]
+      set rsp_ap0_temp         [msg readSigned   1]
+      set rsp_ap1_temp         [msg readSigned   1]
+      set rsp_ap2_temp         [msg readSigned   1]
+      set rsp_ap3_temp         [msg readSigned   1]
+      set rsp_clk              [msg readUnsigned 1]
+      set rsp_rsvd             [msg readUnsigned 2]
+      # ETH status
+      set eth_nof_frames       [msg readUnsigned 4]
+      set eth_nof_errors       [msg readUnsigned 4]
+      set eth_last_error       [msg readUnsigned 1]
+      set eth_rsvd             [msg readUnsigned 3]
+      # MEP status
+      set mep_seq_nr           [msg readUnsigned 2]
+      set mep_prev_error       [msg readUnsigned 1]
+      set mep_rsvd             [msg readUnsigned 1]
+      # DIAG status
+      set diag_interface       [msg readUnsigned 1]
+      set diag_mode            [msg readUnsigned 1]
+      set diag_ri_errors(rsp)  [msg readUnsigned 2]
+      set diag_rcux_errors     [msg readUnsigned 2]
+      set diag_rcuy_errors     [msg readUnsigned 2]
+      set diag_eth_errors(LCU) [msg readUnsigned 2]
+      set diag_eth_errors(CEP) [msg readUnsigned 2]
+      set diag_serdes_errors   [msg readUnsigned 2]
+      set diag_ri_errors(0)    [msg readUnsigned 2]
+      set diag_ri_errors(1)    [msg readUnsigned 2]
+      set diag_ri_errors(2)    [msg readUnsigned 2]
+      set diag_ri_errors(3)    [msg readUnsigned 2]
+      set diag_rsvd            [msg readUnsigned 2]
+      # BS status
+      for {set bi 0} {$bi < $c_rsp_nof_blp} {incr bi} {
+        set bs_ext_cnt($bi)    [msg readUnsigned 4]
+        set bs_sync_cnt($bi)   [msg readUnsigned 4]
+        set bs_sample_cnt($bi) [msg readUnsigned 4]
+        set bs_slice_cnt($bi)  [msg readUnsigned 4]
+      }
+      # RCU status
+      for {set bi 0} {$bi < $c_rsp_nof_blp} {incr bi} {
+        set rcu_status($bi)    [msg readUnsigned 4]
+        set rcu_nof_ovr_x($bi) [msg readUnsigned 4]
+        set rcu_nof_ovr_y($bi) [msg readUnsigned 4]
+      }
+      # RSU status
+      set rsu_cp_status  [msg readUnsigned 4]
+      # ADO status
+      for {set bi 0} {$bi < $c_rsp_nof_blp} {incr bi} {
+        set ado_x($bi)         [msg readSigned 4]
+        set ado_y($bi)         [msg readSigned 4]
+      }
+      # RAD BP status - RI, XB[0:3], S[0:3]
+      set rad_ri               [msg readUnsigned 4]
+      for {set la 0} {$la < $c_rsp_nof_lanes} {incr la} {
+        set rad_lane($la,crosslets)  [msg readUnsigned 4]
+        set rad_lane($la,beamlets)   [msg readUnsigned 4]
+      }
+      for {set la 0} {$la < $c_rsp_nof_lanes} {incr la} {
+        set rad_lane($la,subbands)  [msg readUnsigned 4]
+      }
+      # RCU test status
+      for {set bi 0} {$bi < $c_rsp_nof_blp} {incr bi} {
+        set rcu_test_x($bi)    [msg readUnsigned 2]
+        set rcu_test_y($bi)    [msg readUnsigned 2]
+      }
+
+      # Report RSR fields indicated by procid
+      tc appendLog $applev ""
+      tc appendLog $applev ">>> RSR read outs for RSP-$ri."
+      tc appendLog $applev ""
+
+      if {$procid == "rsp" || $procid == "all"} {
+        tc appendLog $applev "RSP board status:"
+        tc appendLog $applev ""
+        tc appendLog $applev "  supply 1.2V = [format "%6.3f" [expr $rsp_volt_1v2 * 2.5/192]] V     (= [format "%3d * 2.5/192" $rsp_volt_1v2])  (unit [format "%5.3f" [expr 2.5/192]] V)"
+        tc appendLog $applev "  supply 2.5V = [format "%6.3f" [expr $rsp_volt_2v5 * 3.3/192]] V     (= [format "%3d * 3.3/192" $rsp_volt_2v5])  (unit [format "%5.3f" [expr 3.3/192]] V)"
+        tc appendLog $applev "  supply 3.3V = [format "%6.3f" [expr $rsp_volt_3v3 * 5.0/192]] V     (= [format "%3d * 5.0/192" $rsp_volt_3v3])  (unit [format "%5.3f" [expr 5.0/192]] V)"
+        tc appendLog $applev ""
+        tc appendLog $applev "  temp PCB = [format "%4d" $rsp_pcb_temp] degrees C"
+        tc appendLog $applev ""
+        tc appendLog $applev "  temp BP  = [format "%4d" $rsp_bp_temp] degrees C"
+        tc appendLog $applev "  temp AP0 = [format "%4d" $rsp_ap0_temp] degrees C"
+        tc appendLog $applev "  temp AP1 = [format "%4d" $rsp_ap1_temp] degrees C"
+        tc appendLog $applev "  temp AP2 = [format "%4d" $rsp_ap2_temp] degrees C"
+        tc appendLog $applev "  temp AP3 = [format "%4d" $rsp_ap3_temp] degrees C"
+        tc appendLog $applev ""
+        tc appendLog $applev "  clk rate = [format "%4d" $rsp_clk] MHz"
+        tc appendLog $applev ""
+        lappend ret "$rsp_volt_1v2 $rsp_volt_2v5 $rsp_volt_3v3 $rsp_pcb_temp $rsp_bp_temp $rsp_ap0_temp $rsp_ap1_temp $rsp_ap2_temp $rsp_ap3_temp $rsp_clk"
+      }
+      if {$procid == "eth" || $procid == "all"} {
+        tc appendLog $applev "Ethernet status:"
+        tc appendLog $applev ""
+        tc appendLog $applev "  Number of frames = $eth_nof_frames"
+        tc appendLog $applev "  Number of errors = $eth_nof_errors"
+        if       {$eth_last_error == $c_ei_eth_err_noerr          } {tc appendLog $applev "  Last error       = OK"
+        } elseif {$eth_last_error == $c_ei_eth_err_preamblevalue  } {tc appendLog $applev "  Last error       = Preamble value error"
+        } elseif {$eth_last_error == $c_ei_eth_err_framedelimiter } {tc appendLog $applev "  Last error       = Frame delimiter error"
+        } elseif {$eth_last_error == $c_ei_eth_err_preamblelength } {tc appendLog $applev "  Last error       = Preamble length error"
+        } elseif {$eth_last_error == $c_ei_eth_err_headerlength   } {tc appendLog $applev "  Last error       = Frame header lenght error"
+        } elseif {$eth_last_error == $c_ei_eth_err_crc            } {tc appendLog $applev "  Last error       = CRC error"
+        } elseif {$eth_last_error == $c_ei_eth_err_oddnibblelength} {tc appendLog $applev "  Last error       = Odd nof nibbles error"
+        } elseif {$eth_last_error == $c_ei_eth_err_framelength    } {tc appendLog $applev "  Last error       = Frame size error"
+        } else                                                      {tc appendLog $applev "  Last error       = Illegal error code: $eth_last_error"}
+        tc appendLog $applev ""
+        lappend ret "$eth_nof_frames $eth_nof_errors $eth_last_error"
+      }
+      if {$procid == "mep" || $procid == "all"} {
+        tc appendLog $applev "MEP status:"
+        tc appendLog $applev ""
+        tc appendLog $applev "  Sequence number           = $mep_seq_nr"
+        if       {$mep_prev_error == $c_ei_mep_err_noerr   } {tc appendLog $applev "  Error status previous msg = OK"
+        } elseif {$mep_prev_error == $c_ei_mep_err_type    } {tc appendLog $applev "  Error status previous msg = Unknown message type"
+        } elseif {$mep_prev_error == $c_ei_mep_err_addr_blp} {tc appendLog $applev "  Error status previous msg = Illegal BLP address"
+        } elseif {$mep_prev_error == $c_ei_mep_err_pid     } {tc appendLog $applev "  Error status previous msg = Invalid PID"
+        } elseif {$mep_prev_error == $c_ei_mep_err_regid   } {tc appendLog $applev "  Error status previous msg = Register does not exist"
+        } elseif {$mep_prev_error == $c_ei_mep_err_offset  } {tc appendLog $applev "  Error status previous msg = Offset too large"
+        } elseif {$mep_prev_error == $c_ei_mep_err_size    } {tc appendLog $applev "  Error status previous msg = Message too large"
+        } elseif {$mep_prev_error == $c_ei_mep_err_ringcrc } {tc appendLog $applev "  Error status previous msg = Ring CRC error"
+        } elseif {$mep_prev_error == $c_ei_mep_err_timeout } {tc appendLog $applev "  Error status previous msg = Timeout"
+        } else                                               {tc appendLog $applev "  Error status previous msg = Illegal error code: $mep_prev_error"}
+        tc appendLog $applev ""
+        lappend ret "$mep_seq_nr $mep_prev_error"
+      }
+      if {$procid == "diag" || $procid == "all"} {
+        tc appendLog $applev "DIAG status:"
+        tc appendLog $applev ""
+        tc appendLog $applev "  Interface                 = $diag_interface"
+        tc appendLog $applev "  Mode                      = $diag_mode"
+        # - BP RI
+        if {$diag_ri_errors(rsp) == $c_diag_res_ok} {
+          tc appendLog $applev "  Test result RI-BP         = OK"
+        } elseif {$diag_ri_errors(rsp) == $c_diag_res_none} {
+          tc appendLog $applev "  Test result RI-BP         = Nothing happened"
+        } elseif {$diag_ri_errors(rsp) == $c_diag_res_sync_timeout} {
+          tc appendLog $applev "  Test result RI-BP         = Sync timeout"
+        } elseif {$diag_ri_errors(rsp) == $c_diag_res_data_timeout} {
+          tc appendLog $applev "  Test result RI-BP         = Data timeout"
+        } elseif {$diag_ri_errors(rsp) == $c_diag_res_word_err} {
+          tc appendLog $applev "  Test result RI-BP         = Data errors occured"
+        } else {
+          tc appendLog $applev "  Test result RI-BP         = Unknown status $diag_ri_errors(rsp)"
+        }
+        tc appendLog $applev "  Test result RCU-X         = $diag_rcux_errors"
+        tc appendLog $applev "  Test result RCU-Y         = $diag_rcuy_errors"
+        # - ETH
+        set eth_interfaces {LCU CEP}
+        foreach ei $eth_interfaces {
+          if {$diag_eth_errors($ei) == $c_diag_res_ok} {
+            tc appendLog $applev "  Test result $ei           = OK"
+          } elseif {$diag_eth_errors($ei) == $c_diag_res_none} {
+            tc appendLog $applev "  Test result $ei           = Nothing happened"
+          } elseif {$diag_eth_errors($ei) == $c_diag_res_data_timeout} {
+            tc appendLog $applev "  Test result $ei           = Data timeout (= frame lost)"
+          } elseif {$diag_eth_errors($ei) == $c_diag_res_word_err} {
+            tc appendLog $applev "  Test result $ei           = Word errors occured"
+          } else {
+            tc appendLog $applev "  Test result $ei           = Unknown status $diag_eth_errors($ei)"
+          }
+        }
+        # - SERDES lanes
+        set lane_mask  [expr round(pow(2,$c_rsp_nof_lanes)-1)]
+        set lane_ref   [expr round(pow(2,$c_rsp_nof_lanes))]
+        for {set i 0} {$i < $c_rsp_nof_lanes} {incr i} {
+          set lane_errors [expr ($diag_serdes_errors >> ($i*$c_rsp_nof_lanes)) & $lane_mask]
+          if {$lane_errors == $c_diag_res_ok} {
+            tc appendLog $applev "  Test result SERDES lane $i = OK"
+          } elseif {$lane_errors == $c_diag_res_none} {
+            tc appendLog $applev "  Test result SERDES lane $i = nothing happened"
+          } elseif {$lane_errors == $c_diag_res_sync_timeout} {
+            tc appendLog $applev "  Test result SERDES lane $i = sync timeout"
+          } elseif {$lane_errors == $c_diag_res_data_timeout} {
+            tc appendLog $applev "  Test result SERDES lane $i = data timeout"
+          } elseif {$lane_errors == $c_diag_res_word_err} {
+            tc appendLog $applev "  Test result SERDES lane $i = word errors occured"
+          } elseif {$lane_errors == $c_diag_res_illegal} {
+            tc appendLog $applev "  Test result SERDES lane $i = illegal status $lane_errors"
+          } else {
+            tc appendLog $applev "  Test result SERDES lane $i = unknown status $lane_errors"
+          }
+        }
+        # - APs RI
+        for {set ai 0} {$ai<4} {incr ai} {
+          if {$diag_ri_errors($ai) == $c_diag_res_ok} {
+            tc appendLog $applev "  Test result RI-AP$ai        = OK"
+          } elseif {$diag_ri_errors($ai) == $c_diag_res_none} {
+            tc appendLog $applev "  Test result RI-AP$ai        = Nothing happened."
+          } elseif {$diag_ri_errors($ai) == $c_diag_res_sync_timeout} {
+            tc appendLog $applev "  Test result RI-AP$ai        = Sync timeout."
+          } elseif {$diag_ri_errors($ai) == $c_diag_res_data_timeout} {
+            tc appendLog $applev "  Test result RI-AP$ai        = Data timeout."
+          } elseif {$diag_ri_errors($ai) == $c_diag_res_word_err} {
+            tc appendLog $applev "  Test result RI-AP$ai        = Data errors occured."
+          } else {
+            tc appendLog $applev "  Test result RI-AP$ai        = Unknown status $diag_ri_errors($ai)."
+          }
+        }
+        tc appendLog $applev ""
+        lappend ret "$diag_interface $diag_mode $diag_ri_errors(rsp) $diag_rcux_errors $diag_rcuy_errors $diag_eth_errors(LCU) $diag_eth_errors(CEP) $diag_serdes_errors $diag_ri_errors(0) $diag_ri_errors(1) $diag_ri_errors(2) $diag_ri_errors(3)"
+      }
+      if {$procid == "bs" || $procid == "all"} {
+        tc appendLog $applev "BS status:"
+        tc appendLog $applev ""
+        for {set bi 0} {$bi < $c_rsp_nof_blp} {incr bi} {
+          set     str "BLP-$bi: "
+          lappend str [format "Ext_cnt = %u, " $bs_ext_cnt($bi)]
+          lappend str [format "Sync_cnt = %u, " $bs_sync_cnt($bi)]
+          lappend str [format "Sample_cnt = %u, " $bs_sample_cnt($bi)]
+          lappend str [format "Slice_cnt = %u." $bs_slice_cnt($bi)]
+          set     str [join $str]
+          tc appendLog $applev "  $str"
+          lappend ret "$bs_ext_cnt($bi) $bs_sync_cnt($bi) $bs_sample_cnt($bi) $bs_slice_cnt($bi)"
+        }
+        tc appendLog $applev ""
+      }
+      if {$procid == "rcuh" || $procid == "all"} {
+        tc appendLog $applev "RCU status:"
+        tc appendLog $applev ""
+        for {set bi 0} {$bi < $c_rsp_nof_blp} {incr bi} {
+          set     str "BLP-$bi: "
+          lappend str [format "status = %u, " $rcu_status($bi)]
+          lappend str [format "nof_ovr_x = %u, " $rcu_nof_ovr_x($bi)]
+          lappend str [format "nof_ovr_y = %u." $rcu_nof_ovr_y($bi)]
+          set     str [join $str]
+          tc appendLog $applev "  $str"
+          lappend ret "$rcu_status($bi) $rcu_nof_ovr_x($bi) $rcu_nof_ovr_y($bi)"
+        }
+        tc appendLog $applev ""
+      }
+      if {$procid == "rsu" || $procid == "all"} {
+        tc appendLog $applev "RSU status:"
+        tc appendLog $applev ""
+        tc appendLog $applev "  CP status = $rsu_cp_status"
+        tc appendLog $applev ""
+        if {(($rsu_cp_status >> $c_cp_statusRdy) & 0x1) == 1} {
+          tc appendLog $applev "    \[$c_cp_statusRdy\] statusRdy       = 1 : CP is done"
+        } else {
+          tc appendLog $applev "    \[$c_cp_statusRdy\] statusRdy       = 0 : CP is in some intermediate state"
+        }
+        if {(($rsu_cp_status >> $c_cp_statusFpgaType) & 0x1) == $c_cp_bp} {
+          tc appendLog $applev "    \[$c_cp_statusFpgaType\] statusFpgaType  = $c_cp_bp : Image was loaded via JTAG"
+        } else {
+          tc appendLog $applev "    \[$c_cp_statusFpgaType\] statusFpgaType  = [expr !$c_cp_bp] : Image was loaded from flash"
+        }
+        if {(($rsu_cp_status >> $c_cp_statusImageType) & 0x1) == 0} {
+          tc appendLog $applev "    \[$c_cp_statusImageType\] statusImageType = 0 : Factory image is running"
+        } else {
+          tc appendLog $applev "    \[$c_cp_statusImageType\] statusImageType = 1 : User image is running"
+        }
+        if       {(($rsu_cp_status >> $c_cp_statusTrigLo) & $c_cp_trig_mask) == $c_cp_trig_ButtonRst} {
+          tc appendLog $applev "  \[$c_cp_statusTrigHi:$c_cp_statusTrigLo\] statusTrig      = $c_cp_trig_ButtonRst : Reconfiguration due to button reset"
+        } elseif {(($rsu_cp_status >> $c_cp_statusTrigLo) & $c_cp_trig_mask) == $c_cp_trig_TempRst} {
+          tc appendLog $applev "  \[$c_cp_statusTrigHi:$c_cp_statusTrigLo\] statusTrig      = $c_cp_trig_TempRst : Reconfiguration due to over temperature"
+        } elseif {(($rsu_cp_status >> $c_cp_statusTrigLo) & $c_cp_trig_mask) == $c_cp_trig_UserRst} {
+          tc appendLog $applev "  \[$c_cp_statusTrigHi:$c_cp_statusTrigLo\] statusTrig      = $c_cp_trig_UserRst : Reconfiguration due to user reset"
+        } elseif {(($rsu_cp_status >> $c_cp_statusTrigLo) & $c_cp_trig_mask) == $c_cp_trig_WdRst} {
+          tc appendLog $applev "  \[$c_cp_statusTrigHi:$c_cp_statusTrigLo\] statusTrig      = $c_cp_trig_WdRst : Reconfiguration due to watchdog reset"
+        } else {
+          tc appendLog $applev "  \[$c_cp_statusTrigHi:$c_cp_statusTrigLo\] statusTrig      = [expr ($rsu_cp_status >> $c_cp_statusTrigLo) & $c_cp_trig_mask] : Unknown reconfiguration trigger"
+        }
+          set cp_version [expr ((($rsu_cp_status >> $c_cp_statusVersion1) & 0x1) << 1) + (($rsu_cp_status >> $c_cp_statusVersion0) & 0x1)]
+          tc appendLog $applev "  \[$c_cp_statusVersion1,$c_cp_statusVersion0\] statusVersion   = $cp_version : CP version number"
+        tc appendLog $applev ""
+        lappend ret "$rsu_cp_status"
+      }
+      if {$procid == "ado" || $procid == "all"} {
+        tc appendLog $applev "ADC offset:"
+        tc appendLog $applev ""
+        set slice_size [expr $c_cpx * $c_rsp_nof_subbands]
+        for {set bi 0} {$bi < $c_rsp_nof_blp} {incr bi} {
+          set nof_samples_psync [expr $bs_slice_cnt($bi) * $slice_size]
+          set str "BLP-$bi, RCU-X ADC offset = "
+          if {$nof_samples_psync != 0} {
+            lappend str [format "%11.7f lsb    " [expr 1.0 * $ado_x($bi) * $c_ado_scale / $nof_samples_psync]]
+          } else {
+            lappend str "-----------"
+          }
+          lappend str [format "(%10d * %u / %11.0f)" $ado_x($bi) $c_ado_scale $nof_samples_psync]
+          set str [join $str]
+          tc appendLog $applev "  $str"
+
+          set str "BLP-$bi, RCU-Y ADC offset = "
+          if {$nof_samples_psync != 0} {
+            lappend str [format "%11.7f lsb    " [expr 1.0 * $ado_y($bi) * $c_ado_scale / $nof_samples_psync]]
+          } else {
+            lappend str "-----------"
+          }
+          lappend str [format "(%10d * %u / %11.0f)" $ado_y($bi) $c_ado_scale $nof_samples_psync]
+          set str [join $str]
+          tc appendLog $applev "  $str"
+
+          lappend ret "$ado_x($bi) $ado_y($bi)"
+        }
+        tc appendLog $applev ""
+      }
+      if {$procid == "rad" || $procid == "all"} {
+        tc appendLog $applev "RAD BP frame rx status:"
+        tc appendLog $applev ""
+        tc appendLog $applev "                     Align  Sync   CRC    Frame cnt"
+        set retb $c_rsr_undefined              ;# default undefined
+        set str "RI               : "
+        set cnt [expr $rad_ri & ((1<<18)-1)]
+        if {$cnt==0} {
+          append str "-      -      -      "
+        } else {
+          set retb $c_rsr_ok                   ;# when rad is busy there is always input from RI, from lane only in case of multiple RSP
+                                       append str "-      "                                                      ;# not applicable for RI
+          if {($rad_ri & (1<<19))!=0} {append str "OK     "} else {append str "Error  "; set retb $c_rsr_error}  ;# sync error(s)
+          if {($rad_ri & (1<<18))==0} {append str "OK     "} else {append str "Error  "; set retb $c_rsr_error}  ;# CRC error(s)
+        }
+        append str [format "%u" $cnt]
+        tc appendLog $applev "  $str"
+        lappend ret "$rad_ri"
+        foreach let {crosslets beamlets subbands} {
+          for {set la 0} {$la < $c_rsp_nof_lanes} {incr la} {
+            set str [format "Lane-$la, %-9s: " $let]
+            set cnt [expr $rad_lane($la,$let) & ((1<<18)-1)]
+            if {$cnt==0} {
+              append str "-      -      -      "
+            } else {
+                                              ;# input from lane can keep retb as set by input from RI, or cause retb to indicate error
+              if {($rad_lane($la,$let) & (1<<20))==0} {append str "OK     "} else {append str "Error  "; set retb $c_rsr_error}  ;# frame(s) discarded
+              if {($rad_lane($la,$let) & (1<<19))!=0} {append str "OK     "} else {append str "Error  "; set retb $c_rsr_error}  ;# sync error(s)
+              if {($rad_lane($la,$let) & (1<<18))==0} {append str "OK     "} else {append str "Error  "; set retb $c_rsr_error}  ;# CRC error(s)
+            }
+            append str [format "%u" $cnt]
+            tc appendLog $applev "  $str"
+            lappend ret "$rad_lane($la,$let)"
+          }
+        }
+        tc appendLog $applev ""
+        set ret "$retb $ret"
+      }
+      if {$procid == "rcuh_test" || $procid == "all"} {
+        tc appendLog $applev "RCU test status:"
+        tc appendLog $applev ""
+        for {set bi 0} {$bi < $c_rsp_nof_blp} {incr bi} {
+          set     str "BLP-$bi: "
+          lappend str [format "rcu_test_x = 0x%x, " $rcu_test_x($bi)]
+          lappend str [format "rcu_test_y = 0x%x"   $rcu_test_y($bi)]
+          set     str [join $str]
+          tc appendLog $applev "  $str"
+          lappend ret "$rcu_test_x($bi) $rcu_test_y($bi)"
+        }
+        tc appendLog $applev ""
+      }
+      tc setResult PASSED
+    } else {
+      tc setResult FAILED
+    }
+    lappend ret_rsp "$ret"
+  }
+
+  return $ret_rsp
+}
+
+
+###############################################################################
+#
+# WG_WRITE_RSR_TIMESTAMP : Write RSR timestamp
+#
+# Input:
+#
+# - timestamp          = Timestamp 32 bit >= 0
+# - timestamp_mode     = Timestamp update at sync:
+#                        0 = no change
+#                        1 = reset to 0xFFFFFFFF = -1
+#                        2 = auto increment
+# - blpId              = BP, AP ID: 'rsp blp#'
+# - rspId              = RSP ID: 'rsp#'
+# - applev             = Append log level
+#
+# Return: void
+#
+proc wg_write_rsr_timestamp {timestamp {timestamp_mode 1} {blpId blp0} {rspId rsp0} {applev 41}} {
+  if {$timestamp_mode==1} {
+    tc appendLog $applev ">>> RSP-$rspId, FPGA-$blpId, write RSR timestamp: $timestamp (mode: reset to 0xFFFFFFFF at sync)"
+  } elseif {$timestamp_mode==2} {
+    tc appendLog $applev ">>> RSP-$rspId, FPGA-$blpId, write RSR timestamp: $timestamp (mode: auto increment at sync)"
+  } else {
+    tc appendLog $applev ">>> RSP-$rspId, FPGA-$blpId, write RSR timestamp: $timestamp (mode: no change at sync)"
+  }
+  foreach ri $rspId {
+    # Make use of MEP broadcast to BP and all BLP on an RSP board
+    if {[rsp writeMsg [msg writeMepMsg "rsr timestamp $blpId" "[wg_i2bbbb $timestamp] $timestamp_mode"] $ri] == 0} {
+      tc setResult PASSED
+    } else {
+      tc setResult FAILED
+    }
+  }
+}
+
+
+###############################################################################
+#
+# WG_READ_RSR_TIMESTAMP : RSR read timestamp
+#
+# Input:
+#
+# - blpId    = BP, AP ID: 'rsp blp#' - only one
+# - rspId    = RSP ID: 'rsp#' - only one
+# - applev   = Append log level
+#
+# Return:
+#
+# - timestamp = RSR timestamp value
+#
+#   tc appendlog messages are reported.
+#
+proc wg_read_rsr_timestamp {{blpId blp0} {rspId rsp0} {applev 21}} {
+  set timestamp {}
+  if {[rsp readMsg [msg readMepMsg "rsr timestamp $blpId" 5] $rspId] == 0} {
+    msg setOffset 0
+    set timestamp [msg readUnsigned 4]
+    set timestamp_mode [msg readUnsigned 1]
+    if {$timestamp_mode==1} {
+      tc appendLog $applev ">>> RSP-$rspId, FPGA-$blpId, read RSR timestamp: $timestamp (mode: reset to 0xFFFFFFFF at sync)"
+    } elseif {$timestamp_mode==2} {
+      tc appendLog $applev ">>> RSP-$rspId, FPGA-$blpId, read RSR timestamp: $timestamp (mode: auto increment at sync)"
+    } else {
+      tc appendLog $applev ">>> RSP-$rspId, FPGA-$blpId, read RSR timestamp: $timestamp (mode: no change at sync)"
+    }
+    tc setResult PASSED
+  } else {
+    tc setResult FAILED
+  }
+  return $timestamp
+}
+
+
+###############################################################################
+#
+# WG_WRITE_RSR_BEAM_MODE_SETTINGS : Write RSR beam mode settings
+#
+# Input:
+#
+# - bm_select          = Select beam mode 0, 1 or 2
+# - blpId              = BP, AP ID: 'rsp blp#'
+# - rspId              = RSP ID: 'rsp#'
+# - applev             = Append log level
+#
+# Return: void
+#
+proc wg_write_rsr_beam_mode_settings {bm_select {blpId blp0} {rspId rsp0} {applev 41}} {
+  tc appendLog $applev ">>> RSP-$rspId, FPGA-$blpId, write RSR beam mode settings:"
+  tc appendLog $applev "      Beam mode select  = $bm_select"
+  foreach ri $rspId {
+    # Make use of MEP broadcast to BP and all BLP on an RSP board
+    if {[rsp writeMsg [msg writeMepMsg "rsr beammode $blpId \"offset 1\"" $bm_select] $ri] == 0} {
+      tc setResult PASSED
+    } else {
+      tc setResult FAILED
+    }
+  }
+}
+
+
+###############################################################################
+#
+# WG_READ_RSR_BEAM_MODE_SETTINGS : Read RSR beam mode settings
+#
+# Input:
+#
+# - blpId    = BP, AP ID: 'rsp blp#' - only one
+# - rspId    = RSP ID: 'rsp#' - only one
+# - applev   = Append log level
+#
+# Return:
+#
+# - bm_max      = Maximum beam mode 0, 1 or 2 that is supported in the hardware
+# - bm_select   = Select beam mode 0, 1 or 2
+#
+#   tc appendlog messages are reported.
+#
+proc wg_read_rsr_beam_mode_settings {{blpId blp0} {rspId rsp0} {applev 21}} {
+  set settings {}
+  if {[rsp readMsg [msg readMepMsg "rsr beammode $blpId" 2] $rspId] == 0} {
+    msg setOffset 0
+    set bm_max    [msg readUnsigned 1]
+    set bm_select [msg readUnsigned 1]
+    tc appendLog $applev ">>> RSP-$rspId, FPGA-$blpId, read RSR beam mode settings:"
+    tc appendLog $applev "      Beam mode max (read only) = $bm_max"
+    tc appendLog $applev "      Beam mode select          = $bm_select"
+    lappend settings $bm_max
+    lappend settings $bm_select
+    tc setResult PASSED
+  } else {
+    tc setResult FAILED
+  }
+  return $settings
+}
+
+
+###############################################################################
+#
+# WG_WRITE_RSR_SDO_MODE_SETTINGS : Write RSR Subband Data Output mode settings
+#
+# Input:
+#
+# - sdo_mode           = Select SDO mode 0, 1, 2 or 3
+# - blpId              = BP, AP ID: 'rsp blp#'
+# - rspId              = RSP ID: 'rsp#'
+# - applev             = Append log level
+#
+# Return: void
+#
+proc wg_write_rsr_sdo_mode_settings {sdo_mode {blpId blp0} {rspId rsp0} {applev 41}} {
+  tc appendLog $applev ">>> RSP-$rspId, FPGA-$blpId, write RSR sdo mode settings:"
+  tc appendLog $applev "      SDO mode select  = $sdo_mode"
+  foreach ri $rspId {
+    # Make use of MEP broadcast to BP and all BLP on an RSP board
+    if {[rsp writeMsg [msg writeMepMsg "rsr sdomode $blpId \"offset 1\"" $sdo_mode] $ri] == 0} {
+      tc setResult PASSED
+    } else {
+      tc setResult FAILED
+    }
+  }
+}
+
+
+###############################################################################
+#
+# WG_READ_RSR_SDO_MODE_SETTINGS : Read RSR Subband Data Output mode settings
+#
+# Input:
+#
+# - blpId    = BP, AP ID: 'rsp blp#' - only one
+# - rspId    = RSP ID: 'rsp#' - only one
+# - applev   = Append log level
+#
+# Return:
+#
+# - sdo_max    = Maximum SDO mode 0, 1, 2 or 3 that is supported in the hardware
+# - sdo_mode   = Select SDO mode 0, 1, 2 or 3
+#
+#   tc appendlog messages are reported.
+#
+proc wg_read_rsr_sdo_mode_settings {{blpId blp0} {rspId rsp0} {applev 21}} {
+  set settings {}
+  if {[rsp readMsg [msg readMepMsg "rsr sdomode $blpId" 2] $rspId] == 0} {
+    msg setOffset 0
+    set sdo_max  [msg readUnsigned 1]
+    set sdo_mode [msg readUnsigned 1]
+    tc appendLog $applev ">>> RSP-$rspId, FPGA-$blpId, read RSR sdo mode settings:"
+    tc appendLog $applev "      SDO mode max (read only) = $sdo_max"
+    tc appendLog $applev "      SDO mode select          = $sdo_mode"
+    lappend settings $sdo_max
+    lappend settings $sdo_mode
+    tc setResult PASSED
+  } else {
+    tc setResult FAILED
+  }
+  return $settings
+}
+
+###############################################################################
+#
+# WG_WRITE_CR_SOFTCLEAR : CR apply softclear
+#
+# Input:
+#
+# - blpId    = BP, AP ID: 'rsp blp#'
+# - rspId    = RSP ID: 'rsp#'
+#
+# Return: void
+#
+# - The data value is don't care, the write event itself causes the softclear.
+#
+proc wg_write_cr_softclear {{blpId blp0} {rspId rsp0}} {
+  foreach ri $rspId {
+    # Make use of MEP broadcast to all BLP on an RSP board
+    set bi $blpId
+#     foreach bi $blpId {
+      if {[rsp writeMsg [msg writeMepMsg "cr softrst $bi" 1] $ri] == 0} {
+        tc setResult PASSED
+      } else {
+        tc setResult FAILED
+      }
+#     }
+  }
+}
+
+
+###############################################################################
+#
+# WG_WRITE_CR_SOFTSYNC : CR apply softsync
+#
+# Input:
+#
+# - blpId    = BP, AP ID: 'rsp blp#'
+# - rspId    = RSP ID: 'rsp#'
+#
+# Return: void
+#
+# - The data value is don't care, the write event itself causes the softsync.
+#
+proc wg_write_cr_softsync {{blpId blp0} {rspId rsp0}} {
+  foreach ri $rspId {
+    # Make use of MEP broadcast to all BLP on an RSP board
+    set bi $blpId
+#     foreach bi $blpId {
+      if {[rsp writeMsg [msg writeMepMsg "cr softsync $bi" 0] $ri] == 0} {
+        tc setResult PASSED
+      } else {
+        tc setResult FAILED
+      }
+#     }
+  }
+}
+
+
+###############################################################################
+#
+# WG_WRITE_CR_SYNC_OFF : CR disable external sync
+# WG_WRITE_CR_SYNC_ON  : CR enable external sync
+#
+# Input:
+#
+# - blpId    = BP, AP ID: 'rsp blp#'
+# - rspId    = RSP ID: 'rsp#'
+#
+# Return: void
+#
+proc wg_write_cr_sync_off {{blpId blp0} {rspId rsp0}} {
+  foreach ri $rspId {
+    # Make use of MEP broadcast to all BLP on an RSP board
+    set bi $blpId
+#     foreach bi $blpId {
+      if {[rsp writeMsg [msg writeMepMsg "cr syncoff $bi" 1] $ri] == 0} {
+        tc setResult PASSED
+      } else {
+        tc setResult FAILED
+      }
+#     }
+  }
+}
+
+proc wg_write_cr_sync_on {{blpId blp0} {rspId rsp0}} {
+  foreach ri $rspId {
+    # Make use of MEP broadcast to all BLP on an RSP board
+    set bi $blpId
+#     foreach bi $blpId {
+      if {[rsp writeMsg [msg writeMepMsg "cr syncoff $bi" 0] $ri] == 0} {
+        tc setResult PASSED
+      } else {
+        tc setResult FAILED
+      }
+#     }
+  }
+}
+
+
+###############################################################################
+#
+# WG_READ_CR_SYNC_OFF : CR read sync off bit
+#
+# Input:
+#
+# - blpId    = BP, AP ID: 'rsp blp#' - only one
+# - rspId    = RSP ID: 'rsp#' - only one
+# - applev   = Append log level
+#
+# Return:
+#
+# - syncoff  = External sync disable bit
+#
+#   tc appendlog messages are reported.
+#
+proc wg_read_cr_sync_off {{blpId blp0} {rspId rsp0} {applev 21}} {
+  set syncoff -1
+  if {[rsp readMsg [msg readMepMsg "cr syncoff $blpId" 1] $rspId] == 0} {
+    msg setOffset 0
+    set syncoff [msg readUnsigned 1]
+    if {$syncoff==0} {
+      tc appendLog $applev ">>> RSP-$rspId, BLP-$blpId, read CR syncoff : $syncoff (= enabled)"
+    } else {
+      tc appendLog $applev ">>> RSP-$rspId, BLP-$blpId, read CR syncoff : $syncoff (= disabled)"
+    }
+    tc setResult PASSED
+  } else {
+    tc setResult FAILED
+  }
+  return $syncoff
+}
+
+
+###############################################################################
+#
+# WG_WRITE_CR_SYNC_DELAY : CR write external sync input delay
+#
+# Input:
+#
+# - syncdelay = 0 is reset input delay to hardware default, > 0 increment input delay one time
+# - syncedge  = 0 is capture ext_sync on rising edge, != 0 is on falling edge
+# - blpId     = BP, AP ID: 'rsp blp#'
+# - rspId     = RSP ID: 'rsp#'
+#
+# Return: void
+#
+proc wg_write_cr_sync_delay {{syncdelay 0} {syncedge 0} {blpId blp0} {rspId rsp0}} {
+  set bit0 [expr $syncdelay > 0]
+  set bit1 [expr $syncedge  > 0]
+  set syncdata [expr ($bit1 << 1) + $bit0]
+  foreach ri $rspId {
+    # Make use of MEP broadcast to BP and all BLP on an RSP board
+    set bi $blpId
+#     foreach bi $blpId {
+      if {[rsp writeMsg [msg writeMepMsg "cr syncdelay $bi" $syncdata] $ri] == 0} {
+        tc setResult PASSED
+      } else {
+        tc setResult FAILED
+      }
+#     }
+  }
+}
+
+
+###############################################################################
+#
+# WG_READ_CR_SYNC_DELAY : CR read sync delay bit
+#
+# Input:
+#
+# - blpId    = BP, AP ID: 'rsp blp#' - only one
+# - rspId    = RSP ID: 'rsp#' - only one
+# - applev   = Append log level
+#
+# Return:
+#
+# - syncdata  = External sync data
+#               . bit 0 : '0' is default input delay, '1' is incremented delay
+#               . bit 1 : '0' capture external sync on rising edge, '1' on falling edge
+#
+#   tc appendlog messages are reported.
+#
+proc wg_read_cr_sync_delay {{blpId blp0} {rspId rsp0} {applev 21}} {
+  set syncdata -1
+  if {[rsp readMsg [msg readMepMsg "cr syncdelay $blpId" 1] $rspId] == 0} {
+    msg setOffset 0
+    set syncdata [msg readUnsigned 1]
+    set bit0 [expr  $syncdata & 1      ]
+    set bit1 [expr ($syncdata & 2) >> 1]
+    if {$bit0==0 && $bit1==0} {
+      tc appendLog $applev ">>> RSP-$rspId, BLP-$blpId, read CR sync: default input delay,     default capture on rising edge"
+    } elseif {$bit0==0 && $bit1!=0} {
+      tc appendLog $applev ">>> RSP-$rspId, BLP-$blpId, read CR sync: default input delay,     capture on falling edge"
+    } elseif {$bit0!=0 && $bit1==0} {
+      tc appendLog $applev ">>> RSP-$rspId, BLP-$blpId, read CR sync: incremented input delay, default capture on rising edge"
+    } else {
+      tc appendLog $applev ">>> RSP-$rspId, BLP-$blpId, read CR sync: incremented input delay, capture on falling edge"
+    }
+    tc setResult PASSED
+  } else {
+    tc setResult FAILED
+  }
+  return $syncdata
+}
+
+
+###############################################################################
+#
+# WG_WRITE_SERDES_RX_DELAY : SERDES write RX_CLK output delay
+#
+# Input:
+#
+# - clk_delay  = Rx clock input delay
+#               . bit 0 : '0' is reset to default delay, '1' is increment delay
+# - rspId     = RSP ID: 'rsp#'
+#
+# Return: void
+#
+proc wg_write_serdes_rx_delay {{clk_delay 0} {rspId rsp0}} {
+  set bit0 [expr $clk_delay & 1]
+  foreach ri $rspId {
+    if {[rsp writeMsg [msg writeMepMsg "serdes rxdelay rsp" $bit0] $ri] == 0} {
+      tc setResult PASSED
+    } else {
+      tc setResult FAILED
+    }
+  }
+}
+
+
+###############################################################################
+#
+# WG_WRITE_SERDES_TX_DELAY : SERDES write TX_CLK output delay
+#
+# Input:
+#
+# - clk_delay  = Tx clock output delay
+#               . bit 0 : '0' is reset to default delay, '1' is increment delay
+# - rspId     = RSP ID: 'rsp#'
+#
+# Return: void
+#
+proc wg_write_serdes_tx_delay {{clk_delay 0} {rspId rsp0}} {
+  set bit0 [expr $clk_delay & 1]
+  foreach ri $rspId {
+    if {[rsp writeMsg [msg writeMepMsg "serdes txdelay rsp" $bit0] $ri] == 0} {
+      tc setResult PASSED
+    } else {
+      tc setResult FAILED
+    }
+  }
+}
+
+
+###############################################################################
+#
+# WG_READ_SERDES_RX_DELAY : SERDES read RX_CLK input delay
+#
+# Input:
+#
+# - rspId    = RSP ID: 'rsp#' - only one
+# - applev   = Append log level
+#
+# Return:
+#
+# - clk_delay  = Rx clock input delay
+#                . bit 0 : '0' is default input delay, '1' is incremented delay
+#
+#   tc appendlog messages are reported.
+#
+proc wg_read_serdes_rx_delay {{rspId rsp0} {applev 21}} {
+  set clk_delay -1
+  if {[rsp readMsg [msg readMepMsg "serdes rxdelay rsp" 1] $rspId] == 0} {
+    msg setOffset 0
+    set clk_delay [msg readUnsigned 1]
+    set bit0 [expr $clk_delay & 1]
+    if {$bit0==0} {
+      tc appendLog $applev ">>> RSP-$rspId, read SERDES rx_clk : default input delay"
+    } else {
+      tc appendLog $applev ">>> RSP-$rspId, read SERDES rx_clk : incremented input delay"
+    }
+    tc setResult PASSED
+  } else {
+    tc setResult FAILED
+  }
+  return $clk_delay
+}
+
+
+###############################################################################
+#
+# WG_READ_SERDES_TX_DELAY : SERDES read TX_CLK output delay
+#
+# Input:
+#
+# - rspId    = RSP ID: 'rsp#' - only one
+# - applev   = Append log level
+#
+# Return:
+#
+# - clk_delay  = Tx clock output delay
+#                . bit 0 : '0' is default delay, '1' is incremented delay
+#
+#   tc appendlog messages are reported.
+#
+proc wg_read_serdes_tx_delay {{rspId rsp0} {applev 21}} {
+  set clk_delay -1
+  if {[rsp readMsg [msg readMepMsg "serdes txdelay rsp" 1] $rspId] == 0} {
+    msg setOffset 0
+    set clk_delay [msg readUnsigned 1]
+    set bit0 [expr $clk_delay & 1]
+    if {$bit0==0} {
+      tc appendLog $applev ">>> RSP-$rspId, read SERDES tx_clk : default output delay"
+    } else {
+      tc appendLog $applev ">>> RSP-$rspId, read SERDES tx_clk : incremented output delay"
+    }
+    tc setResult PASSED
+  } else {
+    tc setResult FAILED
+  }
+  return $clk_delay
+}
+
+
+###############################################################################
+#
+# WG_WRITE_RSU_ALTSYNC : RSU apply altsync
+#
+# Input:
+#
+# - rspId = RSP ID: 'rsp#'
+#
+# Return: void
+#
+proc wg_write_rsu_altsync {{rspId rsp0}} {
+  foreach ri $rspId {
+    if {[rsp writeMsg [msg writeMepMsg "rsu sysctrl rsp" 1] $ri] == 0} {
+      tc setResult PASSED
+    } else {
+      tc setResult FAILED
+    }
+  }
+}
+
+
+###############################################################################
+#
+# WG_WRITE_RD_SMBH_PROTOCOL_LIST : Write and readback protocol list to SMBus handler in RSP. The list will take effect at next sync
+#
+# Input:
+#
+# - smbh          = SMBus handler: 'smbh' or 'rcuh'
+# - protocol_list = Protocol list
+# - polId         = Polarization ID: x, y or "x y"
+# - blpId         = BLP ID: 'blp#'
+# - rspId         = RSP ID: 'rsp#'
+#
+# Report:
+#
+#   tc appendlog messages are reported.
+#   tc setResult is set
+#
+proc wg_write_rd_smbh_protocol_list {smbh protocol_list {polId {}} {blpId blp0} {rspId rsp0}} {
+  if {$smbh == "tdsh"} {
+    # Force blpId and polId to single element
+    set polId z     ;# dummy
+    set blpId rsp   ;# rsp = bp
+  }
+
+  # - Write the protocol list to the SMBH
+  smb_write_protocol_list $smbh $protocol_list $polId $blpId $rspId
+
+  # - Read back the protocol list to verify that this is possible
+  foreach ri $rspId {
+    foreach bi $blpId {
+      foreach pi $polId {
+        set rb_protocol_list [smb_readback_protocol_list $smbh [llength $protocol_list] $pi $bi $ri]
+        if {[string equal $protocol_list $rb_protocol_list] == 1} {
+          if {$smbh == "rcuh"} {
+            tc appendLog 21 ">>> RSP-$ri, BLP-$bi, $smbh-$pi: The protocol list READBACK went OK"
+          } else {
+            tc appendLog 21 ">>> RSP-$ri, BLP-$bi, $smbh  : The protocol list READBACK went OK"
+          }
+          tc setResult PASSED
+        } else {
+          if {$smbh == "rcuh"} {
+            tc appendLog 11 ">>> RSP-$ri, BLP-$bi, $smbh-$pi: The protocol list READBACK went wrong:"
+          } else {
+            tc appendLog 11 ">>> RSP-$ri, BLP-$bi, $smbh  : The protocol list READBACK went wrong:"
+          }
+          tc appendLog 11 "Expected protocol list: $protocol_list"
+          tc appendLog 11 "Readback protocol list: $rb_protocol_list"
+          tc setResult FAILED
+        }
+      }
+    }
+  }
+}
+
+
+###############################################################################
+#
+# WG_OVERWRITE_RD_SMBH_PROTOCOL_RESULTS : Overwrite and read protocol result of SMBus handler in RSP.
+#
+# Input:
+#
+# - smbh          = SMBus handler: 'smbh' or 'rcuh'
+# - polId         = Polarization ID: x, y or "x y"
+# - blpId         = BLP ID: 'blp#'
+# - rspId         = RSP ID: 'rsp#'
+#
+# Report:
+#
+#   tc appendlog messages are reported.
+#   tc setResult is set
+#
+proc wg_overwrite_rd_smbh_protocol_results {smbh {polId {}} {blpId blp0} {rspId rsp0}} {
+  global env
+  source "$env(RSP)/rsp/tb/tc/5. Datapath/constants.tcl"
+  
+  set nof_result_bytes [expr round(pow(2,$c_rcuh_result_adr_w))]
+  if {$smbh == "tdsh"} {
+    set nof_result_bytes [expr round(pow(2,$c_tdsh_result_adr_w))]
+    # Force blpId and polId to single element
+    set polId z     ;# dummy
+    set blpId rsp   ;# rsp = bp
+  }
+
+  # - Overwrite first entries of protocol result register to be sure that the results will be fresh
+  set wr_result {}
+  for {set i 1} {$i <= $nof_result_bytes} {incr i} {
+    lappend wr_result 17      ;# Just some number not equal to 0, 1, 255 and < 256
+  }
+
+  # - Overwrite
+  smb_overwrite_results $smbh $wr_result $polId $blpId $rspId
+
+  # - Readback to verify overwrite
+  foreach ri $rspId {
+    foreach bi $blpId {
+      foreach pi $polId {
+        # Read the protocol result from the I2C handler
+        set rd_result [smb_read_results $smbh $nof_result_bytes $pi $bi $ri]
+        if {[string equal $wr_result $rd_result] == 1} {
+          if {$smbh == "rcuh"} {
+            tc appendLog 21 ">>> RSP-$ri, BLP-$bi, $smbh-$pi: The protocol results OVERWRITE and read went OK"
+          } else {
+            tc appendLog 21 ">>> RSP-$ri, BLP-$bi, $smbh  : The protocol results OVERWRITE and read went OK"
+          }
+          tc setResult PASSED
+        } else {
+          if {$smbh == "rcuh"} {
+            tc appendLog 11 ">>> RSP-$ri, BLP-$bi, $smbh-$pi: The protocol results OVERWRITE and read went wrong:"
+          } else {
+            tc appendLog 11 ">>> RSP-$ri, BLP-$bi, $smbh  : The protocol results OVERWRITE and read went wrong:"
+          }
+          tc appendLog 11 "Expected protocol result: $wr_result"
+          tc appendLog 11 "Readback protocol result: $rd_result"
+          tc setResult FAILED
+        }
+      }
+    }
+  }
+}
+
+
+###############################################################################
+#
+# WG_WRITE_RCUH_SETTINGS : Write RCUH settings to register in RSP. The settings will take effect immediately
+#
+# Input:
+#
+# - input_en_x     = Input enable for x, 1 is RCU input enable, 0 is RCU input disable (powerup default)
+# - input_en_y     = Input enable for y, 1 is RCU input enable, 0 is RCU input disable (powerup default)
+# - input_delay_x  = Input sample delay depth for x
+# - input_delay_y  = Input sample delay depth for y
+# - blpId          = BLP ID: 'blp#'
+# - rspId          = RSP ID: 'rsp#'
+# - applev         = Append log level
+#
+# Report:
+#
+#   tc appendlog messages are reported.
+#   tc setResult is set
+#
+proc wg_write_rcuh_settings {input_en_x input_en_y input_delay_x input_delay_y {blpId blp0} {rspId rsp0} {applev 41}} {
+  # Assemble settings bytes from input arguments
+  set inp_x [expr $input_delay_x & 0x7F]
+  set inp_x [expr $inp_x | (($input_en_x != 0)<<7)]
+  set inp_y [expr $input_delay_y & 0x7F]
+  set inp_y [expr $inp_y | (($input_en_y != 0)<<7)]
+  
+  set test_data 0
+  
+  set inp_x_hi [expr ($input_delay_x & 0x7F80) >> 7]
+  set inp_y_hi [expr ($input_delay_y & 0x7F80) >> 7]
+  
+  tc appendLog $applev ">>> RSP-$rspId, BLP-$blpId, RCU-x write: input_en = [expr ($inp_x & 0x80)>0], input_delay = [expr ($inp_x_hi << 7) + ($inp_x & 0x7F)]"
+  tc appendLog $applev ">>> RSP-$rspId, BLP-$blpId, RCU-y write: input_en = [expr ($inp_y & 0x80)>0], input_delay = [expr ($inp_y_hi << 7) + ($inp_y & 0x7F)]"
+
+  foreach ri $rspId {
+    # Make use of MEP broadcast to all BLP on an RSP board
+    if {[rsp writeMsg [msg writeMepMsg "rcuh settings $blpId" "$inp_x $inp_y $test_data $inp_x_hi $inp_y_hi"] $ri] == 0} {
+      tc setResult PASSED
+    } else {
+      tc setResult FAILED
+    }
+  }
+}
+
+
+###############################################################################
+#
+# WG_READ_RCUH_SETTINGS : Read RCUH settings from register in RSP.
+#
+# Input:
+#
+# - blpId  = BLP ID: 'blp#'   -- only one
+# - rspId  = RSP ID: 'rsp#'   -- only one
+# - applev   = Append log level
+#
+# Report:
+#
+#   tc appendlog messages are reported.
+#   . input_en_x     = 1 is RCU X input enable, 0 is RCU input disable (powerup default)
+#   . input_delay_x  = Input sample delay depth for RCU X
+#   . input_en_y     = idem RCU Y
+#   . input_delay_y  = idem RCU Y
+#
+#   tc setResult is set
+#
+proc wg_read_rcuh_settings {{blpId blp0} {rspId rsp0} {applev 21} } {
+  set settings {-1 -1 -1 -1}
+  if {[rsp readMsg [msg readMepMsg "rcuh settings $blpId" 5] $rspId] == 0} {
+    msg setOffset 0
+    set inp_x     [msg readUnsigned 1]
+    set inp_y     [msg readUnsigned 1]
+    set test_data [msg readUnsigned 1]
+    set inp_x_hi  [msg readUnsigned 1]
+    set inp_y_hi  [msg readUnsigned 1]
+    set input_en_x    [expr ($inp_x & 0x80)>0]
+    set input_en_y    [expr ($inp_y & 0x80)>0]
+    set input_delay_x [expr ($inp_x_hi << 7) + ($inp_x & 0x7F)]
+    set input_delay_y [expr ($inp_y_hi << 7) + ($inp_y & 0x7F)]
+    set settings "$input_en_x $input_delay_x $input_en_y $input_delay_y"
+    tc appendLog $applev ">>> RSP-$rspId, BLP-$blpId, RCU-x read: input_en = $input_en_x, input_delay = $input_delay_x"
+    tc appendLog $applev ">>> RSP-$rspId, BLP-$blpId, RCU-y read: input_en = $input_en_y, input_delay = $input_delay_y"
+    tc setResult PASSED
+  } else {
+    tc setResult FAILED
+  }
+  return $settings
+}
+
+
+###############################################################################
+#
+# WG_WRITE_RCUH_SETTINGS_TEST : Write RCUH test data settings to register in RSP.
+#
+# Input:
+#
+# - sel_x    = Test data for x, 1 is COUNTER data, 0 is PRSG data (powerup default)
+# - sel_y    = Test data for y, 1 is COUNTER data, 0 is PRSG data (powerup default)
+# - en_x     = '0' disable x reference test data (powerup default), '1' enable x reference test data
+# - en_y     = '0' disable y reference test data (powerup default), '1' enable y reference test data
+# - blpId    = BLP ID: 'blp#'
+# - rspId    = RSP ID: 'rsp#'
+# - applev   = Append log level
+#
+# Report:
+#
+#   tc appendlog messages are reported.
+#   tc setResult is set
+#
+proc wg_write_rcuh_settings_test {en_x en_y sel_x sel_y {blpId blp0} {rspId rsp0} {applev 41}} {
+  # Assemble settings word from input arguments
+  set en_x  [expr $en_x & 0x1]
+  set en_y  [expr $en_y & 0x1]
+  set sel_x [expr $sel_x & 0x1]
+  set sel_y [expr $sel_y & 0x1]
+  
+  set testdata [expr $sel_x + ($sel_y<<1) + ($en_x<<2) + ($en_y<<3)]
+
+  if {$en_x==0} {
+    tc appendLog $applev ">>> RSP-$rspId, BLP-$blpId, RCUH-x disable reference test data"
+  } else {
+    if {$sel_x==0} {
+      tc appendLog $applev ">>> RSP-$rspId, BLP-$blpId, RCUH-x enable PRSG reference test data"
+    } else {
+      tc appendLog $applev ">>> RSP-$rspId, BLP-$blpId, RCUH-x enable COUNTER reference test data"
+    }
+  }
+  if {$en_y==0} {
+    tc appendLog $applev ">>> RSP-$rspId, BLP-$blpId, RCUH-y disable reference test data"
+  } else {
+    if {$sel_y==0} {
+      tc appendLog $applev ">>> RSP-$rspId, BLP-$blpId, RCUH-y enable PRSG reference test data"
+    } else {
+      tc appendLog $applev ">>> RSP-$rspId, BLP-$blpId, RCUH-y enable COUNTER reference test data"
+    }
+  }
+
+  foreach ri $rspId {
+    # Make use of MEP broadcast to all BLP on an RSP board
+    if {[rsp writeMsg [msg writeMepMsg "rcuh settings $blpId \"offset 2\"" $testdata] $ri] == 0} {
+      tc setResult PASSED
+    } else {
+      tc setResult FAILED
+    }
+  }
+}
+
+
+###############################################################################
+#
+# WG_READ_RCUH_SETTINGS_TEST : Read RCUH test data settings from register in RSP.
+#
+# Input:
+#
+# - blpId  = BLP ID: 'blp#'   -- only one
+# - rspId  = RSP ID: 'rsp#'   -- only one
+# - applev = Append log level
+#
+# Report:
+#
+#   tc appendlog messages are reported.
+#   . sel_x = Test data for x, 1 is COUNTER data, 0 is PRSG data (powerup default)
+#   . sel_y = Test data for y, 1 is COUNTER data, 0 is PRSG data (powerup default)
+#   . en_x  = '0' disabled x reference test data (powerup default), '1' enabled x reference test data
+#   . en_y  = '0' disabled y reference test data (powerup default), '1' enabled y reference test data
+#
+#   tc setResult is set
+#
+proc wg_read_rcuh_settings_test {{blpId blp0} {rspId rsp0} {applev 21} } {
+  set testdata -1
+  if {[rsp readMsg [msg readMepMsg "rcuh settings $blpId \"offset 2\"" 1] $rspId] == 0} {
+    msg setOffset 0
+    set testdata [msg readUnsigned 1]
+    set sel_x [expr $testdata & 0x1]
+    set sel_y [expr $testdata & 0x2]
+    set en_x  [expr $testdata & 0x4]
+    set en_y  [expr $testdata & 0x8]
+    if {$en_x==0} {
+      tc appendLog $applev ">>> RSP-$rspId, BLP-$blpId, RCUH-x reference test data read: Disabled"
+    } else {
+      if {$sel_x==0} {
+        tc appendLog $applev ">>> RSP-$rspId, BLP-$blpId, RCUH-x reference test data read: PRSG"
+      } else {
+        tc appendLog $applev ">>> RSP-$rspId, BLP-$blpId, RCUH-x reference test data read: COUNTER"
+      }
+    }
+    if {$en_y==0} {
+      tc appendLog $applev ">>> RSP-$rspId, BLP-$blpId, RCUH-y reference test data read: Disabled"
+    } else {
+      if {$sel_y==0} {
+        tc appendLog $applev ">>> RSP-$rspId, BLP-$blpId, RCUH-y reference test data read: PRSG"
+      } else {
+        tc appendLog $applev ">>> RSP-$rspId, BLP-$blpId, RCUH-y reference test data read: COUNTER"
+      }
+    }
+    tc setResult PASSED
+  } else {
+    tc setResult FAILED
+  }
+  return $testdata
+}
+
+
+###############################################################################
+#
+# WG_WRITE_RCUH_CLOCK_CONTROL : RCUH write RCU clock input delay
+#
+# Input:
+#
+# - clk_delay = 0 is reset RCU clock input delay to hardware default, > 0 increment input delay one time
+# - clk_edge  = 0 is capture RCU data on rising edge, != 0 is on falling edge
+# - polId     = Polarization ID: x, y or "x y"
+# - blpId     = BP, AP ID: 'rsp blp#'
+# - rspId     = RSP ID: 'rsp#'
+#
+# Return: void
+#
+proc wg_write_rcuh_clock_control {{clk_delay 0} {clk_edge 0} {polId x} {blpId blp0} {rspId rsp0}} {
+  set bit0 [expr $clk_delay > 0]  ;# RCU clock idelay control bit           
+  set bit1 [expr $clk_edge  > 0]  ;# RCU clock edge data capture control bit
+  set clk_control [expr ($bit1 << 1) + $bit0]
+  foreach ri $rspId {
+    # Make use of MEP broadcast to all BLP on an RSP board
+    set bi $blpId
+#     foreach bi $blpId {
+      foreach pi $polId {
+        if {[rsp writeMsg [msg writeMepMsg "rcuh clock$pi $bi" $clk_control] $ri] == 0} {
+          tc setResult PASSED
+        } else {
+          tc setResult FAILED
+        }
+      }
+#     }
+  }
+}
+
+
+###############################################################################
+#
+# WG_READ_RCUH_CLOCK_CONTROL : RCUH read RCU clock input delay bit and clock edge bit
+#
+# Input:
+#
+# - polId    = Polarization ID: x, y or "x y" - only one
+# - blpId    = BP, AP ID: 'rsp blp#' - only one
+# - rspId    = RSP ID: 'rsp#' - only one
+# - applev   = Append log level
+#
+# Return:
+#
+# - clk_control = RCU clock control
+#             . bit 0 : '0' is default RCU clock delay, '1' is incremented delay
+#             . bit 1 : '0' capture RCU data on rising edge, '1' on falling edge
+#
+#   tc appendlog messages are reported.
+#
+proc wg_read_rcuh_clock_control {{polId x} {blpId blp0} {rspId rsp0} {applev 21}} {
+  set clk_control -1
+  if {[rsp readMsg [msg readMepMsg "rcuh clock$polId $blpId" 1] $rspId] == 0} {
+    msg setOffset 0
+    set clk_control [msg readUnsigned 1]
+    set bit0 [expr  $clk_control & 1      ]  ;# RCU clock idelay control bit
+    set bit1 [expr ($clk_control & 2) >> 1]  ;# RCU clock edge data capture control bit
+    if {$bit0==0 && $bit1==0} {
+      tc appendLog $applev ">>> RSP-$rspId, BLP-$blpId, RCU-$polId read clock control: default input delay,     default capture data on rising edge"
+    } elseif {$bit0==0 && $bit1!=0} {
+      tc appendLog $applev ">>> RSP-$rspId, BLP-$blpId, RCU-$polId read clock control: default input delay,     capture data on falling edge"
+    } elseif {$bit0!=0 && $bit1==0} {
+      tc appendLog $applev ">>> RSP-$rspId, BLP-$blpId, RCU-$polId read clock control: incremented input delay, default capture data on rising edge"
+    } else {
+      tc appendLog $applev ">>> RSP-$rspId, BLP-$blpId, RCU-$polId read clock control: incremented input delay, capture data on falling edge"
+    }
+    tc setResult PASSED
+  } else {
+    tc setResult FAILED
+  }
+  return $clk_control
+}
+
+
+###############################################################################
+#
+# WG_WRITE_RCUH_CONTROL_LIST : Write RCU protocol list to register in RSP. The list will take effect at next sync
+#
+# Input:
+#
+# - ctrl     = RCU control, three decimal byte values
+# - polId    = Polarization ID: x, y or "x y"
+# - blpId    = BLP ID: 'blp#'
+# - rspId    = RSP ID: 'rsp#'
+#
+# Report:
+#
+#   tc appendlog messages are reported.
+#   tc setResult is set
+#
+proc wg_write_rcuh_control_list {ctrl {polId {x y}} {blpId blp0} {rspId rsp0}} {
+  # - Prepare the protocol list for RCU control register
+  set c_nof_ctrl_bytes  3
+  set ctrl [join $ctrl]
+  if {([llength $ctrl] % $c_nof_ctrl_bytes) == 0} {
+    # Treat as one or more seperate accesses each accessing the whole ctrl word of c_nof_ctrl_bytes
+    set cn 0
+    set cw {}
+    set addr              1
+    set protocol_list {}
+    foreach ci $ctrl {
+      lappend cw $ci
+      incr cn
+      if {$cn == $c_nof_ctrl_bytes} {
+        lappend protocol_list [smb_protocol PROTOCOL_C_SEND_BLOCK    $c_nof_ctrl_bytes $addr $cw]
+        lappend protocol_list [smb_protocol PROTOCOL_C_RECEIVE_BLOCK $c_nof_ctrl_bytes $addr]
+        set cn 0
+        set cw {}
+      }
+    }
+  } else {
+    # Treat as single access, this results in a wrapped and/or partial RCU ctrl word access 
+    lappend protocol_list [smb_protocol PROTOCOL_C_SEND_BLOCK    [llength $ctrl]   $addr $ctrl]
+    lappend protocol_list [smb_protocol PROTOCOL_C_RECEIVE_BLOCK $c_nof_ctrl_bytes $addr]
+  }
+  lappend protocol_list [smb_protocol PROTOCOL_C_END]
+  set protocol_list [join $protocol_list]
+
+  # - Write (and readback) the protocol list to the RCUH, use same for all RCU
+  wg_write_rd_smbh_protocol_list rcuh $protocol_list $polId $blpId $rspId
+
+  # - Overwrite (and readback) first entry of protocol result register to be sure that the results will be fresh
+  wg_overwrite_rd_smbh_protocol_results rcuh $polId $blpId $rspId
+}
+
+
+###############################################################################
+#
+# WG_READ_RCUH_CONTROL_RESULT : Read RCU protocol results from register in RSP
+#
+# Input:
+#
+# - ctrl     = Expected RCU control bytes, three decimal byte values
+# - polId    = Polarization: x, y or "x y"
+# - blpId    = BLP ID: 'blp#'
+# - rspId    = RSP ID: 'rsp#'
+#
+# Report:
+#
+#   tc appendlog messages are reported.
+#   tc setResult is set
+#
+proc wg_read_rcuh_control_result {ctrl {polId {x y}} {blpId blp0} {rspId rsp0}} {
+  global env
+  source "$env(RSP)/rsp/tb/tc/5. Datapath/constants.tcl"
+
+  # - Prepare expected read result
+  set c_nof_ctrl_bytes  3
+  if {([llength $ctrl] % $c_nof_ctrl_bytes) == 0} {
+    # Treat as one or more seperate accesses each accessing the whole ctrl word of c_nof_ctrl_bytes
+    set ctrl [join $ctrl]
+    set cn 0
+    set cw {}
+    set exp_result ""
+    foreach ci $ctrl {
+      if {$cn == 0} {
+        # correct expected read for RCU version number in ctrlreg[23:20]
+        lappend cw [expr (($c_rcu_version & 0xF) << 4) + ($ci & 0xF)]
+      } else {
+        lappend cw $ci
+      }
+      incr cn
+      if {$cn == $c_nof_ctrl_bytes} {
+        append exp_result "0 $cw 0 "
+        set cn 0
+        set cw {}
+      }
+    }
+    append exp_result "0"
+  } else {
+    # Treat as single access, this results in a wrapped and/or partial RCU ctrl word access 
+    tc appendLog 11 "Can not determine expected results for wrapped and/or partial RCU ctrl word access"
+    crash
+  }
+
+  # - Read the protocol results from the RCUH
+  foreach ri $rspId {
+    foreach bi $blpId {
+      foreach pi $polId {
+        set rd_result [smb_read_results rcuh [llength $exp_result] $pi $bi $ri]
+
+        # Equal?
+        if {[string equal $rd_result $exp_result] == 1} {
+          tc appendLog 21 ">>> RSP-$ri, BLP-$bi, RCU-$pi I2C access result buffer contents is OK"
+          tc setResult PASSED
+        } else {
+          tc appendLog 11 ">>> RSP-$ri, BLP-$bi, RCU-$pi I2C access result buffer contents is wrong:"
+          tc appendLog 11 "Expected protocol result: $exp_result"
+          tc appendLog 11 "Read     protocol result: $rd_result"
+          tc setResult FAILED
+        }
+      }
+    }
+  }
+}
+
+
+###############################################################################
+#
+# WG_WRITE_TBBI_SETTINGS : Write TBBI settings to register in RSP. The settings will take effect at sync.
+#
+# Input:
+#
+# - station_id     = Station identifier number, 1 byte.
+# - rsp_id         = RSP board identifier number, 1 byte.
+# - rcu_id         = RCU board identifier number, 1 byte.
+# - sample_freq    = 160 or 200, to represent the sample frequency of the RCU in MHz, 1 byte
+# - nof_samples    = Number of samples, 2 bytes
+# - nof_bands      = Number of bands, 2 bytes
+# - polId          = Polarization ID: x, y or "x y"
+# - blpId          = BLP ID: 'blp#'
+# - rspId          = RSP ID: 'rsp#'
+# - applev         = Append log level
+#
+# Report:
+#
+#   tc appendlog messages are reported.
+#   tc setResult is set
+#
+proc wg_write_tbbi_settings {station_id rsp_id rcu_id sample_freq nof_samples nof_bands {polId {x y}} {blpId blp0} {rspId rsp0} {applev 41}} {
+  tc appendLog $applev ">>> RSP-$rspId, BLP-$blpId, RCU-$polId write TBBI settings:"
+  tc appendLog $applev "      station_id     = $station_id"
+  tc appendLog $applev "      rsp_id         = $rsp_id"
+  tc appendLog $applev "      rcu_id         = $rcu_id"
+  tc appendLog $applev "      sample_freq    = $sample_freq"
+  tc appendLog $applev "      nof_samples    = $nof_samples"
+  tc appendLog $applev "      nof_bands      = $nof_bands"
+
+  foreach ri $rspId {
+    foreach pi $polId {
+      # Make use of MEP broadcast to all BLP on an RSP board
+      if {[rsp writeMsg [msg writeMepMsg "tbbi settings$pi $blpId" "$station_id
+                                                                    $rsp_id
+                                                                    $rcu_id
+                                                                    $sample_freq
+                                                                    [wg_i2bb $nof_samples]
+                                                                    [wg_i2bb $nof_bands]" ] $ri] == 0} {
+        tc setResult PASSED
+      } else {
+        tc setResult FAILED
+      }
+    }
+  }
+}
+
+
+###############################################################################
+#
+# WG_READ_TBBI_SETTINGS : Read TBBI settings register in RSP
+#
+# Input:
+#
+# - polId    = Polarization ID: x, y or "x y" - only one
+# - blpId    = BLP ID: 'rsp blp#' - only one
+# - rspId    = RSP ID: 'rsp#' - only one
+# - applev   = Append log level
+#
+# Return:
+#
+# - settings = TBBI settings
+#
+#   tc appendlog messages are reported.
+#
+proc wg_read_tbbi_settings {{polId x} {blpId blp0} {rspId rsp0} {applev 21}} {
+  set settings {}
+  if {[rsp readMsg [msg readMepMsg "tbbi settings$polId $blpId" 8] $rspId] == 0} {
+    msg setOffset 0
+    set station_id  [msg readUnsigned 1]
+    set rsp_id      [msg readUnsigned 1]
+    set rcu_id      [msg readUnsigned 1]
+    set sample_freq [msg readUnsigned 1]
+    set nof_samples [msg readUnsigned 2]
+    set nof_bands   [msg readUnsigned 2]
+    tc appendLog $applev ">>> RSP-$rspId, BLP-$blpId, RCU-$polId read TBBI settings:"
+    tc appendLog $applev "      station_id  = $station_id"
+    tc appendLog $applev "      rsp_id      = $rsp_id"
+    tc appendLog $applev "      rcu_id      = $rcu_id"
+    tc appendLog $applev "      sample_freq = $sample_freq"
+    tc appendLog $applev "      nof_samples = $nof_samples"
+    tc appendLog $applev "      nof_bands   = $nof_bands"
+    lappend settings $station_id
+    lappend settings $rsp_id
+    lappend settings $rcu_id
+    lappend settings $sample_freq
+    lappend settings $nof_samples
+    lappend settings $nof_bands
+    tc setResult PASSED
+  } else {
+    tc setResult FAILED
+  }
+  return $settings
+}
+
+
+###############################################################################
+#
+# WG_WRITE_TBBI_BANDSEL : Write TBBI band selections to register in RSP. The settings will take effect at sync.
+#
+# Input:
+#
+# - nof_bands      = When 0 then use bandsel array, else select first nof_bands
+# - bandsel        = Array of band select bytes ('dec' or 0x'hex'), will be padded with 0 bytes to total nof 64 bytes if necessary
+# - polId          = Polarization ID: x, y or "x y"
+# - blpId          = BLP ID: 'blp#'
+# - rspId          = RSP ID: 'rsp#'
+# - applev         = Append log level
+#
+# Report:
+#
+#   tc appendlog messages are reported.
+#   tc setResult is set
+#
+proc wg_write_tbbi_bandsel {nof_bands bandsel {polId {x y}} {blpId blp0} {rspId rsp0} {applev 41}} {
+  set bytesel {}
+  set bytenr 0
+  if {$nof_bands==0} {
+    foreach bs $bandsel {
+      lappend bytesel [expr $bs]
+      incr bytenr
+    }
+  } else {
+    set nof_bytes [expr $nof_bands/8]
+    set nof_bits  [expr $nof_bands - 8*$nof_bytes]
+  tc appendLog $applev "      nof_bytes = $nof_bytes"
+  tc appendLog $applev "      nof_bits = $nof_bits"
+    
+    for {set bi 0} {$bi < $nof_bytes} {incr bi} {
+      lappend bytesel [expr 0xFF]
+    }
+    set bytenr $nof_bytes
+    if {$nof_bits > 0} {
+      lappend bytesel [expr (1 << $nof_bits) - 1]
+      incr bytenr
+    }
+  }
+  for {set bi $bytenr} {$bi < 64} {incr bi} {
+    lappend bytesel 0
+  }
+  
+  tc appendLog $applev ">>> RSP-$rspId, BLP-$blpId, RCU-$polId write TBBI bandsel:"
+  tc appendLog $applev "      nof_bands = $nof_bands"
+  set bytenr 0
+  for {set br 0} {$br < 8} {incr br} {
+    set bytelo       $bytenr
+    set bytehi [expr $bytenr + 8-1]
+    set str ""
+    for {set bc 0} {$bc < 8} {incr bc} {
+      append str [format " %2x" [lindex $bytesel $bytenr]]
+      incr bytenr
+    }
+    tc appendLog $applev "      bandsel\[$bytelo:$bytehi\] = $str"
+  }
+  
+  foreach ri $rspId {
+    foreach pi $polId {
+      # Make use of MEP broadcast to all BLP on an RSP board
+      if {[rsp writeMsg [msg writeMepMsg "tbbi selmem$pi $blpId" $bytesel] $ri] == 0} {
+        tc setResult PASSED
+      } else {
+        tc setResult FAILED
+      }
+    }
+  }
+}
+
+
+###############################################################################
+#
+# WG_READ_TBBI_BANDSEL : Read TBBI band selections from register in RSP.
+#
+# Input:
+#
+# - polId          = Polarization ID: x, y or "x y" - only one
+# - blpId          = BLP ID: 'blp#' - only one
+# - rspId          = RSP ID: 'rsp#' - only one
+# - applev         = Append log level
+#
+# Report:
+#
+#   bandsel        = Array of band select bytes ('dec' or 0x'hex'), will be padded with 0 bytes to total nof 64 bytes if necessary
+#   tc appendlog messages are reported.
+#   tc setResult is set
+#
+proc wg_read_tbbi_bandsel {{polId x} {blpId blp0} {rspId rsp0} {applev 41}} {
+  set bandsel {}
+  if {[rsp readMsg [msg readMepMsg "tbbi selmem$polId $blpId" 64] $rspId] == 0} {
+    msg setOffset 0
+    for {set bi 0} {$bi < 64} {incr bi} {
+      lappend bandsel [msg readUnsigned 1]
+    }
+    tc appendLog $applev ">>> RSP-$rspId, BLP-$blpId, RCU-$polId read TBBI bandsel:"
+    set bytenr 0
+    for {set br 0} {$br < 8} {incr br} {
+      set bytelo       $bytenr
+      set bytehi [expr $bytenr + 8-1]
+      set str ""
+      for {set bc 0} {$bc < 8} {incr bc} {
+        append str [format " %2x" [lindex $bandsel $bytenr]]
+        incr bytenr
+      }
+      tc appendLog $applev "      bandsel\[$bytelo:$bytehi\] = $str"
+    }
+    tc setResult PASSED
+  } else {
+    tc setResult FAILED
+  }
+  return $bandsel
+}
+
+
+###############################################################################
+#
+# WG_WRITE_TBBI_TEST : Write TBBI tx test data settings to register in RSP.
+#
+# Input:
+#
+# - sel_x    = Test data for x, 1 is COUNTER data, 0 is PRSG data (powerup default)
+# - sel_y    = Test data for y, 1 is COUNTER data, 0 is PRSG data (powerup default)
+# - en_x     = '0' disable x tx test data (powerup default), '1' enable x tx test data
+# - en_y     = '0' disable y tx test data (powerup default), '1' enable y tx test data
+# - blpId    = BLP ID: 'blp#'
+# - rspId    = RSP ID: 'rsp#'
+# - applev   = Append log level
+#
+# Report:
+#
+#   tc appendlog messages are reported.
+#   tc setResult is set
+#
+proc wg_write_tbbi_test {en_x en_y sel_x sel_y {blpId blp0} {rspId rsp0} {applev 41}} {
+  # Assemble settings word from input arguments
+  set en_x  [expr $en_x & 0x1]
+  set en_y  [expr $en_y & 0x1]
+  set sel_x [expr $sel_x & 0x1]
+  set sel_y [expr $sel_y & 0x1]
+  
+  set testdata [expr $sel_x + ($sel_y<<1) + ($en_x<<2) + ($en_y<<3)]
+
+  if {$en_x==0} {
+    tc appendLog $applev ">>> RSP-$rspId, BLP-$blpId, TBBI-x disable tx test data"
+  } else {
+    if {$sel_x==0} {
+      tc appendLog $applev ">>> RSP-$rspId, BLP-$blpId, TBBI-x enable PRSG tx test data"
+    } else {
+      tc appendLog $applev ">>> RSP-$rspId, BLP-$blpId, TBBI-x enable COUNTER tx test data"
+    }
+  }
+  if {$en_y==0} {
+    tc appendLog $applev ">>> RSP-$rspId, BLP-$blpId, TBBI-y disable tx test data"
+  } else {
+    if {$sel_y==0} {
+      tc appendLog $applev ">>> RSP-$rspId, BLP-$blpId, TBBI-y enable PRSG tx test data"
+    } else {
+      tc appendLog $applev ">>> RSP-$rspId, BLP-$blpId, TBBI-y enable COUNTER tx test data"
+    }
+  }
+
+  foreach ri $rspId {
+    # Make use of MEP broadcast to all BLP on an RSP board
+    if {[rsp writeMsg [msg writeMepMsg "tbbi test $blpId" $testdata] $ri] == 0} {
+      tc setResult PASSED
+    } else {
+      tc setResult FAILED
+    }
+  }
+}
+
+
+###############################################################################
+#
+# WG_READ_TBBI_TEST : Read TBBI tx test data settings from register in RSP.
+#
+# Input:
+#
+# - blpId  = BLP ID: 'blp#'   -- only one
+# - rspId  = RSP ID: 'rsp#'   -- only one
+# - applev = Append log level
+#
+# Report:
+#
+#   tc appendlog messages are reported.
+#   . sel_x = Test data for x, 1 is COUNTER data, 0 is PRSG data (powerup default)
+#   . sel_y = Test data for y, 1 is COUNTER data, 0 is PRSG data (powerup default)
+#   . en_x  = '0' disabled x tx test data (powerup default), '1' enabled x tx test data
+#   . en_y  = '0' disabled y tx test data (powerup default), '1' enabled y tx test data
+#
+#   tc setResult is set
+#
+proc wg_read_tbbi_test {{blpId blp0} {rspId rsp0} {applev 21} } {
+  set testdata -1
+  if {[rsp readMsg [msg readMepMsg "tbbi test $blpId" 1] $rspId] == 0} {
+    msg setOffset 0
+    set testdata [msg readUnsigned 1]
+    set sel_x [expr $testdata & 0x1]
+    set sel_y [expr $testdata & 0x2]
+    set en_x  [expr $testdata & 0x4]
+    set en_y  [expr $testdata & 0x8]
+    if {$en_x==0} {
+      tc appendLog $applev ">>> RSP-$rspId, BLP-$blpId, TBBI-x tx test data read: Disabled"
+    } else {
+      if {$sel_x==0} {
+        tc appendLog $applev ">>> RSP-$rspId, BLP-$blpId, TBBI-x tx test data read: PRSG"
+      } else {
+        tc appendLog $applev ">>> RSP-$rspId, BLP-$blpId, TBBI-x tx test data read: COUNTER"
+      }
+    }
+    if {$en_y==0} {
+      tc appendLog $applev ">>> RSP-$rspId, BLP-$blpId, TBBI-y tx test data read: Disabled"
+    } else {
+      if {$sel_y==0} {
+        tc appendLog $applev ">>> RSP-$rspId, BLP-$blpId, TBBI-y tx test data read: PRSG"
+      } else {
+        tc appendLog $applev ">>> RSP-$rspId, BLP-$blpId, TBBI-y tx test data read: COUNTER"
+      }
+    }
+    tc setResult PASSED
+  } else {
+    tc setResult FAILED
+  }
+  return $testdata
+}
+
+
+###############################################################################
+#
+# WG_WRITE_DIAG_BYPASS : DIAG write bypass
+#
+# Input:
+#
+# - bypass   = Bypass enable bits
+# - blpId    = BLP ID: 'blp#'
+# - rspId    = RSP ID: 'rsp#'
+# - applev   = Append log level
+#
+# Return: void
+#
+#   tc appendlog messages are reported.
+#
+proc wg_write_diag_bypass {bypass {blpId blp0} {rspId rsp0} {applev 41}} {
+  tc appendLog $applev ">>> RSP-$rspId, BLP-$blpId, write DIAG bypass:"
+  tc appendLog $applev "      bit(0) : Bypass DC                      = [expr ($bypass &  1    ) > 0]"
+  tc appendLog $applev "      bit(1) : Bypass PFS                     = [expr ($bypass & (1<<1)) > 0]"
+  tc appendLog $applev "      bit(2) : Bypass PFT                     = [expr ($bypass & (1<<2)) > 0]"
+  tc appendLog $applev "      bit(3) : Bypass BF                      = [expr ($bypass & (1<<3)) > 0]"
+  tc appendLog $applev "      bit(4) : SI enable X                    = [expr ($bypass & (1<<4)) > 0]"
+  tc appendLog $applev "      bit(5) : SI enable Y                    = [expr ($bypass & (1<<5)) > 0]"
+  tc appendLog $applev "      bit(6) : DIAG result buffer use sync    = [expr ($bypass & (1<<6)) > 0]"
+  tc appendLog $applev "      bit(7) : DIAG result buffer use resync  = [expr ($bypass & (1<<7)) > 0]"
+  tc appendLog $applev "      bit(8) : PFT switching disable          = [expr ($bypass & (1<<8)) > 0]"
+  tc appendLog $applev "   bit(10:9) : DIAG result buffer for BM bank = [expr ($bypass & (3<<9)) > 0]"
+  tc appendLog $applev "     bit(11) : DIAG result buffer for BP      = [expr ($bypass & (1<<11)) > 0]"
+  tc appendLog $applev "     bit(12) : Page swap on system sync       = [expr ($bypass & (1<<12)) > 0]"
+  tc appendLog $applev "     bit(13) : RAD tx beamlet disable         = [expr ($bypass & (1<<13)) > 0]"
+  tc appendLog $applev "     bit(14) : RAD tx crosslet disable        = [expr ($bypass & (1<<14)) > 0]"
+  tc appendLog $applev "     bit(15) : RAD tx subband disable         = [expr ($bypass & (1<<15)) > 0]"
+
+  foreach ri $rspId {
+    # Make use of MEP broadcast to all BLP on an RSP board
+    if {[rsp writeMsg [msg writeMepMsg "diag bypass $blpId" [wg_i2bb $bypass]] $ri] == 0} {
+      tc setResult PASSED
+    } else {
+      tc setResult FAILED
+    }
+  }
+}
+
+
+###############################################################################
+#
+# WG_READ_DIAG_BYPASS : DIAG read bypass
+#
+# Input:
+#
+# - blpId    = BLP ID: 'blp#' - only one
+# - rspId    = RSP ID: 'rsp#' - only one
+# - applev   = Append log level
+#
+# Return:
+#
+# - bypass   = Bypass enable bits
+#
+#   tc appendlog messages are reported.
+#
+proc wg_read_diag_bypass {{blpId blp0} {rspId rsp0} {applev 21}} {
+  set bypass -1
+  if {[rsp readMsg [msg readMepMsg "diag bypass $blpId" 2] $rspId] == 0} {
+    msg setOffset 0
+    set bypass [msg readUnsigned 2]
+    tc appendLog $applev ">>> RSP-$rspId, BLP-$blpId, read DIAG bypass:"
+    tc appendLog $applev "      bit(0) : Bypass DC                      = [expr ($bypass &  1    ) > 0]"
+    tc appendLog $applev "      bit(1) : Bypass PFS                     = [expr ($bypass & (1<<1)) > 0]"
+    tc appendLog $applev "      bit(2) : Bypass PFT                     = [expr ($bypass & (1<<2)) > 0]"
+    tc appendLog $applev "      bit(3) : Bypass BF                      = [expr ($bypass & (1<<3)) > 0]"
+    tc appendLog $applev "      bit(4) : SI enable X                    = [expr ($bypass & (1<<4)) > 0]"
+    tc appendLog $applev "      bit(5) : SI enable Y                    = [expr ($bypass & (1<<5)) > 0]"
+    tc appendLog $applev "      bit(6) : DIAG result buffer use sync    = [expr ($bypass & (1<<6)) > 0]"
+    tc appendLog $applev "      bit(7) : DIAG result buffer use resync  = [expr ($bypass & (1<<7)) > 0]"
+    tc appendLog $applev "      bit(8) : PFT switching disable          = [expr ($bypass & (1<<8)) > 0]"
+    tc appendLog $applev "   bit(10:9) : DIAG result buffer for BM bank = [expr ($bypass & (3<<9)) > 0]"
+    tc appendLog $applev "     bit(11) : DIAG result buffer for BP      = [expr ($bypass & (1<<11)) > 0]"
+    tc appendLog $applev "     bit(12) : Page swap on system sync       = [expr ($bypass & (1<<12)) > 0]"
+    tc appendLog $applev "     bit(13) : RAD tx beamlet disable         = [expr ($bypass & (1<<13)) > 0]"
+    tc appendLog $applev "     bit(14) : RAD tx crosslet disable        = [expr ($bypass & (1<<14)) > 0]"
+    tc appendLog $applev "     bit(15) : RAD tx subband disable         = [expr ($bypass & (1<<15)) > 0]"
+    tc setResult PASSED
+  } else {
+    tc setResult FAILED
+  }
+  return $bypass
+}
+
+
+###############################################################################
+#
+# WG_SETUP_DIAG_WAVEFORM_GENERATOR : Setup the waveform generator
+#
+# Input:
+#
+# - mode     = Mode: 'idle', 'single', 'repeat', 'calc'
+# - phase    = - Calc phase: 8 bit INTEGER
+# - freq     = - Calc freq: 32 bit INTEGER
+# - ampl     = - Calc ampl: 32 bit INTEGER
+# - polId    = Polarization ID: x, y or "x y"
+# - blpId    = BLP ID: 'blp#'
+# - rspId    = RSP ID: 'rsp#'
+# - bc       = When != 0 use MEP broadcast
+#
+# Return: void
+#
+proc wg_setup_diag_waveform_generator {mode nof_samples {phase 0} {freq 0} {ampl 0} {polId {x y}} {blpId blp0} {rspId rsp0} {bc 0}} {
+  # Format bytes (LSByte first):  mode 1, phase 1, nof_samples 2, freq 4, ampl 4.
+  set m 0
+  switch $mode {
+    idle    {set m 0}
+    calc    {set m 1}
+    single  {set m 3}
+    repeat  {set m 5}
+    default {
+      puts "Unknown WG mode $mode."
+      exit
+    }
+  }
+  foreach ri $rspId {
+    foreach pi $polId {
+      if {$bc == 0} {
+        foreach bi $blpId {
+          if {[rsp writeMsg [msg writeMepMsg "diag set$pi $bi" "$m
+                                                                [expr      $phase%256]
+                                                                [wg_i2bb   $nof_samples]
+                                                                [wg_i2bbbb $freq]
+                                                                [wg_i2bbbb $ampl]" ] $ri] == 0} {
+            tc setResult PASSED
+          } else {
+            tc setResult FAILED
+          }
+        }
+      } else {
+        # Make use of MEP broadcast to all BLP on an RSP board
+        if {[rsp writeMsg [msg writeMepMsg "diag set$pi $blpId" "$m
+                                                                 [expr      $phase%256]
+                                                                 [wg_i2bb   $nof_samples]
+                                                                 [wg_i2bbbb $freq]
+                                                                 [wg_i2bbbb $ampl]" ] $ri] == 0} {
+          tc setResult PASSED
+        } else {
+          tc setResult FAILED
+        }
+      }
+    }
+  }
+}
+
+
+###############################################################################
+#
+# WG_READ_DIAG_WAVEFORM_GENERATOR : Read the DIAG waveform generator settings
+#
+# Input:
+#
+# - polId    = Polarization: x | y   - only one
+# - blpId    = BLP ID: 'blp#'        - only one
+# - rspId    = RSP ID: 'rsp#'        - only one
+#
+# Return:
+#
+# - settings = List of WG settings fields
+#
+proc wg_read_diag_waveform_generator {{polId x} {blpId blp0} {rspId rsp0}} {
+  set settings {}
+  if {[rsp readMsg [msg readMepMsg "diag set$polId $blpId" 12] $rspId] == 0} {
+    msg setOffset 0
+    switch [msg readUnsigned 1] {
+      0  {set m idle}
+      1  {set m calc}
+      3  {set m single}
+      5  {set m repeat}
+      default {
+        set m "unknown"
+      }
+    }
+    lappend settings $m                       ;# mode
+    lappend settings [msg readUnsigned 1]     ;# phase
+    lappend settings [msg readUnsigned 2]     ;# nof samples
+    lappend settings [msg readUnsigned 4]     ;# freq
+    lappend settings [msg readUnsigned 4]     ;# ampl
+    tc setResult PASSED
+  } else {
+    tc setResult FAILED
+  }
+  return $settings
+}
+
+
+###############################################################################
+#
+# WG_WRITE_DIAG_WAVEFORM : Write waveform to the waveform generator
+#
+# Input:
+#
+# - wavep    = Polarization: 'wavex' or 'wavey'
+# - samples  = Waveform sample values, INTEGERs
+# - polId    = Polarization ID: x, y or "x y"
+# - blpId    = BLP ID: 'blp#'
+# - rspId    = RSP ID: 'rsp#'
+# - bc       = When != 0 use MEP broadcast
+#
+# Return:
+#
+# - ret      = 1 if write PASSED else 0
+#
+proc wg_write_diag_waveform {samples {polId {x y}} {blpId blp0} {rspId rsp0} {bc 0}} {
+  set c_eth_block 1400
+
+  set data    [wg_i2bbbb $samples]
+  set len     [llength $data]
+  set ret_all 0
+
+  foreach ri $rspId {
+    foreach pi $polId {
+      set i 0
+      while {$i < $len} {
+        if {$bc == 0} {
+          foreach bi $blpId {
+            if {[rsp writeMsg [msg writeMepMsg "diag wave$pi $bi \"offset $i\"" [lrange $data $i [expr $i +  $c_eth_block - 1]]] $ri] == 0} {
+              tc setResult PASSED
+            } else {
+              tc setResult FAILED
+              set ret_all 1
+            }
+          }
+        } else {
+          # Make use of MEP broadcast to all BLP on an RSP board
+          if {[rsp writeMsg [msg writeMepMsg "diag wave$pi $blpId \"offset $i\"" [lrange $data $i [expr $i +  $c_eth_block - 1]]] $ri] == 0} {
+            tc setResult PASSED
+          } else {
+            tc setResult FAILED
+            set ret_all 1
+          }
+        }
+        incr i $c_eth_block
+      }
+    }
+  }
+
+  return $ret_all
+}
+
+
+###############################################################################
+#
+# WG_READ_DIAG_WAVEFORM : Readback DIAG waveform
+#
+# Input:
+#
+# - len_w    = Number of words to read from the waveform buffer, INTEGER
+# - polId    = Polarization ID: 'x' or 'y' - only one
+# - blpId    = BLP ID: 'blp#' - only one
+# - rspId    = RSP ID: 'rsp#' - only one
+#
+# Return:
+#
+# - waveform = Read message result (0 when readMsg went PASSED else 1) and the read waveform samples
+#
+proc wg_read_diag_waveform {len_w {polId x} {blpId blp0} {rspId rsp0}} {
+  set c_diag_reg_wave_dat_w  18
+  set c_sign                 [expr round(pow(2,$c_diag_reg_wave_dat_w-1))]
+
+  set c_eth_block   1400
+  set i             0
+  set n             $c_eth_block
+  set width         4
+  set len           [expr $len_w * $width]
+  set ret           0
+  set waveform      {}
+
+  while {$i < $len && $ret == 0} {
+    if {$len - $i < $n} {set n [expr $len - $i]}
+    if {[rsp readMsg [msg readMepMsg "diag wave$polId $blpId \"offset $i\"" $n] $rspId] == 0} {
+      msg setOffset 0
+      for {set k 0} {$k < $n/$width} {incr k} {
+        set sample [msg readUnsigned $width]
+        if {$sample >= $c_sign} {
+          lappend waveform [expr $sample - 2*$c_sign]
+        } else {
+          lappend waveform $sample
+        }
+      }
+      tc setResult PASSED
+    } else {
+      tc setResult FAILED
+      set ret 1
+    }
+    incr i $c_eth_block
+  }
+  lappend ret $waveform
+
+  return $ret
+}
+
+
+###############################################################################
+#
+# WG_READ_DIAG_RESULT_BUFFER : Read DIAG result buffer
+#
+# Input:
+#
+# - len      = Number of bytes to read from the result buffer, INTEGER
+# - width    = Word width of result buffer samples, INTEGER 1, 2 or 4
+# - blpId    = BLP ID: 'blp#' - only one
+# - rspId    = RSP ID: 'rsp#' - only one
+#
+# Return:
+#
+# - res_buffer = Result buffer samples
+#
+proc wg_read_diag_result_buffer {len width {blpId blp0} {rspId rsp0}} {
+  set c_eth_block   1400
+  set i             0
+  set n             $c_eth_block
+  set ret           0
+  set res_buffer    {}
+
+  while {$i < $len && $ret == 0} {
+    if {$len - $i < $n} {set n [expr $len - $i]}
+    if {[rsp readMsg [msg readMepMsg "diag result $blpId \"offset $i\"" $n] $rspId] == 0} {
+      msg setOffset 0
+      for {set k 0} {$k < $n/$width} {incr k} {
+        lappend res_buffer [msg readSigned $width]
+      }
+      tc setResult PASSED
+    } else {
+      tc setResult FAILED
+      set ret 1
+    }
+    incr i $c_eth_block
+  }
+
+  return $res_buffer
+}
+
+
+###############################################################################
+#
+# WG_WRITE_BS_NOF_SAMPLES_PSYNC : Write BS number of samples per sync interval
+#
+# Input:
+#
+# - nof_samples_psync  = BS nof samples per sync interval
+# - blpId              = BLP ID: 'blp#'
+# - rspId              = RSP ID: 'rsp#'
+# - applev             = Append log level
+#
+# Return: void
+#
+proc wg_write_bs_nof_samples_psync {nof_samples_psync {blpId blp0} {rspId rsp0} {applev 41}} {
+  tc appendLog $applev ">>> RSP-$rspId, BLP-$blpId, write BS nof samples per sync: $nof_samples_psync"
+  foreach ri $rspId {
+    # Make use of MEP broadcast to all BLP on an RSP board
+    if {[rsp writeMsg [msg writeMepMsg "bs psync $blpId" [wg_i2bbbb $nof_samples_psync]] $ri] == 0} {
+      tc setResult PASSED
+    } else {
+      tc setResult FAILED
+    }
+  }
+}
+
+
+###############################################################################
+#
+# WG_READ_BS_NOF_SAMPLES_PSYNC : BS read nof samples per sync interval
+#
+# Input:
+#
+# - blpId    = BLP ID: 'blp#' - only one
+# - rspId    = RSP ID: 'rsp#' - only one
+# - applev   = Append log level
+#
+# Return:
+#
+# - nof_samples_psync = BS nof samples per sync value
+#
+#   tc appendlog messages are reported.
+#
+proc wg_read_bs_nof_samples_psync {{blpId blp0} {rspId rsp0} {applev 21}} {
+  set nof_samples_psync -1
+  if {[rsp readMsg [msg readMepMsg "bs psync $blpId" 4] $rspId] == 0} {
+    msg setOffset 0
+    set nof_samples_psync [msg readUnsigned 4]
+    tc appendLog $applev ">>> RSP-$rspId, BLP-$blpId, read BS nof samples per sync : $nof_samples_psync"
+    tc setResult PASSED
+  } else {
+    tc setResult FAILED
+  }
+  return $nof_samples_psync
+}
+
+
+###############################################################################
+#
+# WG_WRITE_SS : Write subband to beamlet map to SS
+#
+# Input:
+#
+# - ss_map   = Subband to beamlet map
+# - bank     = SS bank number
+# - blpId    = BLP ID: 'blp#'
+# - rspId    = RSP ID: 'rsp#'
+# - bc       = When != 0 use MEP broadcast
+# - str      = SS instance name
+#
+# Return: void
+#
+proc wg_write_ss {ss_map {bank 0} {blpId blp0} {rspId rsp0} {bc 0} {str ss}} {
+  set ss_map_bb [wg_i2bb $ss_map]
+  foreach ri $rspId {
+    if {$bc == 0} {
+      foreach bi $blpId {
+        if {[rsp writeMsg [msg writeMepMsg "$str settings$bank $bi" $ss_map_bb] $ri] == 0} {
+          tc setResult PASSED
+        } else {
+          tc setResult FAILED
+        }
+      }
+    } else {
+      # Make use of MEP broadcast to all BLP on an RSP board
+      if {[rsp writeMsg [msg writeMepMsg "$str settings$bank $blpId" $ss_map_bb] $ri] == 0} {
+        tc setResult PASSED
+      } else {
+        tc setResult FAILED
+      }
+    }
+  }
+}
+
+
+###############################################################################
+#
+# WG_READ_SS : Read back SS register
+#
+# Input:
+#
+# - len_w    = Number of words to read from the SS register, INTEGER
+# - bank     = SS bank number
+# - blpId    = BLP ID: 'blp#' - only one
+# - rspId    = RSP ID: 'rsp#' - only one
+# - str      = SS instance name
+#
+# Return:
+#
+# - ss_map    = SS mapping
+#
+proc wg_read_ss {len_w {bank 0} {blpId blp0} {rspId rsp0} {str ss}} {
+  set c_eth_block   1400
+  set i             0
+  set n             $c_eth_block
+  set ret           0
+  set width         2
+  set len           [expr $len_w * $width]
+  set ss_map        {}
+
+  while {$i < $len && $ret == 0} {
+    if {$len - $i < $n} {set n [expr $len - $i]}
+    if {[rsp readMsg [msg readMepMsg "$str settings$bank $blpId \"offset $i\"" $n] $rspId] == 0} {
+      msg setOffset 0
+      for {set k 0} {$k < $n/$width} {incr k} {
+        lappend ss_map [msg readSigned $width]
+      }
+      tc setResult PASSED
+    } else {
+      tc setResult FAILED
+      set ret 1
+    }
+    incr i $c_eth_block
+  }
+
+  return $ss_map
+}
+
+
+###############################################################################
+#
+# WG_WRITE_SDO_SS : Write subband data output map to SDO-SS
+#
+# Input:
+#
+# - ss_map   = Subband data output map
+# - bank     = SDO SS bank number
+# - blpId    = BLP ID: 'blp#'
+# - rspId    = RSP ID: 'rsp#'
+# - bc       = When != 0 use MEP broadcast
+#
+# Return: void
+#
+proc wg_write_sdo_ss {ss_map {bank 0} {blpId blp0} {rspId rsp0} {bc 0}} {
+  return [wg_write_ss $ss_map $bank $blpId $rspId $bc sdo_ss]
+}
+
+
+###############################################################################
+#
+# WG_READ_SDO_SS : Read back subband data output map from SDO-SS register
+#
+# Input:
+#
+# - len_w    = Number of words to read from the SDO-SS register, INTEGER
+# - bank     = SDO SS bank number
+# - blpId    = BLP ID: 'blp#' - only one
+# - rspId    = RSP ID: 'rsp#' - only one
+#
+# Return:
+#
+# - ss_map   = SDO-SS mapping
+#
+proc wg_read_sdo_ss {len_w {bank 0} {blpId blp0} {rspId rsp0}} {
+  return [wg_read_ss $len_w $bank $blpId $rspId sdo_ss]
+}
+
+
+###############################################################################
+#
+# WG_WRITE_BF : Write beamformer coefficients
+#
+# Input:
+#
+# - coefs    = Row of coefficients for xr, xi, yr or yi output
+# - row      = Coefficent matrix row number: 'coefxr', 'coefxi', 'coefyr' or 'coefyi'
+# - bank     = Beam mode bank number
+# - blpId    = BLP ID: 'blp#'
+# - rspId    = RSP ID: 'rsp#'
+# - bc       = When != 0 use MEP broadcast
+#
+# Return:
+#
+# - ret      = 1 if write PASSED else 0
+#
+proc wg_write_bf {coefs row {bank 0} {blpId blp0} {rspId rsp0} {bc 0}} {
+  set c_eth_block 1400
+  set coefs_bb [wg_i2bb $coefs]
+  set len [llength $coefs_bb]
+  set ret 0
+
+  foreach ri $rspId {
+    set i 0
+    while {$i < $len} {
+      if {$bc == 0} {
+        foreach bi $blpId {
+          if {[rsp writeMsg [msg writeMepMsg "bf $row$bank $bi \"offset $i\"" [lrange $coefs_bb $i [expr $i +  $c_eth_block - 1]]] $ri] == 0} {
+            tc setResult PASSED
+          } else {
+            tc setResult FAILED
+            set ret 1
+          }
+        }
+      } else {
+        # Make use of MEP broadcast to all BLP on an RSP board
+        if {[rsp writeMsg [msg writeMepMsg "bf $row$bank $blpId \"offset $i\"" [lrange $coefs_bb $i [expr $i +  $c_eth_block - 1]]] $ri] == 0} {
+          tc setResult PASSED
+        } else {
+          tc setResult FAILED
+          set ret 1
+        }
+      }
+      incr i $c_eth_block
+    }
+  }
+
+  return $ret
+}
+
+
+###############################################################################
+#
+# WG_READ_BF : Read back BF register
+#
+# Input:
+#
+# - row      = Coefficent matrix row number: 'coefxr', 'coefxi', 'coefyr' or 'coefyi'
+# - len_w    = Number of words to read from the coefficients register, INTEGER
+# - bank     = Beam mode bank number
+# - blpId    = BLP ID: 'blp#' - only one
+# - rspId    = RSP ID: 'rsp#' - only one
+#
+# Return:
+#
+# - coefs    = Coefficients
+#
+proc wg_read_bf {row len_w {bank 0} {blpId blp0} {rspId rsp0}} {
+  set c_eth_block   1400
+  set i             0
+  set n             $c_eth_block
+  set ret           0
+  set width         2
+  set len           [expr $len_w * $width]
+  set coefs         {}
+
+  while {$i < $len && $ret == 0} {
+    if {$len - $i < $n} {set n [expr $len - $i]}
+    if {[rsp readMsg [msg readMepMsg "bf $row$bank $blpId \"offset $i\"" $n] $rspId] == 0} {
+      msg setOffset 0
+      for {set k 0} {$k < $n/$width} {incr k} {
+        lappend coefs [msg readSigned $width]
+      }
+      tc setResult PASSED
+    } else {
+      tc setResult FAILED
+      set ret 1
+    }
+    incr i $c_eth_block
+  }
+
+  return $coefs
+}
+
+
+###############################################################################
+#
+# WG_OVERWRITE_SUBBAND_POWER_STATISTICS : Overwrite the subband statistics buffer
+#
+# Input:
+#
+# - samples  = SST buffer sample values, INTEGERs
+# - blpId    = BLP ID: 'blp#'
+# - rspId    = RSP ID: 'rsp#'
+# - bc       = When != 0 use MEP broadcast
+#
+# Return:
+#
+# - ret      = 1 if write PASSED else 0
+#
+# Warning: SST buffer does not support write access (yet), so this function can not be used
+#
+proc wg_overwrite_subband_power_statistics {samples {blpId blp0} {rspId rsp0} {bc 0}} {
+  set c_eth_block 1400
+
+  set data    [wg_i2bbbb $samples]
+  set len     [llength $data]
+  set ret_all 0
+
+  foreach ri $rspId {
+    set i 0
+    while {$i < $len} {
+      if {$bc == 0} {
+        foreach bi $blpId {
+          if {[rsp writeMsg [msg writeMepMsg "sst power $bi \"offset $i\"" [lrange $data $i [expr $i +  $c_eth_block - 1]]] $ri] == 0} {
+            tc setResult PASSED
+          } else {
+            tc setResult FAILED
+            set ret_all 1
+          }
+        }
+      } else {
+        # Make use of MEP broadcast to all BLP on an RSP board
+        if {[rsp writeMsg [msg writeMepMsg "sst power $blpId \"offset $i\"" [lrange $data $i [expr $i +  $c_eth_block - 1]]] $ri] == 0} {
+          tc setResult PASSED
+        } else {
+          tc setResult FAILED
+          set ret_all 1
+        }
+      }
+      incr i $c_eth_block
+    }
+  }
+
+  return $ret_all
+}
+
+
+###############################################################################
+#
+# WG_READ_SUBBAND_POWER_STATISTICS : Read subband statistics buffer
+#
+# Input:
+#
+# - len_w    = Number of words to read from the statistics buffer, INTEGER
+# - blpId    = BLP ID: 'blp#' - only one
+# - rspId    = RSP ID: 'rsp#' - only one
+#
+# Return:
+#
+# - sst_buffer = Subband power statistics
+#
+proc wg_read_subband_power_statistics {len_w {blpId blp0} {rspId rsp0}} {
+  set width         4
+  set len           [expr $len_w * $width]
+  set c_eth_block   1400
+  set i             0
+  set n             $c_eth_block
+  set ret           0
+  set sst_buffer    {}
+
+  while {$i < $len && $ret == 0} {
+    if {$len - $i < $n} {set n [expr $len - $i]}
+    if {[rsp readMsg [msg readMepMsg "sst power $blpId \"offset $i\"" $n] $rspId] == 0} {
+      msg setOffset 0
+      for {set k 0} {$k < $n/$width} {incr k} {
+        lappend sst_buffer [msg readUnsigned $width]
+      }
+      tc setResult PASSED
+    } else {
+      tc setResult FAILED
+      set ret 1
+    }
+    incr i $c_eth_block
+  }
+
+  return $sst_buffer
+}
+
+
+###############################################################################
+#
+# WG_READ_BEAMLET_POWER_STATISTICS : Read beamlet statistics buffer
+#
+# Input:
+#
+# - len_w    = Number of words to read from the statistics register, INTEGER
+# - regId    = Statistics register to read '#', # = 0..3 - select one
+# - rspId    = RSP ID: 'rsp#' - only one
+#
+# Return:
+#
+# - bst_lane = Beamlet power statistics for lane $regId
+#
+proc wg_read_beamlet_power_statistics {len_w {regId 0} {rspId rsp0}} {
+  set width         4
+  set len           [expr $len_w * $width]
+  set c_eth_block   1400
+  set i             0
+  set n             $c_eth_block
+  set ret           0
+  set bst_lane    {}
+
+  while {$i < $len && $ret == 0} {
+    if {$len - $i < $n} {set n [expr $len - $i]}
+    if {[rsp readMsg [msg readMepMsg "bst power$regId rsp \"offset $i\"" $n] $rspId] == 0} {
+      msg setOffset 0
+      for {set k 0} {$k < $n/$width} {incr k} {
+        lappend bst_lane [msg readUnsigned $width]
+      }
+      tc setResult PASSED
+    } else {
+      tc setResult FAILED
+      set ret 1
+    }
+    incr i $c_eth_block
+  }
+
+  return $bst_lane
+}
+
+
+###############################################################################
+#
+# WG_READ_CROSSLET_POWER_STATISTICS : Read crosslet statistics buffer
+#
+# Input:
+#
+# - len_w    = Number of words to read from the statistics register, INTEGER
+# - regId    = Statistics register to read 'r#', # = 0..31 - select one
+# - rspId    = RSP ID: 'rsp#' - only one
+#
+# Return:
+#
+# - xst_buffer = Crossler power statistics from one register
+#
+proc wg_read_crosslet_power_statistics {len_w {regId r0} {rspId rsp0}} {
+  set width         4
+  set len           [expr $len_w * $width]
+  set c_eth_block   1400
+  set i             0
+  set n             $c_eth_block
+  set ret           0
+  set xst_buffer    {}
+
+  while {$i < $len && $ret == 0} {
+    if {$len - $i < $n} {set n [expr $len - $i]}
+    if {[rsp readMsg [msg readMepMsg "xst $regId rsp \"offset $i\"" $n] $rspId] == 0} {
+      msg setOffset 0
+      for {set k 0} {$k < $n/$width} {incr k} {
+        lappend xst_buffer [msg readUnsigned $width]
+      }
+      tc setResult PASSED
+    } else {
+      tc setResult FAILED
+      set ret 1
+    }
+    incr i $c_eth_block
+  }
+
+  return $xst_buffer
+}
+
+
+###############################################################################
+#
+# WG_WRITE_RAD_SETTINGS : RAD_BP write settings
+#
+# Input:
+#
+# - settings = Lane settings for beamlets and crosslets
+# - rspId    = RSP ID: 'rsp#'
+# - applev   = Append log level
+#
+# Return: void
+#
+#   tc appendlog messages are reported (see wg_read_rad_settings for lane mode definition).
+#
+proc wg_write_rad_settings {settings {rspId rsp0} {applev 21}} {
+  set nof_lanes 4
+  tc appendLog $applev ">>> RSP-$rspId write RAD settings:"
+  # beamlet lane modes
+  for {set i 0} {$i < $nof_lanes} {incr i} {
+    set lane_mode [expr (($settings >> (8*$i)) & 0x3)]
+    switch $lane_mode {
+      0       {tc appendLog $applev "      lane($i): beamlet  mode local"}
+      1       {tc appendLog $applev "      lane($i): beamlet  mode disable"}
+      2       {tc appendLog $applev "      lane($i): beamlet  mode combine"}
+      default {tc appendLog $applev "      lane($i): beamlet  mode remote"}
+    }
+  }
+  # crosslet lane modes
+  for {set i 0} {$i < $nof_lanes} {incr i} {
+    set lane_mode [expr (($settings >> (8*$i + 2)) & 0x3)]
+    switch $lane_mode {
+      0       {tc appendLog $applev "      lane($i): crosslet mode local"}
+      1       {tc appendLog $applev "      lane($i): crosslet mode disable"}
+      2       {tc appendLog $applev "      lane($i): crosslet mode combine"}
+      default {tc appendLog $applev "      lane($i): crosslet mode remote"}
+    }
+  }
+  foreach ri $rspId {
+    if {[rsp writeMsg [msg writeMepMsg "rad settings rsp" [wg_i2bbbb $settings]] $ri] == 0} {
+      tc setResult PASSED
+    } else {
+      tc setResult FAILED
+    }
+  }
+}
+
+
+###############################################################################
+#
+# WG_READ_RAD_SETTINGS : RAD_BP read settings
+#
+# Input:
+#
+# - rspId    = RSP ID: 'rsp#' - only one
+# - applev   = Append log level
+#
+# Return:
+#
+# - settings = Lane settings for beamlets and crosslets
+#
+#     lane mode: one byte for each lane
+#     format: XXXXAABB
+#   
+#     where XX = don't care
+#           AA = xlet mode
+#           BB = blet mode
+#   
+#      mode 00 = ignore remote data (only local)  DEFAULT
+#      mode 01 = disable
+#      mode 10 = combine local and remote data
+#      mode 11 = ignore local data (only remote)
+#
+#   tc appendlog messages are reported.
+#
+proc wg_read_rad_settings {{rspId rsp0} {applev 21}} {
+  set nof_lanes 4
+  set settings {}
+  if {[rsp readMsg [msg readMepMsg "rad settings rsp" 4] $rspId] == 0} {
+    msg setOffset 0
+    set settings [msg readUnsigned 4]
+    tc appendLog $applev ">>> RSP-$rspId read RAD settings:"
+    # beamlet lane modes
+    for {set i 0} {$i < $nof_lanes} {incr i} {
+      set lane_mode [expr (($settings >> (8*$i)) & 0x3)]
+      switch $lane_mode {
+        0       {tc appendLog $applev "      lane($i): beamlet  mode local"}
+        1       {tc appendLog $applev "      lane($i): beamlet  mode disable"}
+        2       {tc appendLog $applev "      lane($i): beamlet  mode combine"}
+        default {tc appendLog $applev "      lane($i): beamlet  mode remote"}
+      }
+    }
+    # crosslet lane modes
+    for {set i 0} {$i < $nof_lanes} {incr i} {
+      set lane_mode [expr (($settings >> (8*$i + 2)) & 0x3)]
+      switch $lane_mode {
+        0       {tc appendLog $applev "      lane($i): crosslet mode local"}
+        1       {tc appendLog $applev "      lane($i): crosslet mode disable"}
+        2       {tc appendLog $applev "      lane($i): crosslet mode combine"}
+        default {tc appendLog $applev "      lane($i): crosslet mode remote"}
+      }
+    }
+    tc setResult PASSED
+  } else {
+    tc setResult FAILED
+  }
+  return $settings
+}
+
+
+###############################################################################
+#
+# WG_READ_RAD_LATENCY : RAD_BP read latency
+#
+# Input:
+#
+# - rspId    = RSP ID: 'rsp#' - only one
+# - applev   = Append log level
+#
+# Return:
+#
+# - latency = RI and lane latencies crosslets and beamlets
+#
+#   tc appendlog messages are reported.
+#
+proc wg_read_rad_latency {{rspId rsp0} {applev 21}} {
+  global env
+  source "$env(RSP)/rsp/tb/tc/5. Datapath/constants.tcl"
+  
+  set nof_lanes $c_rsp_nof_lanes
+  set nof_rd [expr 2*$c_rad_nof_rx_latency]
+  set latency {}
+  if {[rsp readMsg [msg readMepMsg "rad latency rsp" $nof_rd] $rspId] == 0} {
+    msg setOffset 0
+    for {set i 0} {$i < $nof_lanes} {incr i} {
+      set lane($i,b) [msg readUnsigned 2]
+      set lane($i,x) [msg readUnsigned 2]
+    }
+    set ring [msg readUnsigned 2]
+
+    tc appendLog $applev ">>> RSP-$rspId read RAD latency:"
+    tc appendLog $applev "      Ring     : $ring"
+    lappend latency $ring
+    for {set i [expr $nof_lanes-1]} {$i >= 0 } {incr i -1} {
+      tc appendLog $applev "      Lane($i,x): $lane($i,x)"
+      tc appendLog $applev "      Lane($i,b): $lane($i,b)"
+      lappend latency $lane($i,x)
+      lappend latency $lane($i,b)
+    }
+    tc setResult PASSED
+  } else {
+    tc setResult FAILED
+  }
+  return $latency
+}
+
+
+###############################################################################
+#
+# WG_WRITE_CDO_SETTINGS : Write the CDO setting register
+#
+# Input:
+#
+# - station_id    = Station identifier (16 bit INTEGER)
+# - config_id     = Configuration identifier (16 bit INTEGER)
+# - ffi           = For Future Implementqation (16 bit INTEGER)
+# - ctrl          = CDO control (16 bit INTEGER)
+# - nof_blocks    = Nof blocks per CEP frame (8 bit INTEGER)
+# - nof_beamlets  = Nof beamlets per block (8 bit INTEGER)
+# - dst_mac       = Destination MAC (6 bytes)
+# - src_mac       = Source MAC (6 bytes)
+# - dst_ip        = Destination IP address = ARP-TPA (4 bytes)
+# - src_ip        = Source IP address = ARP-SPA (4 bytes)
+# - rspId         = RSP ID: 'rsp#'
+# - applev        = Append log level
+#
+# Return: void
+#
+proc wg_write_cdo_settings {{station_id 0} {config_id 0} {ffi 0} {ctrl 0} {nof_blocks 16} {nof_beamlets 54} {dst_mac "0 0 0 0 0 0"} {src_mac "0 0 0 0 0 0"} {dst_ip "0 0 0 0"} {src_ip "0 0 0 0"} {rspId rsp0} {applev 21}} {
+  # Format bytes (LSByte first, postfix _le = little endian):
+  set dst_mac_le {}
+  set src_mac_le {}
+  if {[llength $dst_mac] != 6} {
+    puts "Incorrect dst_mac length ($dst_mac has length [llength $dst_mac])."
+    exit
+  } elseif {[llength $src_mac] != 6} {
+    puts "Incorrect src_mac length ($src_mac has length [llength $src_mac])."
+    exit
+  } else {
+    for {set i 5} {$i >= 0} {incr i -1} {
+      lappend dst_mac_le [lindex $dst_mac $i]
+      lappend src_mac_le [lindex $src_mac $i]
+    }
+  }
+  set dst_ip_le {}
+  set src_ip_le {}
+  if {[llength $dst_ip] != 4} {
+    puts "Incorrect dst_ip length ($dst_ip has length [llength $dst_ip])."
+    exit
+  } elseif {[llength $src_ip] != 4} {
+    puts "Incorrect src_ip length ($src_ip has length [llength $src_ip])."
+    exit
+  } else {
+    for {set i 3} {$i >= 0} {incr i -1} {
+      lappend dst_ip_le [lindex $dst_ip $i]
+      lappend src_ip_le [lindex $src_ip $i]
+    }
+  }
+
+  tc appendLog $applev ">>> RSP-$rspId write CDO settings:"
+  tc appendLog $applev "      Station ID               = $station_id"
+  tc appendLog $applev "      Configuration ID         = $config_id"
+  tc appendLog $applev "      FFI                      = $ffi"
+  tc appendLog $applev "      CDO control              = $ctrl"
+  tc appendLog $applev "        cdo_en                 = [expr  $ctrl       & 0x1]"
+  tc appendLog $applev "        cdo_lane_sel           = [expr ($ctrl >> 1) & 0x3]"
+  tc appendLog $applev "        cdo_fiber_balance_en   = [expr ($ctrl >> 3) & 0x1]"
+  tc appendLog $applev "        cdo_arp_en             = [expr ($ctrl >> 4) & 0x1]"
+  tc appendLog $applev "      Nof blocks per CEP frame = $nof_blocks"
+  tc appendLog $applev "      Nof beamlets per block   = $nof_beamlets"
+  tc appendLog $applev "      Destination MAC          = $dst_mac"
+  tc appendLog $applev "      Source MAC               = $src_mac"
+  tc appendLog $applev "      Destination IP address   = $dst_ip"
+  tc appendLog $applev "      Source IP address        = $src_ip"
+
+  foreach ri $rspId {
+    if {[rsp writeMsg [msg writeMepMsg "cdo settings rsp" "[wg_i2bb $station_id]
+                                                           [wg_i2bb $config_id]
+                                                           [wg_i2bb $ffi]
+                                                           [wg_i2bb $ctrl]
+                                                           $nof_blocks
+                                                           $nof_beamlets
+                                                           $dst_mac_le
+                                                           $src_mac_le
+                                                           $dst_ip_le
+                                                           $src_ip_le" ] $ri] == 0} {
+      tc setResult PASSED
+    } else {
+      tc setResult FAILED
+    }
+  }
+}
+
+
+###############################################################################
+#
+# WG_READ_CDO_SETTINGS : Read CDO settings register
+#
+# Input:
+#
+# - rspId    = RSP ID: 'rsp#' - only one
+# - applev   = Append log level
+#
+# Return:
+#
+# - settings = CDO settings
+#
+#   tc appendlog messages are reported.
+#
+proc wg_read_cdo_settings {{rspId rsp0} {applev 21}} {
+  set settings {}
+  if {[rsp readMsg [msg readMepMsg "cdo settings rsp" 30] $rspId] == 0} {
+    msg setOffset 0
+    set station_id   [msg readUnsigned 2]
+    set config_id    [msg readUnsigned 2]
+    set ffi          [msg readUnsigned 2]
+    set ctrl         [msg readUnsigned 2]
+    set nof_blocks   [msg readUnsigned 1]
+    set nof_beamlets [msg readUnsigned 1]
+    set dst_mac      {}
+    set dst_mac      [linsert $dst_mac 0 [msg readUnsigned 1]]
+    set dst_mac      [linsert $dst_mac 0 [msg readUnsigned 1]]
+    set dst_mac      [linsert $dst_mac 0 [msg readUnsigned 1]]
+    set dst_mac      [linsert $dst_mac 0 [msg readUnsigned 1]]
+    set dst_mac      [linsert $dst_mac 0 [msg readUnsigned 1]]
+    set dst_mac      [linsert $dst_mac 0 [msg readUnsigned 1]]
+    set src_mac      {}
+    set src_mac      [linsert $src_mac 0 [msg readUnsigned 1]]
+    set src_mac      [linsert $src_mac 0 [msg readUnsigned 1]]
+    set src_mac      [linsert $src_mac 0 [msg readUnsigned 1]]
+    set src_mac      [linsert $src_mac 0 [msg readUnsigned 1]]
+    set src_mac      [linsert $src_mac 0 [msg readUnsigned 1]]
+    set src_mac      [linsert $src_mac 0 [msg readUnsigned 1]]
+    set dst_ip       {}
+    set dst_ip       [linsert $dst_ip  0 [msg readUnsigned 1]]
+    set dst_ip       [linsert $dst_ip  0 [msg readUnsigned 1]]
+    set dst_ip       [linsert $dst_ip  0 [msg readUnsigned 1]]
+    set dst_ip       [linsert $dst_ip  0 [msg readUnsigned 1]]
+    set src_ip       {}
+    set src_ip       [linsert $src_ip  0 [msg readUnsigned 1]]
+    set src_ip       [linsert $src_ip  0 [msg readUnsigned 1]]
+    set src_ip       [linsert $src_ip  0 [msg readUnsigned 1]]
+    set src_ip       [linsert $src_ip  0 [msg readUnsigned 1]]
+    tc appendLog $applev ">>> RSP-$rspId read CDO settings:"
+    tc appendLog $applev "      Station ID               = $station_id"
+    tc appendLog $applev "      Configuration ID         = $config_id"
+    tc appendLog $applev "      FFI                      = $ffi"
+    tc appendLog $applev "      CDO control              = $ctrl"
+    tc appendLog $applev "        cdo_en                 = [expr  $ctrl       & 0x1]"
+    tc appendLog $applev "        cdo_lane_sel           = [expr ($ctrl >> 1) & 0x3]"
+    tc appendLog $applev "        cdo_fiber_balance_en   = [expr ($ctrl >> 3) & 0x1]"
+    tc appendLog $applev "        cdo_arp_en             = [expr ($ctrl >> 4) & 0x1]"
+    tc appendLog $applev "      Nof blocks per CEP frame = $nof_blocks"
+    tc appendLog $applev "      Nof beamlets per block   = $nof_beamlets"
+    tc appendLog $applev "      Destination MAC          = $dst_mac"
+    tc appendLog $applev "      Source MAC               = $src_mac"
+    tc appendLog $applev "      Destination IP address   = $dst_ip"
+    tc appendLog $applev "      Source IP address        = $src_ip"
+    lappend settings $station_id
+    lappend settings $config_id
+    lappend settings $ffi
+    lappend settings $ctrl
+    lappend settings $nof_blocks
+    lappend settings $nof_beamlets
+    lappend settings $dst_mac
+    lappend settings $src_mac
+    lappend settings $dst_ip
+    lappend settings $src_ip
+    tc setResult PASSED
+  } else {
+    tc setResult FAILED
+  }
+  return $settings
+}
+
+
+###############################################################################
+#
+# WG_WRITE_CDO_TRANSPORT_HEADER : Write the CDO transport header register
+#
+# Input:
+#
+# - transport  = Transport header: 32 bytes
+# - rspId      = RSP ID: 'rsp#'
+# - applev     = Append log level
+#
+# Return: void
+#
+proc wg_write_cdo_transport_header {transport {rspId rsp0} {applev 21}} {
+  if {[llength $transport] != 32} {
+    puts "Incorrect transport header lenght ($transport has lenght [llength $transport])."
+    exit
+  }
+
+  foreach ri $rspId {
+    if {[rsp writeMsg [msg writeMepMsg "cdo iphdr rsp" $transport ] $ri] == 0} {
+      tc setResult PASSED
+    } else {
+      tc setResult FAILED
+    }
+  }
+}
+
+
+###############################################################################
+#
+# WG_READ_CDO_TRANSPORT_HEADER : Read CDO transport header register
+#
+# Input:
+#
+# - rspId    = RSP ID: 'rsp#' - only one
+# - applev   = Append log level
+#
+# Return:
+#
+# - transport = CDO transport header
+#
+#   tc appendlog messages are reported.
+#
+proc wg_read_cdo_transport_header {{rspId rsp0} {applev 21}} {
+  set transport {}
+  if {[rsp readMsg [msg readMepMsg "cdo iphdr rsp" 32] $rspId] == 0} {
+    msg setOffset 0
+    for {set i 0} {$i < 32} {incr i} {
+      lappend transport [msg readUnsigned 1]
+    }
+    set th_version         [expr ([lindex $transport  0] & 0xF0) >> 4]
+    set th_header_length   [expr  [lindex $transport  0] & 0xF]
+    set th_type_of_service        [lindex $transport  1]
+    set th_total_length    [expr  [lindex $transport  2] * 256 + [lindex $transport 3]]
+    set th_identification  [expr  [lindex $transport  4] * 256 + [lindex $transport 5]]
+    set th_flags           [expr ([lindex $transport  6] & 0xE0) >> 5]
+    set th_fragment_offset [expr ([lindex $transport  6] & 0x1F) * 256 + [lindex $transport 7]]
+    set th_ttl                    [lindex $transport  8]
+    set th_protocol               [lindex $transport  9]
+    set th_header_crc      [expr  [lindex $transport 10] * 256 + [lindex $transport 11]]
+    set th_source_ip              [lrange $transport 12 15]
+    set th_dest_ip                [lrange $transport 16 19]
+    set th_udp_source_port [expr  [lindex $transport 20] * 256 + [lindex $transport 21]]
+    set th_udp_dest_port   [expr  [lindex $transport 22] * 256 + [lindex $transport 23]]
+    set th_udp_length      [expr  [lindex $transport 24] * 256 + [lindex $transport 25]]
+    set th_udp_checksum    [expr  [lindex $transport 26] * 256 + [lindex $transport 27]]
+    set th_user_defined           [lrange $transport 28 31]
+
+    tc appendLog $applev ">>> RSP-$rspId write CDO transport header:"
+    tc appendLog $applev "      Raw header           = $transport "
+    tc appendLog $applev "      Version              = $th_version"
+    tc appendLog $applev "      Header length        = $th_header_length"
+    tc appendLog $applev "      Type of service      = $th_type_of_service"
+    tc appendLog $applev "      Total lenght         = $th_total_length"
+    tc appendLog $applev "      Identification       = $th_identification"
+    tc appendLog $applev "      Flags                = $th_flags"
+    tc appendLog $applev "      Fragment offset      = $th_fragment_offset"
+    tc appendLog $applev "      TTL                  = $th_ttl"
+    tc appendLog $applev "      Protocol             = $th_protocol"
+    tc appendLog $applev "      Header CRC           = $th_header_crc"
+    tc appendLog $applev "      Source IP            = $th_source_ip"
+    tc appendLog $applev "      Destination IP       = $th_dest_ip"
+    tc appendLog $applev "      UDP source port      = $th_udp_source_port"
+    tc appendLog $applev "      UDP destination port = $th_udp_dest_port"
+    tc appendLog $applev "      UDP length           = $th_udp_length"
+    tc appendLog $applev "      Checksum             = $th_udp_checksum"
+    tc appendLog $applev "      User defined         = $th_user_defined"
+
+    tc setResult PASSED
+  } else {
+    tc setResult FAILED
+  }
+  return $transport
+}
+
+
+###############################################################################
+#
+# WG_ADC : Analogue to Digital converter.
+#
+# Input:
+#
+# - sample      = List of one or more sample values, REAL
+# - nof_bits    = number of bits of the ADC, INTEGER
+#
+# Return:
+#
+# - ret         = Quantized sample value(s)
+#
+proc wg_adc {sample nof_bits} {
+  set adc_max [expr round(pow(2,$nof_bits - 1)) - 1]
+  set adc_min [expr -$adc_max - 1]
+
+  set ret {}
+  foreach a $sample {
+    set q [expr round($a)]
+    if {$q > $adc_max} {set q $adc_max}
+    if {$q < $adc_min} {set q $adc_min}
+    lappend ret $q
+  }
+
+  return $ret
+}
+
+
+###############################################################################
+#
+# WG_CALCULATE_ANALOGUE_WAVEFORM : Analogue waveform generator.
+#
+# Input:
+#
+# - type        = type of signal, STRING :
+#                 - sinus
+#                 - slope          (includes: sawtooth, triangle, incr, decr)
+#                 - block          (includes: DC, impulse, square)
+#                 - uniform noise
+# - ampl        = amplitude, in units of ADC LSbit, REAL
+# - offset      = DC offset, in units of ADC LSbit, REAL
+# - phase       = phase, in units of a sample period, REAL typically between +-period,
+#                 used as seed for random signal
+# - period      = period, in units of a sample period, REAL
+# - duty        = duty cycle for rising slope or block high, not used for sinus,
+#                 in units of a sample period, REAL between 0 and period
+# - nof_samples = number of samples of the sinus, INTEGER
+#
+# Return:
+#
+# - Real sample values of the requested waveform
+#
+proc wg_calculate_analogue_waveform {{type sinus} {ampl 1000} {offset 0} {phase 0} {period 512} {duty 1} {nof_samples 1024}} {
+
+  set c_pi [expr 4*atan(1.0)]
+
+  set amp [expr double($ampl)]
+  set ofs [expr double($offset)]
+  set phs [expr double($phase)]
+  set per [expr double($period)]
+  set dty [expr double($duty)]
+
+  set waveform {}
+
+  set p [expr $phs - int($phs/$per)*$per]
+  if {$p < 0} {set p [expr $p + $per]}
+
+  switch $type {
+    sinus {
+      for {set i 0} {$i < $nof_samples} {incr i} {
+        lappend waveform [expr $ofs + $amp * sin(2*$c_pi * ($i + $phs) / $per)]
+      }
+    }
+    cosin {
+      for {set i 0} {$i < $nof_samples} {incr i} {
+        lappend waveform [expr $ofs + $amp * cos(2*$c_pi * ($i + $phs) / $per)]
+      }
+    }
+    slope {
+      set a_up {}
+      set b_up {}
+      set a_down {}
+      set b_down {}
+      if {$dty != 0} {
+        set a_up   [expr $amp/$dty]
+        set b_up    0
+      }
+      if {$dty != $per} {
+        set a_down [expr -$amp/($per - $dty)]
+        set b_down  $amp
+      }
+      for {set i 0} {$i < $nof_samples} {incr i} {
+        if {$p >= $per} {set p [expr $p - $per]}
+        if {$p < $dty} {
+          lappend waveform [expr $ofs + $b_up   + $a_up   * $p]
+        } else {
+          lappend waveform [expr $ofs + $b_down + $a_down * $p]
+        }
+        set p [expr $p + 1]
+      }
+    }
+    block {
+      set q_high [expr $ofs + $amp]
+      set q_low  [expr $ofs]
+      for {set i 0} {$i < $nof_samples} {incr i} {
+        if {$p >= $per} {set p [expr $p - $per]}
+        if {$p < $dty} {
+          lappend waveform $q_high
+        } else {
+          lappend waveform $q_low
+        }
+        set p [expr $p + 1]
+      }
+    }
+    uniform {
+      expr srand(int($phs))
+      for {set i 0} {$i < $nof_samples} {incr i} {
+        lappend waveform [expr $ofs + $amp - 2*$amp*rand()]
+      }
+    }
+    default {}
+  }
+  return $waveform
+}
+
+
+###############################################################################
+#
+# WG_CALCULATE_NEXT_SEQUENCE_VALUE : Calculate next sequence value
+#
+# Input:
+#
+# - in_word   = shift register seed
+# - seq       = PSRG    : use PSRG sequence as in RCU (width = 12)
+#               others  : use COUNTER sequence
+#
+# Return:
+#
+# - out_word  = shift register contents after one cycle
+#
+proc wg_calculate_next_sequence_value {in_word {seq PSRG} {width 12}} {
+  if {[string equal $seq PSRG] == 1} {
+    # ----- RCU PSRG sequence -----
+
+    # Polynoom
+    set w [expr int(pow(2,$width))-1]
+    set taps  {0 3 5 11}
+
+    # Feedback shift register
+    set p 0
+    foreach t $taps {
+      set b  [expr int(pow(2,$t))]
+      set b  [expr !!($in_word & $b)]
+      set p  [expr $p ^ $b]
+    }
+    set out_word [expr (($in_word << 1) & $w) + !$p]
+  } elseif {[string equal $seq COUNTER] == 1} {
+    # ----- RCU COUNTER sequence -----
+
+    set w [expr int(pow(2,$width))-1]
+    set out_word [expr ($in_word+1) & $w]
+  }
+  return $out_word
+}
+
+
+###############################################################################
+#
+# WG_SDO_GENERATE_MAP : Generate the SDO-SS map for an AP frame.
+#
+# Description:
+# . Support various different subband data in the 4 lane frames (LF). The
+#   subband data  in the lane frames depends on the data_mode. The data modes
+#   assume that the default incrementing counter data [0:1023] is in WG
+#   waveform X and Y and that the DSP data path blocks that preceed the SDO-SS
+#   are bypassed.
+# . This function is equivaluent to func_sdo_ss_generate_map() in
+#   tb_sdo_pkg.vhd.
+#
+# Input:
+#
+# - ap_id     = AP index number 0,1,2,3
+# - value     = data value in case mode = "CONSTANT"
+# - data_mode = "RCU"        : use RCU index 0:7 as LF[0:3] data
+#             = "SUBBAND"    : use subband index 0:35 as LF[0:3] data
+#             = "LANE"       : use lane index 0:3 as LF[0:3] data
+#             = "SS_MAP"     : use this SS map index as LF[0:3] data
+#             = "COUNT_UP"   : count up as LF[0:3] data
+#             = "COUNT_DOWN" : count down as LF[0:3] data
+#             = "CONSTANT"   : constant value as LF[0:3] data
+#
+# Return:
+#
+# - ss_map = SDO-SS mapping
+#
+proc wg_sdo_ss_generate_map {ap_id value {data_mode CONSTANT}} {
+  global env
+  source "$env(RSP)/rsp/tb/tc/5. Datapath/constants.tcl"
+
+  set ss_map {}
+  for {set i 0} {$i < $c_sdo_ss_nof_subbands_ap} {incr i} {
+    lappend ss_map 0
+  } ;# lrepeat yields invalid command name error
+    
+  set vKmax $c_sdo_ss_nof_subbands_rsp
+  
+  for {set vLane 0} {$vLane < $c_rsp_nof_lanes} {incr vLane} {
+    for {set vSub 0} {$vSub < $c_rsp_sdo_nof_subbands_per_lane} {incr vSub} {
+      for {set vAp 0} {$vAp < $c_rsp_nof_ap} {incr vAp} {
+        for {set vPol 0} {$vPol < $c_pol} {incr vPol} {
+          # logical index
+          set vRcu     [expr $vAp*$c_pol + $vPol]
+          set vSubband [expr $vLane*$c_rsp_sdo_nof_subbands_per_lane + $vSub]
+          set vK       [expr ($vSubband*$c_rsp_nof_ap + $vAp)*$c_pol + $vPol]
+            
+          # location in ss_map
+          set vLP_band [expr $vSub*$c_pol + $vPol]
+          set vAP_band [expr $vLane*$c_rsp_sdo_nof_subbands_per_lane*$c_pol + $vLP_band]
+          
+          set vB $vAP_band
+          if {$vAp==$ap_id} {
+            if {$data_mode=="rcu"       } {set ss_map [lreplace $ss_map $vB $vB $vRcu              ]}
+            if {$data_mode=="subband"   } {set ss_map [lreplace $ss_map $vB $vB $vSubband          ]}
+            if {$data_mode=="lane"      } {set ss_map [lreplace $ss_map $vB $vB $vLane             ]}
+            if {$data_mode=="ss_map"    } {set ss_map [lreplace $ss_map $vB $vB $vAP_band          ]}
+            if {$data_mode=="count_up"  } {set ss_map [lreplace $ss_map $vB $vB $vK                ]}
+            if {$data_mode=="count_down"} {set ss_map [lreplace $ss_map $vB $vB [expr $vKmax - $vK]]}
+            if {$data_mode=="constant"  } {set ss_map [lreplace $ss_map $vB $vB $value             ]}
+          }
+          set vK [expr $vK + $c_rsp_nof_rcu]
+        }
+      }
+    }
+  }
+  return $ss_map
+}
+
+###############################################################################
+#
+# WG_WRITE_FILE : Write signal to a file
+#
+# Input:
+#
+# - fname      = Signal name, STRING
+# - sig        = Signal values, INTEGERs
+#
+# Return: void
+#
+#
+proc wg_write_file {fname sig} {
+  set chan [open "$fname.sig" w]
+  foreach i $sig {puts $chan $i}
+  close $chan
+}
+
+
+###############################################################################
+#
+# WG_READ_FILE : Read signal from a file
+#
+# Input:
+#
+# - fname      = Signal name, STRING
+#
+# Return:
+#
+# - sig        = Signal values
+#
+proc wg_read_file {fname} {
+  set sig {}
+  set chan [open "$fname" r]
+  while {[gets $chan line] >= 0} {
+    lappend sig $line
+  }
+  close $chan
+  return $sig
+}
+
+
+###############################################################################
+#
+# WG_FLIP : Flip a list
+#
+# Input:
+#
+# - inp      = Input list inp[0:n-1]
+#
+# Return:
+#
+# - outp     = inp[n-1:0]
+#
+proc wg_flip {inp} {
+  set outp $inp
+  set n    [llength $inp]
+  set i    0
+  foreach e $inp {
+    lset outp [expr $n-1-$i] $e
+    incr i
+  }
+  return $outp
+}
+
+
+###############################################################################
+#
+# WG_TRANSPOSE : Transpose a list that with m x n elements to list with n x m elements
+#
+# Input:
+#
+# - m        = Number of rows
+# - n        = Number of colums
+# - inp      = Input list inp[(0,0:m-1):(n-1,0:m-1)
+#
+# Return:
+#
+# - outp     = inp[(0:n-1,0):(m-1:n-1,0)]
+#
+proc wg_transpose {inp m n} {
+  set outp $inp
+  set j    0    ;# row index
+  set i    0    ;# column index
+  foreach e $inp {
+    lset outp [expr $i+$j*$n] $e
+    if {$j < $m-1} {
+      incr j
+    } else {
+      set  j 0
+      incr i
+    }
+  }
+  return $outp
+}
+
+
+###############################################################################
+#
+# WG_CLIP : Clip an integer value to w bits
+#
+# Input:
+#
+# - inp      = Integer value
+# - w        = Output width in number of bits
+#
+# Description: Output range -2**(w-1) to +2**(w-1)-1
+#
+# Return:
+#
+# - outp     = Clipped value
+#
+proc wg_clip {inp w} {
+  set outp 0
+  if {$w>0} {
+    set clip_p [expr  int(pow(2,($w-1)))-1]
+    set clip_n [expr -int(pow(2,($w-1)))  ]
+    if {$inp > $clip_p} {
+      set outp $clip_p
+    } elseif {$inp < $clip_n} {
+      set outp $clip_n
+    } else {
+      set outp $inp
+    }
+  }
+  return $outp
+}
+
+
+###############################################################################
+#
+# WG_WRAP : Wrap an integer value to w bits
+#
+# Input:
+#
+# - inp      = Integer value
+# - w        = Output width in number of bits
+#
+# Description: Remove MSbits, output range -2**(w-1) to +2**(w-1)-1
+#
+# Return:
+#
+# - outp     = Wrapped value
+#
+proc wg_wrap {inp w} {
+  set outp 0
+  if {$w>0} {
+    set wrap_mask [expr int(pow(2,($w-1)))-1]
+    set wrap_sign [expr int(pow(2,($w-1)))]
+    if {($inp & $wrap_sign) == 0} {
+      set outp [expr  $inp & $wrap_mask]
+    } else {
+      set outp [expr ($inp & $wrap_mask) - $wrap_sign]
+    }
+  }
+  return $outp
+}
+
+
+###############################################################################
+#
+# WG_ROUND : Round the w LSbits of an integer value
+#
+# Input:
+#
+# - inp       = Integer value
+# - w         = Number of LSbits to round
+# - direction = "HALF_AWAY", "HALF_UP"
+#
+# Description:
+#   direction = "HALF_AWAY" --> Round half away from zero so +0.5 --> 1, -0.5 --> -1.
+#   direction = "HALF_UP"   --> Round half to +infinity   so +0.5 --> 1, -0.5 --> 0.
+# Return:
+#
+# - outp     = Rounded value
+#
+proc wg_round {inp w {direction "HALF_AWAY"}} {
+  set outp $inp
+  if {$w>0} {
+    set round_factor [expr int(pow(2,$w))]
+    set round_p [expr int(pow(2,($w-1)))  ]
+    set round_n [expr int(pow(2,($w-1)))-1]
+    if {$direction == "HALF_UP"} {
+      set outp [expr ($inp+$round_p)/$round_factor]
+    }
+    if {$direction == "HALF_AWAY"} {
+      if {$inp >= 0} {
+        set outp [expr ($inp+$round_p)/$round_factor]
+      } else {
+        set outp [expr ($inp+$round_n)/$round_factor]
+      }
+    }
+  }
+  return $outp
+}
+
+
+###############################################################################
+#
+# WG_TRUNCATE : Truncate the w LSbits of an integer value
+#
+# Input:
+#
+# - inp      = Integer value
+# - w        = Number of LSbits to truncate
+#
+# Description: Remove LSBits.
+# Return:
+#
+# - outp     = Truncated value
+#
+proc wg_truncate {inp w} {
+  set outp $inp
+  if {$w>0} {
+    if {$inp >= 0} {
+      set outp [expr $inp>>$w]
+    } else {
+      set outp [expr -((-$inp)>>$w)]
+    }
+  }
+  return $outp
+}
+
+
+###############################################################################
+#
+# WG_WAIT : Wait some time
+#
+# Input:
+#
+# - t  =  wait time in msec
+#
+# Return: void
+#
+proc wg_wait {t} {
+#   set c [clock clicks -milliseconds]
+#   while {[clock clicks -milliseconds] < $c + $t} {}
+  after [expr int(ceil($t))]
+}