| 1 |
5 |
danv |
-------------------------------------------------------------------------------
|
| 2 |
|
|
--
|
| 3 |
|
|
-- Copyright (C) 2017
|
| 4 |
|
|
-- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
|
| 5 |
|
|
-- JIVE (Joint Institute for VLBI in Europe) <http://www.jive.nl/>
|
| 6 |
|
|
-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
|
| 7 |
|
|
--
|
| 8 |
|
|
-- This program is free software: you can redistribute it and/or modify
|
| 9 |
|
|
-- it under the terms of the GNU General Public License as published by
|
| 10 |
|
|
-- the Free Software Foundation, either version 3 of the License, or
|
| 11 |
|
|
-- (at your option) any later version.
|
| 12 |
|
|
--
|
| 13 |
|
|
-- This program is distributed in the hope that it will be useful,
|
| 14 |
|
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 15 |
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 16 |
|
|
-- GNU General Public License for more details.
|
| 17 |
|
|
--
|
| 18 |
|
|
-- You should have received a copy of the GNU General Public License
|
| 19 |
|
|
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
| 20 |
|
|
--
|
| 21 |
|
|
-------------------------------------------------------------------------------
|
| 22 |
|
|
|
| 23 |
|
|
LIBRARY IEEE, common_pkg_lib, common_components_lib, dp_pkg_lib;
|
| 24 |
|
|
USE IEEE.std_logic_1164.all;
|
| 25 |
|
|
USE common_pkg_lib.common_pkg.ALL;
|
| 26 |
|
|
USE dp_pkg_lib.dp_stream_pkg.ALL;
|
| 27 |
|
|
|
| 28 |
|
|
-- Author: Eric Kooistra, 17 nov 2017
|
| 29 |
|
|
-- Purpose:
|
| 30 |
|
|
-- Restore global BSN.
|
| 31 |
|
|
-- Description:
|
| 32 |
|
|
-- The input global BSN is active at the sync. In between sync the other BSN
|
| 33 |
|
|
-- BSN at the sop may count a local BSN that restarted at 0 for every sync.
|
| 34 |
|
|
-- This dp_bsn_restore_global takes the BSN at the sync and starts counting
|
| 35 |
|
|
-- from there for every sop, so in this way it restores the global BSN count
|
| 36 |
|
|
-- for the blocks in between syncs.
|
| 37 |
|
|
-- The increment for each restored BSN is 1. The assumption is that the
|
| 38 |
|
|
-- number of blocks between syncs equals the difference in global BSN values
|
| 39 |
|
|
-- between syncs. In this way the restored BSN counts without gaps or
|
| 40 |
|
|
-- duplicates.
|
| 41 |
|
|
-- Remarks:
|
| 42 |
|
|
|
| 43 |
|
|
ENTITY dp_bsn_restore_global IS
|
| 44 |
|
|
GENERIC (
|
| 45 |
|
|
g_bsn_w : NATURAL := c_dp_stream_bsn_w;
|
| 46 |
|
|
g_pipeline : NATURAL := 1 -- 0 for wires, > 0 for registers
|
| 47 |
|
|
);
|
| 48 |
|
|
PORT (
|
| 49 |
|
|
rst : IN STD_LOGIC;
|
| 50 |
|
|
clk : IN STD_LOGIC;
|
| 51 |
|
|
-- ST sink
|
| 52 |
|
|
snk_out : OUT t_dp_siso;
|
| 53 |
|
|
snk_in : IN t_dp_sosi;
|
| 54 |
|
|
-- ST source
|
| 55 |
|
|
src_in : IN t_dp_siso := c_dp_siso_rdy;
|
| 56 |
|
|
src_out : OUT t_dp_sosi
|
| 57 |
|
|
);
|
| 58 |
|
|
END dp_bsn_restore_global;
|
| 59 |
|
|
|
| 60 |
|
|
|
| 61 |
|
|
ARCHITECTURE str OF dp_bsn_restore_global IS
|
| 62 |
|
|
|
| 63 |
|
|
SIGNAL blk_sync : STD_LOGIC;
|
| 64 |
|
|
SIGNAL bsn_at_sync : STD_LOGIC_VECTOR(g_bsn_w-1 DOWNTO 0);
|
| 65 |
|
|
SIGNAL nxt_bsn_at_sync : STD_LOGIC_VECTOR(g_bsn_w-1 DOWNTO 0);
|
| 66 |
|
|
SIGNAL bsn_restored : STD_LOGIC_VECTOR(g_bsn_w-1 DOWNTO 0);
|
| 67 |
|
|
SIGNAL snk_in_restored : t_dp_sosi;
|
| 68 |
|
|
|
| 69 |
|
|
BEGIN
|
| 70 |
|
|
|
| 71 |
|
|
-- keep BSN at sync
|
| 72 |
|
|
p_clk : PROCESS(clk, rst)
|
| 73 |
|
|
BEGIN
|
| 74 |
|
|
IF rst='1' THEN
|
| 75 |
|
|
bsn_at_sync <= (OTHERS=>'0');
|
| 76 |
|
|
ELSIF rising_edge(clk) THEN
|
| 77 |
|
|
bsn_at_sync <= nxt_bsn_at_sync;
|
| 78 |
|
|
END IF;
|
| 79 |
|
|
END PROCESS;
|
| 80 |
|
|
|
| 81 |
|
|
-- Store global BSN at sync
|
| 82 |
|
|
nxt_bsn_at_sync <= snk_in.bsn(g_bsn_w-1 DOWNTO 0) WHEN snk_in.sync='1' ELSE bsn_at_sync;
|
| 83 |
|
|
|
| 84 |
|
|
-- Create block sync from snk_in.sync, this blk_sync is active during entire first sop-eop block of sync interval
|
| 85 |
|
|
u_common_switch : ENTITY common_components_lib.common_switch
|
| 86 |
|
|
GENERIC MAP (
|
| 87 |
|
|
g_rst_level => '0', -- Defines the output level at reset.
|
| 88 |
|
|
g_priority_lo => FALSE, -- When TRUE then input switch_low has priority, else switch_high. Don't care when switch_high and switch_low are pulses that do not occur simultaneously.
|
| 89 |
|
|
g_or_high => TRUE, -- When TRUE and priority hi then the registered switch_level is OR-ed with the input switch_high to get out_level, else out_level is the registered switch_level
|
| 90 |
|
|
g_and_low => FALSE -- When TRUE and priority lo then the registered switch_level is AND-ed with the input switch_low to get out_level, else out_level is the registered switch_level
|
| 91 |
|
|
)
|
| 92 |
|
|
PORT MAP (
|
| 93 |
|
|
rst => rst,
|
| 94 |
|
|
clk => clk,
|
| 95 |
|
|
switch_high => snk_in.sync, -- A pulse on switch_high makes the out_level go high
|
| 96 |
|
|
switch_low => snk_in.eop, -- A pulse on switch_low makes the out_level go low
|
| 97 |
|
|
out_level => blk_sync
|
| 98 |
|
|
);
|
| 99 |
|
|
|
| 100 |
|
|
-- Use stored global BSN at sync and add local BSN to restore the global BSN for every next sop
|
| 101 |
|
|
bsn_restored <= snk_in.bsn WHEN blk_sync='1' ELSE ADD_UVEC(bsn_at_sync, snk_in.bsn, g_bsn_w);
|
| 102 |
|
|
|
| 103 |
|
|
snk_in_restored <= func_dp_stream_bsn_set(snk_in, bsn_restored);
|
| 104 |
|
|
|
| 105 |
|
|
-- Add pipeline to ensure timing closure for the restored BSN summation
|
| 106 |
|
|
u_pipeline : ENTITY work.dp_pipeline
|
| 107 |
|
|
GENERIC MAP (
|
| 108 |
|
|
g_pipeline => g_pipeline -- 0 for wires, > 0 for registers
|
| 109 |
|
|
)
|
| 110 |
|
|
PORT MAP (
|
| 111 |
|
|
rst => rst,
|
| 112 |
|
|
clk => clk,
|
| 113 |
|
|
-- ST sink
|
| 114 |
|
|
snk_out => snk_out,
|
| 115 |
|
|
snk_in => snk_in_restored,
|
| 116 |
|
|
-- ST source
|
| 117 |
|
|
src_in => src_in,
|
| 118 |
|
|
src_out => src_out
|
| 119 |
|
|
);
|
| 120 |
|
|
|
| 121 |
|
|
END str;
|