OpenCores
URL https://opencores.org/ocsvn/tinycpu/tinycpu/trunk

Subversion Repositories tinycpu

[/] [tinycpu/] [trunk/] [src/] [fetch.vhd] - Diff between revs 21 and 22

Only display areas with differences | Details | Blame | View Log

Rev 21 Rev 22
--This component interfaces with the memory controller and fetches the next instruction according to IP and CS
--This component interfaces with the memory controller and fetches the next instruction according to IP and CS
--Each instruction is 16 bits.
--Each instruction is 16 bits.
 
 
--How it works: IROut keeps the instruction that was featched in the "last" clock cycle. 
--How it works: IROut keeps the instruction that was featched in the "last" clock cycle. 
--What is basically required is that AddressIn must be the value that CS:IP "will be" in the next clock cycle
--What is basically required is that AddressIn must be the value that CS:IP "will be" in the next clock cycle
--This can cause some (in my opinion) odd logic at times, but should not have any problems synthesizing
--This can cause some (in my opinion) odd logic at times, but should not have any problems synthesizing
 
 
 
 
 
 
 
 
library IEEE;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
use IEEE.NUMERIC_STD.ALL;
use work.tinycpu.all;
use work.tinycpu.all;
 
 
entity fetch is
entity fetch is
  port(
  port(
    Enable: in std_logic;
    Enable: in std_logic;
    AddressIn: in std_logic_vector(15 downto 0);
    AddressIn: in std_logic_vector(15 downto 0);
    Clock: in std_logic;
    Clock: in std_logic;
    DataIn: in std_logic_vector(15 downto 0); --interface from memory
    DataIn: in std_logic_vector(15 downto 0); --interface from memory
    IROut: out std_logic_vector(15 downto 0);
    IROut: out std_logic_vector(15 downto 0);
    AddressOut: out std_logic_vector(15 downto 0) --interface to memory
    AddressOut: out std_logic_vector(15 downto 0) --interface to memory
   );
   );
end fetch;
end fetch;
 
 
architecture Behavioral of fetch is
architecture Behavioral of fetch is
  signal IR: std_logic_vector(15 downto 0);
  signal IR: std_logic_vector(15 downto 0);
begin
begin
  process(Clock, AddressIn, DataIn)
  process(Clock, AddressIn, DataIn, Enable)
  begin
  begin
    --if(rising_edge(Clock)) then
    --if(rising_edge(Clock)) then
      if(Enable='1') then
      if(Enable='1') then
        IR <= DataIn;
        IR <= DataIn;
        AddressOut <= AddressIn;
        AddressOut <= AddressIn;
      else
      else
 
        IR <= x"FFFF"; --avoid a latch
        AddressOut <= "ZZZZZZZZZZZZZZZZ";
        AddressOut <= "ZZZZZZZZZZZZZZZZ";
      end if;
      end if;
    --end if;
    --end if;
  end process;
  end process;
  --AddressOut <= AddressIn when Enable='1' else "ZZZZZZZZZZZZZZZZ";
  --AddressOut <= AddressIn when Enable='1' else "ZZZZZZZZZZZZZZZZ";
  IROut <= IR;
  IROut <= IR;
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.