use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.numeric_std.all;
-use work.mbl_pkg.all;
use work.util_pkg.all;
use work.lx_rocon_pkg.all;
signal ram_write_s : std_logic_vector(3 downto 0);
signal ram_data_i_s : std_logic_vector(31 downto 0);
signal ram_data_o_s : std_logic_vector(31 downto 0);
+ --
+ signal irc_reg_s : std_logic_vector(31 downto 0);
+ signal irc_reg_r : std_logic_vector(31 downto 0);
begin
incr: irc_proc_inc
+ generic map (num_irc_g)
port map
(
clk_i => clk_i,
);
-- FIXME: Template needs to support 1-bit WE enabling, getting KEEP conflicts on wea here
- ram: xilinx_dualport_bram_no_change
+ ram: xilinx_dualport_bram
generic map
(
we_width => 4,
byte_width => 8,
- address_width => ram_addr_s'length
+ address_width => ram_addr_s'length,
+ port_a_type => READ_FIRST,
+ port_b_type => READ_FIRST
)
port map
(
ram_addr_s <= axis_s & op_s(1);
update:
- process (irc_i, op_r, axis_r, ram_data_o_s, reset_i)
+ process (irc_i, irc_reg_r, op_r, axis_r, ram_data_o_s, reset_i)
variable skip_v : std_logic;
variable irc_v : IRC_COUNT_OUTPUT_Type;
variable res_v : std_logic_vector(31 downto 0);
variable count_v : std_logic_vector(31 downto 0);
+ variable src_v : std_logic_vector(31 downto 0);
begin
-- Init (reset the index reset events)
ram_en_s <= '0';
ram_write_s <= "0000";
ram_data_i_s <= (others => '0');
-
- count_v := (others => '0');
- skip_v := '1';
+ irc_reg_s <= irc_reg_r;
+ --
+ count_v := (others => '0');
+ skip_v := '1';
+ src_v := (others => '0');
-- No reset
if reset_i = '0' then
irc_v := irc_i(to_integer(unsigned(axis_r)));
if op_r(0) = '0' then
- count_v(7 downto 0) := irc_v.qcount;
- skip_v := '0';
- else
- if irc_v.index_event = '1' then
- irc_index_reset_o(to_integer(unsigned(axis_r))) <= '1';
- count_v(7 downto 0) := irc_v.index;
- skip_v := '0';
- end if;
+ count_v(7 downto 0) := irc_v.qcount;
+ skip_v := '0';
+ src_v := ram_data_o_s;
+ irc_reg_s <= ram_data_o_s;
+ elsif irc_v.index_event = '1' then
+ irc_index_reset_o(to_integer(unsigned(axis_r))) <= '1';
+ count_v(7 downto 0) := irc_v.index;
+ skip_v := '0';
+ src_v := irc_reg_r;
end if;
if skip_v = '0' then
- -- signed extension
- if count_v(7) = '1' then
- count_v(31 downto 8) := (others => '1');
- else
- count_v(31 downto 8) := (others => '0');
- end if;
-- calculate qs8
- ep_add32nc(count_v, not ram_data_o_s, '1', res_v);
+ res_v(7 downto 0) := std_logic_vector(unsigned(count_v(7 downto 0)) -
+ unsigned(src_v(7 downto 0)));
-- extend it
- count_v(7 downto 0) := res_v(7 downto 0);
+ count_v(7 downto 0) := res_v(7 downto 0);
if res_v(7) = '1' then
count_v(31 downto 8) := (others => '1');
end if;
-- add it back
- ep_add32nc(ram_data_o_s, count_v, '0', res_v);
+ res_v := std_logic_vector(unsigned(src_v) + unsigned(count_v));
-- store it
ram_en_s <= '1';
begin
wait until clk_i'event and clk_i = '1';
- op_r <= op_s;
- axis_r <= axis_s;
+ op_r <= op_s;
+ axis_r <= axis_s;
+
+ if reset_i = '1' then
+ irc_reg_r <= (others => '0');
+ else
+ irc_reg_r <= irc_reg_s;
+ end if;
end process;