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

Subversion Repositories dp_pkg

[/] [dp_pkg/] [trunk/] [dp_stream_verify.vhd] - Blame information for rev 2

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 danv
-------------------------------------------------------------------------------
2
--
3
-- Copyright (C) 2015
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
-- Purpose:
23
-- . The dp_stream_verify verifies the stream of packets with counter data that
24
--   are generated by dp_stimuli_st.
25
-- Description:
26
--   The component can verify a stream:
27
--   . The sosi control fields are verified conform the bus specifications
28
--     eg. considering the RL, no missing eop, etc.
29
--   . The sosi data fields are verified based on their previous value under
30
--     the assumption that they contain incrementing data. Whether a field
31
--     is checked depends on verify_snk_in_enable.
32
--  
33
--   The component also checks whether the stream is active at all. A
34
--   pulse in verify_expected_snk_in_evt triggers the verification of the
35
--   corresponding field in snk_in using the expected_snk_in as reference.
36
--
37
-- Usage:
38
-- . See tb_dp_example_no_dut for usage example
39
--
40
 
41
LIBRARY IEEE, common_pkg_lib;
42
USE IEEE.std_logic_1164.ALL;
43
USE IEEE.numeric_std.ALL;
44
USE common_pkg_lib.common_pkg.ALL;
45
USE common_pkg_lib.common_lfsr_sequences_pkg.ALL;
46
USE common_pkg_lib.tb_common_pkg.ALL;
47
USE work.dp_stream_pkg.ALL;
48
USE work.tb_dp_pkg.ALL;
49
 
50
 
51
ENTITY dp_stream_verify IS
52
  GENERIC (
53
    g_instance_nr         : NATURAL := 0;
54
    -- flow control
55
    g_random_w            : NATURAL := 14;                       -- use different random width for stimuli and for verify to have different random sequences
56
    g_pulse_active        : NATURAL := 1;
57
    g_pulse_period        : NATURAL := 2;
58
    g_flow_control        : t_dp_flow_control_enum := e_active;  -- always active, random or pulse flow control
59
    -- initializations
60
    g_sync_period         : NATURAL := 10;
61
    g_sync_offset         : NATURAL := 7;
62
    g_snk_in_cnt_max      : t_dp_sosi_unsigned := c_dp_sosi_unsigned_rst;  -- default 0 is no wrap
63
    g_snk_in_cnt_gap      : t_dp_sosi_unsigned := c_dp_sosi_unsigned_ones; -- default only accept increment +1
64
    -- specific
65
    g_in_dat_w            : NATURAL := 32;
66
    g_pkt_len             : NATURAL := 16
67
  );
68
  PORT (
69
    rst                        : IN  STD_LOGIC;
70
    clk                        : IN  STD_LOGIC;
71
 
72
    -- Verify data
73
    snk_out                    : OUT t_dp_siso;
74
    snk_in                     : IN  t_dp_sosi;
75
 
76
    -- During stimuli
77
    verify_snk_in_enable       : IN  t_dp_sosi_sl;  -- enable to verify that the snk_in fields are incrementing 
78
 
79
    -- End of stimuli
80
    expected_snk_in            : IN  t_dp_sosi;          -- expected snk_in at verify_expected_snk_in_evt
81
    verify_expected_snk_in_evt : IN  t_dp_sosi_sl   -- trigger to verify the expected_snk_in 
82
  );
83
END dp_stream_verify;
84
 
85
 
86
ARCHITECTURE tb OF dp_stream_verify IS
87
 
88
  CONSTANT c_rl                       : NATURAL := 1;
89
  CONSTANT c_no_dut                   : BOOLEAN:= TRUE;
90
 
91
  SIGNAL random                     : STD_LOGIC_VECTOR(g_random_w-1 DOWNTO 0) := TO_UVEC(g_instance_nr, g_random_w);  -- use different initialization to have different random sequences per stream
92
  SIGNAL pulse                      : STD_LOGIC;
93
  SIGNAL pulse_en                   : STD_LOGIC := '1';
94
 
95
  SIGNAL i_snk_out                  : t_dp_siso := c_dp_siso_rdy;
96
  SIGNAL prev_snk_out               : t_dp_siso;
97
  SIGNAL hold_snk_in_data           : STD_LOGIC_VECTOR(c_dp_stream_data_w-1 DOWNTO 0);  -- used to hold valid data for verify at verify_expected_snk_in_evt
98
  SIGNAL snk_in_data                : STD_LOGIC_VECTOR(g_in_dat_w-1 DOWNTO 0);
99
  SIGNAL prev_snk_in                : t_dp_sosi;
100
 
