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 10 bits width address bus with HW barrel and multiplier
13 entity lx_rocon_tumbl is
16 IMEM_ABITS_g : positive := 11;
17 DMEM_ABITS_g : positive := 12;
19 USE_HW_MUL_g : boolean := true;
20 USE_BARREL_g : boolean := true;
21 COMPATIBILITY_MODE_g : boolean := false
27 halt_i : in std_logic;
29 trace_i : in std_logic;
30 trace_kick_i : in std_logic;
33 pc_o : out std_logic_vector(31 downto 0);
35 -- Internal halt (remove with trace kick)
36 halted_o : out std_logic;
37 halt_code_o : out std_logic_vector(4 downto 0);
39 -- Internal memory (instruction)
40 imem_clk : in std_logic;
41 imem_en : in std_logic;
42 imem_we : in std_logic_vector(3 downto 0);
43 imem_addr : in std_logic_vector(8 downto 0);
44 imem_din : in std_logic_vector(31 downto 0);
45 imem_dout : out std_logic_vector(31 downto 0);
47 -- Internal memory (data)
48 dmem_clk : in std_logic;
49 dmem_en : in std_logic;
50 dmem_we : in std_logic_vector(3 downto 0);
51 dmem_addr : in std_logic_vector(9 downto 0);
52 dmem_din : in std_logic_vector(31 downto 0);
53 dmem_dout : out std_logic_vector(31 downto 0);
55 -- External memory bus
56 XMEMB_sel_o : out std_logic;
57 XMEMB_i : in DMEMB2CORE_Type;
58 XMEMB_o : out CORE2DMEMB_Type;
60 bad_op_o : out std_logic
62 end entity lx_rocon_tumbl;
64 architecture rtl of lx_rocon_tumbl is
66 constant DMEM_TEST_c : std_logic_vector((31-DMEM_ABITS_g) downto 0) := (others => '0');
68 signal imem_clken_s : std_logic;
69 signal imem_addr_s : std_logic_vector(31 downto 0);
70 signal imem_data_s : std_logic_vector(31 downto 0);
71 signal gprf_clken_s : std_logic;
72 signal core_clken_s : std_logic;
73 signal pc_ctrl_s : std_logic;
74 signal c2dmemb_s : CORE2DMEMB_Type;
75 signal dmem_data_s : std_logic_vector(31 downto 0);
76 signal DMEMB_i_s : DMEMB2CORE_Type;
78 signal MEM2CTRL_s : MEM2CTRL_Type;
79 signal INT_CTRL_s : INT_CTRL_Type;
80 signal ID2CTRL_s : ID2CTRL_Type;
82 signal IF2ID_s, IF2ID_r : IF2ID_Type;
83 signal ID2EX_s, ID2EX_r : ID2EX_Type;
84 signal ID2GPRF_s : ID2GPRF_Type;
85 signal GPRF2EX_s : GPRF2EX_Type;
86 signal EX2IF_s, EX2IF_r : EX2IF_Type;
87 signal EX2CTRL_s : EX2CTRL_Type;
88 signal EX2MEM_s, EX2MEM_r : EX2MEM_Type;
89 signal EX_WRB_s, EX_WRB_r : WRB_Type;
90 signal MEM_WRB_s : WRB_Type;
91 signal IMM_LOCK_s, IMM_LOCK_r : IMM_LOCK_Type;
92 signal HAZARD_WRB_s, HAZARD_WRB_r : HAZARD_WRB_Type;
93 signal EX2MSR_s : MSR_Type;
94 signal MSR2EX_s : MSR_Type;
95 signal MEM_REG_s, MEM_REG_r : MEM_REG_Type;
96 signal dmem_sel_s, dmem_sel_r : std_logic;
97 signal bad_op_s : std_logic;
98 signal HALT_s : HALT_Type;
99 signal ext_halt_s : std_logic;
101 signal imem_really_clken_s : std_logic;
102 signal dmem_really_sel_s : std_logic;
103 signal gprf_really_clken_s : std_logic;
107 -- select internal data memory when all address bits above DMEM_ABITS_g are zero
108 dmem_sel_s <= '1' when (c2dmemb_s.addr(31 downto DMEM_ABITS_g) = DMEM_TEST_c)
110 XMEMB_sel_o <= not dmem_sel_s;
111 XMEMB_o <= c2dmemb_s;
112 pc_o <= ID2EX_r.program_counter; -- Program counter for EXEQ
113 halted_o <= HALT_s.halt;
114 halt_code_o <= HALT_s.halt_code;
115 bad_op_o <= bad_op_s;
116 ext_halt_s <= halt_i;
118 imem_really_clken_s <= imem_clken_s and core_clken_s;
119 dmem_really_sel_s <= dmem_sel_s and core_clken_s;
120 gprf_really_clken_s <= gprf_clken_s and core_clken_s;
122 I_IMEM: lx_rocon_imem
126 cs_i => imem_really_clken_s,
127 adr_i => imem_addr_s((IMEM_ABITS_g-1) downto 2),
128 dat_o => imem_data_s,
138 I_DMEM: lx_rocon_dmem
142 ce_i => dmem_really_sel_s,
143 adr_i => c2dmemb_s.addr((DMEM_ABITS_g-1) downto 2),
144 wre_i => c2dmemb_s.wre,
145 bsel_i => c2dmemb_s.bSel,
146 dat_i => c2dmemb_s.data,
147 dat_o => dmem_data_s,
160 prog_cntr_i => IF2ID_r.program_counter,
161 inc_pc_i => pc_ctrl_s,
167 generic map(USE_HW_MUL_g, USE_BARREL_g, COMPATIBILITY_MODE_g)
171 imem_data_i => imem_data_s,
173 ID2GPRF_o => ID2GPRF_s,
176 INT_CTRL_i => INT_CTRL_s,
177 ID2CTRL_o => ID2CTRL_s,
179 noLiteOpc_o => bad_op_s
182 I_GPRF: lx_rocon_gprf_abd
187 clken_i => gprf_really_clken_s,
189 ID2GPRF_i => ID2GPRF_s,
190 MEM_WRB_i => MEM_WRB_s,
191 GPRF2EX_o => GPRF2EX_s
195 generic map(USE_HW_MUL_g, USE_BARREL_g, COMPATIBILITY_MODE_g)
199 GPRF2EX_i => GPRF2EX_s,
201 EX2CTRL_o => EX2CTRL_s,
204 EX_WRB_i => EX_WRB_r,
205 EX_WRB_o => EX_WRB_s,
206 MEM_WRB_i => MEM_WRB_s,
208 HAZARD_WRB_i => HAZARD_WRB_r,
209 HAZARD_WRB_o => HAZARD_WRB_s,
211 IMM_LOCK_i => IMM_LOCK_r,
212 IMM_LOCK_o => IMM_LOCK_s,
220 -- this is a very simple address block decoder, just "internal" dmem or "external"
221 -- clken and int hardwired for fast internal data-memory
222 DMEMB_i_s.clken <= '1' when (dmem_sel_s = '1') else XMEMB_i.clken;
223 DMEMB_i_s.data <= dmem_data_s when (dmem_sel_r = '1') else XMEMB_i.data;
224 DMEMB_i_s.int <= XMEMB_i.int;
229 EX2MEM_i => EX2MEM_r,
230 MEM_WRB_o => MEM_WRB_s,
232 DMEMB_i => DMEMB_i_s,
233 DMEMB_o => c2dmemb_s,
235 MEM_REG_i => MEM_REG_r,
236 MEM_REG_o => MEM_REG_s,
238 MEM2CTRL_o => MEM2CTRL_s
242 generic map (COMPATIBILITY_MODE_g)
247 halt_i => ext_halt_s,
248 bad_op_i => bad_op_s,
251 trace_kick_i => trace_kick_i,
252 core_clken_o => core_clken_s,
253 -- specific fetch i/o
254 imem_addr_o => imem_addr_s,
255 imem_clken_o => imem_clken_s,
256 pc_ctrl_o => pc_ctrl_s,
257 -- fetch to decode pipeline registers
258 IF2ID_REG_i => IF2ID_s,
259 IF2ID_REG_o => IF2ID_r,
260 -- decode to exeq pipeline registers
261 ID2EX_REG_i => ID2EX_s,
262 ID2EX_REG_o => ID2EX_r,
264 gprf_clken_o => gprf_clken_s,
265 -- exeq to fetch feedback registers
266 EX2IF_REG_i => EX2IF_s,
267 EX2IF_REG_o => EX2IF_r,
268 EX2CTRL_REG_i => EX2CTRL_s,
269 -- exeq to core (halting)
270 exeq_halt_i => HALT_s.halt,
271 -- exeq to mem pipeline registers
272 EX2MEM_REG_i => EX2MEM_s,
273 EX2MEM_REG_o => EX2MEM_r,
274 -- mem pipeline register
275 MEM_REG_i => MEM_REG_s,
276 MEM_REG_o => MEM_REG_r,
277 -- decode control i/o
278 ID2CTRL_i => ID2CTRL_s,
279 INT_CTRL_o => INT_CTRL_s,
281 EX_WRB_i => EX_WRB_s,
282 EX_WRB_o => EX_WRB_r,
284 HAZARD_WRB_i => HAZARD_WRB_s,
285 HAZARD_WRB_o => HAZARD_WRB_r,
286 -- for handling the 'IMM' instruction
287 IMM_LOCK_i => IMM_LOCK_s,
288 IMM_LOCK_o => IMM_LOCK_r,
289 -- for handling the Machine Status Register
293 MEM2CTRL_i => MEM2CTRL_s
296 regd_proc: process(clk_i, rst_i)
298 if clk_i = '1' and clk_i'event then
299 if (rst_i = '1') then -- synchronous reset ...
301 else -- delay select_external_mem (needed for reading ...)
302 if (DMEMB_i_s.clken = '1') then
303 dmem_sel_r <= dmem_sel_s; -- OR c2dmemb_s.wre; ??
307 end process regd_proc;
309 end architecture rtl;