Debian Codegraph @

hdl/fpga/ip/nuand/synthesis/tb/fsk_tb.vhd

raw
1 -- Copyright (c) 2013 Nuand LLC
2 --
3 -- Permission is hereby granted, free of charge, to any person obtaining a copy
4 -- of this software and associated documentation files (the "Software"), to deal
5 -- in the Software without restriction, including without limitation the rights
6 -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 -- copies of the Software, and to permit persons to whom the Software is
8 -- furnished to do so, subject to the following conditions:
9 --
10 -- The above copyright notice and this permission notice shall be included in
11 -- all copies or substantial portions of the Software.
12 --
13 -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 -- THE SOFTWARE.
20
21 library ieee ;
22 use ieee.std_logic_1164.all ;
23 use ieee.numeric_std.all ;
24 use ieee.math_real.all ;
25
26 entity fsk_tb is
27 end entity ; -- fsk_tb
28
29 architecture arch of fsk_tb is
30
31 signal clock : std_logic := '1' ;
32 signal reset : std_logic := '1' ;
33
34 signal tx_symbol : std_logic := '0' ;
35 signal tx_valid : std_logic := '0' ;
36
37 signal tx_sig_real : signed(15 downto 0) ;
38 signal tx_sig_imag : signed(15 downto 0) ;
39 signal tx_sig_valid : std_logic ;
40
41 signal rx_symbol : signed(15 downto 0) ;
42 signal rx_valid : std_logic ;
43
44 procedure nop( signal clock : in std_logic ; count : in natural ) is
45 begin
46 for i in 1 to count loop
47 wait until rising_edge( clock ) ;
48 end loop ;
49 end procedure ;
50
51 begin
52
53 clock <= not clock after 1 ns ;
54
55 U_fsk_modulator : entity work.fsk_modulator
56 port map (
57 clock => clock,
58 reset => reset,
59 symbol => tx_symbol,
60 symbol_valid => tx_valid,
61 out_real => tx_sig_real,
62 out_imag => tx_sig_imag,
63 out_valid => tx_sig_valid
64 ) ;
65
66 U_fsk_demodulator : entity work.fsk_demodulator
67 port map (
68 clock => clock,
69 reset => reset,
70 in_real => tx_sig_real,
71 in_imag => tx_sig_imag,
72 in_valid => tx_sig_valid,
73 out_ssd => rx_symbol,
74 out_valid => rx_valid
75 ) ;
76
77 tb : process
78 variable s1, s2 : natural ;
79 variable random : real ;
80 begin
81 reset <= '1' ;
82 nop( clock, 10 ) ;
83
84 reset <= '0' ;
85 nop( clock, 10 ) ;
86
87 s1 := 1234 ;
88 s2 := 2345 ;
89 for i in 0 to 10000 loop
90 uniform( s1, s2, random ) ;
91 if( random >= 0.5 ) then
92 tx_symbol <= '1' ;
93 else
94 tx_symbol <= '0' ;
95 end if ;
96 tx_valid <= '1' ;
97 nop( clock, 50 ) ;
98 end loop ;
99
100 report "-- End of Simulation --" severity failure ;
101 end process ;
102
103 end architecture ; -- arch