2 USE ieee.std_logic_1164.ALL;
3 USE ieee.numeric_std.all;
8 ENTITY lx_dad_top_tb IS
11 ARCHITECTURE behavior OF lx_dad_top_tb IS
13 -- Component Declaration for the Unit Under Test (UUT)
17 --clk_cpu : IN std_logic;
18 clk_50m : IN std_logic;
19 cs0_xc : IN std_logic;
21 bls : IN std_logic_vector(3 downto 0);
22 address : IN std_logic_vector(15 downto 0);
23 data : INOUT std_logic_vector(31 downto 0);
27 -- signal connected to external JK FF
28 event_jk_j : out std_logic;
29 -- signals to image sensor
32 phi_rst : out std_logic;
33 LED_1 : out std_logic;
34 sck_o : out std_logic;
35 cnv_o : out std_logic;
36 phist : out std_logic;
44 --signal clk_cpu : std_logic := '0';
45 signal clk_50m : std_logic := '0';
46 signal cs0_xc : std_logic := '1';
47 signal rd : std_logic := '1';
48 signal bls : std_logic_vector(3 downto 0) := (others => '1');
49 signal address : std_logic_vector(15 downto 0) := (others => '0');
51 signal init : std_logic := '1';
54 signal data : std_logic_vector(31 downto 0);
56 -- Clock period definitions
57 --constant clk_period_cpu : time := 13.8 ns;
58 constant clk_period_50m : time := 20 ns;
60 signal adc_sck : std_logic;
64 -- Instantiate the Unit Under Test (UUT)
65 uut: lx_dad_top PORT MAP (
77 -- signals to image sensor
89 -- Clock process definitions
90 -- clk_cpu_process :process
93 -- wait for clk_period_cpu/2;
95 -- wait for clk_period_cpu/2;
98 clk_50m_process :process
101 wait for clk_period_50m/2;
103 wait for clk_period_50m/2;
110 -- External ModelSim script
115 setup_imem_process : process
116 -- file imem_file : text open READ_MODE is "imem.bits";
117 -- variable my_line : LINE;
118 -- variable bits_line : LINE;
119 -- variable mem_location : bit_vector(31 downto 0);
120 -- variable imem_fill_addr : natural range 0 to 2**8-1 := 0;
123 constant addr: std_logic_vector(15 downto 0);
124 constant wrdata: std_logic_vector(31 downto 0)
127 wait until clk_50m'event and clk_50m = '1';
128 wait until clk_50m'event and clk_50m = '0';
134 wait until clk_50m'event and clk_50m = '1';
135 wait until clk_50m'event and clk_50m = '1';
136 wait until clk_50m'event and clk_50m = '1';
139 data <= (others => 'Z');
140 wait until clk_50m'event and clk_50m = '1';
145 -- Assert LX_DAD system reset for 3 clock cycles
146 wait until clk_50m'event and clk_50m = '1';
148 wait until clk_50m'event and clk_50m = '1';
149 wait until clk_50m'event and clk_50m = '1';
150 wait until clk_50m'event and clk_50m = '1';
153 -- Fill Tumbl instruction memory
154 --fill_loop: while not endfile(imem_file) loop
155 -- wait until clk_50m'event and clk_50m = '1';
159 -- wait until clk_50m'event and clk_50m = '1';
160 -- address <= std_logic_vector(to_unsigned(imem_fill_addr, 16));
161 -- readline(imem_file, bits_line);
162 -- read(bits_line, mem_location);
163 -- data <= to_stdLogicVector(mem_location);
166 -- imem_fill_addr := imem_fill_addr + 1;
167 -- wait until clk_50m'event and clk_50m = '1';
168 -- wait until clk_50m'event and clk_50m = '1';
172 --end loop fill_loop;
174 -- Write to example bus memory
175 mcu_write(x"1000", x"00000000");
177 mcu_write(x"1001", x"00000009"); -- 9
178 mcu_write(x"1002", x"00000020"); -- 399
179 mcu_write(x"1003", x"00000020"); -- 409
180 mcu_write(x"1004", x"00000020"); -- 399
181 mcu_write(x"1005", x"00000009"); -- 9
182 mcu_write(x"1006", x"00000040"); -- 599
183 mcu_write(x"1007", x"00000050"); -- 609
184 mcu_write(x"1008", x"00002000"); -- 5023999
185 mcu_write(x"1009", x"00000008"); -- 499
187 mcu_write(x"100C", x"00000010");
189 mcu_write(x"1000", x"00000009"); -- standard
190 -- mcu_write(x"1000", x"00000011"); -- leakage
191 -- mcu_write(x"1000", x"00000021"); -- multi
193 -- Simulate external master accesses example bus memory
195 wait until clk_50m'event and clk_50m = '1';
196 wait until clk_50m'event and clk_50m = '1';
200 wait until clk_50m'event and clk_50m = '1';
201 wait until clk_50m'event and clk_50m = '1';
202 wait until clk_50m'event and clk_50m = '1';
203 wait until clk_50m'event and clk_50m = '1';