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

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.6/] [rtl/] [w11a/] [pdp11_psr.vhd] - Blame information for rev 24

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 13 wfjm
-- $Id: pdp11_psr.vhd 427 2011-11-19 21:04:11Z mueller $
2 2 wfjm
--
3 13 wfjm
-- Copyright 2006-2011 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4 2 wfjm
--
5
-- This program is free software; you may redistribute and/or modify it under
6
-- the terms of the GNU General Public License as published by the Free
7
-- Software Foundation, either version 2, or at your option any later version.
8
--
9
-- This program is distributed in the hope that it will be useful, but
10
-- WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
11
-- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12
-- for complete details.
13
--
14
------------------------------------------------------------------------------
15
-- Module Name:    pdp11_psr - syn
16
-- Description:    pdp11: processor status word register
17
--
18 8 wfjm
-- Dependencies:   ib_sel
19 2 wfjm
-- Test bench:     tb/tb_pdp11_core (implicit)
20
-- Target Devices: generic
21 13 wfjm
-- Tool versions:  xst 8.2, 9.1, 9.2, 12.1, 13.1; ghdl 0.18-0.29
22 8 wfjm
--
23 2 wfjm
-- Revision History: 
24
-- Date         Rev Version  Comment
25 13 wfjm
-- 2011-11-18   427   1.2.2  now numeric_std clean
26 8 wfjm
-- 2010-10-23   335   1.2.1  use ib_sel
27
-- 2010-10-17   333   1.2    use ibus V2 interface
28 2 wfjm
-- 2009-05-30   220   1.1.4  final removal of snoopers (were already commented)
29
-- 2008-08-22   161   1.1.3  rename ubf_ -> ibf_; use iblib
30
-- 2008-03-02   121   1.1.2  remove snoopers
31
-- 2008-01-05   110   1.1.1  rename IB_MREQ(ena->req) SRES(sel->ack, hold->busy)
32
-- 2007-12-30   107   1.1    use IB_MREQ/IB_SRES interface now
33
-- 2007-06-14    56   1.0.1  Use slvtypes.all
34
-- 2007-05-12    26   1.0    Initial version 
35
------------------------------------------------------------------------------
36
 
37
library ieee;
38
use ieee.std_logic_1164.all;
39 13 wfjm
use ieee.numeric_std.all;
40 2 wfjm
 
41
use work.slvtypes.all;
42
use work.iblib.all;
43
use work.pdp11.all;
44
 
45
-- ----------------------------------------------------------------------------
46
 
47
entity pdp11_psr is                     -- processor status word register
48
  port (
49
    CLK : in slbit;                     -- clock
50
    CRESET : in slbit;                  -- console reset
51
    DIN : in slv16;                     -- input data
52
    CCIN : in slv4;                     -- cc input
53
    CCWE : in slbit;                    -- enable update cc
54
    WE : in slbit;                      -- write enable (from DIN)
55
    FUNC : in slv3;                     -- write function (from DIN)
56
    PSW : out psw_type;                 -- current psw
57
    IB_MREQ : in ib_mreq_type;          -- ibus request
58
    IB_SRES : out ib_sres_type          -- ibus response
59
  );
60
end pdp11_psr;
61
 
62
architecture syn of pdp11_psr is
63
 
