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

Subversion Repositories astron_diagnostics

[/] [astron_diagnostics/] [trunk/] [diag_tx_seq.vhd] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
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 4 danv
LIBRARY IEEE, common_pkg_lib, astron_counter_lib;
22 2 danv
USE IEEE.std_logic_1164.ALL;
23
USE IEEE.numeric_std.ALL;
24
USE common_pkg_lib.common_pkg.ALL;
25
USE common_pkg_lib.common_lfsr_sequences_pkg.ALL;
26
 
27
-- Purpose: Transmit continuous PRSG or COUNTER test sequence data.
28
-- Description:
29
--   The Tx test data can sequence data or constant value data dependent on
30
--   diag_dc. 
31
--   The Tx test sequence data can be PRSG or COUNTER dependent on diag_sel.
32
--   The Tx is enabled by diag_en. When the Tx is disabled then the sequence
33
--   data gets initialised with diag_init.
34
--   The out_ready acts as a data request. When the generator is enabled then
35
--   output is valid for every active out_ready, to support streaming flow
36
--   control. With g_latency=1 the out_val is active one cycle after diag_req,
37
--   by using g_latency=0 outval is active in the same cycle as diag_req.
38
--   Use diag_mod=0 for default binary wrap at 2**g_dat_w. For diag_rx_seq
39
--   choose diag_step = 2**g_seq_dat_w - diag_mod + g_cnt_incr to verify ok.
40
 
41
ENTITY diag_tx_seq IS
42
  GENERIC (
43
    g_latency  : NATURAL := 1;  -- default 1 for registered out_cnt/dat/val output, use 0 for immediate combinatorial out_cnt/dat/val output
44
    g_sel      : STD_LOGIC := '1';  -- '0' = PRSG, '1' = COUNTER
45
    g_init     : NATURAL := 0;      -- init value for out_dat when diag_en = '0'
46
    g_cnt_incr : INTEGER := 1;
47
    g_cnt_w    : NATURAL := c_word_w;
48
    g_dat_w    : NATURAL            -- >= 1, test data width
49
  );
50
  PORT (
51
    rst        : IN  STD_LOGIC;
52
    clk        : IN  STD_LOGIC;
53
    clken      : IN  STD_LOGIC := '1';
54
    -- Static control input (connect via MM or leave open to use default)
55
    diag_en    : IN  STD_LOGIC;           -- '0' = init and disable output sequence, '1' = enable output sequence
56
    diag_sel   : IN  STD_LOGIC := g_sel;  -- '0' = PRSG sequence data, '1' = COUNTER sequence data
57
    diag_dc    : IN  STD_LOGIC := '0';    -- '0' = output diag_sel sequence data, '1' = output constant diag_init data
58
    diag_init  : IN  STD_LOGIC_VECTOR(g_dat_w-1 DOWNTO 0) := TO_UVEC(g_init, g_dat_w);  -- init value for out_dat when diag_en = '0'
59
    diag_mod   : IN  STD_LOGIC_VECTOR(g_dat_w-1 DOWNTO 0) := TO_UVEC(0, g_dat_w);       -- default 0 to wrap modulo 2*g_dat_w
60
    -- ST output
61
    diag_req   : IN  STD_LOGIC := '1';   -- '1' = request output, '0' = halt output
62
    out_cnt    : OUT STD_LOGIC_VECTOR(g_cnt_w-1 DOWNTO 0);  -- count valid output test sequence data
63
    out_dat    : OUT STD_LOGIC_VECTOR(g_dat_w-1 DOWNTO 0);  -- output test sequence data
64
    out_val    : OUT STD_LOGIC                              -- '1' when out_dat is valid
65
  );
66
END diag_tx_seq;
67
 
68
 
69
ARCHITECTURE rtl OF diag_tx_seq IS
70
 
71
  CONSTANT c_lfsr_nr     : NATURAL := g_dat_w - c_common_lfsr_first;
72
 
73
  SIGNAL diag_dis        : STD_LOGIC;
