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 -- Connects tumbl to the Master CPU
20 reset_i : in std_logic;
21 -- Master CPU bus for the memory
22 bls_i : in std_logic_vector(3 downto 0);
23 address_i : in std_logic_vector(11 downto 0);
24 data_i : in std_logic_vector(31 downto 0);
25 data_o : out std_logic_vector(31 downto 0);
26 -- Tumbl extrenal memory bus
27 xmemb_sel_o : out std_logic;
28 xmemb_i : in DMEMB2CORE_Type;
29 xmemb_o : out CORE2DMEMB_Type
33 architecture Behavioral of bus_tumbl is
35 type TUMBL_Input_Type is record
39 trace_kick : std_logic;
42 type TUMBL_State_Type is record
43 pc : std_logic_vector(31 downto 0);
45 halt_code : std_logic_vector(4 downto 0);
49 signal tumbl_reset_s : std_logic;
51 signal tumbl_input_s : TUMBL_Input_Type;
52 signal tumbl_state_s : TUMBL_State_Type;
54 -- Internal memory signals
55 signal imem_en_s : std_logic;
56 signal imem_en_r : std_logic;
57 signal dmem_en_s : std_logic;
58 signal dmem_en_r : std_logic;
60 signal imem_we_s : std_logic_vector(3 downto 0);
61 signal dmem_we_s : std_logic_vector(3 downto 0);
63 signal imem_data_o_s : std_logic_vector(31 downto 0);
64 signal dmem_data_o_s : std_logic_vector(31 downto 0);
66 -- Control registers read access
67 signal tumbl_reg_en_control_r : std_logic;
68 signal tumbl_reg_en_pc_r : std_logic;
69 signal tumbl_reg_en_halt_code_r : std_logic;
71 -- Internal bus structure
72 -- 12 address bits: 2 bits for selection, 10 bits for address
84 -- Bit 1: RW - Interrupt
90 -- Bit 0: W - Write 1 for trace kick
93 -- Tumbl program counter (R)
100 -- Wire it to the tumbl
101 I_TUMBL: lx_rocon_tumbl
107 USE_HW_MUL_g => true,
108 USE_BARREL_g => true,
109 COMPATIBILITY_MODE_g => false
114 rst_i => tumbl_reset_s,
115 halt_i => tumbl_input_s.halt,
116 int_i => tumbl_input_s.int,
117 trace_i => tumbl_input_s.trace,
118 trace_kick_i => tumbl_input_s.trace_kick,
120 pc_o => tumbl_state_s.pc,
121 halted_o => tumbl_state_s.halted,
122 halt_code_o => tumbl_state_s.halt_code,
124 -- Internal memory (instruction)
126 imem_en_i => imem_en_s,
127 imem_we_i => imem_we_s,
128 imem_addr_i => address_i(8 downto 0),
129 imem_data_i => data_i,
130 imem_data_o => imem_data_o_s,
132 -- Internal memory (data)
134 dmem_en_i => dmem_en_s,
135 dmem_we_i => dmem_we_s,
136 dmem_addr_i => address_i(9 downto 0),
137 dmem_data_i => data_i,
138 dmem_data_o => dmem_data_o_s,
140 -- External memory bus
141 xmemb_sel_o => xmemb_sel_o,
147 enabling: process(ce_i, address_i)
150 if ce_i = '1' and address_i(11 downto 10) = "00" then
156 if ce_i = '1' and address_i(11 downto 10) = "01" then
166 process(ce_i, bls_i, address_i, imem_en_s, imem_data_o_s, dmem_en_s,
167 dmem_data_o_s, tumbl_reset_s, tumbl_input_s, tumbl_state_s,
168 imem_en_r, dmem_en_r, tumbl_reg_en_control_r, tumbl_reg_en_pc_r,
169 tumbl_reg_en_halt_code_r)
172 if imem_en_s = '1' then
178 if dmem_en_s = '1' then
184 if imem_en_r = '1' then
185 data_o <= imem_data_o_s;
186 elsif dmem_en_r = '1' then
187 data_o <= dmem_data_o_s;
188 elsif tumbl_reg_en_control_r = '1' then
189 data_o(0) <= tumbl_reset_s;
190 data_o(1) <= tumbl_input_s.int;
191 data_o(2) <= tumbl_input_s.halt;
192 data_o(3) <= tumbl_input_s.trace;
193 data_o(4) <= tumbl_state_s.halted;
194 data_o(31 downto 5) <= (others => '0');
195 elsif tumbl_reg_en_pc_r = '1' then
196 data_o <= tumbl_state_s.pc;
197 elsif tumbl_reg_en_halt_code_r = '1' then
198 data_o(4 downto 0) <= tumbl_state_s.halt_code;
199 data_o(31 downto 5) <= (others => '0');
201 data_o <= (others => 'X');
206 -- Transaction acknowledge and writing to registers
212 wait until clk_i'event and clk_i = '1';
214 imem_en_r <= imem_en_s;
215 dmem_en_r <= dmem_en_s;
217 tumbl_reg_en_control_r <= '0';
218 tumbl_reg_en_pc_r <= '0';
219 tumbl_reg_en_halt_code_r <= '0';
221 tumbl_input_s.trace_kick <= '0';
223 if reset_i = '1' then
224 tumbl_reset_s <= '1';
225 tumbl_input_s.int <= '0';
226 tumbl_input_s.halt <= '0';
227 tumbl_input_s.trace <= '0';
231 if ce_i = '1' and address_i(11 downto 10) = "11" then
232 if bls_i(0) = '1' then
233 if address_i(9 downto 0) = "0000000000" then
234 tumbl_reset_s <= data_i(0);
235 tumbl_input_s.int <= data_i(1);
236 tumbl_input_s.halt <= data_i(2);
237 tumbl_input_s.trace <= data_i(3);
238 elsif address_i(9 downto 0) = "0000000001" then
239 if data_i(0) = '1' then
240 tumbl_input_s.trace_kick <= '1';
246 if address_i(9 downto 0) = "0000000000" then
247 tumbl_reg_en_control_r <= '1';
248 elsif address_i(9 downto 0) = "0000000010" then
249 tumbl_reg_en_pc_r <= '1';
250 elsif address_i(9 downto 0) = "0000000011" then
251 tumbl_reg_en_halt_code_r <= '1';