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

Subversion Repositories t48

[/] [t48/] [tags/] [rel_1_4/] [rtl/] [vhdl/] [psw.vhd] - Blame information for rev 344

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

powered by: WebSVN 2.1.0

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