1 |
2 |
jeunes2 |
-- This file is part of the marca processor.
|
2 |
|
|
-- Copyright (C) 2007 Wolfgang Puffitsch
|
3 |
|
|
|
4 |
|
|
-- This program is free software; you can redistribute it and/or modify it
|
5 |
|
|
-- under the terms of the GNU Library General Public License as published
|
6 |
|
|
-- by the Free Software Foundation; either version 2, or (at your option)
|
7 |
|
|
-- any later version.
|
8 |
|
|
|
9 |
|
|
-- This program is distributed in the hope that it will be useful,
|
10 |
|
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11 |
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
12 |
|
|
-- Library General Public License for more details.
|
13 |
|
|
|
14 |
|
|
-- You should have received a copy of the GNU Library General Public
|
15 |
|
|
-- License along with this program; if not, write to the Free Software
|
16 |
|
|
-- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
17 |
|
|
|
18 |
|
|
-------------------------------------------------------------------------------
|
19 |
|
|
-- MARCA interrupt unit
|
20 |
|
|
-------------------------------------------------------------------------------
|
21 |
|
|
-- architecture for the interrupt unit
|
22 |
|
|
-------------------------------------------------------------------------------
|
23 |
|
|
|
24 |
|
|
-------------------------------------------------------------------------------
|
25 |
|
|
-- Wolfgang Puffitsch
|
26 |
|
|
-- Computer Architecture Lab, Group 3
|
27 |
|
|
-------------------------------------------------------------------------------
|
28 |
|
|
|
29 |
|
|
library IEEE;
|
30 |
|
|
use IEEE.std_logic_1164.all;
|
31 |
|
|
use IEEE.numeric_std.all;
|
32 |
|
|
|
33 |
|
|
use work.marca_pkg.all;
|
34 |
|
|
|
35 |
|
|
architecture behaviour of intr is
|
36 |
|
|
|
37 |
|
|
type vectors is array (VEC_COUNT-1 downto 0) of std_logic_vector(REG_WIDTH-1 downto 0);
|
38 |
|
|
signal vecs, next_vecs : vectors;
|
39 |
|
|
|
40 |
|
|
signal ira, next_ira : std_logic_vector(REG_WIDTH-1 downto 0);
|
41 |
|
|
|
42 |
|
|
begin -- behaviour
|
43 |
|
|
|
44 |
|
|
syn_proc: process (clock, reset)
|
45 |
|
|
begin -- process syn_proc
|
46 |
|
|
if reset = RESET_ACTIVE then -- asynchronous reset (active low)
|
47 |
|
|
vecs <= (others => (others => '0'));
|
48 |
|
|
ira <= (others => '0');
|
49 |
|
|
elsif clock'event and clock = '1' then -- rising clock edge
|
50 |
|
|
vecs <= next_vecs;
|
51 |
|
|
ira <= next_ira;
|
52 |
|
|
end if;
|
53 |
|
|
end process syn_proc;
|
54 |
|
|
|
55 |
|
|
compute: process (op, a, i, pc, vecs, ira, enable, trigger)
|
56 |
|
|
begin -- process compute
|
57 |
|
|
|
58 |
|
|
next_vecs <= vecs;
|
59 |
|
|
next_ira <= ira;
|
60 |
|
|
|
61 |
|
|
exc <= '0';
|
62 |
|
|
pcchg <= '0';
|
63 |
|
|
result <= (others => '0');
|
64 |
|
|
|
65 |
|
|
case op is
|
66 |
|
|
when INTR_INTR =>
|
67 |
|
|
if enable = '1' then
|
68 |
|
|
pcchg <= '1';
|
69 |
|
|
result <= vecs(to_integer(unsigned(i)));
|
70 |
|
|
next_ira <= std_logic_vector(unsigned(pc) + 1);
|
71 |
|
|
end if;
|
72 |
|
|
when INTR_RETI =>
|
73 |
|
|
pcchg <= '1';
|
74 |
|
|
result <= ira;
|
75 |
|
|
when INTR_SETIRA =>
|
76 |
|
|
next_ira <= a;
|
77 |
|
|
when INTR_GETIRA =>
|
78 |
|
|
result <= ira;
|
79 |
|
|
when INTR_STVEC =>
|
80 |
|
|
next_vecs(to_integer(unsigned(i))) <= a;
|
81 |
|
|
when INTR_LDVEC =>
|
82 |
|
|
result <= vecs(to_integer(unsigned(i)));
|
83 |
|
|
when others => null;
|
84 |
|
|
end case;
|
85 |
|
|
|
86 |
|
|
if enable = '1' then
|
87 |
|
|
for v in VEC_COUNT-1 downto 1 loop
|
88 |
|
|
if trigger(v) = '1' then
|
89 |
|
|
exc <= '1';
|
90 |
|
|
pcchg <= '1';
|
91 |
|
|
result <= vecs(v);
|
92 |
|
|
if v = EXC_ALU or v = EXC_MEM then
|
93 |
|
|
-- don't repeat division by zero and ill memory access
|
94 |
|
|
next_ira <= std_logic_vector(unsigned(pc) + 1);
|
95 |
|
|
else
|
96 |
|
|
-- repeat the instruction if interrupted
|
97 |
|
|
next_ira <= pc;
|
98 |
|
|
end if;
|
99 |
|
|
end if;
|
100 |
|
|
end loop;
|
101 |
|
|
end if;
|
102 |
|
|
|
103 |
|
|
end process compute;
|
104 |
|
|
|
105 |
|
|
end behaviour;
|