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