Debian Codegraph @

hdl/fpga/ip/nuand/vctcxo_tamer/vhdl/tb/vctcxo_tamer_tb.vhd

raw
1 -- Copyright (c) 2015 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 library ieee;
21 use ieee.std_logic_1164.all;
22 use ieee.numeric_std.all;
23
24 entity vctcxo_tamer_tb is
25 end entity;
26
27 architecture tb of vctcxo_tamer_tb is
28
29 function half_clk_per( freq : real ) return time is
30 begin
31 return ( (0.5 sec) / real(freq) );
32 end function;
33
34 constant SYS_CLK_PER : time := half_clk_per( 80.0e6 );
35 constant REF_1PPS_PER : time := half_clk_per( 1.0e3 ); --5.0e6 );
36 constant IDEAL_384_PER : time := half_clk_per( 38.4e6 );
37
38 signal ref_1pps : std_logic := '1';
39 signal ideal_38p4 : std_logic := '1';
40
41 signal sys_clk : std_logic := '1';
42 signal sys_rst : std_logic;
43 signal rd_req : std_logic;
44 signal wr_req : std_logic;
45 signal addr : std_logic_vector(7 downto 0);
46 signal wr_data : std_logic_vector(7 downto 0);
47 signal rd_data : std_logic_vector(7 downto 0);
48 signal rd_data_val : std_logic;
49 signal wait_req : std_logic;
50 signal irq : std_logic;
51 signal tcxo_clock : std_logic;
52
53 signal dac_count : unsigned(15 downto 0) := x"7FFF";
54 signal tcxo_vcon : real := 1.4;
55
56 -- alias uut_pps_1s_target is << signal .vctcxo_tamer_tb.uut.pps_1s.target : signed(63 downto 0) >>;
57 -- alias uut_pps_10s_target is << signal .vctcxo_tamer_tb.uut.pps_10s.target : signed(63 downto 0) >>;
58 -- alias uut_pps_100s_target is << signal .vctcxo_tamer_tb.uut.pps_100s.target : signed(63 downto 0) >>;
59 --
60 -- alias drv_pps_1s_target is << signal .vctcxo_tamer_tb.driver.PPS_1S_TARGET : signed(63 downto 0) >>;
61 -- alias drv_pps_10s_target is << signal .vctcxo_tamer_tb.driver.PPS_10S_TARGET : signed(63 downto 0) >>;
62 -- alias drv_pps_100s_target is << signal .vctcxo_tamer_tb.driver.PPS_100S_TARGET : signed(63 downto 0) >>;
63 --
64 -- constant PPS_1S_TARGET : signed(63 downto 0) := x"0000_0000_0000_0F00";--12_2C00";
65 -- constant PPS_10S_TARGET : signed(63 downto 0) := x"0000_0000_0000_9600";--B_B800";
66 -- constant PPS_100S_TARGET : signed(63 downto 0) := x"0000_0000_0005_DC00";--75_3000";
67
68 begin
69
70 --process
71 --begin
72 -- uut_pps_1s_target <= force PPS_1S_TARGET;
73 -- drv_pps_1s_target <= force PPS_1S_TARGET;
74 --
75 -- uut_pps_10s_target <= force PPS_10S_TARGET;
76 -- drv_pps_10s_target <= force PPS_10S_TARGET;
77 --
78 -- uut_pps_100s_target <= force PPS_100S_TARGET;
79 -- drv_pps_100s_target <= force PPS_100S_TARGET;
80 -- wait;
81 --end process;
82
83
84 sys_clk <= not sys_clk after SYS_CLK_PER;
85 sys_rst <= '1', '0' after SYS_CLK_PER*5;
86
87 ref_1pps <= not ref_1pps after REF_1PPS_PER;
88
89 ideal_38p4 <= not ideal_38p4 after IDEAL_384_PER;
90
91 -- process
92 -- begin
93 -- dac_count <= (others => '0');
94 -- wait for 10 us;
95 -- dac_count <= dac_count + x"1000";
96 -- wait for 10 us;
97 -- dac_count <= dac_count + x"1000";
98 -- wait for 10 us;
99 -- dac_count <= dac_count + x"1000";
100 -- wait for 10 us;
101 -- dac_count <= dac_count + x"1000";
102 -- wait for 10 us;
103 -- dac_count <= dac_count + x"1000";
104 -- wait for 10 us;
105 -- dac_count <= dac_count + x"1000";
106 -- wait for 10 us;
107 -- dac_count <= dac_count + x"1000";
108 -- wait for 10 us;
109 -- dac_count <= dac_count + x"1000";
110 -- wait for 10 us;
111 -- dac_count <= dac_count + x"1000";
112 -- wait for 10 us;
113 -- dac_count <= dac_count + x"1000";
114 -- wait;
115 -- end process;
116
117
118 uut : entity work.vctcxo_tamer(arch)
119 port map(
120 -- Physical Interface
121 tune_ref => ref_1pps,
122 vctcxo_clock => tcxo_clock,
123
124 -- Avalon-MM Interface
125 mm_clock => sys_clk, -- in std_logic;
126 mm_reset => sys_rst, -- in std_logic;
127 mm_rd_req => rd_req, -- in std_logic;
128 mm_wr_req => wr_req, -- in std_logic;
129 mm_addr => addr, -- in std_logic_vector(ADDR_WIDTH-1 downto 0);
130 mm_wr_data => wr_data, -- in std_logic_vector(DATA_WIDTH-1 downto 0);
131 mm_rd_data => rd_data, -- out std_logic_vector(DATA_WIDTH-1 downto 0);
132 mm_rd_datav => rd_data_val, -- out std_logic;
133 mm_wait_req => wait_req, -- out std_logic;
134
135 -- Interrupt interface
136 mm_irq => irq
137 );
138
139
140 driver : entity work.mm_driver
141 port map (
142 mm_clock => sys_clk, -- in std_logic;
143 mm_reset => sys_rst, -- in std_logic;
144 mm_rd_req => rd_req, -- out std_logic;
145 mm_wr_req => wr_req, -- out std_logic;
146 mm_addr => addr, -- out std_logic_vector(7 downto 0);
147 mm_wr_data => wr_data, -- out std_logic_vector(7 downto 0);
148 mm_rd_data => rd_data, -- in std_logic_vector(7 downto 0);
149 mm_rd_datav => rd_data_val, -- in std_logic;
150 mm_wait_req => wait_req, -- in std_logic
151
152 mm_irq => irq,
153
154 dac_count => dac_count,
155 tcxo_clock => open --tcxo_clock
156 );
157
158 dac : entity work.dac161s055_model
159 generic map (
160 DIRECT_CONTROL => true
161 )
162 port map (
163 -- SPI Control interface
164 --sclk : in std_logic;
165 --sen : in std_logic;
166 --sdi : in std_logic;
167 --sdo : out std_logic;
168
169 -- Direct control interface
170 dac_count => dac_count, -- in unsigned(DAC_WIDTH-1 downto 0);
171 ldacb => '0', -- in std_logic := '0';
172
173 -- Analog output
174 vout => tcxo_vcon -- out real
175 );
176
177 vctcxo : entity work.asvtx12a384m_model
178 port map (
179 vcon => tcxo_vcon, -- in real; -- control voltage
180 clock => tcxo_clock -- out std_logic -- output clock
181 );
182
183 end architecture;