Debian Codegraph @

hdl/fpga/ip/nuand/synthesis/tb/nco_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
25 library work ;
26 use work.cordic_p.all ;
27 use work.nco_p.all ;
28
29 entity nco_tb is
30 end entity ; -- nco_tb
31
32 architecture arch of nco_tb is
33
34 signal clock : std_logic := '1' ;
35 signal reset : std_logic := '1' ;
36
37 signal inputs : nco_input_t := ( dphase => (others =>'0'), valid => '0' );
38 signal outputs : nco_output_t ;
39
40 procedure nop( signal clock : in std_logic ; count : in natural ) is
41 begin
42 for i in 1 to count loop
43 wait until rising_edge( clock ) ;
44 end loop ;
45 end procedure ;
46
47 begin
48
49 clock <= not clock after 1 ns ;
50
51 U_nco : entity work.nco
52 port map (
53 clock => clock,
54 reset => reset,
55 inputs => inputs,
56 outputs => outputs
57 ) ;
58
59 tb : process
60 variable up_downx : boolean := true ;
61 begin
62 reset <= '1' ;
63 nop( clock, 10 ) ;
64
65 reset <= '0' ;
66 nop( clock, 10 ) ;
67
68 for i in 0 to 100000 loop
69 if( inputs.dphase = 4096 ) then
70 up_downx := false ;
71 elsif( inputs.dphase = -4096 ) then
72 up_downx := true ;
73 end if ;
74
75 if( up_downx ) then
76 inputs.dphase <= inputs.dphase + 1 ;
77 else
78 inputs.dphase <= inputs.dphase - 1 ;
79 end if ;
80
81 inputs.valid <= '1' ;
82 wait until rising_edge( clock ) ;
83 inputs.valid <= '0' ;
84
85 nop( clock, 10 ) ;
86
87 end loop ;
88
89 report "-- End of Simulation --" severity failure ;
90 end process ;
91
92 end architecture ; -- arch