-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
--
|
--
|
-- Copyright (C) 2013
|
-- Copyright 2020
|
-- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
|
-- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
|
-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
|
-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
|
--
|
--
|
-- This program is free software: you can redistribute it and/or modify
|
-- Licensed under the Apache License, Version 2.0 (the "License");
|
-- it under the terms of the GNU General Public License as published by
|
-- you may not use this file except in compliance with the License.
|
-- the Free Software Foundation, either version 3 of the License, or
|
-- You may obtain a copy of the License at
|
-- (at your option) any later version.
|
|
--
|
--
|
-- This program is distributed in the hope that it will be useful,
|
-- http://www.apache.org/licenses/LICENSE-2.0
|
-- 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
|
-- Unless required by applicable law or agreed to in writing, software
|
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
-- 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.
|
--
|
--
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
|
|
-- Purpose: Add flow XON-XOFF control by flushing frames
|
-- Purpose: Add flow XON-XOFF control by flushing frames
|
-- Description:
|
-- Description:
|
-- . The in_siso.ready = out_siso.ready so passed on unchanged, to support
|
-- . The in_siso.ready = out_siso.ready so passed on unchanged, to support
|
-- detailed output to input flow control per cycle. The in_siso.xon is
|
-- detailed output to input flow control per cycle. The in_siso.xon is
|
-- always '1', because the out_siso.xon is taken care of in this
|
-- always '1', because the out_siso.xon is taken care of in this
|
-- dp_xonoff.vhd by flushing any in_sosi data when out_siso.xon = '0'.
|
-- dp_xonoff.vhd by flushing any in_sosi data when out_siso.xon = '0'.
|
--
|
--
|
-- . When g_bypass=TRUE then the in and out are wired and the component is void.
|
-- . When g_bypass=TRUE then the in and out are wired and the component is void.
|
-- . When g_bypass=FALSE then:
|
-- . When g_bypass=FALSE then:
|
-- The output is ON when flush='0'.
|
-- The output is ON when flush='0'.
|
-- The output is OFF when flush='1'.
|
-- The output is OFF when flush='1'.
|
-- The transition from OFF to ON occurs after an in_sosi.eop so between frames
|
-- The transition from OFF to ON occurs after an in_sosi.eop so between frames
|
-- The transition from ON to OFF occurs after an in_sosi.eop so between frames
|
-- The transition from ON to OFF occurs after an in_sosi.eop so between frames
|
-- Thanks to frm_busy it is also possible to switch between frames, so it
|
-- Thanks to frm_busy it is also possible to switch between frames, so it
|
-- is not necessary that first an eop occurs, before the xon can change.
|
-- is not necessary that first an eop occurs, before the xon can change.
|
-- The possibility to switch xon at an eop is needed to be able to switch
|
-- The possibility to switch xon at an eop is needed to be able to switch
|
-- xon in case there are no gaps between the frames.
|
-- xon in case there are no gaps between the frames.
|
-- . The primary control is via out_siso.xon, however there is an option to override
|
-- . The primary control is via out_siso.xon, however there is an option to override
|
-- the out_siso.xon control and force the output to off by using force_xoff.
|
-- the out_siso.xon control and force the output to off by using force_xoff.
|
-- Remark:
|
-- Remark:
|
-- . The output controls are not registered.
|
-- . The output controls are not registered.
|
-- . The xon timing is not cycle critical therefor register flush to ease
|
-- . The xon timing is not cycle critical therefor register flush to ease
|
-- timing closure
|
-- timing closure
|
-- . Originally based on rad_frame_onoff from LOFAR RSP firmware
|
-- . Originally based on rad_frame_onoff from LOFAR RSP firmware
|
|
|
LIBRARY IEEE, dp_pkg_lib;
|
LIBRARY IEEE, dp_pkg_lib;
|
USE IEEE.std_logic_1164.ALL;
|
USE IEEE.std_logic_1164.ALL;
|
USE dp_pkg_lib.dp_stream_pkg.ALL;
|
USE dp_pkg_lib.dp_stream_pkg.ALL;
|
|
|
ENTITY dp_xonoff IS
|
ENTITY dp_xonoff IS
|
GENERIC (
|
GENERIC (
|
g_bypass : BOOLEAN := FALSE
|
g_bypass : BOOLEAN := FALSE
|
);
|
);
|
PORT (
|
PORT (
|
rst : IN STD_LOGIC;
|
rst : IN STD_LOGIC;
|
clk : IN STD_LOGIC;
|
clk : IN STD_LOGIC;
|
-- Frame in
|
-- Frame in
|
in_siso : OUT t_dp_siso;
|
in_siso : OUT t_dp_siso;
|
in_sosi : IN t_dp_sosi;
|
in_sosi : IN t_dp_sosi;
|
-- Frame out
|
-- Frame out
|
out_siso : IN t_dp_siso; -- flush control via out_siso.xon
|
out_siso : IN t_dp_siso; -- flush control via out_siso.xon
|
out_sosi : OUT t_dp_sosi;
|
out_sosi : OUT t_dp_sosi;
|
-- Optional override to force XOFF ('1' = enable override)
|
-- Optional override to force XOFF ('1' = enable override)
|
force_xoff : IN STD_LOGIC := '0'
|
force_xoff : IN STD_LOGIC := '0'
|
);
|
);
|
END dp_xonoff;
|
END dp_xonoff;
|
|
|
|
|
ARCHITECTURE rtl OF dp_xonoff IS
|
ARCHITECTURE rtl OF dp_xonoff IS
|
|
|
SIGNAL frm_busy : STD_LOGIC;
|
SIGNAL frm_busy : STD_LOGIC;
|
SIGNAL frm_busy_reg : STD_LOGIC;
|
SIGNAL frm_busy_reg : STD_LOGIC;
|
|
|
SIGNAL flush : STD_LOGIC;
|
SIGNAL flush : STD_LOGIC;
|
SIGNAL nxt_flush : STD_LOGIC;
|
SIGNAL nxt_flush : STD_LOGIC;
|
|
|
SIGNAL out_en : STD_LOGIC;
|
SIGNAL out_en : STD_LOGIC;
|
SIGNAL nxt_out_en : STD_LOGIC;
|
SIGNAL nxt_out_en : STD_LOGIC;
|
|
|
BEGIN
|
BEGIN
|
|
|
gen_bypass : IF g_bypass=TRUE GENERATE
|
gen_bypass : IF g_bypass=TRUE GENERATE
|
in_siso <= out_siso;
|
in_siso <= out_siso;
|
out_sosi <= in_sosi;
|
out_sosi <= in_sosi;
|
END GENERATE;
|
END GENERATE;
|
|
|
no_bypass : IF g_bypass=FALSE GENERATE
|
no_bypass : IF g_bypass=FALSE GENERATE
|
in_siso.ready <= out_siso.ready; -- pass on ready for detailed flow control per cycle
|
in_siso.ready <= out_siso.ready; -- pass on ready for detailed flow control per cycle
|
in_siso.xon <= '1'; -- upstream can remain on, because flush will handle out_siso.xon
|
in_siso.xon <= '1'; -- upstream can remain on, because flush will handle out_siso.xon
|
nxt_flush <= NOT out_siso.xon OR force_xoff; -- use xon for flow control at frame level
|
nxt_flush <= NOT out_siso.xon OR force_xoff; -- use xon for flow control at frame level
|
|
|
p_clk: PROCESS(clk, rst)
|
p_clk: PROCESS(clk, rst)
|
BEGIN
|
BEGIN
|
IF rst='1' THEN
|
IF rst='1' THEN
|
frm_busy_reg <= '0';
|
frm_busy_reg <= '0';
|
flush <= '0';
|
flush <= '0';
|
out_en <= '1';
|
out_en <= '1';
|
ELSIF rising_edge(clk) THEN
|
ELSIF rising_edge(clk) THEN
|
frm_busy_reg <= frm_busy;
|
frm_busy_reg <= frm_busy;
|
flush <= nxt_flush; -- pipeline register flush to ease timing closure
|
flush <= nxt_flush; -- pipeline register flush to ease timing closure
|
out_en <= nxt_out_en; -- state register out_en because it can only change between frames
|
out_en <= nxt_out_en; -- state register out_en because it can only change between frames
|
END IF;
|
END IF;
|
END PROCESS;
|
END PROCESS;
|
|
|
-- Detect in_sosi frame busy, frm_busy is '1' from sop including sop, until eop excluding eop
|
-- Detect in_sosi frame busy, frm_busy is '1' from sop including sop, until eop excluding eop
|
p_frm_busy : PROCESS(in_sosi, in_sosi, frm_busy_reg)
|
p_frm_busy : PROCESS(in_sosi, in_sosi, frm_busy_reg)
|
BEGIN
|
BEGIN
|
frm_busy <= frm_busy_reg;
|
frm_busy <= frm_busy_reg;
|
IF in_sosi.sop='1' THEN
|
IF in_sosi.sop='1' THEN
|
frm_busy <= '1';
|
frm_busy <= '1';
|
ELSIF in_sosi.eop='1' THEN
|
ELSIF in_sosi.eop='1' THEN
|
frm_busy <= '0';
|
frm_busy <= '0';
|
END IF;
|
END IF;
|
END PROCESS;
|
END PROCESS;
|
|
|
p_out_en : PROCESS(flush, out_en, frm_busy)
|
p_out_en : PROCESS(flush, out_en, frm_busy)
|
BEGIN
|
BEGIN
|
nxt_out_en <= out_en;
|
nxt_out_en <= out_en;
|
IF frm_busy='0' THEN
|
IF frm_busy='0' THEN
|
IF flush='1' THEN
|
IF flush='1' THEN
|
nxt_out_en <= '0';
|
nxt_out_en <= '0';
|
ELSE
|
ELSE
|
nxt_out_en <= '1';
|
nxt_out_en <= '1';
|
END IF;
|
END IF;
|
END IF;
|
END IF;
|
END PROCESS;
|
END PROCESS;
|
|
|
p_out_sosi : PROCESS(in_sosi, out_en)
|
p_out_sosi : PROCESS(in_sosi, out_en)
|
BEGIN
|
BEGIN
|
-- Pass on sosi data via wires
|
-- Pass on sosi data via wires
|
out_sosi <= in_sosi;
|
out_sosi <= in_sosi;
|
|
|
-- XON/XOFF flow control via sosi control
|
-- XON/XOFF flow control via sosi control
|
out_sosi.sync <= in_sosi.sync AND out_en;
|
out_sosi.sync <= in_sosi.sync AND out_en;
|
out_sosi.valid <= in_sosi.valid AND out_en;
|
out_sosi.valid <= in_sosi.valid AND out_en;
|
out_sosi.sop <= in_sosi.sop AND out_en;
|
out_sosi.sop <= in_sosi.sop AND out_en;
|
out_sosi.eop <= in_sosi.eop AND out_en;
|
out_sosi.eop <= in_sosi.eop AND out_en;
|
END PROCESS;
|
END PROCESS;
|
END GENERATE;
|
END GENERATE;
|
|
|
END ARCHITECTURE;
|
END ARCHITECTURE;
|
|
|