OpenCores
URL https://opencores.org/ocsvn/common_components/common_components/trunk

Subversion Repositories common_components

[/] [common_components/] [trunk/] [common_select_symbol.vhd] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 danv
-------------------------------------------------------------------------------
2
--
3 4 danv
-- Copyright 2020
4 3 danv
-- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
5
-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
6 4 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 3 danv
--
19
-------------------------------------------------------------------------------
20
 
21
LIBRARY IEEE, common_pkg_lib;
22
USE IEEE.std_logic_1164.ALL;
23
USE common_pkg_lib.common_pkg.ALL;
24
USE work.common_components_pkg.ALL;
25
 
26
-- Purpose: Select symbol from input data stream
27
-- Description:
28
--   The in_data is a concatenation of g_nof_symbols, that are each g_symbol_w
29
--   bits wide. The symbol with index set by in_sel is passed on to the output
30
--   out_dat.
31
-- Remarks:
32
-- . If the in_select index is too large for g_nof_input range then the output
33
--   passes on symbol 0.
34
 
35
ENTITY common_select_symbol IS
36
  GENERIC (
37
    g_pipeline_in  : NATURAL := 0;
38
    g_pipeline_out : NATURAL := 1;
39
    g_nof_symbols  : NATURAL := 4;
40
    g_symbol_w     : NATURAL := 16;
41
    g_sel_w        : NATURAL := 2
42
  );
43
  PORT (
44
    rst        : IN  STD_LOGIC;
45
    clk        : IN  STD_LOGIC;
46
 
47
    in_data    : IN  STD_LOGIC_VECTOR(g_nof_symbols*g_symbol_w-1 DOWNTO 0);
48
    in_val     : IN  STD_LOGIC := '0';
49
    in_sop     : IN  STD_LOGIC := '0';
50
    in_eop     : IN  STD_LOGIC := '0';
51
    in_sync    : IN  STD_LOGIC := '0';
52
 
53
    in_sel     : IN  STD_LOGIC_VECTOR(g_sel_w-1 DOWNTO 0);
54
    out_sel    : OUT STD_LOGIC_VECTOR(g_sel_w-1 DOWNTO 0);  -- pipelined in_sel, use range to allow leaving it OPEN
55
 
56
    out_symbol : OUT STD_LOGIC_VECTOR(g_symbol_w-1 DOWNTO 0);
57
    out_val    : OUT STD_LOGIC;         -- pipelined in_val
58
    out_sop    : OUT STD_LOGIC;         -- pipelined in_sop
59
    out_eop    : OUT STD_LOGIC;         -- pipelined in_eop
60
    out_sync   : OUT STD_LOGIC          -- pipelined in_sync
61
  );
62
END common_select_symbol;
63
 
64
 
65
ARCHITECTURE rtl OF common_select_symbol IS
66
 
67
  CONSTANT c_pipeline   : NATURAL := g_pipeline_in + g_pipeline_out;
68
 
69
  SIGNAL in_data_reg    : STD_LOGIC_VECTOR(in_data'RANGE);
70
  SIGNAL in_sel_reg     : STD_LOGIC_VECTOR(in_sel'RANGE);
71
 
72
  SIGNAL sel_symbol     : STD_LOGIC_VECTOR(g_symbol_w-1 DOWNTO 0);
73
 
74
BEGIN
75
 
76
  -- pipeline input
77
  u_pipe_in_data : common_pipeline GENERIC MAP ("SIGNED", g_pipeline_in, 0, in_data'LENGTH, in_data'LENGTH) PORT MAP (rst, clk, '1', '0', '1', in_data, in_data_reg);
78
  u_pipe_in_sel  : common_pipeline GENERIC MAP ("SIGNED", g_pipeline_in, 0, g_sel_w,        g_sel_w)        PORT MAP (rst, clk, '1', '0', '1', in_sel,  in_sel_reg);
79
 
80
  no_sel : IF g_nof_symbols=1 GENERATE
81
    sel_symbol <= in_data_reg;
82
  END GENERATE;
83
 
84
  gen_sel : IF g_nof_symbols>1 GENERATE
85
    -- Default pass on symbol 0 else if supported pass on the selected symbol
86
    p_sel : PROCESS(in_sel_reg, in_data_reg)
87
    BEGIN
88
      sel_symbol <= in_data_reg(g_symbol_w-1 DOWNTO 0);
89
 
90
      FOR I IN g_nof_symbols-1 DOWNTO 0 LOOP
91
        IF TO_UINT(in_sel_reg)=I THEN
92
          sel_symbol <= in_data_reg((I+1)*g_symbol_w-1 DOWNTO I*g_symbol_w);
93
        END IF;
94
      END LOOP;
95
    END PROCESS;
96
  END GENERATE;
97
 
98
  -- pipeline selected symbol output and control outputs
99
  u_pipe_out_symbol : common_pipeline GENERIC MAP ("SIGNED", g_pipeline_out, 0, g_symbol_w,    g_symbol_w)    PORT MAP (rst, clk, '1', '0', '1', sel_symbol, out_symbol);
100
  u_pipe_out_sel    : common_pipeline GENERIC MAP ("SIGNED", c_pipeline,     0, in_sel'LENGTH, in_sel'LENGTH) PORT MAP (rst, clk, '1', '0', '1', in_sel,     out_sel);
101
 
102
  u_pipe_out_val  : common_pipeline_sl GENERIC MAP (c_pipeline, 0, FALSE) PORT MAP (rst, clk, '1', '0', '1', in_val,  out_val);
103
  u_pipe_out_sop  : common_pipeline_sl GENERIC MAP (c_pipeline, 0, FALSE) PORT MAP (rst, clk, '1', '0', '1', in_sop,  out_sop);
104
  u_pipe_out_eop  : common_pipeline_sl GENERIC MAP (c_pipeline, 0, FALSE) PORT MAP (rst, clk, '1', '0', '1', in_eop,  out_eop);
105
  u_pipe_out_sync : common_pipeline_sl GENERIC MAP (c_pipeline, 0, FALSE) PORT MAP (rst, clk, '1', '0', '1', in_sync, out_sync);
106
 
107
END rtl;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.