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

Subversion Repositories astron_pipeline

[/] [astron_pipeline/] [trunk/] [tb_dp_pipeline_ready.vhd] - Blame information for rev 3

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
-- Purpose: Verify dp_pipeline_ready for different RL
22
-- Description:
23
-- Usage:
24
-- > as 10
25
-- > run -all  -- signal tb_end will stop the simulation by stopping the clk
26
-- . The verify procedures check the correct output
27
 
28
LIBRARY IEEE, common_pkg_lib, dp_pkg_lib, dp_components_lib;
29
USE IEEE.std_logic_1164.ALL;
30
USE IEEE.numeric_std.ALL;
31
USE common_pkg_lib.common_pkg.ALL;
32
USE common_pkg_lib.common_lfsr_sequences_pkg.ALL;
33
USE common_pkg_lib.tb_common_pkg.ALL;
34
USE dp_pkg_lib.dp_stream_pkg.ALL;
35
USE dp_pkg_lib.tb_dp_pkg.ALL;
36
 
37
 
38
ENTITY tb_dp_pipeline_ready IS
39
  GENERIC (
40
    g_in_en          : t_dp_flow_control_enum := e_random;  -- always active, random or pulse flow control
41
    g_out_ready      : t_dp_flow_control_enum := e_random;  -- always active, random or pulse flow control
42
    g_in_latency     : NATURAL := 1;  -- >= 0
43
    g_out_latency    : NATURAL := 0;  -- >= 0
44
    g_nof_repeat     : NATURAL := 50
45
  );
46
END tb_dp_pipeline_ready;
47
 
48
 
49
ARCHITECTURE tb OF tb_dp_pipeline_ready IS
50
  CONSTANT c_data_w          : NATURAL := 16;
51
  CONSTANT c_rl              : NATURAL := 1;
52
  CONSTANT c_data_init       : INTEGER := 0;
53
  CONSTANT c_frame_len_init  : NATURAL := 1;  -- >= 1
54
  CONSTANT c_pulse_active    : NATURAL := 1;
55
  CONSTANT c_pulse_period    : NATURAL := 7;
56
  CONSTANT c_sync_period     : NATURAL := 7;
57
  CONSTANT c_sync_offset     : NATURAL := 2;
58
 
59
  SIGNAL tb_end              : STD_LOGIC := '0';
60
  SIGNAL clk                 : STD_LOGIC := '1';
61
  SIGNAL rst                 : STD_LOGIC := '1';
62
 
63
  -- Flow control
64
  SIGNAL random_0            : STD_LOGIC_VECTOR(14 DOWNTO 0) := (OTHERS=>'0');  -- use different lengths to have different random sequences
65
  SIGNAL random_1            : STD_LOGIC_VECTOR(15 DOWNTO 0) := (OTHERS=>'0');  -- use different lengths to have different random sequences
66
  SIGNAL pulse_0             : STD_LOGIC;
67
  SIGNAL pulse_1             : STD_LOGIC;
68
  SIGNAL pulse_en            : STD_LOGIC := '1';
69
 
70
  -- Stimuli
71
  SIGNAL in_en               : STD_LOGIC := '1';
72
  SIGNAL in_siso             : t_dp_siso;
73
  SIGNAL in_sosi             : t_dp_sosi;
74
  SIGNAL adapt_siso          : t_dp_siso;
75
  SIGNAL adapt_sosi          : t_dp_sosi;
76
 
77
  SIGNAL out_siso            : t_dp_siso := c_dp_siso_hold;  -- ready='0', xon='1'
78
  SIGNAL out_sosi            : t_dp_sosi;
79
 
80
  -- Verification
81
  SIGNAL verify_en           : STD_LOGIC := '0';
82
  SIGNAL verify_done         : STD_LOGIC := '0';
83
  SIGNAL count_eop           : NATURAL := 0;
84
 
85
  SIGNAL prev_out_ready      : STD_LOGIC_VECTOR(0 TO g_out_latency);
86
  SIGNAL prev_out_data       : STD_LOGIC_VECTOR(c_data_w-1 DOWNTO 0) := TO_SVEC(c_data_init-1, c_data_w);
87
  SIGNAL out_bsn             : STD_LOGIC_VECTOR(c_data_w-1 DOWNTO 0);
88
  SIGNAL out_data            : STD_LOGIC_VECTOR(c_data_w-1 DOWNTO 0);
89
  SIGNAL out_sync            : STD_LOGIC;
90
  SIGNAL out_val             : STD_LOGIC;
91
  SIGNAL out_sop             : STD_LOGIC;
92
  SIGNAL out_eop             : STD_LOGIC;
93
  SIGNAL hold_out_sop        : STD_LOGIC;
94
  SIGNAL expected_out_data   : STD_LOGIC_VECTOR(c_data_w-1 DOWNTO 0);
95
 
96
BEGIN
97
 
98
  clk <= (NOT clk) OR tb_end AFTER clk_period/2;
99
  rst <= '1', '0' AFTER clk_period*7;
100
 
101
  random_0 <= func_common_random(random_0) WHEN rising_edge(clk);
102
  random_1 <= func_common_random(random_1) WHEN rising_edge(clk);
103
 
104
  proc_common_gen_duty_pulse(c_pulse_active, c_pulse_period,   '1', rst, clk, pulse_en, pulse_0);
105
  proc_common_gen_duty_pulse(c_pulse_active, c_pulse_period+1, '1', rst, clk, pulse_en, pulse_1);
106
 
107
 
108
  ------------------------------------------------------------------------------
109
  -- STREAM CONTROL
110
  ------------------------------------------------------------------------------
111
 
112
  in_en          <= '1'                     WHEN g_in_en=e_active      ELSE
