CFLAGS += -Wall
GHDLFLAGS+=
-ANALYZEFLAGS+=--std=93c --ieee=synopsys -fexplicit
+ANALYZEFLAGS+=--std=93c --ieee=synopsys -fexplicit -ggdb
#SIM_FLAGS=--stop-time=1000ns #--ieee-asserts=disable
$(GHDL) $(GHDLFLAGS) -m $(ANALYZEFLAGS) lx_tumbl_tb
$(GHDL) $(GHDLFLAGS) -r lx_tumbl_tb --stop-time=10000ns --vcd=$@.vcd --wave=$@.ghw
-test-rocon: analyze-all
+test-rocon: analyze-all imem.bits
$(GHDL) $(GHDLFLAGS) -m $(ANALYZEFLAGS) lx_rocon_top_tb
$(GHDL) $(GHDLFLAGS) -r lx_rocon_top_tb --stop-time=10000ns --vcd=$@.vcd --wave=$@.ghw
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
+USE ieee.numeric_std.all;
+
+LIBRARY std;
+USE std.textio.all;
ENTITY lx_rocon_top_tb IS
END lx_rocon_top_tb;
wait;
end process;
+ setup_imem_process : process
+ file imem_file : text open READ_MODE is "imem.bits";
+ variable my_line : LINE;
+ variable bits_line : LINE;
+ variable mem_location : bit_vector(31 downto 0);
+ variable imem_fill_addr : natural range 0 to 2**8-1 := 0;
+ begin
+
+ -- Assert ROCON system reset for 3 clock cycles
+ wait until clk_50m'event and clk_50m = '1';
+ init <= '0';
+ wait until clk_50m'event and clk_50m = '1';
+ wait until clk_50m'event and clk_50m = '1';
+ wait until clk_50m'event and clk_50m = '1';
+ init <= '1';
+
+ -- Fill Tumbl instruction memory
+ fill_loop: while not endfile(imem_file) loop
+ wait until clk_50m'event and clk_50m = '1';
+ cs0_xc <= '1';
+ rd <= '1';
+ bls <= "1111";
+ wait until clk_50m'event and clk_50m = '1';
+ address <= std_logic_vector(to_unsigned(imem_fill_addr, 16));
+ readline(imem_file, bits_line);
+ read(bits_line, mem_location);
+ data <= to_stdLogicVector(mem_location);
+ bls <= "0000";
+ cs0_xc <= '0';
+ imem_fill_addr := imem_fill_addr + 1;
+ wait until clk_50m'event and clk_50m = '1';
+ wait until clk_50m'event and clk_50m = '1';
+ cs0_xc <= '1';
+ rd <= '1';
+ bls <= "1111";
+ end loop fill_loop;
+
+ -- Negate Tumbl reset state in Tumbl control register
+ wait until clk_50m'event and clk_50m = '1';
+ wait until clk_50m'event and clk_50m = '1';
+ address <= x"0C00";
+ data <= x"00000000";
+ bls <= "0000";
+ cs0_xc <= '0';
+ wait until clk_50m'event and clk_50m = '1';
+ wait until clk_50m'event and clk_50m = '1';
+ cs0_xc <= '1';
+ rd <= '1';
+ bls <= "1111";
+
+ -- Simulate external master accesses to Tumbl shared xmem bus
+ xmem_loop: loop
+ wait until clk_50m'event and clk_50m = '1';
+ wait until clk_50m'event and clk_50m = '1';
+ address <= x"8808";
+ rd <= '0';
+ cs0_xc <= '0';
+ wait until clk_50m'event and clk_50m = '1';
+ wait until clk_50m'event and clk_50m = '1';
+ wait until clk_50m'event and clk_50m = '1';
+ cs0_xc <= '1';
+ rd <= '1';
+ bls <= "1111";
+ end loop xmem_loop;
+
+ wait;
+
+ end process;
+
END;
-- Simulate special events and interactions
signal delay_access_s : std_logic := '0';
+ signal delay_access_r : std_logic := '0';
+ signal delay_access_r2 : std_logic := '0';
BEGIN
-- Instantiate the Unit Under Test (UUT)
end process;
- events_process: process(cycle_cnt)
+ events_process: process(cycle_cnt, xmemb_sel_s, delay_access_r, delay_access_r2)
begin
- -- Enable clken only when available for Tumbl
- if cycle_cnt >= 34 and cycle_cnt <= 34 then
+ -- Simulate externall access to xmem bus shared with Tumbl
+ if cycle_cnt >= 33 and cycle_cnt <= 33 then
+ -- if xmemb_sel_s = '1' and (delay_access_r = '0' or delay_access_r2 = '0') then
delay_access_s <= '1';
else
delay_access_s <= '0';
end if;
end process;
+ -- Enable xmem clken only when bus available for Tumbl
xmemb_i_s.clken <= not delay_access_s;
xmemb_process :process
write(my_line, string'(")"));
writeline(output, my_line);
end if;
+
+ delay_access_r <= delay_access_s;
+ delay_access_r2 <= delay_access_r;
end process;