2 use ieee.std_logic_1164.all;
3 use ieee.std_logic_unsigned.all;
4 use ieee.numeric_std.all;
6 use work.lx_rocon_pkg.all;
8 -- Main unit in the IRC cooprocessor
9 entity irc_proc_main is
14 reset_i : in std_logic;
16 irc1_i : in IRC_SLIM_OUTPUT_Type;
17 irc2_i : in IRC_SLIM_OUTPUT_Type;
18 irc3_i : in IRC_SLIM_OUTPUT_Type;
19 irc4_i : in IRC_SLIM_OUTPUT_Type;
21 irc_index_reset_o : out std_logic_vector(3 downto 0);
22 -- BRAM access (the other port)
23 mem_clk_i : in std_logic;
24 mem_en_i : in std_logic;
25 mem_we_i : in std_logic_vector(3 downto 0);
26 mem_addr_i : in std_logic_vector(2 downto 0);
27 mem_data_i : in std_logic_vector(31 downto 0);
28 mem_data_o : out std_logic_vector(31 downto 0)
32 architecture Behavioral of irc_proc_main is
35 type IRC_OUTPUT_Array_Type is array (0 to 3) of IRC_SLIM_OUTPUT_Type;
37 signal op_s : std_logic_vector(1 downto 0);
38 signal axis_s : std_logic_vector(1 downto 0);
40 signal op_r : std_logic_vector(1 downto 0);
41 signal axis_r : std_logic_vector(1 downto 0);
43 signal irc_array_s : IRC_OUTPUT_Array_Type;
45 signal ram_en_s : std_logic;
46 signal ram_addr_s : std_logic_vector(2 downto 0);
47 signal ram_write_s : std_logic_vector(3 downto 0);
48 signal ram_data_i_s : std_logic_vector(31 downto 0);
49 signal ram_data_o_s : std_logic_vector(31 downto 0);
62 ram: xilinx_dualport_bram_no_change
78 douta => ram_data_o_s,
89 -- RAM address (delayed by a cycle when writing)
90 ram_addr_s <= (axis_r & op_r(1)) when ram_write_s = "1111" else (axis_s & op_s(1));
92 irc_array_s(0) <= irc1_i;
93 irc_array_s(1) <= irc2_i;
94 irc_array_s(2) <= irc3_i;
95 irc_array_s(3) <= irc4_i;
100 variable skip_v : std_logic;
101 variable irc_v : IRC_SLIM_OUTPUT_Type;
102 variable res_v : std_logic_vector(31 downto 0);
103 variable count_v : std_logic_vector(31 downto 0);
107 if clk_i = '1' and clk_i'event then
109 -- Init (reset the index reset events)
110 irc_index_reset_o <= (others => '0');
112 if reset_i = '1' then
115 ram_write_s <= "0000";
116 ram_data_i_s <= (others => '0');
118 op_r <= (others => '0');
119 axis_r <= (others => '0');
125 ram_write_s <= "0000";
128 if op_r(1) = '0' then
130 irc_v := irc_array_s(to_integer(unsigned(axis_s)));
132 if op_r(0) = '0' then
133 count_v(7 downto 0) := irc_v.qcount;
136 if irc_v.index_event = '1' then
137 irc_index_reset_o(to_integer(unsigned(axis_s))) <= '1';
138 count_v(7 downto 0) := irc_v.index;
145 if count_v(7) = '1' then
146 count_v(31 downto 8) := (others => '1');
148 count_v(31 downto 8) := (others => '0');
152 ep_add32nc(count_v, not ram_data_o_s, '1', res_v);
155 count_v(7 downto 0) := res_v(7 downto 0);
157 if res_v(7) = '1' then
158 count_v(31 downto 8) := (others => '1');
160 count_v(31 downto 8) := (others => '0');
164 ep_add32nc(ram_data_o_s, count_v, '0', res_v);
168 ram_write_s <= "1111";
169 ram_data_i_s <= res_v;
174 -- Read next stored IRC