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

Subversion Repositories astron_pipeline

[/] [astron_pipeline/] [trunk/] [tb_dp_pipeline.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) 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, dp_pkg_lib;
24
USE IEEE.std_logic_1164.ALL;
25
USE IEEE.numeric_std.ALL;
26
USE common_pkg_lib.common_pkg.ALL;
27
USE dp_pkg_lib.dp_stream_pkg.ALL;
28
USE dp_pkg_lib.tb_dp_pkg.ALL;
29
 
30
ENTITY tb_dp_pipeline IS
31
  GENERIC (
32
    g_pipeline : NATURAL := 5
33
  );
34
END tb_dp_pipeline;
35
 
36
 
37
ARCHITECTURE tb OF tb_dp_pipeline IS
38
 
39
  -- See tb_dp_pkg.vhd for explanation and run time
40
 
41
  -- DUT ready latency
42
  CONSTANT c_dut_latency    : NATURAL := 1;              -- fixed 1 for dp_pipeline
43
  CONSTANT c_tx_latency     : NATURAL := c_dut_latency;  -- TX ready latency of TB
44
  CONSTANT c_tx_void        : NATURAL := sel_a_b(c_tx_latency, 1, 0);  -- used to avoid empty range VHDL warnings when c_tx_latency=0
45
  CONSTANT c_tx_offset_sop  : NATURAL := 3;
46
  CONSTANT c_tx_period_sop  : NATURAL := 7;              -- sop in data valid cycle 3,  10,  17, ...
47
  CONSTANT c_tx_offset_eop  : NATURAL := 5;              -- eop in data valid cycle   5,  12,  19, ...
48
  CONSTANT c_tx_period_eop  : NATURAL := c_tx_period_sop;
49
  CONSTANT c_tx_offset_sync : NATURAL := 3;              -- sync in data valid cycle 3, 20, 37, ...
50
  CONSTANT c_tx_period_sync : NATURAL := 17;
51
  CONSTANT c_rx_latency     : NATURAL := c_dut_latency;  -- RX ready latency from DUT
52
  CONSTANT c_verify_en_wait : NATURAL := 4+g_pipeline;   -- wait some cycles before asserting verify enable
53
 
54
  CONSTANT c_random_w       : NATURAL := 19;
55
 
56
  SIGNAL tb_end         : STD_LOGIC := '0';
57
  SIGNAL clk            : STD_LOGIC := '0';
58
  SIGNAL rst            : STD_LOGIC;
59
  SIGNAL sync           : STD_LOGIC;
60
  SIGNAL lfsr1          : STD_LOGIC_VECTOR(c_random_w-1 DOWNTO 0) := (OTHERS=>'0');
61
  SIGNAL lfsr2          : STD_LOGIC_VECTOR(c_random_w   DOWNTO 0) := (OTHERS=>'0');
62
 
63
  SIGNAL cnt_dat        : STD_LOGIC_VECTOR(c_dp_data_w-1 DOWNTO 0);
64
  SIGNAL cnt_val        : STD_LOGIC;
65
  SIGNAL cnt_en         : STD_LOGIC;
66
 
67
  SIGNAL tx_data        : t_dp_data_arr(0 TO c_tx_latency + c_tx_void)    := (OTHERS=>(OTHERS=>'0'));
68
  SIGNAL tx_val         : STD_LOGIC_VECTOR(0 TO c_tx_latency + c_tx_void) := (OTHERS=>'0');
69
 
70
  SIGNAL in_ready       : STD_LOGIC;
71
  SIGNAL in_data        : STD_LOGIC_VECTOR(c_dp_data_w-1 DOWNTO 0) := (OTHERS=>'0');
72
  SIGNAL in_sync        : STD_LOGIC;
73
  SIGNAL in_val         : STD_LOGIC;
74
  SIGNAL in_sop         : STD_LOGIC;
75
  SIGNAL in_eop         : STD_LOGIC;
76
 
77
  SIGNAL in_siso        : t_dp_siso;
78
  SIGNAL in_sosi        : t_dp_sosi := c_dp_sosi_rst;
79
  SIGNAL out_siso       : t_dp_siso;
80
  SIGNAL out_sosi       : t_dp_sosi;
81
 
82
  SIGNAL out_ready      : STD_LOGIC;
83
  SIGNAL prev_out_ready : STD_LOGIC_VECTOR(0 TO c_rx_latency);
84
  SIGNAL out_data       : STD_LOGIC_VECTOR(c_dp_data_w-1 DOWNTO 0);
85
  SIGNAL out_sync       : STD_LOGIC;
86
  SIGNAL out_val        : STD_LOGIC;
87
  SIGNAL out_sop        : STD_LOGIC;
