Merge pull request #81 from antonblanchard/logical
[microwatt.git] / common.vhdl
1 library ieee;
2 use ieee.std_logic_1164.all;
3
4 library work;
5 use work.decode_types.all;
6
7 package common is
8 type ctrl_t is record
9 lr: std_ulogic_vector(63 downto 0);
10 ctr: std_ulogic_vector(63 downto 0);
11 tb: std_ulogic_vector(63 downto 0);
12 carry: std_ulogic;
13 end record;
14
15 type Fetch1ToIcacheType is record
16 req: std_ulogic;
17 stop_mark: std_ulogic;
18 nia: std_ulogic_vector(63 downto 0);
19 end record;
20
21 type IcacheToFetch2Type is record
22 valid: std_ulogic;
23 stop_mark: std_ulogic;
24 nia: std_ulogic_vector(63 downto 0);
25 insn: std_ulogic_vector(31 downto 0);
26 end record;
27
28 type Fetch2ToDecode1Type is record
29 valid: std_ulogic;
30 stop_mark : std_ulogic;
31 nia: std_ulogic_vector(63 downto 0);
32 insn: std_ulogic_vector(31 downto 0);
33 end record;
34 constant Fetch2ToDecode1Init : Fetch2ToDecode1Type := (valid => '0', stop_mark => '0', others => (others => '0'));
35
36 type Decode1ToDecode2Type is record
37 valid: std_ulogic;
38 stop_mark : std_ulogic;
39 nia: std_ulogic_vector(63 downto 0);
40 insn: std_ulogic_vector(31 downto 0);
41 decode: decode_rom_t;
42 end record;
43 constant Decode1ToDecode2Init : Decode1ToDecode2Type := (valid => '0', stop_mark => '0', decode => decode_rom_init, others => (others => '0'));
44
45 type Decode2ToExecute1Type is record
46 valid: std_ulogic;
47 insn_type: insn_type_t;
48 nia: std_ulogic_vector(63 downto 0);
49 write_reg: std_ulogic_vector(4 downto 0);
50 read_reg1: std_ulogic_vector(4 downto 0);
51 read_reg2: std_ulogic_vector(4 downto 0);
52 read_data1: std_ulogic_vector(63 downto 0);
53 read_data2: std_ulogic_vector(63 downto 0);
54 read_data3: std_ulogic_vector(63 downto 0);
55 cr: std_ulogic_vector(31 downto 0);
56 lr: std_ulogic;
57 rc: std_ulogic;
58 invert_a: std_ulogic;
59 invert_out: std_ulogic;
60 input_carry: carry_in_t;
61 output_carry: std_ulogic;
62 input_cr: std_ulogic;
63 output_cr: std_ulogic;
64 is_32bit: std_ulogic;
65 is_signed: std_ulogic;
66 insn: std_ulogic_vector(31 downto 0);
67 end record;
68 constant Decode2ToExecute1Init : Decode2ToExecute1Type :=
69 (valid => '0', insn_type => OP_ILLEGAL, lr => '0', rc => '0', invert_a => '0',
70 invert_out => '0', input_carry => ZERO, output_carry => '0', input_cr => '0', output_cr => '0',
71 is_32bit => '0', is_signed => '0', others => (others => '0'));
72
73 type Decode2ToMultiplyType is record
74 valid: std_ulogic;
75 insn_type: insn_type_t;
76 write_reg: std_ulogic_vector(4 downto 0);
77 data1: std_ulogic_vector(64 downto 0);
78 data2: std_ulogic_vector(64 downto 0);
79 rc: std_ulogic;
80 end record;
81 constant Decode2ToMultiplyInit : Decode2ToMultiplyType := (valid => '0', insn_type => OP_ILLEGAL, rc => '0', others => (others => '0'));
82
83 type Decode2ToDividerType is record
84 valid: std_ulogic;
85 write_reg: std_ulogic_vector(4 downto 0);
86 dividend: std_ulogic_vector(63 downto 0);
87 divisor: std_ulogic_vector(63 downto 0);
88 is_signed: std_ulogic;
89 is_32bit: std_ulogic;
90 is_extended: std_ulogic;
91 is_modulus: std_ulogic;
92 rc: std_ulogic;
93 end record;
94 constant Decode2ToDividerInit: Decode2ToDividerType := (valid => '0', is_signed => '0', is_32bit => '0', is_extended => '0', is_modulus => '0', rc => '0', others => (others => '0'));
95
96 type Decode2ToRegisterFileType is record
97 read1_enable : std_ulogic;
98 read1_reg : std_ulogic_vector(4 downto 0);
99 read2_enable : std_ulogic;
100 read2_reg : std_ulogic_vector(4 downto 0);
101 read3_enable : std_ulogic;
102 read3_reg : std_ulogic_vector(4 downto 0);
103 end record;
104
105 type RegisterFileToDecode2Type is record
106 read1_data : std_ulogic_vector(63 downto 0);
107 read2_data : std_ulogic_vector(63 downto 0);
108 read3_data : std_ulogic_vector(63 downto 0);
109 end record;
110
111 type Decode2ToCrFileType is record
112 read : std_ulogic;
113 end record;
114
115 type CrFileToDecode2Type is record
116 read_cr_data : std_ulogic_vector(31 downto 0);
117 end record;
118
119 type Execute1ToFetch1Type is record
120 redirect: std_ulogic;
121 redirect_nia: std_ulogic_vector(63 downto 0);
122 end record;
123 constant Execute1ToFetch1TypeInit : Execute1ToFetch1Type := (redirect => '0', others => (others => '0'));
124
125 type Decode2ToLoadstore1Type is record
126 valid : std_ulogic;
127 load : std_ulogic; -- is this a load or store
128 addr1 : std_ulogic_vector(63 downto 0);
129 addr2 : std_ulogic_vector(63 downto 0);
130 data : std_ulogic_vector(63 downto 0); -- data to write, unused for read
131 write_reg : std_ulogic_vector(4 downto 0); -- read data goes to this register
132 length : std_ulogic_vector(3 downto 0);
133 byte_reverse : std_ulogic;
134 sign_extend : std_ulogic; -- do we need to sign extend?
135 update : std_ulogic; -- is this an update instruction?
136 update_reg : std_ulogic_vector(4 downto 0); -- if so, the register to update
137 end record;
138 constant Decode2ToLoadstore1Init : Decode2ToLoadstore1Type := (valid => '0', load => '0', byte_reverse => '0', sign_extend => '0', update => '0', others => (others => '0'));
139
140 type Loadstore1ToLoadstore2Type is record
141 valid : std_ulogic;
142 load : std_ulogic;
143 addr : std_ulogic_vector(63 downto 0);
144 data : std_ulogic_vector(63 downto 0);
145 write_reg : std_ulogic_vector(4 downto 0);
146 length : std_ulogic_vector(3 downto 0);
147 byte_reverse : std_ulogic;
148 sign_extend : std_ulogic;
149 update : std_ulogic;
150 update_reg : std_ulogic_vector(4 downto 0);
151 end record;
152
153 type Loadstore2ToWritebackType is record
154 valid : std_ulogic;
155 write_enable: std_ulogic;
156 write_reg : std_ulogic_vector(4 downto 0);
157 write_data : std_ulogic_vector(63 downto 0);
158 end record;
159 constant Loadstore2ToWritebackInit : Loadstore2ToWritebackType := (valid => '0', write_enable => '0', others => (others => '0'));
160
161 type Execute1ToExecute2Type is record
162 valid: std_ulogic;
163 write_enable : std_ulogic;
164 write_reg: std_ulogic_vector(4 downto 0);
165 write_data: std_ulogic_vector(63 downto 0);
166 write_cr_enable : std_ulogic;
167 write_cr_mask : std_ulogic_vector(7 downto 0);
168 write_cr_data : std_ulogic_vector(31 downto 0);
169 rc : std_ulogic;
170 end record;
171 constant Execute1ToExecute2Init : Execute1ToExecute2Type := (valid => '0', write_enable => '0', write_cr_enable => '0', rc => '0', others => (others => '0'));
172
173 type Execute2ToWritebackType is record
174 valid: std_ulogic;
175 write_enable : std_ulogic;
176 write_reg: std_ulogic_vector(4 downto 0);
177 write_data: std_ulogic_vector(63 downto 0);
178 write_cr_enable : std_ulogic;
179 write_cr_mask : std_ulogic_vector(7 downto 0);
180 write_cr_data : std_ulogic_vector(31 downto 0);
181 end record;
182 constant Execute2ToWritebackInit : Execute2ToWritebackType := (valid => '0', write_enable => '0', write_cr_enable => '0', others => (others => '0'));
183
184 type MultiplyToWritebackType is record
185 valid: std_ulogic;
186
187 write_reg_enable : std_ulogic;
188 write_reg_nr: std_ulogic_vector(4 downto 0);
189 write_reg_data: std_ulogic_vector(63 downto 0);
190 write_cr_enable: std_ulogic;
191 write_cr_mask: std_ulogic_vector(7 downto 0);
192 write_cr_data: std_ulogic_vector(31 downto 0);
193 end record;
194 constant MultiplyToWritebackInit : MultiplyToWritebackType := (valid => '0', write_reg_enable => '0', write_cr_enable => '0', others => (others => '0'));
195
196 type DividerToWritebackType is record
197 valid: std_ulogic;
198
199 write_reg_enable : std_ulogic;
200 write_reg_nr: std_ulogic_vector(4 downto 0);
201 write_reg_data: std_ulogic_vector(63 downto 0);
202 write_cr_enable: std_ulogic;
203 write_cr_mask: std_ulogic_vector(7 downto 0);
204 write_cr_data: std_ulogic_vector(31 downto 0);
205 end record;
206 constant DividerToWritebackInit : DividerToWritebackType := (valid => '0', write_reg_enable => '0', write_cr_enable => '0', others => (others => '0'));
207
208 type WritebackToRegisterFileType is record
209 write_reg : std_ulogic_vector(4 downto 0);
210 write_data : std_ulogic_vector(63 downto 0);
211 write_enable : std_ulogic;
212 end record;
213 constant WritebackToRegisterFileInit : WritebackToRegisterFileType := (write_enable => '0', others => (others => '0'));
214
215 type WritebackToCrFileType is record
216 write_cr_enable : std_ulogic;
217 write_cr_mask : std_ulogic_vector(7 downto 0);
218 write_cr_data : std_ulogic_vector(31 downto 0);
219 end record;
220 constant WritebackToCrFileInit : WritebackToCrFileType := (write_cr_enable => '0', others => (others => '0'));
221 end common;
222
223 package body common is
224 end common;