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 -- Tumbl configured as a coprocessor for lx_rocon
11 -- Uses 12 bits width address bus with HW barrel and multiplier
13 entity lx_rocon_tumbl is
16 -- This is for 32-bit addressing
17 IMEM_ABITS_g : positive := 9;
18 DMEM_ABITS_g : positive := 10;
20 USE_HW_MUL_g : boolean := true;
21 USE_BARREL_g : boolean := true;
22 COMPATIBILITY_MODE_g : boolean := false
28 halt_i : in std_logic;
30 trace_i : in std_logic;
31 trace_kick_i : in std_logic;
33 pc_o : out std_logic_vector(31 downto 0);
34 -- Internal halt (remove with trace kick)
35 halted_o : out std_logic;
36 halt_code_o : out std_logic_vector(4 downto 0);
37 -- Internal memory (instruction)
38 imem_clk_i : in std_logic;
39 imem_en_i : in std_logic;
40 imem_we_i : in std_logic_vector(3 downto 0);
41 imem_addr_i : in std_logic_vector(8 downto 0);
42 imem_data_i : in std_logic_vector(31 downto 0);
43 imem_data_o : out std_logic_vector(31 downto 0);
44 -- Internal memory (data)
45 dmem_clk_i : in std_logic;
46 dmem_en_i : in std_logic;
47 dmem_we_i : in std_logic_vector(3 downto 0);
48 dmem_addr_i : in std_logic_vector(9 downto 0);
49 dmem_data_i : in std_logic_vector(31 downto 0);
50 dmem_data_o : out std_logic_vector(31 downto 0);
51 -- External memory bus
52 xmemb_sel_o : out std_logic;
53 xmemb_i : in DMEMB2CORE_Type;
54 xmemb_o : out CORE2DMEMB_Type
56 end entity lx_rocon_tumbl;
58 architecture rtl of lx_rocon_tumbl is
60 constant DMEM_TEST_c : std_logic_vector((14-DMEM_ABITS_g) downto 0) := (others => '0');
62 signal imem_clken_s : std_logic;
63 signal imem_addr_s : std_logic_vector((IMEM_ABITS_g-1) downto 0);
64 signal imem_data_s : std_logic_vector(31 downto 0);
65 signal gprf_clken_s : std_logic;
66 signal gprf_finish_wrb_mem_s : std_logic;
67 signal core_clken_s : std_logic;
68 signal pc_ctrl_s : std_logic;
69 signal c2dmemb_s : CORE2DMEMB_Type;
70 signal dmem_data_s : std_logic_vector(31 downto 0);
71 signal DMEMB_i_s : DMEMB2CORE_Type;
73 signal MEM2CTRL_s : MEM2CTRL_Type;
74 signal INT_CTRL_s : INT_CTRL_Type;
75 signal ID2CTRL_s : ID2CTRL_Type;
77 signal IF2ID_s, IF2ID_r : IF2ID_Type;
78 signal ID2EX_s, ID2EX_r : ID2EX_Type;
79 signal delay_bit_r : std_logic;
80 signal ID2GPRF_s : ID2GPRF_Type;
81 signal GPRF2EX_s : GPRF2EX_Type;
82 signal EX2IF_s, EX2IF_r : EX2IF_Type;
83 signal EX2CTRL_s : EX2CTRL_Type;
84 signal EX2MEM_s, EX2MEM_r : EX2MEM_Type;
85 signal EX_WRB_s, EX_WRB_r : WRB_Type;
86 signal MEM_WRB_s : WRB_Type;
87 signal IMM_LOCK_s, IMM_LOCK_r : IMM_LOCK_Type;
88 signal HAZARD_WRB_s, HAZARD_WRB_r : HAZARD_WRB_Type;
89 signal EX2MSR_s : MSR_Type;
90 signal MSR2EX_s : MSR_Type;
91 signal MEM_REG_s, MEM_REG_r : MEM_REG_Type;
92 signal dmem_sel_s, dmem_sel_r : std_logic;
93 signal HALT_s : HALT_Type;
94 signal ext_halt_s : std_logic;
96 signal imem_really_clken_s : std_logic;
97 signal dmem_really_sel_s : std_logic;
98 signal gprf_really_clken_s : std_logic;
103 -- select internal data memory when all address bits above DMEM_ABITS_g are zero
104 dmem_sel_s <= '1' when (c2dmemb_s.addr(14 downto DMEM_ABITS_g) = DMEM_TEST_c)
106 XMEMB_sel_o <= (not dmem_sel_s) and core_clken_s;
107 XMEMB_o <= c2dmemb_s;
108 pc_o <= ID2EX_r.program_counter; -- Program counter for EXEQ
109 halted_o <= HALT_s.halt;
110 halt_code_o <= HALT_s.halt_code;
111 ext_halt_s <= halt_i;
113 imem_really_clken_s <= imem_clken_s and core_clken_s;
114 dmem_really_sel_s <= dmem_sel_s and core_clken_s;
115 gprf_really_clken_s <= gprf_clken_s and core_clken_s;
117 I_IMEM: lx_rocon_imem
121 cs_i => imem_really_clken_s,
122 adr_i => imem_addr_s((IMEM_ABITS_g-1) downto 0),
123 dat_o => imem_data_s,
128 addr_m => imem_addr_i,
129 din_m => imem_data_i,
130 dout_m => imem_data_o
133 I_DMEM: lx_rocon_dmem
137 ce_i => dmem_really_sel_s,
138 adr_i => c2dmemb_s.addr((DMEM_ABITS_g-1) downto 0),
139 bls_i => c2dmemb_s.bls,
140 dat_i => c2dmemb_s.data,
141 dat_o => dmem_data_s,
146 addr_m => dmem_addr_i,
147 din_m => dmem_data_i,
148 dout_m => dmem_data_o
154 prog_cntr_i => IF2ID_r.program_counter,
155 inc_pc_i => pc_ctrl_s,
161 generic map(USE_HW_MUL_g, USE_BARREL_g, COMPATIBILITY_MODE_g)
165 imem_data_i => imem_data_s,
167 ID2GPRF_o => ID2GPRF_s,
170 INT_CTRL_i => INT_CTRL_s,
171 ID2CTRL_o => ID2CTRL_s
174 I_GPRF: lx_rocon_gprf_abd
179 clken_i => gprf_really_clken_s,
180 gprf_finish_wrb_mem_i => gprf_finish_wrb_mem_s,
182 ID2GPRF_i => ID2GPRF_s,
183 MEM_WRB_i => MEM_WRB_s,
184 GPRF2EX_o => GPRF2EX_s
188 generic map(USE_HW_MUL_g, USE_BARREL_g, COMPATIBILITY_MODE_g)
194 delayBit_i => delay_bit_r,
195 GPRF2EX_i => GPRF2EX_s,
197 EX2CTRL_o => EX2CTRL_s,
200 EX_WRB_i => EX_WRB_r,
201 EX_WRB_o => EX_WRB_s,
202 MEM_WRB_i => MEM_WRB_s,
204 HAZARD_WRB_i => HAZARD_WRB_r,
205 HAZARD_WRB_o => HAZARD_WRB_s,
207 IMM_LOCK_i => IMM_LOCK_r,
208 IMM_LOCK_o => IMM_LOCK_s,
216 -- this is a very simple address block decoder, just "internal" dmem or "external"
217 -- clken and int hardwired for fast internal data-memory
218 DMEMB_i_s.bus_wait <= '0' when (dmem_sel_s = '1') else XMEMB_i.bus_wait;
219 DMEMB_i_s.bus_taken <= '0' when (dmem_sel_s = '1') else XMEMB_i.bus_taken;
220 DMEMB_i_s.data <= dmem_data_s when (dmem_sel_r = '1') else XMEMB_i.data;
221 DMEMB_i_s.int <= XMEMB_i.int;
226 EX2MEM_i => EX2MEM_r,
227 MEM_WRB_o => MEM_WRB_s,
229 DMEMB_i => DMEMB_i_s,
230 DMEMB_o => c2dmemb_s,
232 MEM_REG_i => MEM_REG_r,
233 MEM_REG_o => MEM_REG_s,
235 MEM2CTRL_o => MEM2CTRL_s
239 generic map (IMEM_ABITS_g, COMPATIBILITY_MODE_g)
244 halt_i => ext_halt_s,
247 trace_kick_i => trace_kick_i,
248 core_clken_o => core_clken_s,
249 -- specific fetch i/o
250 imem_addr_o => imem_addr_s,
251 imem_clken_o => imem_clken_s,
252 pc_ctrl_o => pc_ctrl_s,
253 -- fetch to decode pipeline registers
254 IF2ID_REG_i => IF2ID_s,
255 IF2ID_REG_o => IF2ID_r,
256 -- decode to exeq pipeline registers
257 ID2EX_REG_i => ID2EX_s,
258 ID2EX_REG_o => ID2EX_r,
259 delay_bit_o => delay_bit_r,
261 gprf_clken_o => gprf_clken_s,
262 gprf_finish_wrb_mem_o => gprf_finish_wrb_mem_s,
263 -- exeq to fetch feedback registers
264 EX2IF_REG_i => EX2IF_s,
265 EX2IF_REG_o => EX2IF_r,
266 EX2CTRL_REG_i => EX2CTRL_s,
267 -- exeq to core (halting)
268 exeq_halt_i => HALT_s.halt,
269 -- exeq to mem pipeline registers
270 EX2MEM_REG_i => EX2MEM_s,
271 EX2MEM_REG_o => EX2MEM_r,
272 -- mem pipeline register
273 MEM_REG_i => MEM_REG_s,
274 MEM_REG_o => MEM_REG_r,
275 -- decode control i/o
276 ID2CTRL_i => ID2CTRL_s,
277 INT_CTRL_o => INT_CTRL_s,
279 EX_WRB_i => EX_WRB_s,
280 EX_WRB_o => EX_WRB_r,
282 HAZARD_WRB_i => HAZARD_WRB_s,
283 HAZARD_WRB_o => HAZARD_WRB_r,
284 -- for handling the 'IMM' instruction
285 IMM_LOCK_i => IMM_LOCK_s,
286 IMM_LOCK_o => IMM_LOCK_r,
287 -- for handling the Machine Status Register
291 MEM2CTRL_i => MEM2CTRL_s
297 wait until clk_i'event and clk_i = '1';
298 if (rst_i = '1') then -- synchronous reset ...
300 else -- delay select_external_mem (needed for reading ...)
301 dmem_sel_r <= dmem_sel_s; -- OR c2dmemb_s.wre; ??
303 end process regd_proc;
305 end architecture rtl;