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 dmem_en_s : std_logic;
58 signal imem_we_s : std_logic_vector(3 downto 0);
59 signal dmem_we_s : std_logic_vector(3 downto 0);
61 signal imem_data_o_s : std_logic_vector(31 downto 0);
62 signal dmem_data_o_s : std_logic_vector(31 downto 0);
64 -- Internal bus structure
65 -- 12 address bits: 2 bits for selection, 10 bits for address
77 -- Bit 1: RW - Interrupt
83 -- Bit 0: W - Write 1 for trace kick
86 -- Tumbl program counter (R)
93 -- Wire it to the tumbl
94 I_TUMBL: lx_rocon_tumbl
100 USE_HW_MUL_g => true,
101 USE_BARREL_g => true,
102 COMPATIBILITY_MODE_g => false
107 rst_i => tumbl_reset_s,
108 halt_i => tumbl_input_s.halt,
109 int_i => tumbl_input_s.int,
110 trace_i => tumbl_input_s.trace,
111 trace_kick_i => tumbl_input_s.trace_kick,
113 pc_o => tumbl_state_s.pc,
114 halted_o => tumbl_state_s.halted,
115 halt_code_o => tumbl_state_s.halt_code,
117 -- Internal memory (instruction)
119 imem_en_i => imem_en_s,
120 imem_we_i => imem_we_s,
121 imem_addr_i => address_i(8 downto 0),
122 imem_data_i => data_i,
123 imem_data_o => imem_data_o_s,
125 -- Internal memory (data)
127 dmem_en_i => dmem_en_s,
128 dmem_we_i => dmem_we_s,
129 dmem_addr_i => address_i(9 downto 0),
130 dmem_data_i => data_i,
131 dmem_data_o => dmem_data_o_s,
133 -- External memory bus
134 xmemb_sel_o => xmemb_sel_o,
140 enabling: process(ce_i, address_i)
143 if ce_i = '1' and address_i(11 downto 10) = "00" then
149 if ce_i = '1' and address_i(11 downto 10) = "01" then
159 process(ce_i, bls_i, address_i, imem_en_s, imem_data_o_s, dmem_en_s,
160 dmem_data_o_s, tumbl_reset_s, tumbl_input_s, tumbl_state_s)
163 if imem_en_s = '1' then
169 if dmem_en_s = '1' then
175 if imem_en_s = '1' then
176 data_o <= imem_data_o_s;
177 elsif dmem_en_s = '1' then
178 data_o <= dmem_data_o_s;
179 elsif ce_i = '1' and address_i(11 downto 10) = "11" then
180 if address_i(9 downto 0) = "0000000000" then
181 data_o(0) <= tumbl_reset_s;
182 data_o(1) <= tumbl_input_s.int;
183 data_o(2) <= tumbl_input_s.halt;
184 data_o(3) <= tumbl_input_s.trace;
185 data_o(4) <= tumbl_state_s.halted;
186 data_o(31 downto 5) <= (others => '0');
187 elsif address_i(9 downto 0) = "0000000010" then
188 data_o <= tumbl_state_s.pc;
189 elsif address_i(9 downto 0) = "0000000011" then
190 data_o(4 downto 0) <= tumbl_state_s.halt_code;
191 data_o(31 downto 5) <= (others => '0');
193 data_o <= (others => 'X');
196 data_o <= (others => 'X');
201 -- Transaction acknowledge and writing to registers
207 wait until clk_i'event and clk_i = '1';
209 tumbl_input_s.trace_kick <= '0';
211 if reset_i = '1' then
212 tumbl_reset_s <= '1';
213 tumbl_input_s.int <= '0';
214 tumbl_input_s.halt <= '0';
215 tumbl_input_s.trace <= '0';
219 if ce_i = '1' and address_i(11 downto 10) = "11" then
220 if bls_i(0) = '1' then
221 if address_i(9 downto 0) = "0000000000" then
222 tumbl_reset_s <= data_i(0);
223 tumbl_input_s.int <= data_i(1);
224 tumbl_input_s.halt <= data_i(2);
225 tumbl_input_s.trace <= data_i(3);
226 elsif address_i(9 downto 0) = "0000000001" then
227 if data_i(0) = '1' then
228 tumbl_input_s.trace_kick <= '1';