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

Subversion Repositories w11

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

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

Line No. Rev Author Line
1 8 wfjm
-- $Id: pdp11_psr.vhd 335 2010-10-24 22:24:23Z mueller $
2 2 wfjm
--
3 8 wfjm
-- Copyright 2006-2010 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 8 wfjm
-- Tool versions:  xst 8.1, 8.2, 9.1, 9.2, 12.1; ghdl 0.18-0.29
22
--
23 2 wfjm
-- Revision History: 
24
-- Date         Rev Version  Comment
25 8 wfjm
-- 2010-10-23   335   1.2.1  use ib_sel
26
-- 2010-10-17   333   1.2    use ibus V2 interface
27 2 wfjm
-- 2009-05-30   220   1.1.4  final removal of snoopers (were already commented)
28
-- 2008-08-22   161   1.1.3  rename ubf_ -> ibf_; use iblib
29
-- 2008-03-02   121   1.1.2  remove snoopers
30
-- 2008-01-05   110   1.1.1  rename IB_MREQ(ena->req) SRES(sel->ack, hold->busy)
31
-- 2007-12-30   107   1.1    use IB_MREQ/IB_SRES interface now
32
-- 2007-06-14    56   1.0.1  Use slvtypes.all
33
-- 2007-05-12    26   1.0    Initial version 
34
------------------------------------------------------------------------------
35
 
36
library ieee;
37
use ieee.std_logic_1164.all;
38
use ieee.std_logic_arith.all;
39
 
40
use work.slvtypes.all;
41
use work.iblib.all;
42
use work.pdp11.all;
43
 
44
-- ----------------------------------------------------------------------------
45
 
46
entity pdp11_psr is                     -- processor status word register
47
  port (
48
    CLK : in slbit;                     -- clock
49
    CRESET : in slbit;                  -- console reset
50
    DIN : in slv16;                     -- input data
51
    CCIN : in slv4;                     -- cc input
52
    CCWE : in slbit;                    -- enable update cc
53
    WE : in slbit;                      -- write enable (from DIN)
54
    FUNC : in slv3;                     -- write function (from DIN)
55
    PSW : out psw_type;                 -- current psw
56
    IB_MREQ : in ib_mreq_type;          -- ibus request
57
    IB_SRES : out ib_sres_type          -- ibus response
58
  );
59
end pdp11_psr;
60
 
61
architecture syn of pdp11_psr is
62
 
