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

Subversion Repositories mblite

[/] [mblite/] [trunk/] [hw/] [core/] [fetch.vhd] - Blame information for rev 11

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 takar
----------------------------------------------------------------------------------------------
2
--
3
--      Input file         : fetch.vhd
4
--      Design name        : fetch
5
--      Author             : Tamar Kranenburg
6
--      Company            : Delft University of Technology
7
--                         : Faculty EEMCS, Department ME&CE
8
--                         : Systems and Circuits group
9
--
10
--      Description        : Instruction Fetch Stage inserts instruction into the pipeline. It
11
--                           uses a single port Random Access Memory component which holds
12
--                           the instructions. The next instruction is computed in the decode
13
--                           stage.
14
--
15
----------------------------------------------------------------------------------------------
16
 
17 8 takar
library ieee;
18
use ieee.std_logic_1164.all;
19
use ieee.std_logic_unsigned.all;
20 2 takar
 
21 8 takar
library mblite;
22
use mblite.config_Pkg.all;
23
use mblite.core_Pkg.all;
24
use mblite.std_Pkg.all;
25 2 takar
 
26 8 takar
entity fetch is port
27 2 takar
(
28 8 takar
    fetch_o : out fetch_out_type;
29
    imem_o  : out imem_out_type;
30
    fetch_i : in fetch_in_type;
31
    rst_i   : in std_logic;
32
    ena_i   : in std_logic;
33
    clk_i   : in std_logic
34 2 takar
);
35 8 takar
end fetch;
36 2 takar
 
37 8 takar
architecture arch of fetch is
38
    signal r, rin   : fetch_out_type;
39
begin
40 2 takar
 
41
    fetch_o.program_counter <= r.program_counter;
42
    imem_o.adr_o <= rin.program_counter;
43
    imem_o.ena_o <= ena_i;
44
 
45 8 takar
    fetch_comb: process(fetch_i, r, rst_i)
46
        variable v : fetch_out_type;
47
    begin
48 2 takar
        v := r;
49 11 takar
        if rst_i = '1' then
50 10 takar
                        v.program_counter := (OTHERS => '0');
51
                elsif fetch_i.hazard = '1' then
52 2 takar
            v.program_counter := r.program_counter;
53 8 takar
        elsif fetch_i.branch = '1' then
54 2 takar
            v.program_counter := fetch_i.branch_target;
55 8 takar
        else
56
            v.program_counter := increment(r.program_counter(CFG_IMEM_SIZE - 1 downto 2)) & "00";
57
        end if;
58 2 takar
        rin <= v;
59 8 takar
    end process;
60 2 takar
 
61 8 takar
    fetch_seq: process(clk_i)
62
    begin
63
        if rising_edge(clk_i) then
64
            if rst_i = '1' then
65
                r.program_counter <= (others => '0');
66
            elsif ena_i = '1' then
67 2 takar
                r <= rin;
68 8 takar
            end if;
69
        end if;
70
    end process;
71 2 takar
 
72 8 takar
end arch;

powered by: WebSVN 2.1.0

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