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

Subversion Repositories igor

[/] [igor/] [trunk/] [processor/] [pl/] [if.vhd] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 atypic
library ieee;
2
use ieee.std_logic_1164.all;
3
use ieee.numeric_std.all;
4
use work.whisk_constants.all;
5
use work.all;
6
 
7
entity instr_fetch is
8
    port(
9
    -- data lines
10
    instruction : out std_logic_vector(MC_INSTR_BITS - 1 downto 0);
11
    next_pc : out std_logic_vector(MC_ADDR_BITS - 1 downto 0);
12
 
13
    branch_target : in std_logic_vector(MC_ADDR_BITS - 1 downto 0);
14
 
15
    -- control lines
16
    core_clk : in std_logic;
17
    core_rst : in std_logic;
18
    pc_mux : in std_logic_vector(1 downto 0)
19
    );
20
end entity;
21
 
22
architecture mixed of instr_fetch is
23
    -- Program counter
24
    signal pc : std_logic_vector(MC_ADDR_BITS - 1 downto 0);
25
    signal pc_inc : std_logic_vector(MC_ADDR_BITS - 1 downto 0);
26
--    signal IFID : IFID_t; -- pipeline register
27
 
28
begin
29
 
30
    imem : entity preload_mem
31
    generic map (
32
        memsize => INSTR_MEM_SIZE,
33
        addrbits => MC_ADDR_BITS,
34
        databits => MC_INSTR_BITS,
35
        initfile => INSTR_MEM_INIT )
36
    port map (
37
        clk => core_clk,
38
        addr => pc,
39
        dout => instruction,
40
        -- just push 0 to the write port.
41
                din => "000000000000000000000000000000000000000000000000",
42
        we => '0' );
43
 
44
    pc_inc <= std_logic_vector(unsigned(pc) + 1);
45
 
46
    -- PC MUX
47
    instr_fetch : process (core_clk)
48
    begin
49
        --pc_inc <= std_logic_vector(unsigned(pc) + 1); 
50
        if rising_edge(core_clk) then
51
            if core_rst = '0' then
52
                pc <= (others => '0');
53
            elsif pc_mux = PCMUX_STALL then
54
                pc <= pc; -- uh
55
            elsif pc_mux = PCMUX_BRANCH then
56
                pc <= branch_target;
57
            elsif pc_mux = PCMUX_NOBRANCH then
58
                pc <= pc_inc; -- is this even legal
59
            else
60
                pc <= pc_inc;
61
            end if;
62
 
63
            -- Write pipeline registers. 
64
            next_pc <= pc;
65
 
66
        end if;
67
    end process;
68
end architecture;

powered by: WebSVN 2.1.0

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