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

powered by: WebSVN 2.1.0

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