74
 
75
  SIGNAL prsg            : STD_LOGIC_VECTOR(out_dat'RANGE);
76
  SIGNAL nxt_prsg        : STD_LOGIC_VECTOR(out_dat'RANGE);
77
  SIGNAL cntr            : STD_LOGIC_VECTOR(out_dat'RANGE) := (OTHERS=>'0');  -- init to avoid Warning: "NUMERIC_STD."<": metavalue detected" with UNSIGNED()
78
  SIGNAL next_cntr       : STD_LOGIC_VECTOR(out_dat'RANGE) := (OTHERS=>'0');  -- init to avoid Warning: "NUMERIC_STD."<": metavalue detected" with UNSIGNED()
79
  SIGNAL nxt_cntr        : STD_LOGIC_VECTOR(out_dat'RANGE);
80
 
81
  SIGNAL nxt_out_dat     : STD_LOGIC_VECTOR(out_dat'RANGE);
82
  SIGNAL nxt_out_val     : STD_LOGIC;
83
 
84
BEGIN
85
 
86
  diag_dis <= NOT diag_en;
87
 
88
  p_clk : PROCESS (rst, clk)
89
  BEGIN
90
    IF rst='1' THEN
91
      prsg         <= (OTHERS=>'0');
92
      cntr         <= (OTHERS=>'0');
93
    ELSIF rising_edge(clk) THEN
94
      IF clken='1' THEN
95
        prsg         <= nxt_prsg;
96
        cntr         <= nxt_cntr;
97
      END IF;
98
    END IF;
99
  END PROCESS;
100
 
101
  gen_latency : IF g_latency/=0 GENERATE
102
    p_clk : PROCESS (rst, clk)
103
    BEGIN
104
      IF rst='1' THEN
105
        out_dat      <= (OTHERS=>'0');
106
        out_val      <= '0';
107
      ELSIF rising_edge(clk) THEN
108
        IF clken='1' THEN
109
          out_dat      <= nxt_out_dat;
110
          out_val      <= nxt_out_val;
111
        END IF;
112
      END IF;
113
    END PROCESS;
114
  END GENERATE;
115
 
116
  no_latency : IF g_latency=0 GENERATE
117
    out_dat      <= nxt_out_dat;
118
    out_val      <= nxt_out_val;
119
  END GENERATE;
120
 
121
  common_lfsr_nxt_seq(c_lfsr_nr,    -- IN
122
                      g_cnt_incr,   -- IN
123
                      diag_en,      -- IN
124
                      diag_req,     -- IN
125
                      diag_init,    -- IN
126
                      prsg,         -- IN
127
                      cntr,         -- IN
128
                      nxt_prsg,     -- OUT
129
                      next_cntr);   -- OUT
130
 
131
  nxt_cntr <= next_cntr WHEN UNSIGNED(next_cntr) < UNSIGNED(diag_mod) ELSE SUB_UVEC(next_cntr, diag_mod);
132
 
133
  nxt_out_dat <= diag_init WHEN diag_dc='1' ELSE prsg WHEN diag_sel='0' ELSE cntr;
134
  nxt_out_val <= diag_en AND diag_req;  -- 'en' for entire test on/off, 'req' for dynamic invalid gaps in the stream
135
 
136
  -- Count number of valid output data
137 4 danv
  u_common_counter : ENTITY astron_counter_lib.common_counter
138 2 danv
  GENERIC MAP (
139
    g_latency   => g_latency,  -- default 1 for registered count output, use 0 for immediate combinatorial count output
140
    g_width     => g_cnt_w
141
  )
142
  PORT MAP (
143
    rst     => rst,
144
    clk     => clk,
145
    clken   => clken,
146
    cnt_clr => diag_dis,    -- synchronous cnt_clr is only interpreted when clken is active
147
    cnt_en  => nxt_out_val,
148
    count   => out_cnt
149
  );
150
 
151
END rtl;

powered by: WebSVN 2.1.0

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