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_0: process(clk)
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);
30 if rising_edge(clk) then
31 -- Do consistency checks only on the clock edge
34 assert (to_integer(unsigned(x)) + to_integer(unsigned(y))) <= 1 severity failure;
36 x(0) := e_in.write_enable or e_in.exc_write_enable;
37 y(0) := l_in.write_enable;
38 assert (to_integer(unsigned(x)) + to_integer(unsigned(y))) <= 1 severity failure;
40 w(0) := e_in.write_cr_enable;
41 x(0) := (e_in.write_enable and e_in.rc);
42 assert (to_integer(unsigned(w)) + to_integer(unsigned(x))) <= 1 severity failure;
46 writeback_1: process(all)
47 variable cf: std_ulogic_vector(3 downto 0);
48 variable zero : std_ulogic;
49 variable sign : std_ulogic;
50 variable scf : std_ulogic_vector(3 downto 0);
52 w_out <= WritebackToRegisterFileInit;
53 c_out <= WritebackToCrFileInit;
56 if e_in.valid = '1' or l_in.valid = '1' then
60 if e_in.exc_write_enable = '1' then
61 w_out.write_reg <= e_in.exc_write_reg;
62 w_out.write_data <= e_in.exc_write_data;
63 w_out.write_enable <= '1';
65 if e_in.write_enable = '1' then
66 w_out.write_reg <= e_in.write_reg;
67 w_out.write_data <= e_in.write_data;
68 w_out.write_enable <= '1';
71 if e_in.write_cr_enable = '1' then
72 c_out.write_cr_enable <= '1';
73 c_out.write_cr_mask <= e_in.write_cr_mask;
74 c_out.write_cr_data <= e_in.write_cr_data;
77 if e_in.write_xerc_enable = '1' then
78 c_out.write_xerc_enable <= '1';
79 c_out.write_xerc_data <= e_in.xerc;
82 if l_in.write_enable = '1' then
83 w_out.write_reg <= l_in.write_reg;
84 w_out.write_data <= l_in.write_data;
85 w_out.write_enable <= '1';
89 -- st*cx. instructions
92 scf(1) := l_in.store_done;
93 scf(0) := l_in.xerc.so;
94 c_out.write_cr_enable <= '1';
95 c_out.write_cr_mask <= num_to_fxm(0);
96 c_out.write_cr_data(31 downto 28) <= scf;
99 -- Perform CR0 update for RC forms
100 -- Note that loads never have a form with an RC bit, therefore this can test e_in.write_data
101 if e_in.rc = '1' and e_in.write_enable = '1' then
102 zero := not (or e_in.write_data(31 downto 0));
103 if e_in.mode_32bit = '0' then
104 sign := e_in.write_data(63);
105 zero := zero and not (or e_in.write_data(63 downto 32));
107 sign := e_in.write_data(31);
109 c_out.write_cr_enable <= '1';
110 c_out.write_cr_mask <= num_to_fxm(0);
112 cf(2) := not sign and not zero;
114 cf(0) := e_in.xerc.so;
115 c_out.write_cr_data(31 downto 28) <= cf;