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

Subversion Repositories dqpskmap

[/] [dqpskmap/] [trunk/] [test/] [d_encoder_d_decoder_tb.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 entactogen
 
2
-- Copyright (c) 2013 Antonio de la Piedra
3
 
4
-- This program is free software: you can redistribute it and/or modify
5
-- it under the terms of the GNU General Public License as published by
6
-- the Free Software Foundation, either version 3 of the License, or
7
-- (at your option) any later version.
8
 
9
-- This program is distributed in the hope that it will be useful,
10
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
11
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
-- GNU General Public License for more details.
13
 
14
-- You should have received a copy of the GNU General Public License
15
-- along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
 
17
LIBRARY ieee;
18
USE ieee.std_logic_1164.ALL;
19
USE ieee.std_logic_unsigned.all;
20
USE ieee.numeric_std.ALL;
21
 
22
ENTITY d_encoder_d_decoder_tb IS
23
END d_encoder_d_decoder_tb;
24
 
25
ARCHITECTURE behavior OF d_encoder_d_decoder_tb IS
26
 
27
    -- Component Declaration for the Unit Under Test (UUT)
28
 
29
    COMPONENT d_encoder_d_decoder
30
    PORT(
31
         tx_tetra_clk_36_KHz : IN  std_logic;
32
         tx_tetra_clk_18_KHz : IN  std_logic;
33
         tx_tetra_rst : IN  std_logic;
34
         tx_tetra_bit_stream_input : IN  std_logic;
35
         tx_tetra_valid_input : IN  std_logic;
36
         tx_tetra_debug_dbit_output : OUT  std_logic_vector(1 downto 0);
37
         tx_tetra_diffPhaseEncoder_output_0 : OUT  std_logic_vector(7 downto 0);
38
         tx_tetra_diffPhaseEncoder_output_1 : OUT  std_logic_vector(7 downto 0);
39
         rx_clk_18_KHz : IN  std_logic;
40
         rx_rst : IN  std_logic;
41
         rx_en : IN  std_logic;
42
         rx_a_k : OUT  std_logic_vector(7 downto 0);
43
         rx_b_k : OUT  std_logic_vector(7 downto 0);
44
         rx_i_k : IN  std_logic_vector(7 downto 0);
45
         rx_q_k : IN  std_logic_vector(7 downto 0)
46
        );
47
    END COMPONENT;
48
 
49
 
50
   --Inputs
51
   signal tx_tetra_clk_36_KHz : std_logic := '0';
52
   signal tx_tetra_clk_18_KHz : std_logic := '0';
53
   signal tx_tetra_rst : std_logic := '0';
54
   signal tx_tetra_bit_stream_input : std_logic := '0';
55
   signal tx_tetra_valid_input : std_logic := '0';
56
   signal rx_clk_18_KHz : std_logic := '0';
57
   signal rx_rst : std_logic := '0';
58
   signal rx_en : std_logic := '0';
59
   signal rx_i_k : std_logic_vector(7 downto 0) := (others => '0');
60
   signal rx_q_k : std_logic_vector(7 downto 0) := (others => '0');
61
 
62
        --Outputs
63
   signal tx_tetra_debug_dbit_output : std_logic_vector(1 downto 0);
64
   signal tx_tetra_diffPhaseEncoder_output_0 : std_logic_vector(7 downto 0);
65
   signal tx_tetra_diffPhaseEncoder_output_1 : std_logic_vector(7 downto 0);
66
   signal rx_a_k : std_logic_vector(7 downto 0);
67
   signal rx_b_k : std_logic_vector(7 downto 0);
68
 
69
        signal start_decoding : std_logic;
70
 
71
        constant tetra_clk_36_KHz_period : time := 27.778 us;
72
        constant tetra_clk_18_KHz_period : time := 55.556 us;
73
 
74
BEGIN
75
 
76
        -- Instantiate the Unit Under Test (UUT)
77
   uut: d_encoder_d_decoder PORT MAP (
78
          tx_tetra_clk_36_KHz => tx_tetra_clk_36_KHz,
79
          tx_tetra_clk_18_KHz => tx_tetra_clk_18_KHz,
80
          tx_tetra_rst => tx_tetra_rst,
81
          tx_tetra_bit_stream_input => tx_tetra_bit_stream_input,
82
          tx_tetra_valid_input => tx_tetra_valid_input,
83
          tx_tetra_debug_dbit_output => tx_tetra_debug_dbit_output,
84
          tx_tetra_diffPhaseEncoder_output_0 => tx_tetra_diffPhaseEncoder_output_0,
85
          tx_tetra_diffPhaseEncoder_output_1 => tx_tetra_diffPhaseEncoder_output_1,
86
          rx_clk_18_KHz => rx_clk_18_KHz,
87
          rx_rst => rx_rst,
88
          rx_en => rx_en,
89
          rx_a_k => rx_a_k,
90
          rx_b_k => rx_b_k,
91
          rx_i_k => rx_i_k,
92
          rx_q_k => rx_q_k
93
        );
94
 
95
 tetra_clk_36_KHz_process :process
96
   begin
97
                tx_tetra_clk_36_KHz <= '0';
98
                wait for tetra_clk_36_KHz_period/2;
99
                tx_tetra_clk_36_KHz <= '1';
100
                wait for tetra_clk_36_KHz_period/2;
101
   end process;
102
 
103
    tetra_clk_18_KHz_process :process
104
   begin
105
                tx_tetra_clk_18_KHz <= '0';
106
                rx_clk_18_KHz <= '0';
107
                wait for tetra_clk_18_KHz_period/2;
108
                tx_tetra_clk_18_KHz <= '1';
109
                rx_clk_18_KHz <= '1';
110
                wait for tetra_clk_18_KHz_period/2;
111
   end process;
112
 
113
         rx_i_k <= tx_tetra_diffPhaseEncoder_output_0 when start_decoding = '1' else (others=>'0');
114
         rx_q_k <= tx_tetra_diffPhaseEncoder_output_1 when start_decoding = '1' else (others=>'0');
115
         rx_en <= '1' when start_decoding = '1' else '0';
116
 
117
        decode_tx: process
118
        begin
119
                wait for 166.668 us;
120
                start_decoding <= '1';
121
                wait;
122
        end process;
123
 
124
 
125
   -- Stimulus process
126
   stim_proc: process
127
   begin
128
      tx_tetra_rst <= '1';
129
                rx_rst <= '1';
130
                wait for tetra_clk_18_KHz_period*2;
131
                tx_tetra_rst <= '0';
132
                rx_rst <= '0';
133
 
134
                tx_tetra_valid_input <= '1';
135
 
136
                tx_tetra_bit_stream_input <= '1';
137
                wait for tetra_clk_36_KHz_period;
138
 
139
                tx_tetra_bit_stream_input <= '0';
140
                wait for tetra_clk_36_KHz_period;
141
 
142
                tx_tetra_bit_stream_input <= '1';
143
                wait for tetra_clk_36_KHz_period;
144
 
145
                tx_tetra_bit_stream_input <= '1';
146
                wait for tetra_clk_36_KHz_period;
147
 
148
                tx_tetra_bit_stream_input <= '0';
149
                wait for tetra_clk_36_KHz_period;
150
 
151
                tx_tetra_bit_stream_input <= '0';
152
                wait for tetra_clk_36_KHz_period;
153
 
154
                tx_tetra_bit_stream_input <= '1';
155
                wait for tetra_clk_36_KHz_period;
156
 
157
                tx_tetra_bit_stream_input <= '1';
158
 
159
                wait for tetra_clk_36_KHz_period*50;
160
      wait;
161
 
162
 
163
      -- insert stimulus here 
164
 
165
      wait;
166
   end process;
167
 
168
END;

powered by: WebSVN 2.1.0

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