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

Subversion Repositories t48

[/] [t48/] [tags/] [rel_0_2_beta/] [rtl/] [vhdl/] [psw.vhd] - Blame information for rev 77

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

Line No. Rev Author Line
1 4 arniml
-------------------------------------------------------------------------------
2
--
3
-- The Program Status Word (PSW).
4
-- Implements the PSW with its special bits.
5
--
6 77 arniml
-- $Id: psw.vhd,v 1.6 2004-04-24 23:44:25 arniml Exp $
7 4 arniml
--
8
-- All rights reserved
9
--
10
-- Redistribution and use in source and synthezised forms, with or without
11
-- modification, are permitted provided that the following conditions are met:
12
--
13
-- Redistributions of source code must retain the above copyright notice,
14
-- this list of conditions and the following disclaimer.
15
--
16
-- Redistributions in synthesized form must reproduce the above copyright
17
-- notice, this list of conditions and the following disclaimer in the
18
-- documentation and/or other materials provided with the distribution.
19
--
20
-- Neither the name of the author nor the names of other contributors may
21
-- be used to endorse or promote products derived from this software without
22
-- specific prior written permission.
23
--
24
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
26
-- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27
-- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE
28
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34
-- POSSIBILITY OF SUCH DAMAGE.
35
--
36
-- Please report bugs to the author, but before you do so, please
37
-- make sure that this is not a derivative work and that
38
-- you have the latest version of this file.
39
--
40
-- The latest version of this file can be found at:
41
--      http://www.opencores.org/cvsweb.shtml/t48/
42
--
43
-------------------------------------------------------------------------------
44
 
45
library ieee;
46
use ieee.std_logic_1164.all;
47
 
48
use work.t48_pack.word_t;
49
 
50
entity psw is
51
 
52
  port (
53
    -- Global Interface -------------------------------------------------------
54
    clk_i              : in  std_logic;
55
    res_i              : in  std_logic;
56
    en_clk_i           : in  boolean;
57
    -- T48 Bus Interface ------------------------------------------------------
58
    data_i             : in  word_t;
59
    data_o             : out word_t;
60
    read_psw_i         : in  boolean;
61
    read_sp_i          : in  boolean;
62
    write_psw_i        : in  boolean;
63
    write_sp_i         : in  boolean;
64
    -- Decoder Interface ------------------------------------------------------
65
    special_data_i     : in  std_logic;
66
    inc_stackp_i       : in  boolean;
67
    dec_stackp_i       : in  boolean;
68
    write_carry_i      : in  boolean;
69
    write_aux_carry_i  : in  boolean;
70
    write_f0_i         : in  boolean;
71
    write_bs_i         : in  boolean;
72
    carry_o            : out std_logic;
73 29 arniml
    aux_carry_i        : in  std_logic;
74 4 arniml
    aux_carry_o        : out std_logic;
75
    f0_o               : out std_logic;
76
    bs_o               : out std_logic
77
  );
78
 
79
end psw;
80
 
81
 
82
library ieee;
83 77 arniml
use ieee.numeric_std.all;
84 4 arniml
 
85
use work.t48_pack.clk_active_c;
86
use work.t48_pack.res_active_c;
87
use work.t48_pack.bus_idle_level_c;
88 37 arniml
use work.t48_pack.nibble_t;
89 4 arniml
 
90
architecture rtl of psw is
91
 
92
  -- special bit positions in PSW
93
  constant carry_c     : natural := 3;
94
  constant aux_carry_c : natural := 2;
95
  constant f0_c        : natural := 1;
96
  constant bs_c        : natural := 0;
97
 
98
  -- the PSW register
99 37 arniml
  signal psw_q : nibble_t;
100 4 arniml
  -- the Stack Pointer
101
  signal sp_q  : unsigned(2 downto 0);
102
 
103 37 arniml
  -- pragma translate_off
104
  signal psw_s : word_t;
105
  -- pragma translate_on
106
 
107 4 arniml
begin
108
 
109
  -----------------------------------------------------------------------------
110
  -- Process psw_reg
111
  --
112
  -- Purpose:
