1 |
2 |
danv |
-------------------------------------------------------------------------------
|
2 |
|
|
--
|
3 |
|
|
-- Copyright (C) 2012
|
4 |
|
|
-- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
|
5 |
|
|
-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
|
6 |
|
|
--
|
7 |
|
|
-- This program is free software: you can redistribute it and/or modify
|
8 |
|
|
-- it under the terms of the GNU General Public License as published by
|
9 |
|
|
-- the Free Software Foundation, either version 3 of the License, or
|
10 |
|
|
-- (at your option) any later version.
|
11 |
|
|
--
|
12 |
|
|
-- This program is distributed in the hope that it will be useful,
|
13 |
|
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
|
|
-- GNU General Public License for more details.
|
16 |
|
|
--
|
17 |
|
|
-- You should have received a copy of the GNU General Public License
|
18 |
|
|
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19 |
|
|
--
|
20 |
|
|
-------------------------------------------------------------------------------
|
21 |
|
|
|
22 |
|
|
LIBRARY IEEE, common_pkg_lib, common_components_lib;
|
23 |
|
|
USE IEEE.STD_LOGIC_1164.ALL;
|
24 |
|
|
USE common_pkg_lib.common_pkg.ALL;
|
25 |
|
|
USE common_components_lib.common_components_pkg.ALL;
|
26 |
|
|
|
27 |
|
|
-- Purpose: Assign input to one of g_nof_out output streams based on out_sel input
|
28 |
|
|
-- Description: The output streams are concatenated into one SLV.
|
29 |
|
|
-- Remarks:
|
30 |
|
|
-- . Same scheme for pipeline handling and g_nof_out=1 handling as in common_select_symbol
|
31 |
|
|
|
32 |
|
|
ENTITY common_demultiplexer IS
|
33 |
|
|
GENERIC (
|
34 |
|
|
g_pipeline_in : NATURAL := 0;
|
35 |
|
|
g_pipeline_out : NATURAL := 0;
|
36 |
|
|
g_nof_out : NATURAL;
|
37 |
|
|
g_dat_w : NATURAL
|
38 |
|
|
);
|
39 |
|
|
PORT (
|
40 |
|
|
rst : IN STD_LOGIC := '0';
|
41 |
|
|
clk : IN STD_LOGIC := '0'; -- for g_pipeline_* = 0 no rst and clk are needed, because then the demultiplexer works combinatorialy
|
42 |
|
|
|
43 |
|
|
in_dat : IN STD_LOGIC_VECTOR(g_dat_w-1 DOWNTO 0);
|
44 |
|
|
in_val : IN STD_LOGIC;
|
45 |
|
|
|
46 |
|
|
out_sel : IN STD_LOGIC_VECTOR(ceil_log2(g_nof_out)-1 DOWNTO 0);
|
47 |
|
|
out_dat : OUT STD_LOGIC_VECTOR(g_nof_out*g_dat_w-1 DOWNTO 0);
|
48 |
|
|
out_val : OUT STD_LOGIC_VECTOR(g_nof_out -1 DOWNTO 0)
|
49 |
|
|
);
|
50 |
|
|
END;
|
51 |
|
|
|
52 |
|
|
ARCHITECTURE rtl OF common_demultiplexer IS
|
53 |
|
|
|
54 |
|
|
CONSTANT c_sel_w : NATURAL := out_sel'LENGTH;
|
55 |
|
|
|
56 |
|
|
SIGNAL in_dat_reg : STD_LOGIC_VECTOR(in_dat'RANGE);
|
57 |
|
|
SIGNAL in_val_reg : STD_LOGIC;
|
58 |
|
|
|
59 |
|
|
SIGNAL out_sel_reg : STD_LOGIC_VECTOR(out_sel'RANGE);
|
60 |
|
|
|
61 |
|
|
SIGNAL sel_dat : STD_LOGIC_VECTOR(g_nof_out*g_dat_w-1 DOWNTO 0);
|
62 |
|
|
SIGNAL sel_val : STD_LOGIC_VECTOR(g_nof_out -1 DOWNTO 0);
|
63 |
|
|
|
64 |
|
|
BEGIN
|
65 |
|
|
|
66 |
|
|
-- pipeline input
|
67 |
|
|
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);
|
68 |
|
|
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);
|
69 |
|
|
|
70 |
|
|
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);
|
71 |
|
|
|
72 |
|
|
-- select combinatorialy
|
73 |
|
|
no_sel : IF g_nof_out=1 GENERATE
|
74 |
|
|
sel_dat <= in_dat_reg;
|
75 |
|
|
sel_val(0) <= in_val_reg;
|
76 |
|
|
END GENERATE;
|
77 |
|
|
|
78 |
|
|
gen_sel : IF g_nof_out>1 GENERATE
|
79 |
|
|
p_sel : PROCESS(out_sel_reg, in_dat_reg, in_val_reg)
|
80 |
|
|
BEGIN
|
81 |
|
|
sel_val <= (OTHERS=>'0');
|
82 |
|
|
FOR I IN g_nof_out-1 DOWNTO 0 LOOP
|
83 |
|
|
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
|
84 |
|
|
IF TO_UINT(out_sel_reg)=I THEN
|
85 |
|
|
sel_val(I) <= in_val_reg; -- let out_sel determine which output is valid
|
86 |
|
|
END IF;
|
87 |
|
|
END LOOP;
|
88 |
|
|
END PROCESS;
|
89 |
|
|
END GENERATE;
|
90 |
|
|
|
91 |
|
|
-- pipeline output
|
92 |
|
|
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);
|
93 |
|
|
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);
|
94 |
|
|
|
95 |
|
|
END rtl;
|