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

Subversion Repositories tinyvliw8

[/] [tinyvliw8/] [trunk/] [src/] [vhdl/] [proc/] [statusReg.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 steckol
-----------------------------------------------------------------
2
-- Project: Aeternitas
3
-- Author:  Oliver Stecklina <stecklina@ihp-microelectronics.com
4
-- Date:    11.11.2013 
5
-- File:    statusReg.vhd
6
-- Design:  AeternitasSWUR
7
-----------------------------------------------------------------
8
-- Description : Status register.
9
-----------------------------------------------------------------
10
-- $Log$
11
-----------------------------------------------------------------
12
 
13
library ieee;
14
 
15
use ieee.std_logic_1164.all;
16
use ieee.std_logic_arith.all;
17
 
18
entity vliwProc_statusReg is
19
        port (
20
                state      : in std_logic_vector(3 downto 0);
21
 
22
                iretEn_n   : in std_logic;
23
                ioEn_n     : in std_logic;
24
                irqEn      : in std_logic;
25
                flagsEn_n  : in std_logic;
26
 
27
                flagsIn    : in std_logic_vector(1 downto 0);       -- carry | zero
28
 
29
                dataIn     : in  std_logic_vector(7 downto 0);
30
                dataOut    : out std_logic_vector(7 downto 0);
31
 
32
                rst_n      : in std_logic
33
        );
34
end vliwProc_statusReg;
35
 
36
architecture behavior of vliwProc_statusReg is
37
 
38
        signal rst_n_s      : std_logic;
39
 
40
        -- signal statusReg_s  : std_logic_vector(2 downto 0);
41
 
42
        signal stallEn_s    : std_logic;
43
        signal stallEvt_s   : std_logic;
44
 
45
        signal irqEn_s      : std_logic;
46
        signal irqEvt_s     : std_logic;
47
        signal ieEn_s       : std_logic;
48
 
49
        signal flags_s      : std_logic_vector(1 downto 0);
50
        signal flagsIInt_s  : std_logic_vector(1 downto 0);
51
 
52
        signal state2_s     : std_logic;
53
 
54
begin
55
 
56
        rst_n_s <= rst_n;
57
 
58
        state2_s <= state(2);
59
 
60
   -----------------------------------------------------------------------------
61
        --
62
        -- setting in-interrupt flag, switches to 
63
        --      '1', when an irq ack occures - falling edge on irqEn_n
64
        --      '0', when pc is loaded by load/store unit - falling edge on iretEn_n
65
        --
66
   -----------------------------------------------------------------------------
67
        irqEn_proc : process(rst_n_s, irqEvt_s)
68
        begin
69
                if (rst_n_s = '0') then
70
                        irqEn_s <= '0';
71
                else
72
                        if (irqEvt_s'event and irqEvt_s = '1') then
73
                                if (irqEn = '1') then
74
                                        irqEn_s <= '1';
75
                                elsif (iretEn_n = '0') then
76
                                        irqEn_s <= '0';
77
                                end if;
78
                        end if;
79
                end if;
80
        end process;
81
 
82
        irqEvt_s <= irqEn xor not(iretEn_n);
83
 
84
   -----------------------------------------------------------------------------
85
        --
86
        -- setting processor stall, switches to 
87
        --      '1', when a '1' is loaded via dataIn(7) - falling edge on ioEn_n
88
        --      '0', when an interrupt occures - falling edge on irqEn_n
89
        --
90
   -----------------------------------------------------------------------------
91
        stallEn_proc : process(rst_n_s, stallEvt_s)
92
        begin
93
                if (rst_n_s = '0') then
94
                        stallEn_s <= '0';
95
                else
96
                        if (stallEvt_s'event and stallEvt_s = '1') then
97
                                if (irqEn = '1') then
98
                                        stallEn_s <= '0';
99
                                elsif (ioEn_n = '0') then
100
                                        stallEn_s <= dataIn(7);
101
                                end if;
102
                        end if;
103
                end if;
104
        end process;
105
 
106
        stallEvt_s <= (not(ioEn_n) and not(state2_s)) xor irqEn;
107
 
108
        ieEn_proc : process(rst_n_s, ioEn_n)
109
        begin
110
                if (rst_n_s = '0') then
111
                        ieEn_s <= '0';
112
                else
113
                        if (ioEn_n'event and ioEn_n = '0') then
114
                                ieEn_s <= dataIn(3);
115
                        end if;
116
                end if;
117
        end process;
118
 
119
        flagsEn_proc : process(rst_n_s, state(3))
120
        begin
121
                if (rst_n_s = '0') then
122
                        flags_s     <= (others => '0');
123
                        flagsIInt_s <= (others => '0');
124
                else
125
                        if (state(3)'event and state(3) = '1') then
126
                                if (irqEn_s = '0') then
127
                                        if (flagsEn_n = '0') then
128
                                                flags_s <= flagsIn;
129
                                        else
130
                                                flags_s <= (others => '0');
131
                                        end if;
132
                                else
133
                                        if (flagsEn_n = '0') then
134
                                                flagsIInt_s <= flagsIn;
135
                                        else
136
                                                flagsIInt_s <= (others => '0');
137
                                        end if;
138
                                end if;
139
                        end if;
140
                end if;
141
        end process;
142
 
143
   -----------------------------------------------------------------------------
144
        --
145
        -- Status register
146
        --   stall | 0 | carry | zero | ie | 0 | 0 | iint
147
        --
148
   -----------------------------------------------------------------------------
149
 
150
        dataOut <= stallEn_s & "0" & flags_s & ieEn_s & "00" & '0'     when rst_n_s = '1' and irqEn_s = '0' else
151
                   stallEn_s & "0" & flagsIInt_s & ieEn_s & "00" & '1' when rst_n_s = '1' and irqEn_s = '1' else
152
                                  (others => '0');
153
 
154
end behavior;

powered by: WebSVN 2.1.0

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