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

Subversion Repositories aes3rx

[/] [aes3rx/] [trunk/] [testbench/] [vhdl/] [rx-test.vhd] - Blame information for rev 10

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 10 nohous
 
2
--------------------------------------------------------------------------------
3
-- Company: 
4
-- Engineer:
5
--
6
-- Create Date:   12:17:15 10/10/2008
7
-- Design Name:   receiver
8
-- Module Name:   C:/Xilinx92i/projects/citac/tb_rx.vhd
9
-- Project Name:  citac
10
-- Target Device:  
11
-- Tool versions:  
12
-- Description:   
13
-- 
14
-- VHDL Test Bench Created by ISE for module: receiver
15
--
16
-- Dependencies:
17
-- 
18
-- Revision:
19
-- Revision 0.01 - File Created
20
-- Additional Comments:
21
--
22
-- Notes: 
23
-- This testbench has been automatically generated using types std_logic and
24
-- std_logic_vector for the ports of the unit under test.  Xilinx recommends 
25
-- that these types always be used for the top-level I/O of a design in order 
26
-- to guarantee that the testbench will bind correctly to the post-implementation 
27
-- simulation model.
28
--------------------------------------------------------------------------------
29
LIBRARY ieee;
30
USE ieee.std_logic_1164.ALL;
31
USE ieee.std_logic_unsigned.all;
32
USE ieee.std_logic_arith.all;
33
USE ieee.numeric_std.ALL;
34
use ieee.math_real.all; -- for UNIFORM, TRUNC
35
 
36
ENTITY tb_rx_vhd IS
37
END tb_rx_vhd;
38
 
39
ARCHITECTURE behavior OF tb_rx_vhd IS
40
 
41
        -- Component Declaration for the Unit Under Test (UUT)
42
        COMPONENT aes3rx
43
        generic (
44
                reg_width : integer := 5
45
        );
46
   port (
47
      clk   : in  std_logic; -- master clock
48
      aes3  : in  std_logic; -- input 
49
      reset : in  std_logic; -- synchronous reset
50
 
51
      sdata : out std_logic; -- output serial data
52
      sclk  : out std_logic; -- output serial data clock
53
      bsync : out std_logic; -- block start (high when Z subframe is being transmitted)
54
      lrck  : out std_logic; -- frame sync (high for channel A, low for B)
55
      active: out std_logic  -- receiver has valid data on its outputs
56
   );
57
        end component;
58
 
59
        --Inputs
60
        SIGNAL CLK_50MHZ :  std_logic := '0';
61
        SIGNAL RX :  std_logic := '0';
62
   signal TX : std_logic := '0';
63
 
64
        --Outputs
65
--      SIGNAL active : std_logic;
66
--      SIGNAL sdata :  std_logic;
67
--      SIGNAL sclk :  std_logic;
68
--      SIGNAL fsync :  std_logic;
69
--      signal bsync : std_logic;
70
 
71
   constant PERIOD : time := 20ns;
72
   constant DUTY_CYCLE : real := 0.5;
73
   constant OFFSET : time := 100 ns;
74
        type INT_ARRAY is array (integer range <>) of integer;
75
        shared variable vals : INT_ARRAY(0 to 191);
76
 
77
        shared variable S : time :=150 ns;
78
        shared variable M : time :=310 ns;
79
        shared variable L : time :=485 ns;
80
 
81
        procedure vector2aes(vector : in std_logic_vector (23 downto 0); signal aes : inout  std_logic) is
82
        begin
83
                for i in 0 to 23 loop
84
                        if vector(i) = '0' then
85
                                aes <= not aes;
86
                                wait for M;
87
                        elsif vector(i) = '1' then
88
                                aes <= not aes;
89
                                wait for S;
90
                                aes <= not aes;
91
                                wait for S;
92
                        end if;
93
                end loop;
94
        end procedure;
95
 
96
        procedure generate_block(pcm_data : in INT_ARRAY(0 to 191); signal aes : inout  std_logic; signal curr_val : out std_logic_vector(23 downto 0)) is
97
        begin
98
                -- Z preamble
99
                aes <= not aes;
100
                wait for L;
101
                aes <= not aes;
102
                wait for S;
103
                aes <= not aes;
104
                wait for S;
105
                aes <= not aes;
106
                wait for L;
107
 
