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

Subversion Repositories arm4u

[/] [arm4u/] [trunk/] [hdl/] [forwarding.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 Bregalad
-- This file is part of ARM4U CPU
2
-- 
3
-- This is a creation of the Laboratory of Processor Architecture
4
-- of Ecole Polytechnique Fédérale de Lausanne ( http://lap.epfl.ch )
5
--
6
-- forwarding.vhd  --  Describes the unit capable of detecting data harzards and forwards
7
--                     register values form memory and writeback pipeline stages into execute stage
8
--
9
-- Written By -  Jonathan Masur and Xavier Jimenez (2013)
10
--
11
-- This program is free software; you can redistribute it and/or modify it
12
-- under the terms of the GNU General Public License as published by the
13
-- Free Software Foundation; either version 2, or (at your option) any
14
-- later version.
15
--
16
-- This program is distributed in the hope that it will be useful,
17
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
18
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
-- GNU General Public License for more details.
20
--
21
-- In other words, you are welcome to use, share and improve this program.
22
-- You are forbidden to forbid anyone else to use, share and improve
23
-- what you give them.   Help stamp out software-hoarding!
24
 
25
library ieee;
26
use ieee.std_logic_1164.all;
27
use ieee.numeric_std.all;
28
use work.arm_types.all;
29
 
30
entity forwarding is
31
        port (
32
                reg : in std_logic_vector(5 downto 0);
33
 
34
                fwd_wb2_enable : in std_logic;
35
                fwd_wb2_address : in std_logic_vector(4 downto 0);
36
                fwd_wb2_data : in std_logic_vector(31 downto 0);
37
                fwd_wb1_enable : in std_logic;
38
                fwd_wb1_address : in std_logic_vector(4 downto 0);
39
                fwd_wb1_data : in std_logic_vector(31 downto 0);
40
                fwd_wb1_is_invalid : in std_logic;
41
                fwd_mem_enable : in std_logic;
42
                fwd_mem_address : in std_logic_vector(4 downto 0);
43
                fwd_mem_data : in std_logic_vector(31 downto 0);
44
                fwd_mem_is_invalid : in std_logic;
45
 
46
                exe_pc_plus_8 : in unsigned(31 downto 0);
47
                rfile_data : in std_logic_vector(31 downto 0);
48
 
49
                op_data : out unsigned(31 downto 0);
50
                forward_ok : out std_logic
51
        );
52
end;
53
 
54
architecture rtl of forwarding is
55
begin
56
        forwarding : process(reg, exe_pc_plus_8, rfile_data,
57
                                                fwd_wb2_enable, fwd_wb2_address, fwd_wb2_data,
58
                                                fwd_wb1_enable, fwd_wb1_address, fwd_wb1_data, fwd_wb1_is_invalid,
59
                                                fwd_mem_enable, fwd_mem_address, fwd_mem_data, fwd_mem_is_invalid) is
60
        begin
61
                if reg(5) = '1'
62
                then
63
                        -- PC+8 is used as an operand
64
                        op_data <= exe_pc_plus_8;
65
                        forward_ok <= '1';
66
                else
67
                        if fwd_mem_enable = '1' and fwd_mem_address = reg(4 downto 0)
68
                        then
69
                                op_data <= unsigned(fwd_mem_data);
70
                                forward_ok <= not fwd_mem_is_invalid;
71
                        elsif fwd_wb1_enable = '1' and fwd_wb1_address = reg(4 downto 0)
72
                        then
73
                                op_data <= unsigned(fwd_wb1_data);
74
                                forward_ok <= not fwd_wb1_is_invalid;
75
                        elsif fwd_wb2_enable = '1' and fwd_wb2_address = reg(4 downto 0)
76
                        then
77
                                op_data <= unsigned(fwd_wb2_data);
78
                                forward_ok <= '1';
79
                        else
80
                                op_data <= unsigned(rfile_data);
81
                                forward_ok <= '1';
82
                        end if;
83
                end if;
84
        end process;
85
end;

powered by: WebSVN 2.1.0

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