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

Subversion Repositories mblite

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

Go to most recent revision | 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
LIBRARY ieee;
18
USE ieee.std_logic_1164.ALL;
19
USE ieee.std_logic_unsigned.ALL;
20
 
21
LIBRARY mblite;
22
USE mblite.config_Pkg.ALL;
23
USE mblite.core_Pkg.ALL;
24
USE mblite.std_Pkg.ALL;
25
 
26
ENTITY fetch IS PORT
27
(
28
    fetch_o : OUT fetch_out_type;
29
    imem_o  : OUT imem_out_type;
30
    fetch_i : IN fetch_in_type;
31 6 takar
    rst_i   : IN std_logic;
32
    ena_i   : IN std_logic;
33
    clk_i   : IN std_logic
34 2 takar
);
35
END fetch;
36
 
37
ARCHITECTURE arch OF fetch IS
38
    SIGNAL r, rin   : fetch_out_type;
39
BEGIN
40
 
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
    fetch_comb: PROCESS(fetch_i, r, rst_i)
46
        VARIABLE v : fetch_out_type;
47
    BEGIN
48
        v := r;
49
        IF fetch_i.hazard = '1' THEN
50
            v.program_counter := r.program_counter;
51
        ELSIF fetch_i.branch = '1' THEN
52
            v.program_counter := fetch_i.branch_target;
53
        ELSE
54
            v.program_counter := increment(r.program_counter(CFG_IMEM_SIZE - 1 DOWNTO 2)) & "00";
55
        END IF;
56
        rin <= v;
57
    END PROCESS;
58
 
59
    fetch_seq: PROCESS(clk_i)
60
    BEGIN
61
        IF rising_edge(clk_i) THEN
62
            IF rst_i = '1' THEN
63
                r.program_counter <= (OTHERS => '0');
64
            ELSIF ena_i = '1' THEN
65
                r <= rin;
66
            END IF;
67
        END IF;
68
    END PROCESS;
69
 
70
END arch;

powered by: WebSVN 2.1.0

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