1 |
2 |
danv |
-------------------------------------------------------------------------------
|
2 |
|
|
--
|
3 |
|
|
-- Copyright (C) 2013
|
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 |
|
|
-- >>> Ported from UniBoard dp_latency_adapter for fixed RL 0 --> 1
|
24 |
|
|
|
25 |
|
|
LIBRARY IEEE;
|
26 |
|
|
USE IEEE.std_logic_1164.ALL;
|
27 |
|
|
|
28 |
|
|
-- Purpose: Adapt from ready latency 1 to 0 to make a look ahead FIFO
|
29 |
|
|
-- Description: -
|
30 |
|
|
-- Remark:
|
31 |
|
|
-- . A show ahead FIFO with RL=0 does not need a rd_emp output signal, because
|
32 |
|
|
-- with RL=0 the rd_val='0' when it is empty (so emp <= NOT rd_val).
|
33 |
|
|
|
34 |
|
|
|
35 |
|
|
ENTITY common_rl_decrease IS
|
36 |
|
|
GENERIC (
|
37 |
|
|
g_adapt : BOOLEAN := TRUE; -- default when TRUE then decrease sink RL 1 to source RL 0, else then implement wires
|
38 |
|
|
g_dat_w : NATURAL := 18
|
39 |
|
|
);
|
40 |
|
|
PORT (
|
41 |
|
|
rst : IN STD_LOGIC;
|
42 |
|
|
clk : IN STD_LOGIC;
|
43 |
|
|
-- ST sink: RL = 1
|
44 |
|
|
snk_out_ready : OUT STD_LOGIC;
|
45 |
|
|
snk_in_dat : IN STD_LOGIC_VECTOR(g_dat_w-1 DOWNTO 0);
|
46 |
|
|
snk_in_val : IN STD_LOGIC := 'X';
|
47 |
|
|
-- ST source: RL = 0
|
48 |
|
|
src_in_ready : IN STD_LOGIC;
|
49 |
|
|
src_out_dat : OUT STD_LOGIC_VECTOR(g_dat_w-1 DOWNTO 0);
|
50 |
|
|
src_out_val : OUT STD_LOGIC
|
51 |
|
|
);
|
52 |
|
|
END common_rl_decrease;
|
53 |
|
|
|
54 |
|
|
|
55 |
|
|
ARCHITECTURE rtl OF common_rl_decrease IS
|
56 |
|
|
|
57 |
|
|
-- Internally use streaming record for the SOSI, for the SISO.ready directly use src_in_ready
|
58 |
|
|
TYPE t_sosi IS RECORD -- Source Out or Sink In
|
59 |
|
|
data : STD_LOGIC_VECTOR(g_dat_w-1 DOWNTO 0);
|
60 |
|
|
valid : STD_LOGIC;
|
61 |
|
|
END RECORD;
|
62 |
|
|
|
63 |
|
|
TYPE t_sosi_arr IS ARRAY (INTEGER RANGE <>) OF t_sosi;
|
64 |
|
|
|
65 |
|
|
CONSTANT c_sosi_rst : t_sosi := ((OTHERS=>'0'), '0');
|
66 |
|
|
|
67 |
|
|
-- SOSI IO
|
68 |
|
|
SIGNAL snk_in : t_sosi;
|
69 |
|
|
SIGNAL src_out : t_sosi;
|
70 |
|
|
|
71 |
|
|
-- The default FIFO has ready latency RL = 1, need to use input RL + 1 words for the buf array, to go to output RL = 0 for show ahead FIFO
|
72 |
|
|
SIGNAL buf : t_sosi_arr(1 DOWNTO 0);
|
73 |
|
|
SIGNAL nxt_buf : t_sosi_arr(1 DOWNTO 0);
|
74 |
|
|
|
75 |
|
|
BEGIN
|
76 |
|
|
|
77 |
|
|
gen_wires : IF g_adapt=FALSE GENERATE
|
78 |
|
|
snk_out_ready <= src_in_ready;
|
79 |
|
|
|
80 |
|
|
src_out_dat <= snk_in_dat;
|
81 |
|
|
src_out_val <= snk_in_val;
|
82 |
|
|
END GENERATE;
|
83 |
|
|
|
84 |
|
|
gen_adapt : IF g_adapt=TRUE GENERATE
|
85 |
|
|
snk_in.data <= snk_in_dat;
|
86 |
|
|
snk_in.valid <= snk_in_val;
|
87 |
|
|
|
88 |
|
|
src_out_dat <= src_out.data;
|
89 |
|
|
src_out_val <= src_out.valid;
|
90 |
|
|
|
91 |
|
|
-- Buf[0] contains the FIFO output with zero ready latency
|
92 |
|
|
src_out <= buf(0);
|
93 |
|
|
|
94 |
|
|
p_clk : PROCESS(rst, clk)
|
95 |
|
|
BEGIN
|
96 |
|
|
IF rst='1' THEN
|
97 |
|
|
buf <= (OTHERS=>c_sosi_rst);
|
98 |
|
|
ELSIF rising_edge(clk) THEN
|
99 |
|
|
buf <= nxt_buf;
|
100 |
|
|
END IF;
|
101 |
|
|
END PROCESS;
|
102 |
|
|
|
103 |
|
|
p_snk_out_ready : PROCESS(buf, src_in_ready, snk_in)
|
104 |
|
|
BEGIN
|
105 |
|
|
snk_out_ready <= '0';
|
106 |
|
|
IF src_in_ready='1' THEN
|
107 |
|
|
-- Default snk_out_ready when src_in_ready.
|
108 |
|
|
snk_out_ready <= '1';
|
109 |
|
|
ELSE
|
110 |
|
|
-- Extra snk_out_ready to look ahead for RL = 0.
|
111 |
|
|
IF buf(0).valid='0' THEN
|
112 |
|
|
snk_out_ready <= '1';
|
113 |
|
|
ELSIF buf(1).valid='0' THEN
|
114 |
|
|
snk_out_ready <= NOT(snk_in.valid);
|
115 |
|
|
END IF;
|
116 |
|
|
END IF;
|
117 |
|
|
END PROCESS;
|
118 |
|
|
|
119 |
|
|
p_buf : PROCESS(buf, src_in_ready, snk_in)
|
120 |
|
|
BEGIN
|
121 |
|
|
-- Keep or shift the buf dependent on src_in_ready, no need to explicitly check buf().valid
|
122 |
|
|
nxt_buf <= buf;
|
123 |
|
|
IF src_in_ready='1' THEN
|
124 |
|
|
nxt_buf(0) <= buf(1);
|
125 |
|
|
nxt_buf(1).valid <= '0'; -- not strictly necessary, but robust
|
126 |
|
|
END IF;
|
127 |
|
|
|
128 |
|
|
-- Put input data at the first available location dependent on src_in_ready, no need to explicitly check snk_in_val
|
129 |
|
|
IF buf(0).valid='0' THEN
|
130 |
|
|
nxt_buf(0) <= snk_in;
|
131 |
|
|
ELSE
|
132 |
|
|
IF buf(1).valid='0' THEN
|
133 |
|
|
IF src_in_ready='0' THEN
|
134 |
|
|
nxt_buf(1) <= snk_in;
|
135 |
|
|
ELSE
|
136 |
|
|
nxt_buf(0) <= snk_in;
|
137 |
|
|
END IF;
|
138 |
|
|
END IF;
|
139 |
|
|
END IF;
|
140 |
|
|
END PROCESS;
|
141 |
|
|
END GENERATE;
|
142 |
|
|
|
143 |
|
|
END rtl;
|