2 use ieee.std_logic_1164.all;
3 use ieee.std_logic_unsigned.all;
4 use ieee.numeric_std.all;
5 use work.lx_rocon_pkg.all;
7 -- IRC bus interconnect
12 reset_i : in std_logic;
14 address_i : in std_logic_vector(4 downto 0);
16 data_i : in std_logic_vector(31 downto 0);
17 data_o : out std_logic_vector(31 downto 0);
19 bls_i : in std_logic_vector(3 downto 0);
21 irc_i : in IRC_INPUT_Array_Type(7 downto 0)
25 architecture Behavioral of bus_irc is
27 constant num_irc_c : positive := 8;
29 signal irc_o_s : IRC_OUTPUT_Array_Type(num_irc_c-1 downto 0);
30 signal irc_count_s : IRC_COUNT_OUTPUT_Array_Type((num_irc_c-1) downto 0);
32 signal reset_index_event_s : std_logic_vector(num_irc_c-1 downto 0);
33 signal reset_index_event2_s : std_logic_vector(num_irc_c-1 downto 0);
34 signal reset_ab_error_s : std_logic_vector(num_irc_c-1 downto 0);
35 signal state_o_s : std_logic_vector(3 downto 0);
36 signal state_o_r : std_logic_vector(3 downto 0);
38 signal irc_en_s : std_logic;
39 signal irc_bls_s : std_logic_vector(3 downto 0);
40 signal irc_addr_s : std_logic_vector(3 downto 0);
41 signal irc_data_s : std_logic_vector(31 downto 0);
42 signal irc_out_s : std_logic;
43 signal irc_out_r : std_logic;
45 signal reset_reg_s : std_logic;
46 signal reset_reg_r : std_logic;
47 signal reset_reg_wr_s : std_logic;
49 signal reset_s : std_logic;
50 signal ce_r : std_logic;
54 irc_generate: for i in 0 to num_irc_c-1 generate
61 reset_index_event_i => reset_index_event_s(i),
62 reset_index_event2_i => reset_index_event2_s(i),
63 reset_ab_error_i => reset_ab_error_s(i),
67 irc_count_s(i) <= irc_o_s(i).count;
70 irc_proc : irc_proc_main
73 num_irc_g => num_irc_c
81 irc_index_reset_o => reset_index_event_s,
85 mem_we_i => irc_bls_s,
86 mem_addr_i => irc_addr_s,
88 mem_data_o => irc_data_s
91 reset_s <= reset_reg_r or reset_i;
94 process(ce_i, ce_r, reset_reg_r, bls_i, address_i, irc_data_s, data_i, irc_o_s)
100 irc_bls_s <= (others => '0');
101 irc_addr_s <= (others => '0');
102 reset_ab_error_s <= (others => '0');
103 reset_index_event2_s <= (others => '0');
104 state_o_s <= (others => '0');
106 reset_reg_wr_s <= '0';
108 -- Incoming bus request
111 -- 0 & axis & irc / index - (all read from bram) (R/W)
112 -- 1 & axis & 0 - status register (R/W)
113 -- 1 & 000 & 1 - reset
114 if address_i(4) = '0' then
116 irc_addr_s <= address_i(3 downto 0);
121 -- Maybe these would be better to latch in ce_i cycle,
122 -- and then just pass them
123 elsif address_i(0) = '0' then
125 state_o_s(0) <= irc_o_s(to_integer(unsigned(address_i(3 downto 1)))).state.mark;
126 state_o_s(1) <= irc_o_s(to_integer(unsigned(address_i(3 downto 1)))).state.ab_error;
127 state_o_s(2) <= irc_o_s(to_integer(unsigned(address_i(3 downto 1)))).state.index_event;
128 state_o_s(3) <= irc_o_s(to_integer(unsigned(address_i(3 downto 1)))).state.index;
130 if bls_i(0) = '1' then
131 if data_i(1) = '1' then
132 reset_ab_error_s(to_integer(unsigned(address_i(3 downto 1)))) <= '1';
134 if data_i(2) = '1' then
135 reset_index_event2_s(to_integer(unsigned(address_i(3 downto 1)))) <= '1';
138 elsif address_i = "10001" then
140 if bls_i(0) = '1' then
141 reset_reg_s <= data_i(0);
142 reset_reg_wr_s <= '1';
145 state_o_s(0) <= reset_reg_r;
146 state_o_s(3 downto 1) <= (others => '0');
155 process(ce_r, irc_data_s, irc_out_r, state_o_r)
158 data_o <= (others => '0');
162 if irc_out_r = '1' then
163 data_o <= irc_data_s;
165 data_o(3 downto 0) <= state_o_r;
174 wait until clk_i'event and clk_i= '1';
176 irc_out_r <= irc_out_s;
177 state_o_r <= state_o_s;
179 if reset_i = '1' then
181 elsif reset_reg_wr_s = '1' then
182 reset_reg_r <= reset_reg_s;