-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforwarding_unit.vhd
63 lines (55 loc) · 1.89 KB
/
forwarding_unit.vhd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
----------------------------------------------------------------------------------
-- Engineer: Zirgon
-- Project: DataKonst2
-- Created: 2013-10-30
--
-- Description:
-- A simple forwarding unit
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
library WORK;
use WORK.MIPS_CONSTANT_PKG.ALL;
entity forwarding_unit is
port(
-- Requested
rs_addr : in STD_LOGIC_VECTOR(REG_ADDR_WIDTH-1 downto 0);
rt_addr : in STD_LOGIC_VECTOR(REG_ADDR_WIDTH-1 downto 0);
-- From mem
mem_addr : in STD_LOGIC_VECTOR(REG_ADDR_WIDTH-1 downto 0);
mem_write : in STD_LOGIC;
-- From wb
wb_addr : in STD_LOGIC_VECTOR(REG_ADDR_WIDTH-1 downto 0);
wb_write : in STD_LOGIC;
-- Forwarding
forward_rs : out FORWARD_TYPE;
forward_rt : out FORWARD_TYPE
);
end forwarding_unit;
architecture Behavioral of forwarding_unit is
begin
RS : process (rs_addr, mem_addr, mem_write, wb_addr, wb_write)
begin
if rs_addr = (REG_ADDR_WIDTH-1 downto 0 => '0') then
forward_rs <= NO_FORWARD;
elsif rs_addr = mem_addr and mem_write = '1' then
forward_rs <= FORWARD_MEM;
elsif rs_addr = wb_addr and wb_write = '1' then
forward_rs <= FORWARD_WB;
else
forward_rs <= NO_FORWARD;
end if;
end process;
RT : process (rt_addr, mem_addr, mem_write, wb_addr, wb_write)
begin
if rt_addr = (REG_ADDR_WIDTH-1 downto 0 => '0') then
forward_rt <= NO_FORWARD;
elsif rt_addr = mem_addr and mem_write = '1' then
forward_rt <= FORWARD_MEM;
elsif rt_addr = wb_addr and wb_write = '1' then
forward_rt <= FORWARD_WB;
else
forward_rt <= NO_FORWARD;
end if;
end process;
end Behavioral;