| 1 |
2 |
danv |
-------------------------------------------------------------------------------
|
| 2 |
|
|
--
|
| 3 |
3 |
danv |
-- Copyright 2020
|
| 4 |
2 |
danv |
-- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
|
| 5 |
|
|
-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
|
| 6 |
3 |
danv |
--
|
| 7 |
|
|
-- Licensed under the Apache License, Version 2.0 (the "License");
|
| 8 |
|
|
-- you may not use this file except in compliance with the License.
|
| 9 |
|
|
-- You may obtain a copy of the License at
|
| 10 |
|
|
--
|
| 11 |
|
|
-- http://www.apache.org/licenses/LICENSE-2.0
|
| 12 |
|
|
--
|
| 13 |
|
|
-- Unless required by applicable law or agreed to in writing, software
|
| 14 |
|
|
-- distributed under the License is distributed on an "AS IS" BASIS,
|
| 15 |
|
|
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 16 |
|
|
-- See the License for the specific language governing permissions and
|
| 17 |
|
|
-- limitations under the License.
|
| 18 |
2 |
danv |
--
|
| 19 |
|
|
-------------------------------------------------------------------------------
|
| 20 |
|
|
|
| 21 |
|
|
LIBRARY IEEE, common_pkg_lib, common_components_lib;
|
| 22 |
|
|
USE IEEE.STD_LOGIC_1164.ALL;
|
| 23 |
|
|
USE common_pkg_lib.common_pkg.ALL;
|
| 24 |
|
|
USE common_components_lib.common_components_pkg.ALL;
|
| 25 |
|
|
|
| 26 |
|
|
-- Purpose: Assign input to one of g_nof_out output streams based on out_sel input
|
| 27 |
|
|
-- Description: The output streams are concatenated into one SLV.
|
| 28 |
|
|
-- Remarks:
|
| 29 |
|
|
-- . Same scheme for pipeline handling and g_nof_out=1 handling as in common_select_symbol
|
| 30 |
|
|
|
| 31 |
|
|
ENTITY common_demultiplexer IS
|
| 32 |
|
|
GENERIC (
|
| 33 |
|
|
g_pipeline_in : NATURAL := 0;
|
| 34 |
|
|
g_pipeline_out : NATURAL := 0;
|
| 35 |
|
|
g_nof_out : NATURAL;
|
| 36 |
|
|
g_dat_w : NATURAL
|
| 37 |
|
|
);
|
| 38 |
|
|
PORT (
|
| 39 |
|
|
rst : IN STD_LOGIC := '0';
|
| 40 |
|
|
clk : IN STD_LOGIC := '0'; -- for g_pipeline_* = 0 no rst and clk are needed, because then the demultiplexer works combinatorialy
|
| 41 |
|
|
|
| 42 |
|
|
in_dat : IN STD_LOGIC_VECTOR(g_dat_w-1 DOWNTO 0);
|
| 43 |
|
|
in_val : IN STD_LOGIC;
|
| 44 |
|
|
|
| 45 |
|
|
out_sel : IN STD_LOGIC_VECTOR(ceil_log2(g_nof_out)-1 DOWNTO 0);
|
| 46 |
|
|
out_dat : OUT STD_LOGIC_VECTOR(g_nof_out*g_dat_w-1 DOWNTO 0);
|
| 47 |
|
|
out_val : OUT STD_LOGIC_VECTOR(g_nof_out -1 DOWNTO 0)
|
| 48 |
|
|
);
|
| 49 |
|
|
END;
|
| 50 |
|
|
|
| 51 |
|
|
ARCHITECTURE rtl OF common_demultiplexer IS
|
| 52 |
|
|
|
| 53 |
|
|
CONSTANT c_sel_w : NATURAL := out_sel'LENGTH;
|
| 54 |
|
|
|
| 55 |
|
|
SIGNAL in_dat_reg : STD_LOGIC_VECTOR(in_dat'RANGE);
|
| 56 |
|
|
SIGNAL in_val_reg : STD_LOGIC;
|
| 57 |
|
|
|
| 58 |
|
|
SIGNAL out_sel_reg : STD_LOGIC_VECTOR(out_sel'RANGE);
|
| 59 |
|
|
|
| 60 |
|
|
SIGNAL sel_dat : STD_LOGIC_VECTOR(g_nof_out*g_dat_w-1 DOWNTO 0);
|
| 61 |
|
|
SIGNAL sel_val : STD_LOGIC_VECTOR(g_nof_out -1 DOWNTO 0);
|
| 62 |
|
|
|
| 63 |
|
|
BEGIN
|
| 64 |
|
|
|
| 65 |
|
|
-- pipeline input
|
| 66 |
|
|
u_pipe_in_dat : common_pipeline GENERIC MAP ("SIGNED", g_pipeline_in, 0, g_dat_w, g_dat_w) PORT MAP (rst, clk, '1', '0', '1', in_dat, in_dat_reg);
|
| 67 |
|
|
u_pipe_in_val : common_pipeline_sl GENERIC MAP ( g_pipeline_in, 0, FALSE) PORT MAP (rst, clk, '1', '0', '1', in_val, in_val_reg);
|
| 68 |
|
|
|
| 69 |
|
|
u_pipe_out_sel : common_pipeline GENERIC MAP ("SIGNED", g_pipeline_in, 0, c_sel_w, c_sel_w) PORT MAP (rst, clk, '1', '0', '1', out_sel, out_sel_reg);
|
| 70 |
|
|
|
| 71 |
|
|
-- select combinatorialy
|
| 72 |
|
|
no_sel : IF g_nof_out=1 GENERATE
|
| 73 |
|
|
sel_dat <= in_dat_reg;
|
| 74 |
|
|
sel_val(0) <= in_val_reg;
|
| 75 |
|
|
END GENERATE;
|
| 76 |
|
|
|
| 77 |
|
|
gen_sel : IF g_nof_out>1 GENERATE
|
| 78 |
|
|
p_sel : PROCESS(out_sel_reg, in_dat_reg, in_val_reg)
|
| 79 |
|
|
BEGIN
|
| 80 |
|
|
sel_val <= (OTHERS=>'0');
|
| 81 |
|
|
FOR I IN g_nof_out-1 DOWNTO 0 LOOP
|
| 82 |
|
|
sel_dat((I+1)*g_dat_w-1 DOWNTO I*g_dat_w) <= in_dat_reg; -- replicate in_dat to all outputs, this requires less logic than default forcing invalid outputs to 0
|
| 83 |
|
|
IF TO_UINT(out_sel_reg)=I THEN
|
| 84 |
|
|
sel_val(I) <= in_val_reg; -- let out_sel determine which output is valid
|
| 85 |
|
|
END IF;
|
| 86 |
|
|
END LOOP;
|
| 87 |
|
|
END PROCESS;
|
| 88 |
|
|
END GENERATE;
|
| 89 |
|
|
|
| 90 |
|
|
-- pipeline output
|
| 91 |
|
|
u_pipe_out_dat : common_pipeline GENERIC MAP ("SIGNED", g_pipeline_out, 0, g_nof_out*g_dat_w, g_nof_out*g_dat_w) PORT MAP (rst, clk, '1', '0', '1', sel_dat, out_dat);
|
| 92 |
|
|
u_pipe_out_val : common_pipeline GENERIC MAP ("SIGNED", g_pipeline_out, 0, g_nof_out , g_nof_out ) PORT MAP (rst, clk, '1', '0', '1', sel_val, out_val);
|
| 93 |
|
|
|
| 94 |
|
|
END rtl;
|