113
  --   Implements the PSW register.
114
  --
115
  psw_reg: process (res_i, clk_i)
116
  begin
117
    if res_i = res_active_c then
118
      psw_q <= (others => '0');
119
      sp_q  <= (others => '0');
120
 
121
    elsif clk_i'event and clk_i = clk_active_c then
122
      if en_clk_i then
123
 
124
        -- T48 bus access
125
        if write_psw_i then
126
          psw_q  <= data_i(7 downto 4);
127
        end if;
128
        if write_sp_i then
129
          sp_q <= unsigned(data_i(2 downto 0));
130
        end if;
131
 
132
        -- increment Stack Pointer
133
        if inc_stackp_i then
134
          sp_q  <= sp_q + 1;
135
        end if;
136
        -- decrement Stack Pointer
137
        if dec_stackp_i then
138
          sp_q  <= sp_q - 1;
139
        end if;
140
 
141
        -- access to special bits
142
        if write_carry_i then
143
          psw_q(carry_c)     <= special_data_i;
144
        end if;
145
        --
146
        if write_aux_carry_i then
147 29 arniml
          psw_q(aux_carry_c) <= aux_carry_i;
148 4 arniml
        end if;
149
        --
150
        if write_f0_i then
151
          psw_q(f0_c)        <= special_data_i;
152
        end if;
153
        --
154
        if write_bs_i then
155
          psw_q(bs_c)        <= special_data_i;
156
        end if;
157
 
158
      end if;
159
 
160
    end if;
161
 
162
  end process psw_reg;
163
  --
164
  -----------------------------------------------------------------------------
165
 
166
 
167
  -----------------------------------------------------------------------------
168
  -- Process data_out
169
  --
170
  -- Purpose:
171
  --   Output multiplexer for T48 Data Bus.
172
  --
173
  data_out: process (read_psw_i,
174
                     read_sp_i,
175
                     psw_q,
176
                     sp_q)
177
  begin
178
    data_o <= (others => bus_idle_level_c);
179
 
180
    if read_psw_i then
181
      data_o(7 downto 4) <= psw_q;
182
    end if;
183
 
184
    if read_sp_i then
185 77 arniml
      data_o(3 downto 0) <= '1' & std_logic_vector(sp_q);
186 4 arniml
    end if;
187
 
188
  end process data_out;
189
  --
190
  -----------------------------------------------------------------------------
191
 
192
 
193 37 arniml
  -- pragma translate_off
194
  tb: process (psw_q, sp_q)
195
  begin
196
    psw_s(7 downto 4) <= psw_q;
197
    psw_s(3)          <= '1';
198 77 arniml
    psw_s(2 downto 0) <= std_logic_vector(sp_q);
199 37 arniml
  end process tb;
200
  -- pragma translate_on
201
 
202 4 arniml
  -----------------------------------------------------------------------------
203
  -- Output mapping.
204
  -----------------------------------------------------------------------------
205
  carry_o     <= psw_q(carry_c);
206
  aux_carry_o <= psw_q(aux_carry_c);
207
  f0_o        <= psw_q(f0_c);
208
  bs_o        <= psw_q(bs_c);
209
 
210
end rtl;
211
 
212
 
213
-------------------------------------------------------------------------------
214
-- File History:
215
--
216
-- $Log: not supported by cvs2svn $
217 77 arniml
-- Revision 1.5  2004/04/24 11:25:39  arniml
218
-- removed dummy_s - workaround not longer needed for GHDL 0.11.1
219
--
220 73 arniml
-- Revision 1.4  2004/04/18 18:59:01  arniml
221
-- add temporary workaround for GHDL 0.11
222
--
223 66 arniml
-- Revision 1.3  2004/04/04 14:15:45  arniml
224
-- add dump_compare support
225
--
226 37 arniml
-- Revision 1.2  2004/03/28 21:28:13  arniml
227
-- take auxiliary carry from direct ALU connection
228
--
229 29 arniml
-- Revision 1.1  2004/03/23 21:31:53  arniml
230
-- initial check-in
231 4 arniml
--
232
-------------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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