-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathr_store.vhd
115 lines (92 loc) · 2.72 KB
/
r_store.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 07:45:10 04/26/2013
-- Design Name:
-- Module Name: r_store - Behavioral
-- Project Name:
-- Target Devices:
-- Tool versions:
-- Description:
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
use work.octagon_types.all;
use work.octagon_funcs.all;
entity r_store is
Port (
clk : in std_logic;
lmuxout : in lmuxout_type;
rout : out rstoreout_type
);
end r_store;
architecture Behavioral of r_store is
signal loadv : std_logic_vector(31 downto 0);
begin
--Control signals
rout.tid <= lmuxout.tid;
rout.r_dest <= lmuxout.r_dest;
rout.valid <= lmuxout.valid;
--Smux
loadv <= lmuxout.wbr_data when lmuxout.wbr_complete = '1' else lmuxout.loadv;
rout.smux <= loadv when lmuxout.load = '1' else lmuxout.lmux;
rout.be <= lmuxout.be when lmuxout.load = '1' else "1111";
process(clk)
variable status_wr : std_logic;
begin
if clk='1' and clk'Event then
if lmuxout.do_int = '1' or lmuxout.invalid_op = '1' then
rout.cop0.epc <= (31 downto IM_BITS => '0') & lmuxout.epc;
rout.cop0.ipend <= lmuxout.ipend;
if lmuxout.do_int = '1' then
rout.cop0.ecode <= X"1";
else
--Invalid opcode
rout.cop0.ecode <= X"2";
end if;
rout.cop0.exc <= '1';
rout.epc_wr <= '1';
rout.cause_wr <= '1';
rout.exc_wr <= '1';
rout.int_wr <= '0';
else
status_wr := to_std_logic(lmuxout.r_dest = "01100" and lmuxout.store_cop0 = '1');
if lmuxout.rfe = '1' then
rout.cop0.exc <= '0';
rout.exc_wr <= '1';
else
rout.cop0.exc <= lmuxout.lmux(1);
rout.exc_wr <= status_wr;
end if;
rout.cop0.epc <= lmuxout.lmux;
rout.epc_wr <= to_std_logic(lmuxout.r_dest = "01110" and lmuxout.store_cop0 = '1');
rout.cop0.imask <= lmuxout.lmux(15 downto 8);
rout.cop0.int <= lmuxout.lmux(0);
rout.int_wr <= status_wr;
rout.cop0.ecode <= lmuxout.lmux(5 downto 2);
rout.cop0.ipend <= lmuxout.lmux(15 downto 8);
rout.cause_wr <= to_std_logic(lmuxout.r_dest = "01101" and lmuxout.store_cop0 = '1');
end if;
rout.cop0_tid <= lmuxout.tid;
rout.lmux <= lmuxout.lmux;
rout.hi_wr <= lmuxout.store_hi;
rout.lo_wr <= lmuxout.store_lo;
rout.mtmul <= lmuxout.mtmul;
end if;
end process;
end Behavioral;