64 13 wfjm
  constant ibaddr_psr : slv16 := slv(to_unsigned(8#177776#,16));
65 2 wfjm
 
66
  signal IBSEL_PSR : slbit := '0';
67
  signal R_PSW : psw_type := psw_init;  -- ps register
68
 
69
begin
70
 
71 8 wfjm
  SEL : ib_sel
72
    generic map (
73
      IB_ADDR => ibaddr_psr)
74
    port map (
75
      CLK     => CLK,
76
      IB_MREQ => IB_MREQ,
77
      SEL     => IBSEL_PSR
78
    );
79
 
80
  proc_ibres: process (IBSEL_PSR, IB_MREQ, R_PSW)
81
    variable idout : slv16 := (others=>'0');
82 2 wfjm
  begin
83 8 wfjm
    idout := (others=>'0');
84
    if IBSEL_PSR = '1' then
85
      idout(psw_ibf_cmode) := R_PSW.cmode;
86
      idout(psw_ibf_pmode) := R_PSW.pmode;
87
      idout(psw_ibf_rset)  := R_PSW.rset;
88
      idout(psw_ibf_pri)   := R_PSW.pri;
89
      idout(psw_ibf_tflag) := R_PSW.tflag;
90
      idout(psw_ibf_cc)    := R_PSW.cc;
91 2 wfjm
    end if;
92 8 wfjm
    IB_SRES.dout <= idout;
93
    IB_SRES.ack  <= IBSEL_PSR and (IB_MREQ.re or IB_MREQ.we); -- ack all
94 2 wfjm
    IB_SRES.busy <= '0';
95 8 wfjm
  end process proc_ibres;
96 2 wfjm
 
97
  proc_psw : process (CLK)
98
  begin
99
 
100 13 wfjm
    if rising_edge(CLK) then
101 2 wfjm
 
102
      if CRESET = '1' then
103
        R_PSW <= psw_init;
104
 
105
      else
106
 
107
        if CCWE = '1' then
108
          R_PSW.cc <= CCIN;
109
        end if;
110
 
111
        if WE = '1' then
112
          case FUNC is
113
            when c_psr_func_wspl =>       -- wspl
114
              R_PSW.pri <= DIN(2 downto 0);
115
 
116
            when c_psr_func_wcc =>        -- wcc
117
              if DIN(4) = '1' then        --   set cc opcodes
118
                R_PSW.cc <= R_PSW.cc or DIN(3 downto 0);
119
              else                        --   clear cc opcodes
120
                R_PSW.cc <= R_PSW.cc and not DIN(3 downto 0);
121
              end if;
122
 
123
            when c_psr_func_wint =>       -- wint (interupt handling)
124
              R_PSW.cmode <= DIN(psw_ibf_cmode);
125
              R_PSW.pmode <= R_PSW.cmode; --   save current mode
126 8 wfjm
              R_PSW.rset  <= DIN(psw_ibf_rset);
127
              R_PSW.pri   <= DIN(psw_ibf_pri);
128 2 wfjm
              R_PSW.tflag <= DIN(psw_ibf_tflag);
129 8 wfjm
              R_PSW.cc    <= DIN(psw_ibf_cc);
130 2 wfjm
 
131
            when c_psr_func_wrti =>       -- wrti (rti/rtt in non-kernel mode)
132
              R_PSW.cmode <= R_PSW.cmode or DIN(psw_ibf_cmode);
133
              R_PSW.pmode <= R_PSW.pmode or DIN(psw_ibf_pmode) or
134
                             R_PSW.cmode or DIN(psw_ibf_cmode);
135 8 wfjm
              R_PSW.rset  <= R_PSW.rset or DIN(psw_ibf_rset);
136 2 wfjm
              R_PSW.tflag <= DIN(psw_ibf_tflag);
137 8 wfjm
              R_PSW.cc    <= DIN(psw_ibf_cc);
138 2 wfjm
 
139
            when c_psr_func_wall =>       -- wall (rti/rtt kernel mode)
140
              R_PSW.cmode <= DIN(psw_ibf_cmode);
141
              R_PSW.pmode <= DIN(psw_ibf_pmode);
142 8 wfjm
              R_PSW.rset  <= DIN(psw_ibf_rset);
143
              R_PSW.pri   <= DIN(psw_ibf_pri);
144 2 wfjm
              R_PSW.tflag <= DIN(psw_ibf_tflag);
145 8 wfjm
              R_PSW.cc    <= DIN(psw_ibf_cc);
146 2 wfjm
 
147
            when others => null;
148
          end case;
149
        end if;
150
      end if;
151
 
152
      if IBSEL_PSR='1' and IB_MREQ.we='1' then
153
        if IB_MREQ.be1 = '1' then
154
          R_PSW.cmode <= IB_MREQ.din(psw_ibf_cmode);
155
          R_PSW.pmode <= IB_MREQ.din(psw_ibf_pmode);
156 8 wfjm
          R_PSW.rset  <= IB_MREQ.din(psw_ibf_rset);
157 2 wfjm
        end if;
158
        if IB_MREQ.be0 = '1' then
159
          R_PSW.pri <= IB_MREQ.din(psw_ibf_pri);
160 8 wfjm
          R_PSW.cc  <= IB_MREQ.din(psw_ibf_cc);
161 2 wfjm
        end if;
162
      end if;
163
 
164
    end if;
165
 
166
  end process proc_psw;
167
 
168
  PSW <= R_PSW;
169
 
170
end syn;

powered by: WebSVN 2.1.0

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