| 1 |
library ieee ; |
| 2 |
use ieee.std_logic_1164.all ; |
| 3 |
use ieee.numeric_std.all ; |
| 4 |
use ieee.math_real.all ; |
| 5 |
|
| 6 |
library std ; |
| 7 |
use std.env.all ; |
| 8 |
|
| 9 |
library nuand ; |
| 10 |
use nuand.util.all ; |
| 11 |
|
| 12 |
entity lms6002d_tb is |
| 13 |
end entity ; |
| 14 |
|
| 15 |
architecture arch of lms6002d_tb is |
| 16 |
|
| 17 |
signal rx_clock : std_logic := '1' ; |
| 18 |
signal rx_reset : std_logic := '1' ; |
| 19 |
signal rx_enable : std_logic := '0' ; |
| 20 |
|
| 21 |
signal rx_sample_i : signed(11 downto 0) ; |
| 22 |
signal rx_sample_q : signed(11 downto 0) ; |
| 23 |
signal rx_sample_valid : std_logic ; |
| 24 |
|
| 25 |
signal rx_lms_data : signed(11 downto 0) := (others =>'0') ; |
| 26 |
signal rx_lms_iq_sel : std_logic := '0' ; |
| 27 |
signal rx_lms_enable : std_logic ; |
| 28 |
|
| 29 |
signal tx_clock : std_logic := '1' ; |
| 30 |
signal tx_reset : std_logic := '1' ; |
| 31 |
signal tx_enable : std_logic := '0' ; |
| 32 |
|
| 33 |
signal tx_sample_i : signed(11 downto 0) := (others =>'0') ; |
| 34 |
signal tx_sample_q : signed(11 downto 0) := (others =>'0') ; |
| 35 |
signal tx_sample_valid : std_logic := '0' ; |
| 36 |
|
| 37 |
signal tx_lms_data : signed(11 downto 0) ; |
| 38 |
signal tx_lms_iq_sel : std_logic ; |
| 39 |
signal tx_lms_enable : std_logic ; |
| 40 |
|
| 41 |
signal lms_resetx : std_logic := '0' ; |
| 42 |
|
| 43 |
-- Simulation end signals |
| 44 |
signal rx_end : boolean := false ; |
| 45 |
signal tx_end : boolean := false ; |
| 46 |
signal tb_end : boolean := false ; |
| 47 |
|
| 48 |
begin |
| 49 |
|
| 50 |
-- Clock stimulus |
| 51 |
tx_clock <= not tx_clock after 1 ns ; |
| 52 |
rx_clock <= not rx_clock after 1 ns ; |
| 53 |
|
| 54 |
U_lms6002d : entity work.lms6002d(arch) |
| 55 |
port map ( |
| 56 |
rx_clock => rx_clock, |
| 57 |
rx_reset => rx_reset, |
| 58 |
rx_enable => rx_enable, |
| 59 |
|
| 60 |
rx_sample_i => rx_sample_i, |
| 61 |
rx_sample_q => rx_sample_q, |
| 62 |
rx_sample_valid => rx_sample_valid, |
| 63 |
|
| 64 |
rx_lms_data => rx_lms_data, |
| 65 |
rx_lms_iq_sel => rx_lms_iq_sel, |
| 66 |
rx_lms_enable => rx_lms_enable, |
| 67 |
|
| 68 |
tx_clock => tx_clock, |
| 69 |
tx_reset => tx_reset, |
| 70 |
tx_enable => tx_enable, |
| 71 |
|
| 72 |
tx_sample_i => tx_sample_i, |
| 73 |
tx_sample_q => tx_sample_q, |
| 74 |
tx_sample_valid => tx_sample_valid, |
| 75 |
|
| 76 |
tx_lms_data => tx_lms_data, |
| 77 |
tx_lms_iq_sel => tx_lms_iq_sel, |
| 78 |
tx_lms_enable => tx_lms_enable |
| 79 |
) ; |
| 80 |
|
| 81 |
lms_resetx <= '1' after 5 ns ; |
| 82 |
|
| 83 |
U_lms6002d_model : entity work.lms6002d_model(arch) |
| 84 |
port map ( |
| 85 |
resetx => lms_resetx, |
| 86 |
rx_clock => rx_clock, |
| 87 |
rx_clock_out => open, |
| 88 |
rx_data => rx_lms_data, |
| 89 |
rx_enable => rx_lms_enable, |
| 90 |
rx_iq_select => rx_lms_iq_sel, |
| 91 |
|
| 92 |
tx_clock => tx_clock, |
| 93 |
tx_data => tx_lms_data, |
| 94 |
tx_enable => tx_lms_enable, |
| 95 |
tx_iq_select => tx_lms_iq_sel, |
| 96 |
|
| 97 |
sclk => '0', |
| 98 |
sen => '0', |
| 99 |
sdio => '0', |
| 100 |
sdo => open, |
| 101 |
|
| 102 |
pll_out => open |
| 103 |
) ; |
| 104 |
|
| 105 |
-- End testbench |
| 106 |
tb_end <= rx_end and tx_end ; |
| 107 |
|
| 108 |
rx_tb : process |
| 109 |
begin |
| 110 |
-- Setup reset input conditions |
| 111 |
rx_reset <= '1' ; |
| 112 |
nop( rx_clock, 10 ) ; |
| 113 |
|
| 114 |
-- Come out of reset |
| 115 |
rx_reset <= '0' ; |
| 116 |
nop( rx_clock, 10 ) ; |
| 117 |
|
| 118 |
-- Enable the RX side of things |
| 119 |
rx_enable <= '1' ; |
| 120 |
nop( rx_clock, 2000 ) ; |
| 121 |
|
| 122 |
-- Disable RX |
| 123 |
rx_enable <= '0' ; |
| 124 |
nop( rx_clock, 100 ) ; |
| 125 |
|
| 126 |
-- Enable the RX side of things |
| 127 |
rx_enable <= '1' ; |
| 128 |
nop( rx_clock, 2000 ) ; |
| 129 |
|
| 130 |
report "-- RX Finished --" ; |
| 131 |
rx_end <= true ; |
| 132 |
wait ; |
| 133 |
end process ; |
| 134 |
|
| 135 |
tx_tb : process |
| 136 |
begin |
| 137 |
-- Setup reset input conditions |
| 138 |
tx_enable <= '0' ; |
| 139 |
nop( tx_clock, 700 ) ; |
| 140 |
tx_reset <= '0' ; |
| 141 |
nop( tx_clock, 10 ) ; |
| 142 |
tx_enable <= '1' ; |
| 143 |
for i in 1 to 10000 loop |
| 144 |
tx_sample_i <= to_signed(i mod 2048,tx_sample_i'length) ; |
| 145 |
tx_sample_q <= to_signed(-(i mod 2048),tx_sample_q'length) ; |
| 146 |
tx_sample_valid <= '1' ; |
| 147 |
nop( tx_clock, 1 ) ; |
| 148 |
tx_sample_valid <= '0' ; |
| 149 |
nop( tx_clock, 1 ) ; |
| 150 |
end loop ; |
| 151 |
report "-- TX Finshed --" ; |
| 152 |
tx_end <= true ; |
| 153 |
wait ; |
| 154 |
end process ; |
| 155 |
|
| 156 |
finish_tb : process |
| 157 |
begin |
| 158 |
wait until tb_end = true ; |
| 159 |
report "-- End of Simulation --" ; |
| 160 |
stop(2) ; |
| 161 |
end process ; |
| 162 |
|
| 163 |
end architecture ; |
| 164 |
|