108
                vector2aes(conv_std_logic_vector(pcm_data(0), 24), aes);
109
                curr_val <= conv_std_logic_vector(pcm_data(0), 24);
110
 
111
                aes <= not aes; -- 1.5
112
                wait for M;
113
                aes <= not aes; -- 1.5
114
                wait for M;
115
                aes <= not aes; -- 1.5
116
                wait for M;
117
                aes <= not aes; -- 1.5
118
                wait for M;
119
 
120
 
121
                for i in 1 to 191 loop
122
                        if i mod 2 /= 0 then --B subframe
123
                                --Y preamble
124
                                aes <= not aes; -- 1.5                          
125
                                wait for L;
126
                                aes <= not aes; -- 1.5
127
                                wait for M;
128
                                aes <= not aes; -- 3
129
                                wait for S;
130
                                aes <= not aes; -- 3.5
131
                                wait for M;
132
 
133
                        else --A subframe
134
                                --X preamble
135
                                aes <= not aes; -- 1.5                          
136
                                wait for L;
137
                                aes <= not aes;
138
                                wait for L;
139
                                aes <= not aes;
140
                                wait for S;
141
                                aes <= not aes;
142
                                wait for S;
143
 
144
                        end if;
145
                        curr_val <= conv_std_logic_vector(pcm_data(i), 24);
146
 
147
                        vector2aes(conv_std_logic_vector(pcm_data(i), 24), aes);
148
 
149
                        aes <= not aes; -- 1.5
150
                        wait for M;
151
                        aes <= not aes; -- 1.5
152
                        wait for M;
153
                        aes <= not aes; -- 1.5
154
                        wait for M;
155
                        aes <= not aes; -- 1.5
156
                        wait for M;
157
 
158
                end loop;
159
 
160
        end procedure;
161
 
162
        shared variable seed1 : positive;
163
        shared variable seed2 : positive;
164
        shared variable rand : real;
165
        signal curr_val : std_logic_vector(23 downto 0);
166
 
167
BEGIN
168
 
169
        -- Instantiate the Unit Under Test (UUT)
170
        uut: aes3rx PORT MAP(
171
                clk  => CLK_50MHZ,
172
                aes3 => RX,
173
                reset => '0'
174
                --bsync => bsync
175
                --bsync => bsync
176
        );
177
 
178
        PROCESS    -- clock process for CLK_50MHZ
179
        BEGIN
180
                WAIT for OFFSET;
181
                CLOCK_LOOP : LOOP
182
                         CLK_50MHZ <= '0';
183
                         WAIT FOR (PERIOD - (PERIOD * DUTY_CYCLE));
184
                         CLK_50MHZ <= '1';
185
                         WAIT FOR (PERIOD * DUTY_CYCLE);
186
                END LOOP CLOCK_LOOP;
187
        END PROCESS;
188
 
189
        tb : PROCESS
190
        BEGIN
191
 
192
                wait for 100 ns;
193
 
194
                for i in 0 to 191 loop
195
                        if i = 0 then
196
                                vals(i) := 8388609;
197
                        else
198
                                vals(i) := 8388609;
199
                        end if;
200
                end loop;
201
 
202
                generate_block(vals, RX, curr_val);
203
 
204
                for i in 0 to 191 loop
205
                        if i = 0 then
206
                                vals(i) := 0;
207
                        else
208
                                vals(i) := vals(i-1) + 10000;
209
                        end if;
210
                end loop;
211
 
212
                generate_block(vals, RX, curr_val);
213
 
214
 
215
                -- Wait 100 ns for global reset to finish
216
                wait for 100 us;
217
 
218
      S := 81.2 ns;
219
      M := 162.6 ns;
220
      L := 244 ns;
221
 
222
      wait for 100 ns;
223
 
224
                for i in 0 to 191 loop
225
                        if i = 0 then
226
                                vals(i) := 0;
227
                        else
228
                                vals(i) := 1;
229
                        end if;
230
                end loop;
231
 
232
                generate_block(vals, RX, curr_val);
233
 
234
                for i in 0 to 191 loop
235
                        if i = 0 then
236
                                vals(i) := 0;
237
                        else
238
                                vals(i) := vals(i-1) + 10000;
239
                        end if;
240
                end loop;
241
 
242
                wait; -- will wait forever
243
        END PROCESS;
244
 
245
END;

powered by: WebSVN 2.1.0

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