library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
-------------------------------------------------------------------------------------
entity fetch is
port ( mem_data_buffer : inout std_logic_vector(7 downto 0);
data_mem_read, reset, clk : in std_logic;
instruction_register_1, instruction_register_2 : out std_logic_vector(7 downto 0);
mem_address_latch : out std_logic_vector(7 downto 0);
address_mem_write : out std_logic
);
end fetch;
architecture fetch_circuit of fetch is
constant rst_pc : std_logic_vector(7 downto 0) := "00000000";
signal pc : std_logic_vector(7 downto 0) := "00000000";
begin
process (clk, reset, data_mem_read)
variable loop_count : integer range 0 to 25;
begin
if clk'event and clk ='1' then
if reset = '1' then
pc <= rst_pc;
else
mem_address_latch <= pc;
address_mem_write <= '1';
while (loop_count < 25) loop
loop_count := loop_count + 1;
if data_mem_read = '1' then
loop_count := 25;
else
null;
end if;
end loop;
end if;
end if;
end process;
end fetch_circuit;