URL
https://opencores.org/ocsvn/tinycpu/tinycpu/trunk
[/] [tinycpu/] [trunk/] [src/] [fetch.vhd] - Blame information for rev 36
Go to most recent revision |
Details |
Compare with Previous |
View Log
| Line No. |
Rev |
Author |
Line |
| 1 |
17 |
earlz |
--This component interfaces with the memory controller and fetches the next instruction according to IP and CS
|
| 2 |
|
|
--Each instruction is 16 bits.
|
| 3 |
|
|
|
| 4 |
|
|
--How it works: IROut keeps the instruction that was featched in the "last" clock cycle.
|
| 5 |
|
|
--What is basically required is that AddressIn must be the value that CS:IP "will be" in the next clock cycle
|
| 6 |
|
|
--This can cause some (in my opinion) odd logic at times, but should not have any problems synthesizing
|
| 7 |
|
|
|
| 8 |
|
|
|
| 9 |
|
|
|
| 10 |
|
|
|
| 11 |
|
|
library IEEE;
|
| 12 |
|
|
use IEEE.STD_LOGIC_1164.ALL;
|
| 13 |
|
|
use IEEE.NUMERIC_STD.ALL;
|
| 14 |
|
|
use work.tinycpu.all;
|
| 15 |
|
|
|
| 16 |
|
|
entity fetch is
|
| 17 |
|
|
port(
|
| 18 |
|
|
Enable: in std_logic;
|
| 19 |
|
|
AddressIn: in std_logic_vector(15 downto 0);
|
| 20 |
|
|
Clock: in std_logic;
|
| 21 |
|
|
DataIn: in std_logic_vector(15 downto 0); --interface from memory
|
| 22 |
|
|
IROut: out std_logic_vector(15 downto 0);
|
| 23 |
|
|
AddressOut: out std_logic_vector(15 downto 0) --interface to memory
|
| 24 |
|
|
);
|
| 25 |
|
|
end fetch;
|
| 26 |
|
|
|
| 27 |
|
|
architecture Behavioral of fetch is
|
| 28 |
|
|
signal IR: std_logic_vector(15 downto 0);
|
| 29 |
|
|
begin
|
| 30 |
22 |
earlz |
process(Clock, AddressIn, DataIn, Enable)
|
| 31 |
17 |
earlz |
begin
|
| 32 |
21 |
earlz |
--if(rising_edge(Clock)) then
|
| 33 |
17 |
earlz |
if(Enable='1') then
|
| 34 |
|
|
IR <= DataIn;
|
| 35 |
|
|
AddressOut <= AddressIn;
|
| 36 |
|
|
else
|
| 37 |
22 |
earlz |
IR <= x"FFFF"; --avoid a latch
|
| 38 |
17 |
earlz |
AddressOut <= "ZZZZZZZZZZZZZZZZ";
|
| 39 |
|
|
end if;
|
| 40 |
21 |
earlz |
--end if;
|
| 41 |
17 |
earlz |
end process;
|
| 42 |
21 |
earlz |
--AddressOut <= AddressIn when Enable='1' else "ZZZZZZZZZZZZZZZZ";
|
| 43 |
17 |
earlz |
IROut <= IR;
|
| 44 |
|
|
end Behavioral;
|
© copyright 1999-2025
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.