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

Subversion Repositories astron_sim_transceiver

[/] [astron_sim_transceiver/] [trunk/] [tb_sim_transceiver_serdes.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 danv
-------------------------------------------------------------------------------
2
--
3
-- Copyright 2020
4
-- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
5
-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
6
-- 
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
--
19
-------------------------------------------------------------------------------
20
 
21
-- Purpose:
22
--   Model a basic serializer->deserializer link and verify received data
23
-- Description:
24
--   Data generator -> Serializer -> Deserializer -> Data verification
25
-- Usage:
26
--   as 10
27
--   run -all
28
--   Observe:
29
--   . user tx_in_data on serializer == user rx_out_data on deserializer
30
--   . serial_line carries 4 bytes per serialized word. Each
31
--     byte is followed by its 2 valid bits and is sent LSb first.
32
 
33
LIBRARY IEEE, common_pkg_lib;
34
USE IEEE.STD_LOGIC_1164.ALL;
35
USE IEEE.numeric_std.ALL;
36
USE common_pkg_lib.common_pkg.ALL;
37
USE common_pkg_lib.tb_common_pkg.ALL;
38
 
39
ENTITY tb_sim_transceiver_serdes IS
40
END ENTITY tb_sim_transceiver_serdes;
41
 
42
ARCHITECTURE tb of tb_sim_transceiver_serdes IS
43
 
44
  CONSTANT c_data_w         : NATURAL := 32;
45
  CONSTANT c_tr_clk_period  : TIME := 6.4 ns;  -- 156.25 MHz
46
 
47
  SIGNAL tb_end           : STD_LOGIC := '0';
48
 
49
  SIGNAL tr_clk           : STD_LOGIC := '0';
50
  SIGNAL tr_rst           : STD_LOGIC := '1';
51
 
52
  SIGNAL tx_enable        : STD_LOGIC := '1';
53
  SIGNAL tx_ready         : STD_LOGIC;
54
 
55
  SIGNAL tx_in_data       : STD_LOGIC_VECTOR(c_data_w-1 DOWNTO 0);
56
  SIGNAL tx_in_val        : STD_LOGIC;
57
  SIGNAL tx_in_ctrl       : STD_LOGIC_VECTOR(c_data_w/c_byte_w-1 DOWNTO 0);
58
 
59
  SIGNAL serial_line      : STD_LOGIC;
60
 
61
  SIGNAL rx_out_data      : STD_LOGIC_VECTOR(c_data_w-1 DOWNTO 0);
62
  SIGNAL rx_out_val       : STD_LOGIC;
63
  SIGNAL rx_out_ctrl      : STD_LOGIC_VECTOR(c_data_w/c_byte_w-1 DOWNTO 0);
64
 
65
  SIGNAL prev_rx_out_data : STD_LOGIC_VECTOR(c_data_w-1 DOWNTO 0);
66
  SIGNAL verify_en        : STD_LOGIC := '0';
67
  SIGNAL rd_ready         : STD_LOGIC := '1';
68
 
69
BEGIN
70
 
71
  p_tb_end : PROCESS
72
  BEGIN
73
    WAIT FOR c_tr_clk_period*300;
74
 
75
    -- Stop the simulation
76
    tb_end <= '1';
77
    ASSERT FALSE REPORT "Simulation finished." SEVERITY NOTE;
78
    WAIT;
79
  END PROCESS;
80
 
81
  tr_clk  <= NOT tr_clk OR tb_end AFTER c_tr_clk_period/2;
82
  tr_rst  <= '0' AFTER c_tr_clk_period*10;
83
 
84
  p_tx_ready: PROCESS
85
  BEGIN
86
    tx_ready <= '0';
87
    WAIT UNTIL tr_rst = '0';
88
    WHILE tb_end='0' LOOP
89
      tx_ready <= '1';
90
      WAIT FOR c_tr_clk_period*50;
91
      tx_ready <= '0';
92
      WAIT FOR c_tr_clk_period*50;
93
    END LOOP;
94
  END PROCESS;
95
 
96
  -- Generate Tx data output with c_rl = 1 and counter data starting at 0
97
  proc_common_gen_data(1, 0, tr_rst, tr_clk, tx_enable, tx_ready, tx_in_data, tx_in_val);
98
 
99
  tx_in_ctrl <= (OTHERS=>tx_in_val);
100
 
101
  u_ser: ENTITY work.sim_transceiver_serializer
102
  GENERIC MAP (
103
    g_data_w        => c_data_w,
104
    g_tr_clk_period => c_tr_clk_period
105
  )
106
  PORT MAP (
107
    tb_end             => tb_end,
108
    tr_clk             => tr_clk,
109
    tr_rst             => tr_rst,
110
 
111
    tx_in_data         => tx_in_data,
112
    tx_in_ctrl         => tx_in_ctrl,
113
 
114
    tx_serial_out      => serial_line
115
  );
116
 
117
  u_des: ENTITY work.sim_transceiver_deserializer
118
  GENERIC MAP (
119
    g_data_w        => c_data_w,
120
    g_tr_clk_period => c_tr_clk_period
121
  )
122
  PORT MAP (
123
    tb_end             => tb_end,
124
    tr_clk             => tr_clk,
125
    tr_rst             => tr_rst,
126
 
127
    rx_out_data        => rx_out_data,
128
    rx_out_ctrl        => rx_out_ctrl,
129
 
130
    rx_serial_in       => serial_line
131
  );
132
 
133
  p_verify_en: PROCESS
134
  BEGIN
135
    verify_en <= '0';
136
    WAIT UNTIL tr_rst = '0';
137
    WAIT FOR c_tr_clk_period*5;
138
    verify_en <= '1';
139
    WAIT;
140
  END PROCESS;
141
 
142
  rx_out_val <= andv(rx_out_ctrl);
143
 
144
  -- Verify dut output incrementing data
145
  proc_common_verify_data(1, tr_clk, verify_en, rd_ready, rx_out_val, rx_out_data, prev_rx_out_data);
146
 
147
END tb;

powered by: WebSVN 2.1.0

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