forked from antonblanchard/microwatt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfetch1.vhdl
78 lines (61 loc) · 1.43 KB
/
fetch1.vhdl
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
73
74
75
76
77
78
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
library work;
use work.common.all;
entity fetch1 is
generic(
RESET_ADDRESS : std_logic_vector(63 downto 0)
);
port(
clk : in std_ulogic;
rst : in std_ulogic;
-- Control inputs:
fetch_one_in : in std_ulogic;
-- redirect from execution unit
e_in : in Execute1ToFetch1Type;
-- fetch data out
f_out : out Fetch1ToFetch2Type
);
end entity fetch1;
architecture behaviour of fetch1 is
type reg_type is record
pc : std_ulogic_vector(63 downto 0);
fetch_one : std_ulogic;
end record;
signal r : reg_type;
signal rin : reg_type;
begin
regs : process(clk)
begin
if rising_edge(clk) then
r <= rin;
end if;
end process;
comb : process(all)
variable v : reg_type;
variable fetch_valid : std_ulogic;
variable fetch_nia : std_ulogic_vector(63 downto 0);
begin
v := r;
fetch_valid := '0';
fetch_nia := (others => '0');
v.fetch_one := v.fetch_one or fetch_one_in;
if e_in.redirect = '1' then
v.pc := e_in.redirect_nia;
end if;
if v.fetch_one = '1' then
fetch_nia := v.pc;
fetch_valid := '1';
v.pc := std_logic_vector(unsigned(v.pc) + 4);
v.fetch_one := '0';
end if;
if rst = '1' then
v.pc := RESET_ADDRESS;
v.fetch_one := '0';
end if;
rin <= v;
f_out.valid <= fetch_valid;
f_out.nia <= fetch_nia;
end process;
end architecture behaviour;