OpenCores
URL https://opencores.org/ocsvn/raytrac/raytrac/trunk

Subversion Repositories raytrac

[/] [raytrac/] [branches/] [fp/] [im.vhd] - Blame information for rev 165

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 147 jguarin200
--! @file im.vhd
2
--! @brief Maquina de Interrupciones. Circuito que detecta eventos que generan interrupciones para que el usuario externo del RayTrac detecte eventos como el final de una instrucción.  
3
--! @author Julián Andrés Guarín Reyes
4
--------------------------------------------------------------
5
-- RAYTRAC
6
-- Author Julian Andres Guarin
7
-- sm.vhd
8
-- This file is part of raytrac.
9
-- 
10
--     raytrac is free software: you can redistribute it and/or modify
11
--     it under the terms of the GNU General Public License as published by
12
--     the Free Software Foundation, either version 3 of the License, or
13
--     (at your option) any later version.
14
-- 
15
--     raytrac is distributed in the hope that it will be useful,
16
--     but WITHOUT ANY WARRANTY; without even the implied warranty of
17
--     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
--     GNU General Public License for more details.
19
-- 
20
--     You should have received a copy of the GNU General Public License
21
--     along with raytrac.  If not, see <http://www.gnu.org/licenses/>.
22
 
23
--! 
24
 
25
library ieee;
26
use ieee.std_logic_1164.all;
27
use ieee.std_logic_unsigned.all;
28 151 jguarin200
use work.arithpack.all;
29 147 jguarin200
entity im is
30
        generic (
31
                num_events : integer :=4;
32
                cycles_to_wait : integer := 1023
33
        );
34
        port (
35
                clk,rst:                in std_logic;
36
                rfull_events:   in std_logic_vector(num_events-1 downto 0);      --! full results queue events
37
                eoi_events:             in std_logic_vector(num_events-1 downto 0);      --! end of instruction related events
38
                eoi_int:                out std_logic_vector(num_events-1 downto 0);--! end of instruction related interruptions
39 151 jguarin200
                rfull_int:              out std_logic_vector(num_events-1downto 0);      --! full results queue related interruptions
40
                state:                  out iCtrlState
41 147 jguarin200
 
42
        );
43
end entity;
44
 
45
architecture im_arch of im is
46
 
47 151 jguarin200
 
48
        signal s_state : iCtrlState;
49
 
50 147 jguarin200
        signal s_event_polling_chain : std_logic_vector(num_events-1 downto 0);
51
        signal s_eoi_events : std_logic_vector(num_events-1 downto 0);
52
 
53
begin
54 151 jguarin200
        state <= s_state;
55
 
56 147 jguarin200
        sm_proc:
57
        process (clk,rst,s_event_polling_chain,rfull_events,eoi_events)
58
                variable tempo : integer range 0 to cycles_to_wait:=cycles_to_wait;
59
        begin
60
                if rst=rstMasterValue then
61
                        tempo := cycles_to_wait;
62 151 jguarin200
                        s_state  <= WAITING_FOR_AN_EVENT;
63 147 jguarin200
                        s_event_polling_chain <= (others => '0');
64
                        s_eoi_events <= (others => '0');
65
                        rfull_int <= (others => '0');
66
                        eoi_int <= (others => '0');
67
                elsif clk'event and clk='1' then
68
 
69
                        for i in num_events-1 downto 0 loop
70
                                if s_eoi_events(i)='0' then --! Hooking events
71
                                        s_eoi_events(i) <= eoi_events(i);
72
                                else                                            --! Event Hooked
73
                                        s_eoi_events(i) <= not(s_event_polling_chain(i));
74
                                end if;
75
                                rfull_int(i) <= s_event_polling_chain(i) and rfull_events(i);
76
                                eoi_int(i) <= s_event_polling_chain(i) and s_eoi_events(i);
77
 
78
                        end loop;
79 151 jguarin200
                        case s_state is
80 147 jguarin200
                                when WAITING_FOR_AN_EVENT =>
81
                                        for i in num_events-1 downto 0 loop
82
                                                if rfull_events(i)='1' then
83 151 jguarin200
                                                        s_state <= FIRING_INTERRUPTIONS;
84 147 jguarin200
                                                        s_event_polling_chain(0) <= '1';
85
                                                end if;
86
                                        end loop;
87
                                when FIRING_INTERRUPTIONS =>
88
                                        if s_event_polling_chain(num_events-1)='1' then
89 151 jguarin200
                                                s_state <= SUSPEND;
90 147 jguarin200
                                                tempo := cycles_to_wait;
91
                                        end if;
92
                                        for i in num_events-1 downto 1 loop
93
                                                s_event_polling_chain(i) <= s_event_polling_chain(i-1);
94
                                        end loop;
95
                                        s_event_polling_chain(0) <= '0';
96
                                when SUSPEND =>
97
                                        if tempo=0 then
98 151 jguarin200
                                                s_state <= WAITING_FOR_AN_EVENT;
99 147 jguarin200
                                        else
100
                                                tempo:=tempo-1;
101
                                        end if;
102
                                when others => null;
103
                        end case;
104
                end if;
105
        end process;
106
end architecture;
107
 
108
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.