2 use ieee.std_logic_1164.all;
3 use ieee.numeric_std.all;
7 use work.crhelpers.all;
13 e_in : in Execute1ToWritebackType;
14 l_in : in Loadstore1ToWritebackType;
16 w_out : out WritebackToRegisterFileType;
17 c_out : out WritebackToCrFileType;
19 complete_out : out std_ulogic
23 architecture behaviour of writeback is
25 writeback_1: process(all)
26 variable x : std_ulogic_vector(0 downto 0);
27 variable y : std_ulogic_vector(0 downto 0);
28 variable w : std_ulogic_vector(0 downto 0);
29 variable cf: std_ulogic_vector(3 downto 0);
30 variable zero : std_ulogic;
31 variable sign : std_ulogic;
32 variable scf : std_ulogic_vector(3 downto 0);
36 assert (to_integer(unsigned(x)) + to_integer(unsigned(y))) <= 1 severity failure;
38 x(0) := e_in.write_enable or e_in.exc_write_enable;
39 y(0) := l_in.write_enable;
40 assert (to_integer(unsigned(x)) + to_integer(unsigned(y))) <= 1 severity failure;
42 w(0) := e_in.write_cr_enable;
43 x(0) := (e_in.write_enable and e_in.rc);
44 assert (to_integer(unsigned(w)) + to_integer(unsigned(x))) <= 1 severity failure;
46 w_out <= WritebackToRegisterFileInit;
47 c_out <= WritebackToCrFileInit;
50 if e_in.valid = '1' or l_in.valid = '1' then
54 if e_in.exc_write_enable = '1' then
55 w_out.write_reg <= e_in.exc_write_reg;
56 w_out.write_data <= e_in.exc_write_data;
57 w_out.write_enable <= '1';
59 if e_in.write_enable = '1' then
60 w_out.write_reg <= e_in.write_reg;
61 w_out.write_data <= e_in.write_data;
62 w_out.write_enable <= '1';
65 if e_in.write_cr_enable = '1' then
66 c_out.write_cr_enable <= '1';
67 c_out.write_cr_mask <= e_in.write_cr_mask;
68 c_out.write_cr_data <= e_in.write_cr_data;
71 if e_in.write_xerc_enable = '1' then
72 c_out.write_xerc_enable <= '1';
73 c_out.write_xerc_data <= e_in.xerc;
76 if l_in.write_enable = '1' then
77 w_out.write_reg <= gpr_to_gspr(l_in.write_reg);
78 w_out.write_data <= l_in.write_data;
79 w_out.write_enable <= '1';
83 -- st*cx. instructions
86 scf(1) := l_in.store_done;
87 scf(0) := l_in.xerc.so;
88 c_out.write_cr_enable <= '1';
89 c_out.write_cr_mask <= num_to_fxm(0);
90 c_out.write_cr_data(31 downto 28) <= scf;
93 -- Perform CR0 update for RC forms
94 -- Note that loads never have a form with an RC bit, therefore this can test e_in.write_data
95 if e_in.rc = '1' and e_in.write_enable = '1' then
96 sign := e_in.write_data(63);
97 zero := not (or e_in.write_data);
98 c_out.write_cr_enable <= '1';
99 c_out.write_cr_mask <= num_to_fxm(0);
101 cf(2) := not sign and not zero;
103 cf(0) := e_in.xerc.so;
104 c_out.write_cr_data(31 downto 28) <= cf;