Line 38... |
Line 38... |
instruction_ready : out std_logic
|
instruction_ready : out std_logic
|
);
|
);
|
end entity pp_fetch;
|
end entity pp_fetch;
|
|
|
architecture behaviour of pp_fetch is
|
architecture behaviour of pp_fetch is
|
--signal pc, pc_next : std_logic_vector(31 downto 0);
|
|
--signal acknowledge, ready : std_logic;
|
|
|
|
signal pc : std_logic_vector(31 downto 0);
|
signal pc : std_logic_vector(31 downto 0);
|
signal pc_next : std_logic_vector(31 downto 0);
|
signal pc_next : std_logic_vector(31 downto 0);
|
|
|
signal cancel_fetch : std_logic;
|
signal cancel_fetch : std_logic;
|
begin
|
begin
|
|
|
imem_address <= pc_next;
|
imem_address <= pc_next when cancel_fetch = '0' else pc;
|
|
|
instruction_data <= imem_data_in;
|
instruction_data <= imem_data_in;
|
instruction_ready <= imem_ack and (not stall) and (not cancel_fetch);
|
instruction_ready <= imem_ack and (not stall) and (not cancel_fetch);
|
instruction_address <= pc;
|
instruction_address <= pc;
|
|
|
--imem_req <= '1' when cancel_fetch = '0' and
|
|
|
|
imem_req <= '1';
|
imem_req <= '1';
|
|
|
set_pc: process(clk)
|
set_pc: process(clk)
|
begin
|
begin
|
if rising_edge(clk) then
|
if rising_edge(clk) then
|
Line 79... |
Line 73... |
end if;
|
end if;
|
end process set_pc;
|
end process set_pc;
|
|
|
calc_next_pc: process(reset, stall, branch, exception, imem_ack, branch_target, evec, pc, cancel_fetch)
|
calc_next_pc: process(reset, stall, branch, exception, imem_ack, branch_target, evec, pc, cancel_fetch)
|
begin
|
begin
|
if reset = '1' then
|
if exception = '1' then
|
pc_next <= RESET_ADDRESS;
|
|
elsif exception = '1' then
|
|
pc_next <= evec;
|
pc_next <= evec;
|
elsif branch = '1' then
|
elsif branch = '1' then
|
pc_next <= branch_target;
|
pc_next <= branch_target;
|
elsif imem_ack = '1' and stall = '0' and cancel_fetch = '0' then
|
elsif imem_ack = '1' and stall = '0' and cancel_fetch = '0' then
|
pc_next <= std_logic_vector(unsigned(pc) + 4);
|
pc_next <= std_logic_vector(unsigned(pc) + 4);
|