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

Subversion Repositories t48

[/] [t48/] [tags/] [rel_0_3_beta/] [rtl/] [vhdl/] [psw.vhd] - Blame information for rev 29

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 29 arniml
-- $Id: psw.vhd,v 1.2 2004-03-28 21:28:13 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
use ieee.std_logic_arith.all;
84
 
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
 
89
architecture rtl of psw is
90
 
91
  -- special bit positions in PSW
92
  constant carry_c     : natural := 3;
93
  constant aux_carry_c : natural := 2;
94
  constant f0_c        : natural := 1;
95
  constant bs_c        : natural := 0;
96
 
97
  -- the PSW register
98
  signal psw_q : std_logic_vector(3 downto 0);
99
  -- the Stack Pointer
100
  signal sp_q  : unsigned(2 downto 0);
101
 
102
begin
103
 
104
  -----------------------------------------------------------------------------
105
  -- Process psw_reg
106
  --
107
  -- Purpose:
108
  --   Implements the PSW register.
109
  --
110
  psw_reg: process (res_i, clk_i)
111
  begin
112
    if res_i = res_active_c then
113
      psw_q <= (others => '0');
114
      sp_q  <= (others => '0');
115
 
116
    elsif clk_i'event and clk_i = clk_active_c then
117
      if en_clk_i then
118
 
119
        -- T48 bus access
120
        if write_psw_i then
121
          psw_q  <= data_i(7 downto 4);
122
        end if;
123
        if write_sp_i then
124
          sp_q <= unsigned(data_i(2 downto 0));
125
        end if;
126
 
127
        -- increment Stack Pointer
128
        if inc_stackp_i then
129
          sp_q  <= sp_q + 1;
130
        end if;
131
        -- decrement Stack Pointer
132
        if dec_stackp_i then
133
          sp_q  <= sp_q - 1;
134
        end if;
135
 
136
        -- access to special bits
137
        if write_carry_i then
138
          psw_q(carry_c)     <= special_data_i;
139
        end if;
140
        --
141
        if write_aux_carry_i then
142 29 arniml
          psw_q(aux_carry_c) <= aux_carry_i;
143 4 arniml
        end if;
144
        --
145
        if write_f0_i then
146
          psw_q(f0_c)        <= special_data_i;
147
        end if;
148
        --
149
        if write_bs_i then
150
          psw_q(bs_c)        <= special_data_i;
151
        end if;
152
 
153
      end if;
154
 
155
    end if;
156
 
157
  end process psw_reg;
158
  --
159
  -----------------------------------------------------------------------------
160
 
161
 
162
  -----------------------------------------------------------------------------
163
  -- Process data_out
164
  --
165
  -- Purpose:
166
  --   Output multiplexer for T48 Data Bus.
167
  --
168
  data_out: process (read_psw_i,
169
                     read_sp_i,
170
                     psw_q,
171
                     sp_q)
172
  begin
173
    data_o <= (others => bus_idle_level_c);
174
 
175
    if read_psw_i then
176
      data_o(7 downto 4) <= psw_q;
177
    end if;
178
 
179
    if read_sp_i then
180
      data_o(3 downto 0) <= '1' & conv_std_logic_vector(sp_q, 3);
181
    end if;
182
 
183
  end process data_out;
184
  --
185
  -----------------------------------------------------------------------------
186
 
187
 
188
  -----------------------------------------------------------------------------
189
  -- Output mapping.
190
  -----------------------------------------------------------------------------
191
  carry_o     <= psw_q(carry_c);
192
  aux_carry_o <= psw_q(aux_carry_c);
193
  f0_o        <= psw_q(f0_c);
194
  bs_o        <= psw_q(bs_c);
195
 
196
end rtl;
197
 
198
 
199
-------------------------------------------------------------------------------
200
-- File History:
201
--
202
-- $Log: not supported by cvs2svn $
203 29 arniml
-- Revision 1.1  2004/03/23 21:31:53  arniml
204
-- initial check-in
205 4 arniml
--
206
-------------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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