63
  constant ibaddr_psr : slv16 := conv_std_logic_vector(8#177776#,16);
64
 
65
  signal IBSEL_PSR : slbit := '0';
66
  signal R_PSW : psw_type := psw_init;  -- ps register
67
 
68
begin
69
 
70 8 wfjm
  SEL : ib_sel
71
    generic map (
72
      IB_ADDR => ibaddr_psr)
73
    port map (
74
      CLK     => CLK,
75
      IB_MREQ => IB_MREQ,
76
      SEL     => IBSEL_PSR
77
    );
78
 
79
  proc_ibres: process (IBSEL_PSR, IB_MREQ, R_PSW)
80
    variable idout : slv16 := (others=>'0');
81 2 wfjm
  begin
82 8 wfjm
    idout := (others=>'0');
83
    if IBSEL_PSR = '1' then
84
      idout(psw_ibf_cmode) := R_PSW.cmode;
85
      idout(psw_ibf_pmode) := R_PSW.pmode;
86
      idout(psw_ibf_rset)  := R_PSW.rset;
87
      idout(psw_ibf_pri)   := R_PSW.pri;
88
      idout(psw_ibf_tflag) := R_PSW.tflag;
89
      idout(psw_ibf_cc)    := R_PSW.cc;
90 2 wfjm
    end if;
91 8 wfjm
    IB_SRES.dout <= idout;
92
    IB_SRES.ack  <= IBSEL_PSR and (IB_MREQ.re or IB_MREQ.we); -- ack all
93 2 wfjm
    IB_SRES.busy <= '0';
94 8 wfjm
  end process proc_ibres;
95 2 wfjm
 
96
  proc_psw : process (CLK)
97
  begin
98
 
99
    if CLK'event and CLK='1' then
100
 
101
      if CRESET = '1' then
102
        R_PSW <= psw_init;
103
 
104
      else
105
 
106
        if CCWE = '1' then
107
          R_PSW.cc <= CCIN;
108
        end if;
109
 
110
        if WE = '1' then
111
          case FUNC is
112
            when c_psr_func_wspl =>       -- wspl
113
              R_PSW.pri <= DIN(2 downto 0);
114
 
115
            when c_psr_func_wcc =>        -- wcc
116
              if DIN(4) = '1' then        --   set cc opcodes
117
                R_PSW.cc <= R_PSW.cc or DIN(3 downto 0);
118
              else                        --   clear cc opcodes
119
                R_PSW.cc <= R_PSW.cc and not DIN(3 downto 0);
120
              end if;
121
 
122
            when c_psr_func_wint =>       -- wint (interupt handling)
123
              R_PSW.cmode <= DIN(psw_ibf_cmode);
124
              R_PSW.pmode <= R_PSW.cmode; --   save current mode
125 8 wfjm
              R_PSW.rset  <= DIN(psw_ibf_rset);
126
              R_PSW.pri   <= DIN(psw_ibf_pri);
127 2 wfjm
              R_PSW.tflag <= DIN(psw_ibf_tflag);
128 8 wfjm
              R_PSW.cc    <= DIN(psw_ibf_cc);
129 2 wfjm
 
130
            when c_psr_func_wrti =>       -- wrti (rti/rtt in non-kernel mode)
131
              R_PSW.cmode <= R_PSW.cmode or DIN(psw_ibf_cmode);
132
              R_PSW.pmode <= R_PSW.pmode or DIN(psw_ibf_pmode) or
133
                             R_PSW.cmode or DIN(psw_ibf_cmode);
134 8 wfjm
              R_PSW.rset  <= R_PSW.rset or DIN(psw_ibf_rset);
135 2 wfjm
              R_PSW.tflag <= DIN(psw_ibf_tflag);
136 8 wfjm
              R_PSW.cc    <= DIN(psw_ibf_cc);
137 2 wfjm
 
138
            when c_psr_func_wall =>       -- wall (rti/rtt kernel mode)
139
              R_PSW.cmode <= DIN(psw_ibf_cmode);
140
              R_PSW.pmode <= DIN(psw_ibf_pmode);
141 8 wfjm
              R_PSW.rset  <= DIN(psw_ibf_rset);
142
              R_PSW.pri   <= DIN(psw_ibf_pri);
143 2 wfjm
              R_PSW.tflag <= DIN(psw_ibf_tflag);
144 8 wfjm
              R_PSW.cc    <= DIN(psw_ibf_cc);
145 2 wfjm
 
146
            when others => null;
147
          end case;
148
        end if;
149
      end if;
150
 
151
      if IBSEL_PSR='1' and IB_MREQ.we='1' then
152
        if IB_MREQ.be1 = '1' then
153
          R_PSW.cmode <= IB_MREQ.din(psw_ibf_cmode);
154
          R_PSW.pmode <= IB_MREQ.din(psw_ibf_pmode);
155 8 wfjm
          R_PSW.rset  <= IB_MREQ.din(psw_ibf_rset);
156 2 wfjm
        end if;
157
        if IB_MREQ.be0 = '1' then
158
          R_PSW.pri <= IB_MREQ.din(psw_ibf_pri);
159 8 wfjm
          R_PSW.cc  <= IB_MREQ.din(psw_ibf_cc);
160 2 wfjm
        end if;
161
      end if;
162
 
163
    end if;
164
 
165
  end process proc_psw;
166
 
167
  PSW <= R_PSW;
168
 
169
end syn;

powered by: WebSVN 2.1.0

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