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

Subversion Repositories raytrac

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

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
 
29
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
                rfull_int:              out std_logic_vector(num_events-1downto 0)       --! full results queue related interruptions
40
 
41
        );
42
end entity;
43
 
44
architecture im_arch of im is
45
 
46
        type macState is (WAITING_FOR_AN_EVENT,FIRING_INTERRUPTIONS,SUSPEND);
47
        signal state : macState;
48
        constant rstMasterValue : std_logic:='0';
49
        signal s_event_polling_chain : std_logic_vector(num_events-1 downto 0);
50
        signal s_eoi_events : std_logic_vector(num_events-1 downto 0);
51
 
52
begin
53
 
54
 
55
        sm_proc:
56
        process (clk,rst,s_event_polling_chain,rfull_events,eoi_events)
57
                variable tempo : integer range 0 to cycles_to_wait:=cycles_to_wait;
58
        begin
59
                if rst=rstMasterValue then
60
                        tempo := cycles_to_wait;
61
                        state  <= WAITING_FOR_AN_EVENT;
62
                        s_event_polling_chain <= (others => '0');
63
                        s_eoi_events <= (others => '0');
64
                        rfull_int <= (others => '0');
65
                        eoi_int <= (others => '0');
66
                elsif clk'event and clk='1' then
67
 
68
                        for i in num_events-1 downto 0 loop
69
                                if s_eoi_events(i)='0' then --! Hooking events
70
                                        s_eoi_events(i) <= eoi_events(i);
71
                                else                                            --! Event Hooked
72
                                        s_eoi_events(i) <= not(s_event_polling_chain(i));
73
                                end if;
74
                                rfull_int(i) <= s_event_polling_chain(i) and rfull_events(i);
75
                                eoi_int(i) <= s_event_polling_chain(i) and s_eoi_events(i);
76
 
77
                        end loop;
78
                        case state is
79
                                when WAITING_FOR_AN_EVENT =>
80
                                        for i in num_events-1 downto 0 loop
81
                                                if rfull_events(i)='1' then
82
                                                        state <= FIRING_INTERRUPTIONS;
83
                                                        s_event_polling_chain(0) <= '1';
84
                                                end if;
85
                                        end loop;
86
                                when FIRING_INTERRUPTIONS =>
87
                                        if s_event_polling_chain(num_events-1)='1' then
88
                                                state <= SUSPEND;
89
                                                tempo := cycles_to_wait;
90
                                        end if;
91
                                        for i in num_events-1 downto 1 loop
92
                                                s_event_polling_chain(i) <= s_event_polling_chain(i-1);
93
                                        end loop;
94
                                        s_event_polling_chain(0) <= '0';
95
                                when SUSPEND =>
96
                                        if tempo=0 then
97
                                                state <= WAITING_FOR_AN_EVENT;
98
                                        else
99
                                                tempo:=tempo-1;
100
                                        end if;
101
                                when others => null;
102
                        end case;
103
                end if;
104
        end process;
105
end architecture;
106
 
107
 

powered by: WebSVN 2.1.0

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