88
  SIGNAL out_eop        : STD_LOGIC;
89
  SIGNAL hold_out_sop   : STD_LOGIC;
90
  SIGNAL prev_out_data  : STD_LOGIC_VECTOR(out_data'RANGE);
91
 
92
  SIGNAL state          : t_dp_state_enum;
93
 
94
  SIGNAL verify_en      : STD_LOGIC;
95
  SIGNAL verify_done    : STD_LOGIC;
96
 
97
  SIGNAL exp_data       : STD_LOGIC_VECTOR(c_dp_data_w-1 DOWNTO 0) := TO_UVEC(sel_a_b(g_pipeline=0, 18953, 18952), c_dp_data_w);
98
 
99
BEGIN
100
 
101
  clk <= NOT clk OR tb_end AFTER clk_period/2;
102
  rst <= '1', '0' AFTER clk_period*7;
103
 
104
  -- Sync interval
105
  proc_dp_sync_interval(clk, sync);
106
 
107
  -- Input data
108
  cnt_val <= in_ready AND cnt_en;
109
 
110
  proc_dp_cnt_dat(rst, clk, cnt_val, cnt_dat);
111
  proc_dp_tx_data(c_tx_latency, rst, clk, cnt_val, cnt_dat, tx_data, tx_val, in_data, in_val);
112
  proc_dp_tx_ctrl(c_tx_offset_sync, c_tx_period_sync, in_data, in_val, in_sync);
113
  proc_dp_tx_ctrl(c_tx_offset_sop, c_tx_period_sop, in_data, in_val, in_sop);
114
  proc_dp_tx_ctrl(c_tx_offset_eop, c_tx_period_eop, in_data, in_val, in_eop);
115
 
116
  -- Stimuli control
117
  proc_dp_count_en(rst, clk, sync, lfsr1, state, verify_done, tb_end, cnt_en);
118
  proc_dp_out_ready(rst, clk, sync, lfsr2, out_ready);
119
 
120
  -- Output verify
121
  proc_dp_verify_en(c_verify_en_wait, rst, clk, sync, verify_en);
122
  proc_dp_verify_data("out_sosi.data", c_rx_latency, clk, verify_en, out_ready, out_val, out_data, prev_out_data);
123
  proc_dp_verify_valid(c_rx_latency, clk, verify_en, out_ready, prev_out_ready, out_val);
124
  proc_dp_verify_sop_and_eop(c_rx_latency, FALSE, clk, out_val, out_val, out_sop, out_eop, hold_out_sop);  -- Verify that sop and eop come in pairs, no check on valid between eop and sop
125
  proc_dp_verify_ctrl(c_tx_offset_sync, c_tx_period_sync, "sync", clk, verify_en, out_data, out_val, out_sync);
126
  proc_dp_verify_ctrl(c_tx_offset_sop, c_tx_period_sop, "sop", clk, verify_en, out_data, out_val, out_sop);
127
  proc_dp_verify_ctrl(c_tx_offset_eop, c_tx_period_eop, "eop", clk, verify_en, out_data, out_val, out_eop);
128
 
129
  -- Check that the test has ran at all
130
  proc_dp_verify_value(e_equal, clk, verify_done, exp_data, out_data);
131
 
132
  ------------------------------------------------------------------------------
133
  -- DUT dp_pipeline
134
  ------------------------------------------------------------------------------
135
 
136
  -- map sl, slv to record
137
  in_ready <= in_siso.ready;                        -- SISO
138
  in_sosi.data(c_dp_data_w-1 DOWNTO 0) <= in_data;  -- SOSI
139
  in_sosi.sync                         <= in_sync;
140
  in_sosi.valid                        <= in_val;
141
  in_sosi.sop                          <= in_sop;
142
  in_sosi.eop                          <= in_eop;
143
 
144
  out_siso.ready <= out_ready;                        -- SISO
145
  out_data <= out_sosi.data(c_dp_data_w-1 DOWNTO 0);  -- SOSI
146
  out_sync <= out_sosi.sync;
147
  out_val  <= out_sosi.valid;
148
  out_sop  <= out_sosi.sop;
149
  out_eop  <= out_sosi.eop;
150
 
151
  dut : ENTITY work.dp_pipeline
152
  GENERIC MAP (
153
    g_pipeline => g_pipeline
154
  )
155
  PORT MAP (
156
    rst         => rst,
157
    clk         => clk,
158
    snk_out     => in_siso,     -- OUT = request to upstream ST source
159
    snk_in      => in_sosi,
160
    src_in      => out_siso,    -- IN  = request from downstream ST sink
161
    src_out     => out_sosi
162
  );
163
 
164
END tb;

powered by: WebSVN 2.1.0

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