3 use ieee.std_logic_1164.all;
4 use ieee.std_logic_arith.all;
5 use ieee.std_logic_unsigned.all;
6 use ieee.numeric_std.all;
8 use work.lx_rocon_pkg.all;
10 -- 32x32b General Puprose Registers for Tumbl Core
13 entity lx_rocon_gprf_abd is
18 clken_i : in std_logic;
19 gprf_finish_wrb_mem_i : in std_logic;
22 ID2GPRF_i : in ID2GPRF_Type;
23 MEM_WRB_i : in WRB_Type;
24 GPRF2EX_o : out GPRF2EX_Type
26 end entity lx_rocon_gprf_abd;
28 architecture rtl of lx_rocon_gprf_abd is
30 signal rdix_rA_s : std_logic_vector(4 downto 0);
31 signal rdix_rB_s : std_logic_vector(4 downto 0);
32 signal rdix_rD_s : std_logic_vector(4 downto 0);
34 signal wre_rD_s : std_logic;
35 signal ena_rA_s : std_logic;
36 signal ena_rB_s : std_logic;
37 signal ena_rD_s : std_logic;
39 signal clken_s : std_logic;
41 signal wthru_rA_r : std_logic;
42 signal rA_DOA_s : std_logic_vector(31 downto 0);
43 signal rA_DOB_s : std_logic_vector(31 downto 0);
44 signal wthru_rB_r : std_logic;
45 signal rB_DOA_s : std_logic_vector(31 downto 0);
46 signal rB_DOB_s : std_logic_vector(31 downto 0);
47 signal wthru_rD_r : std_logic;
48 signal rD_DOA_s : std_logic_vector(31 downto 0);
49 signal rD_DOB_s : std_logic_vector(31 downto 0);
53 -- writeback if WRB_EX or WRB_MEM, but not when r0 involved
54 wre_rD_s <= '1' when ((MEM_WRB_i.wrb_Action /= NO_WRB) and
55 (MEM_WRB_i.wrix_rD /= "00000")) else '0';
57 -- ports A should remain unchanged when clken_i is low, while also
58 -- reading from the same address as will be written to should be disabled
59 -- (setup for writeThru of data_rD)
60 ena_rA_s <= '1' when rst_i = '1' else clken_i when ((ID2GPRF_i.rdix_rA /= MEM_WRB_i.wrix_rD)) else '0';
61 ena_rB_s <= '1' when rst_i = '1' else clken_i when ((ID2GPRF_i.rdix_rB /= MEM_WRB_i.wrix_rD)) else '0';
62 ena_rD_s <= '1' when rst_i = '1' else clken_i when ((ID2GPRF_i.rdix_rD /= MEM_WRB_i.wrix_rD)) else '0';
64 -- make sure reset does it's job (writes 0 to R0 and resets the ports)
65 clken_s <= rst_i or clken_i;
66 rdix_rA_s <= (others => '0') when rst_i = '1' else ID2GPRF_i.rdix_rA;
67 rdix_rB_s <= (others => '0') when rst_i = '1' else ID2GPRF_i.rdix_rB;
68 rdix_rD_s <= (others => '0') when rst_i = '1' else ID2GPRF_i.rdix_rD;
70 GPRF2EX_o.data_rA <= rA_DOA_s when (wthru_rA_r = '0') else rA_DOB_s;
71 GPRF2EX_o.data_rB <= rB_DOA_s when (wthru_rB_r = '0') else rB_DOB_s;
72 GPRF2EX_o.data_rD <= rD_DOA_s when (wthru_rD_r = '0') else rD_DOB_s; -- also for rD ???
74 I_rA: xilinx_dualport_bram
80 port_a_type => WRITE_FIRST,
81 port_b_type => WRITE_FIRST
97 addrb => MEM_WRB_i.wrix_rD,
98 dinb => MEM_WRB_i.data_rD,
102 I_rB: xilinx_dualport_bram
108 port_a_type => WRITE_FIRST,
109 port_b_type => WRITE_FIRST
125 addrb => MEM_WRB_i.wrix_rD,
126 dinb => MEM_WRB_i.data_rD,
130 I_rD: xilinx_dualport_bram
136 port_a_type => WRITE_FIRST,
137 port_b_type => WRITE_FIRST
153 addrb => MEM_WRB_i.wrix_rD,
154 dinb => MEM_WRB_i.data_rD,
161 wait until clk_i'event and clk_i = '1';
162 if (clken_i = '1') then
163 wthru_rA_r <= not ena_rA_s and not gprf_finish_wrb_mem_i;
164 wthru_rB_r <= not ena_rB_s and not gprf_finish_wrb_mem_i;
165 wthru_rD_r <= not ena_rD_s and not gprf_finish_wrb_mem_i;
169 end architecture rtl;