Add Tercel PHY reset synchronization
[microwatt.git] / execute1.vhdl
1 library ieee;
2 use ieee.std_logic_1164.all;
3 use ieee.numeric_std.all;
4
5 library work;
6 use work.decode_types.all;
7 use work.common.all;
8 use work.helpers.all;
9 use work.crhelpers.all;
10 use work.insn_helpers.all;
11 use work.ppc_fx_insns.all;
12
13 entity execute1 is
14 generic (
15 EX1_BYPASS : boolean := true;
16 HAS_FPU : boolean := true;
17 -- Non-zero to enable log data collection
18 LOG_LENGTH : natural := 0
19 );
20 port (
21 clk : in std_ulogic;
22 rst : in std_ulogic;
23
24 -- asynchronous
25 flush_in : in std_ulogic;
26 busy_out : out std_ulogic;
27
28 e_in : in Decode2ToExecute1Type;
29 l_in : in Loadstore1ToExecute1Type;
30 fp_in : in FPUToExecute1Type;
31
32 ext_irq_in : std_ulogic;
33 interrupt_in : std_ulogic;
34
35 -- asynchronous
36 l_out : out Execute1ToLoadstore1Type;
37 fp_out : out Execute1ToFPUType;
38
39 e_out : out Execute1ToWritebackType;
40 bypass_data : out bypass_data_t;
41 bypass_cr_data : out cr_bypass_data_t;
42
43 dbg_msr_out : out std_ulogic_vector(63 downto 0);
44
45 icache_inval : out std_ulogic;
46 terminate_out : out std_ulogic;
47
48 log_out : out std_ulogic_vector(14 downto 0);
49 log_rd_addr : out std_ulogic_vector(31 downto 0);
50 log_rd_data : in std_ulogic_vector(63 downto 0);
51 log_wr_addr : in std_ulogic_vector(31 downto 0)
52 );
53 end entity execute1;
54
55 architecture behaviour of execute1 is
56 type reg_type is record
57 e : Execute1ToWritebackType;
58 cur_instr : Decode2ToExecute1Type;
59 busy: std_ulogic;
60 terminate: std_ulogic;
61 fp_exception_next : std_ulogic;
62 trace_next : std_ulogic;
63 prev_op : insn_type_t;
64 br_taken : std_ulogic;
65 mul_in_progress : std_ulogic;
66 mul_finish : std_ulogic;
67 div_in_progress : std_ulogic;
68 cntz_in_progress : std_ulogic;
69 log_addr_spr : std_ulogic_vector(31 downto 0);
70 end record;
71 constant reg_type_init : reg_type :=
72 (e => Execute1ToWritebackInit,
73 cur_instr => Decode2ToExecute1Init,
74 busy => '0', terminate => '0',
75 fp_exception_next => '0', trace_next => '0', prev_op => OP_ILLEGAL, br_taken => '0',
76 mul_in_progress => '0', mul_finish => '0', div_in_progress => '0', cntz_in_progress => '0',
77 others => (others => '0'));
78
79 signal r, rin : reg_type;
80
81 signal a_in, b_in, c_in : std_ulogic_vector(63 downto 0);
82 signal cr_in : std_ulogic_vector(31 downto 0);
83 signal xerc_in : xer_common_t;
84
85 signal valid_in : std_ulogic;
86 signal ctrl: ctrl_t := (others => (others => '0'));
87 signal ctrl_tmp: ctrl_t := (others => (others => '0'));
88 signal right_shift, rot_clear_left, rot_clear_right: std_ulogic;
89 signal rot_sign_ext: std_ulogic;
90 signal rotator_result: std_ulogic_vector(63 downto 0);
91 signal rotator_carry: std_ulogic;
92 signal logical_result: std_ulogic_vector(63 downto 0);
93 signal countzero_result: std_ulogic_vector(63 downto 0);
94 signal alu_result: std_ulogic_vector(63 downto 0);
95 signal adder_result: std_ulogic_vector(63 downto 0);
96 signal misc_result: std_ulogic_vector(63 downto 0);
97 signal muldiv_result: std_ulogic_vector(63 downto 0);
98 signal spr_result: std_ulogic_vector(63 downto 0);
99 signal result_mux_sel: std_ulogic_vector(2 downto 0);
100 signal sub_mux_sel: std_ulogic_vector(2 downto 0);
101 signal next_nia : std_ulogic_vector(63 downto 0);
102 signal current: Decode2ToExecute1Type;
103
104 signal carry_32 : std_ulogic;
105 signal carry_64 : std_ulogic;
106 signal overflow_32 : std_ulogic;
107 signal overflow_64 : std_ulogic;
108
109 signal trapval : std_ulogic_vector(4 downto 0);
110
111 signal write_cr_mask : std_ulogic_vector(7 downto 0);
112 signal write_cr_data : std_ulogic_vector(31 downto 0);
113
114 -- multiply signals
115 signal x_to_multiply: MultiplyInputType;
116 signal multiply_to_x: MultiplyOutputType;
117
118 -- divider signals
119 signal x_to_divider: Execute1ToDividerType;
120 signal divider_to_x: DividerToExecute1Type;
121
122 -- random number generator signals
123 signal random_raw : std_ulogic_vector(63 downto 0);
124 signal random_cond : std_ulogic_vector(63 downto 0);
125 signal random_err : std_ulogic;
126
127 -- signals for logging
128 signal exception_log : std_ulogic;
129 signal irq_valid_log : std_ulogic;
130
131 type privilege_level is (USER, SUPER);
132 type op_privilege_array is array(insn_type_t) of privilege_level;
133 constant op_privilege: op_privilege_array := (
134 OP_ATTN => SUPER,
135 OP_MFMSR => SUPER,
136 OP_MTMSRD => SUPER,
137 OP_RFID => SUPER,
138 OP_TLBIE => SUPER,
139 others => USER
140 );
141
142 function instr_is_privileged(op: insn_type_t; insn: std_ulogic_vector(31 downto 0))
143 return boolean is
144 begin
145 if op_privilege(op) = SUPER then
146 return true;
147 elsif op = OP_MFSPR or op = OP_MTSPR then
148 return insn(20) = '1';
149 else
150 return false;
151 end if;
152 end;
153
154 procedure set_carry(e: inout Execute1ToWritebackType;
155 carry32 : in std_ulogic;
156 carry : in std_ulogic) is
157 begin
158 e.xerc.ca32 := carry32;
159 e.xerc.ca := carry;
160 end;
161
162 procedure set_ov(e: inout Execute1ToWritebackType;
163 ov : in std_ulogic;
164 ov32 : in std_ulogic) is
165 begin
166 e.xerc.ov32 := ov32;
167 e.xerc.ov := ov;
168 if ov = '1' then
169 e.xerc.so := '1';
170 end if;
171 end;
172
173 function calc_ov(msb_a : std_ulogic; msb_b: std_ulogic;
174 ca: std_ulogic; msb_r: std_ulogic) return std_ulogic is
175 begin
176 return (ca xor msb_r) and not (msb_a xor msb_b);
177 end;
178
179 function decode_input_carry(ic : carry_in_t;
180 xerc : xer_common_t) return std_ulogic is
181 begin
182 case ic is
183 when ZERO =>
184 return '0';
185 when CA =>
186 return xerc.ca;
187 when OV =>
188 return xerc.ov;
189 when ONE =>
190 return '1';
191 end case;
192 end;
193
194 function msr_copy(msr: std_ulogic_vector(63 downto 0))
195 return std_ulogic_vector is
196 variable msr_out: std_ulogic_vector(63 downto 0);
197 begin
198 -- ISA says this:
199 -- Defined MSR bits are classified as either full func-
200 -- tion or partial function. Full function MSR bits are
201 -- saved in SRR1 or HSRR1 when an interrupt other
202 -- than a System Call Vectored interrupt occurs and
203 -- restored by rfscv, rfid, or hrfid, while partial func-
204 -- tion MSR bits are not saved or restored.
205 -- Full function MSR bits lie in the range 0:32, 37:41, and
206 -- 48:63, and partial function MSR bits lie in the range
207 -- 33:36 and 42:47. (Note this is IBM bit numbering).
208 msr_out := (others => '0');
209 msr_out(63 downto 31) := msr(63 downto 31);
210 msr_out(26 downto 22) := msr(26 downto 22);
211 msr_out(15 downto 0) := msr(15 downto 0);
212 return msr_out;
213 end;
214
215 -- Tell vivado to keep the hierarchy for the random module so that the
216 -- net names in the xdc file match.
217 attribute keep_hierarchy : string;
218 attribute keep_hierarchy of random_0 : label is "yes";
219
220 begin
221
222 rotator_0: entity work.rotator
223 port map (
224 rs => c_in,
225 ra => a_in,
226 shift => b_in(6 downto 0),
227 insn => e_in.insn,
228 is_32bit => e_in.is_32bit,
229 right_shift => right_shift,
230 arith => e_in.is_signed,
231 clear_left => rot_clear_left,
232 clear_right => rot_clear_right,
233 sign_ext_rs => rot_sign_ext,
234 result => rotator_result,
235 carry_out => rotator_carry
236 );
237
238 logical_0: entity work.logical
239 port map (
240 rs => c_in,
241 rb => b_in,
242 op => e_in.insn_type,
243 invert_in => e_in.invert_a,
244 invert_out => e_in.invert_out,
245 result => logical_result,
246 datalen => e_in.data_len
247 );
248
249 countzero_0: entity work.zero_counter
250 port map (
251 clk => clk,
252 rs => c_in,
253 count_right => e_in.insn(10),
254 is_32bit => e_in.is_32bit,
255 result => countzero_result
256 );
257
258 multiply_0: entity work.multiply
259 port map (
260 clk => clk,
261 m_in => x_to_multiply,
262 m_out => multiply_to_x
263 );
264
265 divider_0: entity work.divider
266 port map (
267 clk => clk,
268 rst => rst,
269 d_in => x_to_divider,
270 d_out => divider_to_x
271 );
272
273 random_0: entity work.random
274 port map (
275 clk => clk,
276 data => random_cond,
277 raw => random_raw,
278 err => random_err
279 );
280
281 dbg_msr_out <= ctrl.msr;
282 log_rd_addr <= r.log_addr_spr;
283
284 a_in <= e_in.read_data1;
285 b_in <= e_in.read_data2;
286 c_in <= e_in.read_data3;
287 cr_in <= e_in.cr;
288
289 -- XER forwarding. To avoid having to track XER hazards, we use
290 -- the previously latched value. Since the XER common bits
291 -- (SO, OV[32] and CA[32]) are only modified by instructions that are
292 -- handled here, we can just forward the result being sent to
293 -- writeback.
294 xerc_in <= r.e.xerc when r.e.write_xerc_enable = '1' or r.busy = '1' else e_in.xerc;
295
296 with e_in.unit select busy_out <=
297 l_in.busy or r.busy or fp_in.busy when LDST,
298 l_in.busy or l_in.in_progress or r.busy or fp_in.busy when others;
299
300 valid_in <= e_in.valid and not busy_out and not flush_in;
301
302 terminate_out <= r.terminate;
303
304 current <= e_in when r.busy = '0' else r.cur_instr;
305
306 -- Result mux
307 with current.result_sel select alu_result <=
308 adder_result when "000",
309 logical_result when "001",
310 rotator_result when "010",
311 muldiv_result when "011",
312 countzero_result when "100",
313 spr_result when "101",
314 next_nia when "110",
315 misc_result when others;
316
317 execute1_0: process(clk)
318 begin
319 if rising_edge(clk) then
320 if rst = '1' then
321 r <= reg_type_init;
322 ctrl.tb <= (others => '0');
323 ctrl.dec <= (others => '0');
324 ctrl.msr <= (MSR_SF => '1', MSR_LE => '1', others => '0');
325 else
326 r <= rin;
327 ctrl <= ctrl_tmp;
328 if valid_in = '1' then
329 report "execute " & to_hstring(e_in.nia) & " op=" & insn_type_t'image(e_in.insn_type) &
330 " wr=" & to_hstring(rin.e.write_reg) & " we=" & std_ulogic'image(rin.e.write_enable) &
331 " tag=" & integer'image(rin.e.instr_tag.tag) & std_ulogic'image(rin.e.instr_tag.valid);
332 end if;
333 end if;
334 end if;
335 end process;
336
337 -- Data path for integer instructions
338 execute1_dp: process(all)
339 variable a_inv : std_ulogic_vector(63 downto 0);
340 variable b_or_m1 : std_ulogic_vector(63 downto 0);
341 variable sum_with_carry : std_ulogic_vector(64 downto 0);
342 variable sign1, sign2 : std_ulogic;
343 variable abs1, abs2 : signed(63 downto 0);
344 variable addend : std_ulogic_vector(127 downto 0);
345 variable addg6s : std_ulogic_vector(63 downto 0);
346 variable crbit : integer range 0 to 31;
347 variable isel_result : std_ulogic_vector(63 downto 0);
348 variable darn : std_ulogic_vector(63 downto 0);
349 variable setb_result : std_ulogic_vector(63 downto 0);
350 variable mfcr_result : std_ulogic_vector(63 downto 0);
351 variable lo, hi : integer;
352 variable l : std_ulogic;
353 variable zerohi, zerolo : std_ulogic;
354 variable msb_a, msb_b : std_ulogic;
355 variable a_lt : std_ulogic;
356 variable a_lt_lo : std_ulogic;
357 variable a_lt_hi : std_ulogic;
358 variable newcrf : std_ulogic_vector(3 downto 0);
359 variable bf, bfa : std_ulogic_vector(2 downto 0);
360 variable crnum : crnum_t;
361 variable scrnum : crnum_t;
362 variable cr_operands : std_ulogic_vector(1 downto 0);
363 variable crresult : std_ulogic;
364 variable bt, ba, bb : std_ulogic_vector(4 downto 0);
365 variable btnum : integer range 0 to 3;
366 variable banum, bbnum : integer range 0 to 31;
367 variable j : integer;
368 begin
369 -- Main adder
370 if e_in.invert_a = '0' then
371 a_inv := a_in;
372 else
373 a_inv := not a_in;
374 end if;
375 if e_in.addm1 = '0' then
376 b_or_m1 := b_in;
377 else
378 b_or_m1 := (others => '1');
379 end if;
380 sum_with_carry := ppc_adde(a_inv, b_or_m1,
381 decode_input_carry(e_in.input_carry, xerc_in));
382 adder_result <= sum_with_carry(63 downto 0);
383 carry_32 <= sum_with_carry(32) xor a_inv(32) xor b_in(32);
384 carry_64 <= sum_with_carry(64);
385 overflow_32 <= calc_ov(a_inv(31), b_in(31), carry_32, sum_with_carry(31));
386 overflow_64 <= calc_ov(a_inv(63), b_in(63), carry_64, sum_with_carry(63));
387
388 -- signals to multiply and divide units
389 sign1 := '0';
390 sign2 := '0';
391 if e_in.is_signed = '1' then
392 if e_in.is_32bit = '1' then
393 sign1 := a_in(31);
394 sign2 := b_in(31);
395 else
396 sign1 := a_in(63);
397 sign2 := b_in(63);
398 end if;
399 end if;
400 -- take absolute values
401 if sign1 = '0' then
402 abs1 := signed(a_in);
403 else
404 abs1 := - signed(a_in);
405 end if;
406 if sign2 = '0' then
407 abs2 := signed(b_in);
408 else
409 abs2 := - signed(b_in);
410 end if;
411
412 -- Interface to multiply and divide units
413 x_to_divider.is_signed <= e_in.is_signed;
414 x_to_divider.is_32bit <= e_in.is_32bit;
415 x_to_divider.is_extended <= '0';
416 x_to_divider.is_modulus <= '0';
417 if e_in.insn_type = OP_MOD then
418 x_to_divider.is_modulus <= '1';
419 end if;
420
421 addend := (others => '0');
422 if e_in.insn(26) = '0' then
423 -- integer multiply-add, major op 4 (if it is a multiply)
424 addend(63 downto 0) := c_in;
425 if e_in.is_signed = '1' then
426 addend(127 downto 64) := (others => c_in(63));
427 end if;
428 end if;
429 if (sign1 xor sign2) = '1' then
430 addend := not addend;
431 end if;
432
433 x_to_multiply.is_32bit <= e_in.is_32bit;
434 x_to_multiply.not_result <= sign1 xor sign2;
435 x_to_multiply.addend <= addend;
436 x_to_divider.neg_result <= sign1 xor (sign2 and not x_to_divider.is_modulus);
437 if e_in.is_32bit = '0' then
438 -- 64-bit forms
439 x_to_multiply.data1 <= std_ulogic_vector(abs1);
440 x_to_multiply.data2 <= std_ulogic_vector(abs2);
441 if e_in.insn_type = OP_DIVE then
442 x_to_divider.is_extended <= '1';
443 end if;
444 x_to_divider.dividend <= std_ulogic_vector(abs1);
445 x_to_divider.divisor <= std_ulogic_vector(abs2);
446 else
447 -- 32-bit forms
448 x_to_multiply.data1 <= x"00000000" & std_ulogic_vector(abs1(31 downto 0));
449 x_to_multiply.data2 <= x"00000000" & std_ulogic_vector(abs2(31 downto 0));
450 x_to_divider.is_extended <= '0';
451 if e_in.insn_type = OP_DIVE then -- extended forms
452 x_to_divider.dividend <= std_ulogic_vector(abs1(31 downto 0)) & x"00000000";
453 else
454 x_to_divider.dividend <= x"00000000" & std_ulogic_vector(abs1(31 downto 0));
455 end if;
456 x_to_divider.divisor <= x"00000000" & std_ulogic_vector(abs2(31 downto 0));
457 end if;
458
459 case current.sub_select(1 downto 0) is
460 when "00" =>
461 muldiv_result <= multiply_to_x.result(63 downto 0);
462 when "01" =>
463 muldiv_result <= multiply_to_x.result(127 downto 64);
464 when "10" =>
465 muldiv_result <= multiply_to_x.result(63 downto 32) &
466 multiply_to_x.result(63 downto 32);
467 when others =>
468 muldiv_result <= divider_to_x.write_reg_data;
469 end case;
470
471 -- Compute misc_result
472 case current.sub_select is
473 when "000" =>
474 misc_result <= (others => '0');
475 when "001" =>
476 -- addg6s
477 addg6s := (others => '0');
478 for i in 0 to 14 loop
479 lo := i * 4;
480 hi := (i + 1) * 4;
481 if (a_in(hi) xor b_in(hi) xor sum_with_carry(hi)) = '0' then
482 addg6s(lo + 3 downto lo) := "0110";
483 end if;
484 end loop;
485 if sum_with_carry(64) = '0' then
486 addg6s(63 downto 60) := "0110";
487 end if;
488 misc_result <= addg6s;
489 when "010" =>
490 -- isel
491 crbit := to_integer(unsigned(insn_bc(e_in.insn)));
492 if cr_in(31-crbit) = '1' then
493 isel_result := a_in;
494 else
495 isel_result := b_in;
496 end if;
497 misc_result <= isel_result;
498 when "011" =>
499 -- darn
500 darn := (others => '1');
501 if random_err = '0' then
502 case e_in.insn(17 downto 16) is
503 when "00" =>
504 darn := x"00000000" & random_cond(31 downto 0);
505 when "10" =>
506 darn := random_raw;
507 when others =>
508 darn := random_cond;
509 end case;
510 end if;
511 misc_result <= darn;
512 when "100" =>
513 -- mfmsr
514 misc_result <= ctrl.msr;
515 when "101" =>
516 if e_in.insn(20) = '0' then
517 -- mfcr
518 mfcr_result := x"00000000" & cr_in;
519 else
520 -- mfocrf
521 crnum := fxm_to_num(insn_fxm(e_in.insn));
522 mfcr_result := (others => '0');
523 for i in 0 to 7 loop
524 lo := (7-i)*4;
525 hi := lo + 3;
526 if crnum = i then
527 mfcr_result(hi downto lo) := cr_in(hi downto lo);
528 end if;
529 end loop;
530 end if;
531 misc_result <= mfcr_result;
532 when "110" =>
533 -- setb
534 bfa := insn_bfa(e_in.insn);
535 crbit := to_integer(unsigned(bfa)) * 4;
536 setb_result := (others => '0');
537 if cr_in(31 - crbit) = '1' then
538 setb_result := (others => '1');
539 elsif cr_in(30 - crbit) = '1' then
540 setb_result(0) := '1';
541 end if;
542 misc_result <= setb_result;
543 when others =>
544 misc_result <= (others => '0');
545 end case;
546
547 -- compute comparison results
548 -- Note, we have done RB - RA, not RA - RB
549 if e_in.insn_type = OP_CMP then
550 l := insn_l(e_in.insn);
551 else
552 l := not e_in.is_32bit;
553 end if;
554 zerolo := not (or (a_in(31 downto 0) xor b_in(31 downto 0)));
555 zerohi := not (or (a_in(63 downto 32) xor b_in(63 downto 32)));
556 if zerolo = '1' and (l = '0' or zerohi = '1') then
557 -- values are equal
558 trapval <= "00100";
559 else
560 a_lt_lo := '0';
561 a_lt_hi := '0';
562 if unsigned(a_in(30 downto 0)) < unsigned(b_in(30 downto 0)) then
563 a_lt_lo := '1';
564 end if;
565 if unsigned(a_in(62 downto 31)) < unsigned(b_in(62 downto 31)) then
566 a_lt_hi := '1';
567 end if;
568 if l = '1' then
569 -- 64-bit comparison
570 msb_a := a_in(63);
571 msb_b := b_in(63);
572 a_lt := a_lt_hi or (zerohi and (a_in(31) xnor b_in(31)) and a_lt_lo);
573 else
574 -- 32-bit comparison
575 msb_a := a_in(31);
576 msb_b := b_in(31);
577 a_lt := a_lt_lo;
578 end if;
579 if msb_a /= msb_b then
580 -- Comparison is clear from MSB difference.
581 -- for signed, 0 is greater; for unsigned, 1 is greater
582 trapval <= msb_a & msb_b & '0' & msb_b & msb_a;
583 else
584 -- MSBs are equal, so signed and unsigned comparisons give the
585 -- same answer.
586 trapval <= a_lt & not a_lt & '0' & a_lt & not a_lt;
587 end if;
588 end if;
589
590 -- CR result mux
591 bf := insn_bf(e_in.insn);
592 crnum := to_integer(unsigned(bf));
593 newcrf := (others => '0');
594 case current.sub_select is
595 when "000" =>
596 -- CMP and CMPL instructions
597 if e_in.is_signed = '1' then
598 newcrf := trapval(4 downto 2) & xerc_in.so;
599 else
600 newcrf := trapval(1 downto 0) & trapval(2) & xerc_in.so;
601 end if;
602 when "001" =>
603 newcrf := ppc_cmprb(a_in, b_in, insn_l(e_in.insn));
604 when "010" =>
605 newcrf := ppc_cmpeqb(a_in, b_in);
606 when "011" =>
607 if current.insn(1) = '1' then
608 -- CR logical instructions
609 j := (7 - crnum) * 4;
610 newcrf := cr_in(j + 3 downto j);
611 bt := insn_bt(e_in.insn);
612 ba := insn_ba(e_in.insn);
613 bb := insn_bb(e_in.insn);
614 btnum := 3 - to_integer(unsigned(bt(1 downto 0)));
615 banum := 31 - to_integer(unsigned(ba));
616 bbnum := 31 - to_integer(unsigned(bb));
617 -- Bits 6-9 of the instruction word give the truth table
618 -- of the requested logical operation
619 cr_operands := cr_in(banum) & cr_in(bbnum);
620 crresult := e_in.insn(6 + to_integer(unsigned(cr_operands)));
621 for i in 0 to 3 loop
622 if i = btnum then
623 newcrf(i) := crresult;
624 end if;
625 end loop;
626 else
627 -- MCRF
628 bfa := insn_bfa(e_in.insn);
629 scrnum := to_integer(unsigned(bfa));
630 j := (7 - scrnum) * 4;
631 newcrf := cr_in(j + 3 downto j);
632 end if;
633 when "100" =>
634 -- MCRXRX
635 newcrf := xerc_in.ov & xerc_in.ca & xerc_in.ov32 & xerc_in.ca32;
636 when others =>
637 end case;
638 if current.insn_type = OP_MTCRF then
639 if e_in.insn(20) = '0' then
640 -- mtcrf
641 write_cr_mask <= insn_fxm(e_in.insn);
642 else
643 -- mtocrf: We require one hot priority encoding here
644 crnum := fxm_to_num(insn_fxm(e_in.insn));
645 write_cr_mask <= num_to_fxm(crnum);
646 end if;
647 write_cr_data <= c_in(31 downto 0);
648 else
649 write_cr_mask <= num_to_fxm(crnum);
650 write_cr_data <= newcrf & newcrf & newcrf & newcrf &
651 newcrf & newcrf & newcrf & newcrf;
652 end if;
653
654 end process;
655
656 execute1_1: process(all)
657 variable v : reg_type;
658 variable lo, hi : integer;
659 variable sh, mb, me : std_ulogic_vector(5 downto 0);
660 variable bo, bi : std_ulogic_vector(4 downto 0);
661 variable overflow : std_ulogic;
662 variable lv : Execute1ToLoadstore1Type;
663 variable irq_valid : std_ulogic;
664 variable exception : std_ulogic;
665 variable illegal : std_ulogic;
666 variable is_branch : std_ulogic;
667 variable is_direct_branch : std_ulogic;
668 variable taken_branch : std_ulogic;
669 variable abs_branch : std_ulogic;
670 variable spr_val : std_ulogic_vector(63 downto 0);
671 variable do_trace : std_ulogic;
672 variable hold_wr_data : std_ulogic;
673 variable fv : Execute1ToFPUType;
674 begin
675 is_branch := '0';
676 is_direct_branch := '0';
677 taken_branch := '0';
678 abs_branch := '0';
679 hold_wr_data := '0';
680
681 v := r;
682 v.e := Execute1ToWritebackInit;
683 v.e.redir_mode := ctrl.msr(MSR_IR) & not ctrl.msr(MSR_PR) &
684 not ctrl.msr(MSR_LE) & not ctrl.msr(MSR_SF);
685 v.e.xerc := xerc_in;
686
687 lv := Execute1ToLoadstore1Init;
688 fv := Execute1ToFPUInit;
689
690 x_to_multiply.valid <= '0';
691 x_to_divider.valid <= '0';
692 v.mul_in_progress := '0';
693 v.div_in_progress := '0';
694 v.cntz_in_progress := '0';
695 v.mul_finish := '0';
696
697 spr_result <= (others => '0');
698 spr_val := (others => '0');
699
700 ctrl_tmp <= ctrl;
701 -- FIXME: run at 512MHz not core freq
702 ctrl_tmp.tb <= std_ulogic_vector(unsigned(ctrl.tb) + 1);
703 ctrl_tmp.dec <= std_ulogic_vector(unsigned(ctrl.dec) - 1);
704
705 irq_valid := '0';
706 if ctrl.msr(MSR_EE) = '1' then
707 if ctrl.dec(63) = '1' then
708 v.e.intr_vec := 16#900#;
709 report "IRQ valid: DEC";
710 irq_valid := '1';
711 elsif ext_irq_in = '1' then
712 v.e.intr_vec := 16#500#;
713 report "IRQ valid: External";
714 irq_valid := '1';
715 end if;
716 end if;
717
718 v.terminate := '0';
719 icache_inval <= '0';
720 v.busy := '0';
721
722 -- Next insn adder used in a couple of places
723 next_nia <= std_ulogic_vector(unsigned(e_in.nia) + 4);
724
725 -- rotator control signals
726 right_shift <= '1' when e_in.insn_type = OP_SHR else '0';
727 rot_clear_left <= '1' when e_in.insn_type = OP_RLC or e_in.insn_type = OP_RLCL else '0';
728 rot_clear_right <= '1' when e_in.insn_type = OP_RLC or e_in.insn_type = OP_RLCR else '0';
729 rot_sign_ext <= '1' when e_in.insn_type = OP_EXTSWSLI else '0';
730
731 v.e.srr1 := (others => '0');
732 exception := '0';
733 illegal := '0';
734 if valid_in = '1' then
735 v.e.last_nia := e_in.nia;
736 else
737 v.e.last_nia := r.e.last_nia;
738 end if;
739
740 v.e.mode_32bit := not ctrl.msr(MSR_SF);
741 v.e.instr_tag := current.instr_tag;
742
743 do_trace := valid_in and ctrl.msr(MSR_SE);
744 if valid_in = '1' then
745 v.prev_op := e_in.insn_type;
746 end if;
747
748 -- Determine if there is any exception to be taken
749 -- before/instead of executing this instruction
750 if valid_in = '1' and e_in.second = '0' and l_in.in_progress = '0' then
751 if HAS_FPU and r.fp_exception_next = '1' then
752 -- This is used for FP-type program interrupts that
753 -- become pending due to MSR[FE0,FE1] changing from 00 to non-zero.
754 exception := '1';
755 v.e.intr_vec := 16#700#;
756 v.e.srr1(47 - 43) := '1';
757 v.e.srr1(47 - 47) := '1';
758 elsif r.trace_next = '1' then
759 -- Generate a trace interrupt rather than executing the next instruction
760 -- or taking any asynchronous interrupt
761 exception := '1';
762 v.e.intr_vec := 16#d00#;
763 v.e.srr1(47 - 33) := '1';
764 if r.prev_op = OP_LOAD or r.prev_op = OP_ICBI or r.prev_op = OP_ICBT or
765 r.prev_op = OP_DCBT or r.prev_op = OP_DCBST or r.prev_op = OP_DCBF then
766 v.e.srr1(47 - 35) := '1';
767 elsif r.prev_op = OP_STORE or r.prev_op = OP_DCBZ or r.prev_op = OP_DCBTST then
768 v.e.srr1(47 - 36) := '1';
769 end if;
770
771 elsif irq_valid = '1' then
772 -- Don't deliver the interrupt until we have a valid instruction
773 -- coming in, so we have a valid NIA to put in SRR0.
774 exception := '1';
775
776 elsif ctrl.msr(MSR_PR) = '1' and instr_is_privileged(e_in.insn_type, e_in.insn) then
777 -- generate a program interrupt
778 exception := '1';
779 v.e.intr_vec := 16#700#;
780 -- set bit 45 to indicate privileged instruction type interrupt
781 v.e.srr1(47 - 45) := '1';
782 report "privileged instruction";
783
784 elsif not HAS_FPU and e_in.fac = FPU then
785 -- make lfd/stfd/lfs/stfs etc. illegal in no-FPU implementations
786 illegal := '1';
787
788 elsif HAS_FPU and ctrl.msr(MSR_FP) = '0' and e_in.fac = FPU then
789 -- generate a floating-point unavailable interrupt
790 exception := '1';
791 v.e.intr_vec := 16#800#;
792 report "FP unavailable interrupt";
793 end if;
794 end if;
795
796 if valid_in = '1' and exception = '0' and illegal = '0' and e_in.unit = ALU then
797 v.cur_instr := e_in;
798 v.e.valid := '1';
799
800 case_0: case e_in.insn_type is
801
802 when OP_ILLEGAL =>
803 -- we need two cycles to write srr0 and 1
804 -- will need more when we have to write HEIR
805 illegal := '1';
806 when OP_SC =>
807 -- check bit 1 of the instruction is 1 so we know this is sc;
808 -- 0 would mean scv, so generate an illegal instruction interrupt
809 -- we need two cycles to write srr0 and 1
810 if e_in.insn(1) = '1' then
811 exception := '1';
812 v.e.intr_vec := 16#C00#;
813 v.e.last_nia := next_nia;
814 report "sc";
815 else
816 illegal := '1';
817 end if;
818 when OP_ATTN =>
819 -- check bits 1-10 of the instruction to make sure it's attn
820 -- if not then it is illegal
821 if e_in.insn(10 downto 1) = "0100000000" then
822 v.terminate := '1';
823 report "ATTN";
824 else
825 illegal := '1';
826 end if;
827 when OP_NOP | OP_DCBF | OP_DCBST | OP_DCBT | OP_DCBTST | OP_ICBT =>
828 -- Do nothing
829 when OP_ADD =>
830 if e_in.output_carry = '1' then
831 if e_in.input_carry /= OV then
832 set_carry(v.e, carry_32, carry_64);
833 else
834 v.e.xerc.ov := carry_64;
835 v.e.xerc.ov32 := carry_32;
836 end if;
837 end if;
838 if e_in.oe = '1' then
839 set_ov(v.e, overflow_64, overflow_32);
840 end if;
841 when OP_CMP =>
842 when OP_TRAP =>
843 -- trap instructions (tw, twi, td, tdi)
844 v.e.intr_vec := 16#700#;
845 -- set bit 46 to say trap occurred
846 v.e.srr1(47 - 46) := '1';
847 if or (trapval and insn_to(e_in.insn)) = '1' then
848 -- generate trap-type program interrupt
849 exception := '1';
850 report "trap";
851 end if;
852 when OP_ADDG6S =>
853 when OP_CMPRB =>
854 when OP_CMPEQB =>
855 when OP_AND | OP_OR | OP_XOR | OP_POPCNT | OP_PRTY | OP_CMPB | OP_EXTS |
856 OP_BPERM | OP_BCD =>
857
858 when OP_B =>
859 is_branch := '1';
860 taken_branch := '1';
861 is_direct_branch := '1';
862 abs_branch := e_in.br_abs;
863 if ctrl.msr(MSR_BE) = '1' then
864 do_trace := '1';
865 end if;
866 when OP_BC | OP_BCREG =>
867 -- read_data1 is CTR
868 -- for OP_BCREG, read_data2 is target register (CTR, LR or TAR)
869 -- If this instruction updates both CTR and LR, then it is
870 -- doubled; the first instruction decrements CTR and determines
871 -- whether the branch is taken, and the second does the
872 -- redirect and the LR update.
873 bo := insn_bo(e_in.insn);
874 bi := insn_bi(e_in.insn);
875 if e_in.second = '0' then
876 taken_branch := ppc_bc_taken(bo, bi, cr_in, a_in);
877 else
878 taken_branch := r.br_taken;
879 end if;
880 v.br_taken := taken_branch;
881 abs_branch := e_in.br_abs;
882 if e_in.repeat = '0' or e_in.second = '1' then
883 is_branch := '1';
884 if e_in.insn_type = OP_BC then
885 is_direct_branch := '1';
886 end if;
887 if ctrl.msr(MSR_BE) = '1' then
888 do_trace := '1';
889 end if;
890 end if;
891
892 when OP_RFID =>
893 v.e.redir_mode := (a_in(MSR_IR) or a_in(MSR_PR)) & not a_in(MSR_PR) &
894 not a_in(MSR_LE) & not a_in(MSR_SF);
895 -- Can't use msr_copy here because the partial function MSR
896 -- bits should be left unchanged, not zeroed.
897 ctrl_tmp.msr(63 downto 31) <= a_in(63 downto 31);
898 ctrl_tmp.msr(26 downto 22) <= a_in(26 downto 22);
899 ctrl_tmp.msr(15 downto 0) <= a_in(15 downto 0);
900 if a_in(MSR_PR) = '1' then
901 ctrl_tmp.msr(MSR_EE) <= '1';
902 ctrl_tmp.msr(MSR_IR) <= '1';
903 ctrl_tmp.msr(MSR_DR) <= '1';
904 end if;
905 -- mark this as a branch so CFAR gets updated
906 is_branch := '1';
907 taken_branch := '1';
908 abs_branch := '1';
909 if HAS_FPU then
910 v.fp_exception_next := fp_in.exception and
911 (a_in(MSR_FE0) or a_in(MSR_FE1));
912 end if;
913 do_trace := '0';
914
915 when OP_CNTZ =>
916 v.e.valid := '0';
917 v.cntz_in_progress := '1';
918 v.busy := '1';
919 when OP_ISEL =>
920 when OP_CROP =>
921 when OP_MCRXRX =>
922 when OP_DARN =>
923 when OP_MFMSR =>
924 when OP_MFSPR =>
925 report "MFSPR to SPR " & integer'image(decode_spr_num(e_in.insn)) &
926 "=" & to_hstring(a_in);
927 if is_fast_spr(e_in.read_reg1) = '1' then
928 spr_val := a_in;
929 if decode_spr_num(e_in.insn) = SPR_XER then
930 -- bits 0:31 and 35:43 are treated as reserved and return 0s when read using mfxer
931 spr_val(63 downto 32) := (others => '0');
932 spr_val(63-32) := xerc_in.so;
933 spr_val(63-33) := xerc_in.ov;
934 spr_val(63-34) := xerc_in.ca;
935 spr_val(63-35 downto 63-43) := "000000000";
936 spr_val(63-44) := xerc_in.ov32;
937 spr_val(63-45) := xerc_in.ca32;
938 end if;
939 else
940 spr_val := c_in;
941 case decode_spr_num(e_in.insn) is
942 when SPR_TB =>
943 spr_val := ctrl.tb;
944 when SPR_TBU =>
945 spr_val(63 downto 32) := (others => '0');
946 spr_val(31 downto 0) := ctrl.tb(63 downto 32);
947 when SPR_DEC =>
948 spr_val := ctrl.dec;
949 when SPR_CFAR =>
950 spr_val := ctrl.cfar;
951 when SPR_PVR =>
952 spr_val(63 downto 32) := (others => '0');
953 spr_val(31 downto 0) := PVR_MICROWATT;
954 when 724 => -- LOG_ADDR SPR
955 spr_val := log_wr_addr & r.log_addr_spr;
956 when 725 => -- LOG_DATA SPR
957 spr_val := log_rd_data;
958 v.log_addr_spr := std_ulogic_vector(unsigned(r.log_addr_spr) + 1);
959 when others =>
960 -- mfspr from unimplemented SPRs should be a nop in
961 -- supervisor mode and a program interrupt for user mode
962 if is_fast_spr(e_in.read_reg1) = '0' and ctrl.msr(MSR_PR) = '1' then
963 illegal := '1';
964 end if;
965 end case;
966 end if;
967 spr_result <= spr_val;
968
969 when OP_MFCR =>
970 when OP_MTCRF =>
971 when OP_MTMSRD =>
972 if e_in.insn(16) = '1' then
973 -- just update EE and RI
974 ctrl_tmp.msr(MSR_EE) <= c_in(MSR_EE);
975 ctrl_tmp.msr(MSR_RI) <= c_in(MSR_RI);
976 else
977 -- Architecture says to leave out bits 3 (HV), 51 (ME)
978 -- and 63 (LE) (IBM bit numbering)
979 if e_in.is_32bit = '0' then
980 ctrl_tmp.msr(63 downto 61) <= c_in(63 downto 61);
981 ctrl_tmp.msr(59 downto 32) <= c_in(59 downto 32);
982 end if;
983 ctrl_tmp.msr(31 downto 13) <= c_in(31 downto 13);
984 ctrl_tmp.msr(11 downto 1) <= c_in(11 downto 1);
985 if c_in(MSR_PR) = '1' then
986 ctrl_tmp.msr(MSR_EE) <= '1';
987 ctrl_tmp.msr(MSR_IR) <= '1';
988 ctrl_tmp.msr(MSR_DR) <= '1';
989 end if;
990 if HAS_FPU then
991 v.fp_exception_next := fp_in.exception and
992 (c_in(MSR_FE0) or c_in(MSR_FE1));
993 end if;
994 end if;
995 when OP_MTSPR =>
996 report "MTSPR to SPR " & integer'image(decode_spr_num(e_in.insn)) &
997 "=" & to_hstring(c_in);
998 if is_fast_spr(e_in.write_reg) then
999 if decode_spr_num(e_in.insn) = SPR_XER then
1000 v.e.xerc.so := c_in(63-32);
1001 v.e.xerc.ov := c_in(63-33);
1002 v.e.xerc.ca := c_in(63-34);
1003 v.e.xerc.ov32 := c_in(63-44);
1004 v.e.xerc.ca32 := c_in(63-45);
1005 end if;
1006 else
1007 -- slow spr
1008 case decode_spr_num(e_in.insn) is
1009 when SPR_DEC =>
1010 ctrl_tmp.dec <= c_in;
1011 when 724 => -- LOG_ADDR SPR
1012 v.log_addr_spr := c_in(31 downto 0);
1013 when others =>
1014 -- mtspr to unimplemented SPRs should be a nop in
1015 -- supervisor mode and a program interrupt for user mode
1016 if ctrl.msr(MSR_PR) = '1' then
1017 illegal := '1';
1018 end if;
1019 end case;
1020 end if;
1021 when OP_RLC | OP_RLCL | OP_RLCR | OP_SHL | OP_SHR | OP_EXTSWSLI =>
1022 if e_in.output_carry = '1' then
1023 set_carry(v.e, rotator_carry, rotator_carry);
1024 end if;
1025 when OP_SETB =>
1026
1027 when OP_ISYNC =>
1028 v.e.redirect := '1';
1029 v.e.br_offset := std_ulogic_vector(to_unsigned(4, 64));
1030
1031 when OP_ICBI =>
1032 icache_inval <= '1';
1033
1034 when OP_MUL_L64 | OP_MUL_H64 | OP_MUL_H32 =>
1035 v.e.valid := '0';
1036 v.mul_in_progress := '1';
1037 v.busy := '1';
1038 x_to_multiply.valid <= '1';
1039
1040 when OP_DIV | OP_DIVE | OP_MOD =>
1041 v.e.valid := '0';
1042 v.div_in_progress := '1';
1043 v.busy := '1';
1044 x_to_divider.valid <= '1';
1045
1046 when others =>
1047 v.terminate := '1';
1048 report "illegal";
1049 end case;
1050
1051 -- Mispredicted branches cause a redirect
1052 if is_branch = '1' then
1053 if taken_branch = '1' then
1054 ctrl_tmp.cfar <= e_in.nia;
1055 end if;
1056 if taken_branch = '1' then
1057 v.e.br_offset := b_in;
1058 v.e.abs_br := abs_branch;
1059 else
1060 v.e.br_offset := std_ulogic_vector(to_unsigned(4, 64));
1061 end if;
1062 if taken_branch /= e_in.br_pred then
1063 v.e.redirect := '1';
1064 end if;
1065 v.e.br_last := is_direct_branch;
1066 v.e.br_taken := taken_branch;
1067 end if;
1068
1069 elsif valid_in = '1' and exception = '0' and illegal = '0' then
1070 -- instruction for other units, i.e. LDST
1071 if e_in.unit = LDST then
1072 lv.valid := '1';
1073 elsif e_in.unit = NONE then
1074 illegal := '1';
1075 elsif HAS_FPU and e_in.unit = FPU then
1076 fv.valid := '1';
1077 end if;
1078 -- Handling an ITLB miss doesn't count as having executed an instruction
1079 if e_in.insn_type = OP_FETCH_FAILED then
1080 do_trace := '0';
1081 end if;
1082 end if;
1083
1084 -- The following cases all occur when r.busy = 1 and therefore
1085 -- valid_in = 0. Hence they don't happen in the same cycle as any of
1086 -- the cases above which depend on valid_in = 1.
1087 if r.cntz_in_progress = '1' then
1088 -- cnt[lt]z always takes two cycles
1089 v.e.valid := '1';
1090 elsif r.mul_in_progress = '1' or r.div_in_progress = '1' then
1091 if (r.mul_in_progress = '1' and multiply_to_x.valid = '1') or
1092 (r.div_in_progress = '1' and divider_to_x.valid = '1') then
1093 if r.mul_in_progress = '1' then
1094 overflow := '0';
1095 else
1096 overflow := divider_to_x.overflow;
1097 end if;
1098 if r.mul_in_progress = '1' and current.oe = '1' then
1099 -- have to wait until next cycle for overflow indication
1100 v.mul_finish := '1';
1101 v.busy := '1';
1102 else
1103 -- We must test oe because the RC update code in writeback
1104 -- will use the xerc value to set CR0:SO so we must not clobber
1105 -- xerc if OE wasn't set.
1106 if current.oe = '1' then
1107 v.e.xerc.ov := overflow;
1108 v.e.xerc.ov32 := overflow;
1109 if overflow = '1' then
1110 v.e.xerc.so := '1';
1111 end if;
1112 end if;
1113 v.e.valid := '1';
1114 end if;
1115 else
1116 v.busy := '1';
1117 v.mul_in_progress := r.mul_in_progress;
1118 v.div_in_progress := r.div_in_progress;
1119 end if;
1120 elsif r.mul_finish = '1' then
1121 hold_wr_data := '1';
1122 v.e.xerc.ov := multiply_to_x.overflow;
1123 v.e.xerc.ov32 := multiply_to_x.overflow;
1124 if multiply_to_x.overflow = '1' then
1125 v.e.xerc.so := '1';
1126 end if;
1127 v.e.valid := '1';
1128 end if;
1129
1130 if illegal = '1' then
1131 exception := '1';
1132 v.e.intr_vec := 16#700#;
1133 -- Since we aren't doing Hypervisor emulation assist (0xe40) we
1134 -- set bit 44 to indicate we have an illegal
1135 v.e.srr1(47 - 44) := '1';
1136 report "illegal";
1137 end if;
1138
1139 v.e.interrupt := exception;
1140
1141 if do_trace = '1' then
1142 v.trace_next := '1';
1143 end if;
1144
1145 if interrupt_in = '1' then
1146 ctrl_tmp.msr(MSR_SF) <= '1';
1147 ctrl_tmp.msr(MSR_EE) <= '0';
1148 ctrl_tmp.msr(MSR_PR) <= '0';
1149 ctrl_tmp.msr(MSR_SE) <= '0';
1150 ctrl_tmp.msr(MSR_BE) <= '0';
1151 ctrl_tmp.msr(MSR_FP) <= '0';
1152 ctrl_tmp.msr(MSR_FE0) <= '0';
1153 ctrl_tmp.msr(MSR_FE1) <= '0';
1154 ctrl_tmp.msr(MSR_IR) <= '0';
1155 ctrl_tmp.msr(MSR_DR) <= '0';
1156 ctrl_tmp.msr(MSR_RI) <= '0';
1157 ctrl_tmp.msr(MSR_LE) <= '1';
1158 v.trace_next := '0';
1159 v.fp_exception_next := '0';
1160 end if;
1161
1162 if hold_wr_data = '0' then
1163 v.e.write_data := alu_result;
1164 else
1165 v.e.write_data := r.e.write_data;
1166 end if;
1167 v.e.write_reg := current.write_reg;
1168 v.e.write_enable := current.write_reg_enable and v.e.valid and not exception;
1169 v.e.rc := current.rc and v.e.valid and not exception;
1170 v.e.write_cr_data := write_cr_data;
1171 v.e.write_cr_mask := write_cr_mask;
1172 v.e.write_cr_enable := current.output_cr and v.e.valid and not exception;
1173 v.e.write_xerc_enable := current.output_xer and v.e.valid and not exception;
1174
1175 bypass_data.tag.valid <= current.instr_tag.valid and current.write_reg_enable and v.e.valid;
1176 bypass_data.tag.tag <= current.instr_tag.tag;
1177 bypass_data.data <= v.e.write_data;
1178
1179 bypass_cr_data.tag.valid <= current.instr_tag.valid and current.output_cr and v.e.valid;
1180 bypass_cr_data.tag.tag <= current.instr_tag.tag;
1181 for i in 0 to 7 loop
1182 if v.e.write_cr_mask(i) = '1' then
1183 bypass_cr_data.data(i*4 + 3 downto i*4) <= v.e.write_cr_data(i*4 + 3 downto i*4);
1184 else
1185 bypass_cr_data.data(i*4 + 3 downto i*4) <= cr_in(i*4 + 3 downto i*4);
1186 end if;
1187 end loop;
1188
1189 -- Outputs to loadstore1 (async)
1190 lv.op := e_in.insn_type;
1191 lv.nia := e_in.nia;
1192 lv.instr_tag := e_in.instr_tag;
1193 lv.addr1 := a_in;
1194 lv.addr2 := b_in;
1195 lv.data := c_in;
1196 lv.write_reg := e_in.write_reg;
1197 lv.length := e_in.data_len;
1198 lv.byte_reverse := e_in.byte_reverse xnor ctrl.msr(MSR_LE);
1199 lv.sign_extend := e_in.sign_extend;
1200 lv.update := e_in.update;
1201 lv.xerc := xerc_in;
1202 lv.reserve := e_in.reserve;
1203 lv.rc := e_in.rc;
1204 lv.insn := e_in.insn;
1205 -- decode l*cix and st*cix instructions here
1206 if e_in.insn(31 downto 26) = "011111" and e_in.insn(10 downto 9) = "11" and
1207 e_in.insn(5 downto 1) = "10101" then
1208 lv.ci := '1';
1209 end if;
1210 lv.virt_mode := ctrl.msr(MSR_DR);
1211 lv.priv_mode := not ctrl.msr(MSR_PR);
1212 lv.mode_32bit := not ctrl.msr(MSR_SF);
1213 lv.is_32bit := e_in.is_32bit;
1214 lv.repeat := e_in.repeat;
1215 lv.second := e_in.second;
1216
1217 -- Outputs to FPU
1218 fv.op := e_in.insn_type;
1219 fv.nia := e_in.nia;
1220 fv.insn := e_in.insn;
1221 fv.itag := e_in.instr_tag;
1222 fv.single := e_in.is_32bit;
1223 fv.fe_mode := ctrl.msr(MSR_FE0) & ctrl.msr(MSR_FE1);
1224 fv.fra := a_in;
1225 fv.frb := b_in;
1226 fv.frc := c_in;
1227 fv.frt := e_in.write_reg;
1228 fv.rc := e_in.rc;
1229 fv.out_cr := e_in.output_cr;
1230
1231 -- Update registers
1232 rin <= v;
1233
1234 -- update outputs
1235 l_out <= lv;
1236 e_out <= r.e;
1237 e_out.msr <= msr_copy(ctrl.msr);
1238 fp_out <= fv;
1239
1240 exception_log <= exception;
1241 irq_valid_log <= irq_valid;
1242 end process;
1243
1244 e1_log: if LOG_LENGTH > 0 generate
1245 signal log_data : std_ulogic_vector(14 downto 0);
1246 begin
1247 ex1_log : process(clk)
1248 begin
1249 if rising_edge(clk) then
1250 log_data <= ctrl.msr(MSR_EE) & ctrl.msr(MSR_PR) &
1251 ctrl.msr(MSR_IR) & ctrl.msr(MSR_DR) &
1252 exception_log &
1253 irq_valid_log &
1254 interrupt_in &
1255 "000" &
1256 r.e.write_enable &
1257 r.e.valid &
1258 (r.e.redirect or r.e.interrupt) &
1259 r.busy &
1260 flush_in;
1261 end if;
1262 end process;
1263 log_out <= log_data;
1264 end generate;
1265 end architecture behaviour;