1 |
2 |
ameziti |
--------------------------------------------------------------------------------
|
2 |
|
|
-- Company:
|
3 |
|
|
--
|
4 |
|
|
-- File: cp_Interrupt.vhd
|
5 |
|
|
--
|
6 |
|
|
-- Description:
|
7 |
|
|
-- projet copyblaze
|
8 |
|
|
-- Interrupt Module
|
9 |
|
|
--
|
10 |
|
|
-- File history:
|
11 |
|
|
-- v1.0: 17/10/11: Creation
|
12 |
|
|
--
|
13 |
|
|
-- Targeted device: ProAsic A3P250 VQFP100
|
14 |
|
|
-- Author: AbdAllah Meziti
|
15 |
|
|
--------------------------------------------------------------------------------
|
16 |
|
|
|
17 |
|
|
library ieee;
|
18 |
|
|
use ieee.std_logic_1164.all;
|
19 |
|
|
use ieee.numeric_std.all;
|
20 |
|
|
|
21 |
|
|
use work.Usefull_Pkg.all; -- Usefull Package
|
22 |
|
|
|
23 |
|
|
--------------------------------------------------------------------------------
|
24 |
|
|
-- Entity: cp_Interrupt
|
25 |
|
|
--
|
26 |
|
|
-- Description:
|
27 |
|
|
--
|
28 |
|
|
-- REMARQUE:
|
29 |
|
|
--
|
30 |
|
|
--
|
31 |
|
|
-- History:
|
32 |
|
|
-- 17/10/11 AM: Creation
|
33 |
|
|
-- ---------------------
|
34 |
|
|
-- xx/xx/xx AM:
|
35 |
|
|
--
|
36 |
|
|
--------------------------------------------------------------------------------
|
37 |
|
|
entity cp_Interrupt is
|
38 |
|
|
port (
|
39 |
|
|
--------------------------------------------------------------------------------
|
40 |
|
|
-- Signaux Systeme
|
41 |
|
|
--------------------------------------------------------------------------------
|
42 |
|
|
Clk_i : in std_ulogic; -- signal d'horloge générale
|
43 |
|
|
Rst_i_n : in std_ulogic; -- signal de reset générale
|
44 |
|
|
|
45 |
|
|
--------------------------------------------------------------------------------
|
46 |
|
|
-- Signaux Fonctionels
|
47 |
|
|
--------------------------------------------------------------------------------
|
48 |
|
|
IEWrite_i : in std_ulogic;
|
49 |
|
|
IEValue_i : in std_ulogic;
|
50 |
|
|
|
51 |
|
|
--Phase1_i : in std_ulogic;
|
52 |
|
|
Phase2_i : in std_ulogic;
|
53 |
|
|
|
54 |
|
|
Interrupt_i : in std_ulogic;
|
55 |
|
|
IEvent_o : out std_ulogic
|
56 |
|
|
);
|
57 |
|
|
end cp_Interrupt;
|
58 |
|
|
|
59 |
|
|
--------------------------------------------------------------------------------
|
60 |
|
|
-- Architecture: RTL
|
61 |
|
|
-- of entity : cp_Interrupt
|
62 |
|
|
--------------------------------------------------------------------------------
|
63 |
|
|
architecture rtl of cp_Interrupt is
|
64 |
|
|
|
65 |
|
|
--------------------------------------------------------------------------------
|
66 |
|
|
-- Définition des fonctions
|
67 |
|
|
--------------------------------------------------------------------------------
|
68 |
|
|
|
69 |
|
|
|
70 |
|
|
|
71 |
|
|
--------------------------------------------------------------------------------
|
72 |
|
|
-- Définition des constantes
|
73 |
|
|
--------------------------------------------------------------------------------
|
74 |
|
|
|
75 |
|
|
--------------------------------------------------------------------------------
|
76 |
|
|
-- Machine d'état principale de pilotage du driver de l'igbt
|
77 |
|
|
--------------------------------------------------------------------------------
|
78 |
|
|
|
79 |
|
|
--------------------------------------------------------------------------------
|
80 |
|
|
-- Définition des signaux interne
|
81 |
|
|
--------------------------------------------------------------------------------
|
82 |
|
|
signal iInterrupt_i_old : std_ulogic;
|
83 |
|
|
signal iInterrupt_i_edge : std_ulogic;
|
84 |
|
|
signal iIDetect : std_ulogic;
|
85 |
|
|
|
86 |
|
|
signal iIE : std_ulogic; -- Interrupt Enable Flags
|
87 |
|
|
signal iIEvent : std_ulogic; -- Interrupt Event Flags
|
88 |
|
|
|
89 |
|
|
--------------------------------------------------------------------------------
|
90 |
|
|
-- Déclaration des composants
|
91 |
|
|
--------------------------------------------------------------------------------
|
92 |
|
|
|
93 |
|
|
begin
|
94 |
|
|
|
95 |
|
|
iInterrupt_i_edge <= (Interrupt_i) and ( not(iInterrupt_i_old) );
|
96 |
|
|
|
97 |
|
|
--------------------------------------------------------------------------------
|
98 |
|
|
-- Process : IE_Proc
|
99 |
|
|
-- Description: Interrupt management
|
100 |
|
|
--------------------------------------------------------------------------------
|
101 |
|
|
-- Interrupt Flag --
|
102 |
|
|
IE_Proc : process(Rst_i_n, Clk_i)
|
103 |
|
|
begin
|
104 |
|
|
if ( Rst_i_n = '0' ) then
|
105 |
|
|
iInterrupt_i_old <= '0';
|
106 |
|
|
iIE <= '0';
|
107 |
|
|
iIEvent <= '0';
|
108 |
|
|
|
109 |
|
|
iIDetect <= '0';
|
110 |
|
|
|
111 |
|
|
elsif ( rising_edge(Clk_i) ) then
|
112 |
|
|
-- Interrupt Input sampling
|
113 |
|
|
iInterrupt_i_old <= Interrupt_i;
|
114 |
|
|
|
115 |
|
|
-- Set the IE bit
|
116 |
|
|
if ( IEWrite_i ='1' ) then
|
117 |
|
|
iIE <= IEValue_i;
|
118 |
|
|
end if;
|
119 |
|
|
if ( iIEvent = '1' ) then
|
120 |
|
|
iIE <= '0';
|
121 |
|
|
end if;
|
122 |
|
|
|
123 |
|
|
-- Save the interrupt edge detection for a phase cycle
|
124 |
|
|
if ( iInterrupt_i_edge = '1' ) then
|
125 |
|
|
iIDetect <= '1';
|
126 |
|
|
elsif ( (Phase2_i = '1') and (iIDetect = '1') ) then
|
127 |
|
|
iIDetect <= '0';
|
128 |
|
|
end if;
|
129 |
|
|
|
130 |
|
|
-- Proceding the interrupt Event
|
131 |
|
|
if ( (Phase2_i = '1') and (iIDetect = '1') and (iIE = '1') ) then
|
132 |
|
|
iIEvent <= '1'; -- Interrupt Event proceding now
|
133 |
|
|
iIDetect <= '0'; -- Now, can clear the EdgeDectection
|
134 |
|
|
|
135 |
|
|
-- Next phase clear the IEvent
|
136 |
|
|
-- TODO : The ENABLE INTERRUPT instruction must clear the "iIEvent" bit if is set while the interrupts are disabled.
|
137 |
|
|
elsif ( (Phase2_i = '1') and (iIEvent = '1') ) then
|
138 |
|
|
iIEvent <= '0'; -- Clear the Interrupt Event
|
139 |
|
|
end if;
|
140 |
|
|
|
141 |
|
|
end if;
|
142 |
|
|
end process IE_Proc;
|
143 |
|
|
|
144 |
|
|
IEvent_o <= iIEvent;
|
145 |
|
|
|
146 |
|
|
end rtl;
|
147 |
|
|
|