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;
20 ID2GPRF_i : in ID2GPRF_Type;
21 MEM_WRB_i : in WRB_Type;
22 GPRF2EX_o : out GPRF2EX_Type
24 end entity lx_rocon_gprf_abd;
26 architecture rtl of lx_rocon_gprf_abd is
28 signal rdix_rA_s : std_logic_vector(4 downto 0);
29 signal rdix_rB_s : std_logic_vector(4 downto 0);
30 signal rdix_rD_s : std_logic_vector(4 downto 0);
32 signal wre_rD_s : std_logic;
33 signal ena_rA_s : std_logic;
34 signal ena_rB_s : std_logic;
35 signal ena_rD_s : std_logic;
37 signal clken_s : std_logic;
39 signal wthru_rA_r : std_logic;
40 signal rA_DOA_s : std_logic_vector(31 downto 0);
41 signal rA_DOB_s : std_logic_vector(31 downto 0);
42 signal wthru_rB_r : std_logic;
43 signal rB_DOA_s : std_logic_vector(31 downto 0);
44 signal rB_DOB_s : std_logic_vector(31 downto 0);
45 signal wthru_rD_r : std_logic;
46 signal rD_DOA_s : std_logic_vector(31 downto 0);
47 signal rD_DOB_s : std_logic_vector(31 downto 0);
51 -- writeback if WRB_EX or WRB_MEM, but not when r0 involved
52 wre_rD_s <= '1' when ((MEM_WRB_i.wrb_Action /= NO_WRB) and
53 (MEM_WRB_i.wrix_rD /= "00000")) else '0';
55 -- ports A should remain unchanged when clken_i is low, while also
56 -- reading from the same address as will be written to should be disabled
57 -- (setup for writeThru of data_rD)
58 ena_rA_s <= '1' when rst_i = '1' else clken_i when ((ID2GPRF_i.rdix_rA /= MEM_WRB_i.wrix_rD)) else '0';
59 ena_rB_s <= '1' when rst_i = '1' else clken_i when ((ID2GPRF_i.rdix_rB /= MEM_WRB_i.wrix_rD)) else '0';
60 ena_rD_s <= '1' when rst_i = '1' else clken_i when ((ID2GPRF_i.rdix_rD /= MEM_WRB_i.wrix_rD)) else '0';
62 -- make sure reset does it's job (writes 0 to R0 and resets the ports)
63 clken_s <= rst_i or clken_i;
64 rdix_rA_s <= (others => '0') when rst_i = '1' else ID2GPRF_i.rdix_rA;
65 rdix_rB_s <= (others => '0') when rst_i = '1' else ID2GPRF_i.rdix_rB;
66 rdix_rD_s <= (others => '0') when rst_i = '1' else ID2GPRF_i.rdix_rD;
68 GPRF2EX_o.data_rA <= rA_DOA_s when (wthru_rA_r = '0') else rA_DOB_s;
69 GPRF2EX_o.data_rB <= rB_DOA_s when (wthru_rB_r = '0') else rB_DOB_s;
70 GPRF2EX_o.data_rD <= rD_DOA_s when (wthru_rD_r = '0') else rD_DOB_s; -- also for rD ???
72 I_rA: xilinx_dualport_bram
78 port_a_type => WRITE_FIRST,
79 port_b_type => WRITE_FIRST
95 addrb => MEM_WRB_i.wrix_rD,
96 dinb => MEM_WRB_i.data_rD,
100 I_rB: xilinx_dualport_bram
106 port_a_type => WRITE_FIRST,
107 port_b_type => WRITE_FIRST
123 addrb => MEM_WRB_i.wrix_rD,
124 dinb => MEM_WRB_i.data_rD,
128 I_rD: xilinx_dualport_bram
134 port_a_type => WRITE_FIRST,
135 port_b_type => WRITE_FIRST
151 addrb => MEM_WRB_i.wrix_rD,
152 dinb => MEM_WRB_i.data_rD,
159 wait until clk_i'event and clk_i = '1';
160 if (clken_i = '1') then
161 wthru_rA_r <= not ena_rA_s;
162 wthru_rB_r <= not ena_rB_s;
163 wthru_rD_r <= not ena_rD_s;
167 end architecture rtl;