Line 23... |
Line 23... |
--!
|
--!
|
|
|
library ieee;
|
library ieee;
|
use ieee.std_logic_1164.all;
|
use ieee.std_logic_1164.all;
|
use ieee.std_logic_unsigned.all;
|
use ieee.std_logic_unsigned.all;
|
|
use work.arithpack.all;
|
entity im is
|
entity im is
|
generic (
|
generic (
|
num_events : integer :=4;
|
num_events : integer :=4;
|
cycles_to_wait : integer := 1023
|
cycles_to_wait : integer := 1023
|
);
|
);
|
port (
|
port (
|
clk,rst: in std_logic;
|
clk,rst: in std_logic;
|
rfull_events: in std_logic_vector(num_events-1 downto 0); --! full results queue events
|
rfull_events: in std_logic_vector(num_events-1 downto 0); --! full results queue events
|
eoi_events: in std_logic_vector(num_events-1 downto 0); --! end of instruction related events
|
eoi_events: in std_logic_vector(num_events-1 downto 0); --! end of instruction related events
|
eoi_int: out std_logic_vector(num_events-1 downto 0);--! end of instruction related interruptions
|
eoi_int: out std_logic_vector(num_events-1 downto 0);--! end of instruction related interruptions
|
rfull_int: out std_logic_vector(num_events-1downto 0) --! full results queue related interruptions
|
rfull_int: out std_logic_vector(num_events-1downto 0); --! full results queue related interruptions
|
|
state: out iCtrlState
|
|
|
);
|
);
|
end entity;
|
end entity;
|
|
|
architecture im_arch of im is
|
architecture im_arch of im is
|
|
|
type macState is (WAITING_FOR_AN_EVENT,FIRING_INTERRUPTIONS,SUSPEND);
|
|
signal state : macState;
|
signal s_state : iCtrlState;
|
constant rstMasterValue : std_logic:='0';
|
|
signal s_event_polling_chain : std_logic_vector(num_events-1 downto 0);
|
signal s_event_polling_chain : std_logic_vector(num_events-1 downto 0);
|
signal s_eoi_events : std_logic_vector(num_events-1 downto 0);
|
signal s_eoi_events : std_logic_vector(num_events-1 downto 0);
|
|
|
begin
|
begin
|
|
state <= s_state;
|
|
|
sm_proc:
|
sm_proc:
|
process (clk,rst,s_event_polling_chain,rfull_events,eoi_events)
|
process (clk,rst,s_event_polling_chain,rfull_events,eoi_events)
|
variable tempo : integer range 0 to cycles_to_wait:=cycles_to_wait;
|
variable tempo : integer range 0 to cycles_to_wait:=cycles_to_wait;
|
begin
|
begin
|
if rst=rstMasterValue then
|
if rst=rstMasterValue then
|
tempo := cycles_to_wait;
|
tempo := cycles_to_wait;
|
state <= WAITING_FOR_AN_EVENT;
|
s_state <= WAITING_FOR_AN_EVENT;
|
s_event_polling_chain <= (others => '0');
|
s_event_polling_chain <= (others => '0');
|
s_eoi_events <= (others => '0');
|
s_eoi_events <= (others => '0');
|
rfull_int <= (others => '0');
|
rfull_int <= (others => '0');
|
eoi_int <= (others => '0');
|
eoi_int <= (others => '0');
|
elsif clk'event and clk='1' then
|
elsif clk'event and clk='1' then
|
Line 73... |
Line 74... |
end if;
|
end if;
|
rfull_int(i) <= s_event_polling_chain(i) and rfull_events(i);
|
rfull_int(i) <= s_event_polling_chain(i) and rfull_events(i);
|
eoi_int(i) <= s_event_polling_chain(i) and s_eoi_events(i);
|
eoi_int(i) <= s_event_polling_chain(i) and s_eoi_events(i);
|
|
|
end loop;
|
end loop;
|
case state is
|
case s_state is
|
when WAITING_FOR_AN_EVENT =>
|
when WAITING_FOR_AN_EVENT =>
|
for i in num_events-1 downto 0 loop
|
for i in num_events-1 downto 0 loop
|
if rfull_events(i)='1' then
|
if rfull_events(i)='1' then
|
state <= FIRING_INTERRUPTIONS;
|
s_state <= FIRING_INTERRUPTIONS;
|
s_event_polling_chain(0) <= '1';
|
s_event_polling_chain(0) <= '1';
|
end if;
|
end if;
|
end loop;
|
end loop;
|
when FIRING_INTERRUPTIONS =>
|
when FIRING_INTERRUPTIONS =>
|
if s_event_polling_chain(num_events-1)='1' then
|
if s_event_polling_chain(num_events-1)='1' then
|
state <= SUSPEND;
|
s_state <= SUSPEND;
|
tempo := cycles_to_wait;
|
tempo := cycles_to_wait;
|
end if;
|
end if;
|
for i in num_events-1 downto 1 loop
|
for i in num_events-1 downto 1 loop
|
s_event_polling_chain(i) <= s_event_polling_chain(i-1);
|
s_event_polling_chain(i) <= s_event_polling_chain(i-1);
|
end loop;
|
end loop;
|
s_event_polling_chain(0) <= '0';
|
s_event_polling_chain(0) <= '0';
|
when SUSPEND =>
|
when SUSPEND =>
|
if tempo=0 then
|
if tempo=0 then
|
state <= WAITING_FOR_AN_EVENT;
|
s_state <= WAITING_FOR_AN_EVENT;
|
else
|
else
|
tempo:=tempo-1;
|
tempo:=tempo-1;
|
end if;
|
end if;
|
when others => null;
|
when others => null;
|
end case;
|
end case;
|