101
  SIGNAL hold_snk_in_sop            : STD_LOGIC := '0';
102
  SIGNAL detected_snk_in_ctrl       : t_dp_sosi_sl := c_dp_sosi_sl_rst;
103
  SIGNAL verify_snk_in_increment    : t_dp_sosi_sl := c_dp_sosi_sl_rst;
104
  SIGNAL verify_snk_in_ctrl         : t_dp_sosi_sl := c_dp_sosi_sl_rst;
105
 
106
  SIGNAL exp_size                   : NATURAL;
107
  SIGNAL cnt_size                   : NATURAL;
108
 
109
BEGIN
110
 
111
  snk_out <= i_snk_out;
112
 
113
  ------------------------------------------------------------------------------
114
  -- STREAM CONTROL
115
  ------------------------------------------------------------------------------
116
 
117
  random <= func_common_random(random) WHEN rising_edge(clk);
118
 
119
  proc_common_gen_duty_pulse(g_pulse_active, g_pulse_period, '1', rst, clk, pulse_en, pulse);
120
 
121
  i_snk_out.ready <= '1'                 WHEN g_flow_control=e_active  ELSE
122
                     random(random'HIGH) WHEN g_flow_control=e_random  ELSE
123
                     pulse               WHEN g_flow_control=e_pulse;
124
 
125
  ------------------------------------------------------------------------------
126
  -- DATA VERIFICATION
127
  ------------------------------------------------------------------------------  
128
 
129
  -- Detect first sync, sop, eop, valid
130
  detected_snk_in_ctrl.sync  <= '1' WHEN snk_in.sync='1'  AND rising_edge(clk);
131
  detected_snk_in_ctrl.valid <= '1' WHEN snk_in.valid='1' AND rising_edge(clk);
132
  detected_snk_in_ctrl.sop   <= '1' WHEN snk_in.sop='1'   AND rising_edge(clk);
133
  detected_snk_in_ctrl.eop   <= '1' WHEN snk_in.eop='1'   AND rising_edge(clk);
134
 
135
  -- Verify that the stimuli have been applied at all so at least one active sosi sync, sop, eop, valid field has been detected
136
  proc_dp_verify_value("snk_in.sync",             clk, verify_expected_snk_in_evt.sync,    expected_snk_in.sync,    detected_snk_in_ctrl.sync);
137
  proc_dp_verify_value("snk_in.sop",              clk, verify_expected_snk_in_evt.sop,     expected_snk_in.sop,     detected_snk_in_ctrl.sop);
138
  proc_dp_verify_value("snk_in.eop",              clk, verify_expected_snk_in_evt.eop,     expected_snk_in.eop,     detected_snk_in_ctrl.eop);
139
  proc_dp_verify_value("snk_in.valid",            clk, verify_expected_snk_in_evt.valid,   expected_snk_in.valid,   detected_snk_in_ctrl.valid);
140
 
141
  -- Verify that the last sosi data, bsn, channel and err fields are correct
142
  proc_dp_verify_value("snk_in.data",    e_equal, clk, verify_expected_snk_in_evt.data,    expected_snk_in.data,    hold_snk_in_data);
143
  proc_dp_verify_value("snk_in.bsn",     e_equal, clk, verify_expected_snk_in_evt.bsn,     expected_snk_in.bsn,     snk_in.bsn);
144
  proc_dp_verify_value("snk_in.channel", e_equal, clk, verify_expected_snk_in_evt.channel, expected_snk_in.channel, snk_in.channel);
145
  proc_dp_verify_value("snk_in.err",     e_equal, clk, verify_expected_snk_in_evt.err,     expected_snk_in.err,     snk_in.err);
146
 
147
  -- Verify that the output is incrementing data, like the input stimuli
148
  p_verify_snk_in_increment : PROCESS(verify_snk_in_enable, detected_snk_in_ctrl)
149
  BEGIN
150
    verify_snk_in_increment         <= verify_snk_in_enable;
151
    verify_snk_in_increment.data    <= verify_snk_in_enable.data    AND detected_snk_in_ctrl.valid;
152
    verify_snk_in_increment.re      <= verify_snk_in_enable.re      AND detected_snk_in_ctrl.valid;
153
    verify_snk_in_increment.im      <= verify_snk_in_enable.im      AND detected_snk_in_ctrl.valid;
154
    verify_snk_in_increment.bsn     <= verify_snk_in_enable.bsn     AND detected_snk_in_ctrl.sop;
155
    verify_snk_in_increment.channel <= verify_snk_in_enable.channel AND detected_snk_in_ctrl.sop;
156
    verify_snk_in_increment.empty   <= verify_snk_in_enable.empty   AND detected_snk_in_ctrl.eop;
157
    verify_snk_in_increment.err     <= verify_snk_in_enable.err     AND detected_snk_in_ctrl.eop;
158
  END PROCESS;
159
 
160
  proc_dp_verify_data("snk_in.data",    c_rl, g_snk_in_cnt_max.data,    g_snk_in_cnt_gap.data,    clk, verify_snk_in_increment.data,    i_snk_out.ready, snk_in.valid, snk_in.data,    prev_snk_in.data);
161
  proc_dp_verify_data("snk_in.re",      c_rl, g_snk_in_cnt_max.re,      g_snk_in_cnt_gap.re,      clk, verify_snk_in_increment.re,      i_snk_out.ready, snk_in.valid, snk_in.re,      prev_snk_in.re);
162
  proc_dp_verify_data("snk_in.im",      c_rl, g_snk_in_cnt_max.im,      g_snk_in_cnt_gap.im,      clk, verify_snk_in_increment.im,      i_snk_out.ready, snk_in.valid, snk_in.im,      prev_snk_in.im);
163
  proc_dp_verify_data("snk_in.bsn",     c_rl, g_snk_in_cnt_max.bsn,     g_snk_in_cnt_gap.bsn,     clk, verify_snk_in_increment.bsn,     i_snk_out.ready, snk_in.sop,   snk_in.bsn,     prev_snk_in.bsn);
164
  proc_dp_verify_data("snk_in.channel", c_rl, g_snk_in_cnt_max.channel, g_snk_in_cnt_gap.channel, clk, verify_snk_in_increment.channel, i_snk_out.ready, snk_in.sop,   snk_in.channel, prev_snk_in.channel);
165
  proc_dp_verify_data("snk_in.empty",   c_rl, g_snk_in_cnt_max.empty,   g_snk_in_cnt_gap.empty,   clk, verify_snk_in_increment.empty,   i_snk_out.ready, snk_in.eop,   snk_in.empty,   prev_snk_in.empty);
166
  proc_dp_verify_data("snk_in.err",     c_rl, g_snk_in_cnt_max.err,     g_snk_in_cnt_gap.err,     clk, verify_snk_in_increment.err,     i_snk_out.ready, snk_in.eop,   snk_in.err,     prev_snk_in.err);
167
 
168
  -- Verify that the snk_in control fields are correct
169
  p_verify_snk_in_ctrl: PROCESS(snk_in, verify_snk_in_enable)
170
  BEGIN
171
    verify_snk_in_ctrl.sync  <= snk_in.sync  AND verify_snk_in_enable.valid AND verify_snk_in_enable.sync;
172
    verify_snk_in_ctrl.sop   <= snk_in.sop   AND verify_snk_in_enable.valid AND verify_snk_in_enable.sop AND verify_snk_in_enable.eop;
173
    verify_snk_in_ctrl.eop   <= snk_in.eop   AND verify_snk_in_enable.valid AND verify_snk_in_enable.sop AND verify_snk_in_enable.eop;
174
    verify_snk_in_ctrl.valid <= snk_in.valid AND verify_snk_in_enable.valid;
175
  END PROCESS;
176
 
177
  -- Verify that the output sync occurs when expected
178
  proc_dp_verify_sync(g_sync_period, g_sync_offset, clk, detected_snk_in_ctrl.sop, verify_snk_in_ctrl.sync, verify_snk_in_ctrl.sop, snk_in.bsn);
179
 
180
  -- Verify output packet ctrl
181
  proc_dp_verify_sop_and_eop(clk, verify_snk_in_ctrl.valid, verify_snk_in_ctrl.sop, verify_snk_in_ctrl.eop, hold_snk_in_sop);
182
 
183
  -- Verify output packet block size
184
  exp_size <= g_pkt_len;
185
 
186
  proc_dp_verify_block_size(exp_size, clk, verify_snk_in_ctrl.valid, verify_snk_in_ctrl.sop, verify_snk_in_ctrl.eop, cnt_size);
187
 
188
  -- Verify output ready latency
189
  proc_dp_verify_valid(clk, detected_snk_in_ctrl.valid, i_snk_out.ready, prev_snk_out.ready, verify_snk_in_ctrl.valid);
190
 
191
  ------------------------------------------------------------------------------
192
  -- Auxiliary
193
  ------------------------------------------------------------------------------
194
 
195
  -- Map to slv to ease monitoring in wave window
196
  snk_in_data  <= snk_in.data(g_in_dat_w-1 DOWNTO 0);
197
 
198
  hold_snk_in_data <= snk_in.data WHEN snk_in.valid='1';
199
 
200
END tb;

powered by: WebSVN 2.1.0

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