forked from MahmoudSamy1452/6StageProcessor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fetch.vhd
72 lines (72 loc) · 2.73 KB
/
fetch.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
64
65
66
67
68
69
70
71
72
library ieee;
use ieee.std_logic_1164.all;
entity fetch is
port( en, rst, clk, branch, int, RET_RTI, stall, BranchStall:in std_logic;
branch_update, RET_RTI_update: in std_logic_vector ( 15 downto 0);
updated_PC: out std_logic_vector ( 15 downto 0);
inst: out std_logic_vector(31 downto 0);
intOut: out std_logic);
end entity fetch;
architecture archfetch of fetch is
component mux2 is
GENERIC (n: integer:= 16);
port(
in1,in2: in std_logic_vector(n - 1 downto 0);
out1 : out std_logic_vector(n - 1 downto 0);
sel : in std_logic
);
end component;
component interruptLatch is
port (
rst, clk, RET_stall, int, condition: std_logic;
LatchedIntOut: out std_logic
);
end component interruptLatch;
component instruction_cache IS
PORT (
address : IN std_logic_vector(15 DOWNTO 0);
dataout : OUT std_logic_vector(31 DOWNTO 0);
resetAddress, intAddress: OUT std_logic_vector(15 DOWNTO 0) );
END component;
component my_nadder IS
generic (n: integer := 16);
PORT (a,b : IN std_logic_vector(n-1 downto 0);
cin : in std_logic;
s : out std_logic_vector(n-1 downto 0);
cout : OUT std_logic );
END component;
component PC is
generic (n: integer := 16);
port (
RST, Enable, IntEnable, clk, int: IN std_logic;
update, rstAddress, intAddress: in std_logic_vector(n-1 downto 0);
inst_address: OUT std_logic_vector(n-1 downto 0);
RET_RTI: IN std_logic;
RET_RTI_update: in std_logic_vector(n-1 downto 0)
);
end component;
signal instruction: std_logic_vector(31 downto 0);
signal instruction_address, add1, add2, sequential_increment, sequential_update, update, rstAddress, intAddress, updated_PC_signal: std_logic_vector(15 downto 0);
signal cout, NotStall, stallInput: std_logic;
signal latchedInterrupt, conditionInt: std_logic;
begin
p1: PC port map(rst, en, NotStall, clk, latchedInterrupt, update, rstAddress, intAddress, instruction_address, RET_RTI, RET_RTI_update);
ic: instruction_cache port map (instruction_address, instruction, rstAddress, intAddress);
ad: my_nadder port map (instruction_address, sequential_increment, '0', sequential_update, cout);
add1 <= (0 => '1', others => '0');
add2 <= (1 => '1', others => '0');
m1: mux2 port map( add1, add2, sequential_increment, instruction(25));
m2: mux2 port map( sequential_update, branch_update, update, branch);
inst <= instruction;
updated_PC_signal <= sequential_update when latchedInterrupt = '0'
else instruction_address;
IL: interruptLatch port map (rst, clk, stallInput, int, '0', latchedInterrupt);
intOut <= latchedInterrupt;
conditionInt <= '1' when instruction_address = intAddress
else '0';
updated_PC <= updated_PC_signal;
stallInput <= '1' when stall ='1' or BranchStall = '1'
else '0';
NotStall <= '1' when not (stallInput = '1')
else '0';
end archfetch;