113
                    random_0(random_0'HIGH) WHEN g_in_en=e_random      ELSE
114
                    pulse_0                 WHEN g_in_en=e_pulse;
115
 
116
  out_siso.ready <= '1'                     WHEN g_out_ready=e_active  ELSE
117
                    random_1(random_1'HIGH) WHEN g_out_ready=e_random  ELSE
118
                    pulse_1                 WHEN g_out_ready=e_pulse;
119
 
120
 
121
  ------------------------------------------------------------------------------
122
  -- DATA GENERATION
123
  ------------------------------------------------------------------------------
124
 
125
  -- Generate data path input data
126
  p_stimuli : PROCESS
127
    VARIABLE v_data_init   : NATURAL;
128
    VARIABLE v_frame_len   : NATURAL;
129
    VARIABLE v_sync        : STD_LOGIC;
130
  BEGIN
131
    v_data_init := c_data_init;
132
    v_frame_len := c_frame_len_init;
133
    in_sosi <= c_dp_sosi_rst;
134
    proc_common_wait_until_low(clk, rst);
135
    proc_common_wait_some_cycles(clk, 5);
136
 
137
    -- Begin of stimuli
138
    FOR R IN 0 TO g_nof_repeat-1 LOOP
139
      v_sync := sel_a_b(R MOD c_sync_period = c_sync_offset, '1', '0');
140
      proc_dp_gen_block_data(c_rl, TRUE, c_data_w, c_data_w, v_data_init, 0, 0, v_frame_len, 0, 0, v_sync, TO_DP_BSN(R), clk, in_en, in_siso, in_sosi);
141
      --proc_common_wait_some_cycles(clk, 10);
142
      v_data_init := v_data_init + v_frame_len;
143
      v_frame_len := v_frame_len + 1;
144
    END LOOP;
145
 
146
    -- End of stimuli
147
    expected_out_data <= TO_UVEC(v_data_init-1, c_data_w);
148
 
149
    proc_common_wait_until_high(clk, verify_done);
150
    proc_common_wait_some_cycles(clk, 10);
151
    tb_end <= '1';
152
    WAIT;
153
  END PROCESS;
154
 
155
  -- proc_dp_gen_block_data() only supports RL=0 or 1, so use a latency adpater to support any g_in_latency
156
  u_input_adapt : ENTITY dp_components_lib.dp_latency_adapter
157
  GENERIC MAP (
158
    g_in_latency   => c_rl,
159
    g_out_latency  => g_in_latency
160
  )
161
  PORT MAP (
162
    rst          => rst,
163
    clk          => clk,
164
    -- ST sink
165
    snk_out      => in_siso,
166
    snk_in       => in_sosi,
167
    -- ST source
168
    src_in       => adapt_siso,
169
    src_out      => adapt_sosi
170
  );
171
 
172
 
173
  ------------------------------------------------------------------------------
174
  -- DATA VERIFICATION
175
  ------------------------------------------------------------------------------
176
 
177
 
178
  -- Verification logistics
179
  verify_en <= '1'          WHEN rising_edge(clk) AND out_sosi.sop='1';          -- enable verify after first output sop
180
  count_eop <= count_eop+1  WHEN rising_edge(clk) AND out_sosi.eop='1' AND((g_out_latency>0) OR
181
                                                                           (g_out_latency=0 AND out_siso.ready='1'));  -- count number of output eop
182
  verify_done <= '1'        WHEN rising_edge(clk) AND count_eop = g_nof_repeat;  -- signal verify done after g_nof_repeat frames
183
 
184
  -- Actual verification of the output streams
185
  proc_dp_verify_data("out_sosi.data", g_out_latency, clk, verify_en, out_siso.ready, out_sosi.valid, out_data, prev_out_data);  -- Verify that the output is incrementing data, like the input stimuli
186
  proc_dp_verify_valid(g_out_latency, clk, verify_en, out_siso.ready, prev_out_ready, out_sosi.valid);                           -- Verify that the output valid fits with the output ready latency
187
  proc_dp_verify_sop_and_eop(g_out_latency, clk, out_siso.ready, out_sosi.valid, out_sosi.sop, out_sosi.eop, hold_out_sop);      -- Verify that sop and eop come in pairs
188
  proc_dp_verify_value(e_equal, clk, verify_done, expected_out_data, prev_out_data);                                             -- Verify that the stimuli have been applied at all
189
  proc_dp_verify_sync(c_sync_period, c_sync_offset, clk, verify_en, out_sosi.sync, out_sosi.sop, out_sosi.bsn);
190
 
191
  -- Monitoring
192
  out_bsn  <= out_sosi.bsn(c_data_w-1 DOWNTO 0);
193
  out_data <= out_sosi.data(c_data_w-1 DOWNTO 0);
194
  out_sync <= out_sosi.sync;
195
  out_val  <= out_sosi.valid;
196
  out_sop  <= out_sosi.sop;
197
  out_eop  <= out_sosi.eop;
198
 
199
 
200
  ------------------------------------------------------------------------------
201
  -- DUT dp_pipeline_ready
202
  ------------------------------------------------------------------------------
203
 
204
  pipeline : ENTITY work.dp_pipeline_ready
205
  GENERIC MAP (
206
    g_in_latency   => g_in_latency,
207
    g_out_latency  => g_out_latency
208
  )
209
  PORT MAP (
210
    rst          => rst,
211
    clk          => clk,
212
    -- ST sink
213
    snk_out      => adapt_siso,
214
    snk_in       => adapt_sosi,
215
    -- ST source
216
    src_in       => out_siso,
217
    src_out      => out_sosi
218
  );
219
 
220
 
221
END tb;

powered by: WebSVN 2.1.0

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