w11 - vhd 0.794
W11 CPU core and support modules
Loading...
Searching...
No Matches
pdp11_psr.vhd
Go to the documentation of this file.
1-- $Id: pdp11_psr.vhd 1340 2023-01-01 08:43:05Z mueller $
2-- SPDX-License-Identifier: GPL-3.0-or-later
3-- Copyright 2006-2022 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4--
5------------------------------------------------------------------------------
6-- Module Name: pdp11_psr - syn
7-- Description: pdp11: processor status word register
8--
9-- Dependencies: ib_sel
10-- Test bench: tb/tb_pdp11_core (implicit)
11-- Target Devices: generic
12-- Tool versions: ise 8.2-14.7; viv 2022.1; ghdl 0.18-2.0.0
13--
14-- Revision History:
15-- Date Rev Version Comment
16-- 2022-12-31 1340 1.6.27 BUGFIX: inhibit CCWE when PSW being written
17-- 2022-08-27 1287 1.2.3 handle pm protection like cm, remove or'ing cm
18-- 2011-11-18 427 1.2.2 now numeric_std clean
19-- 2010-10-23 335 1.2.1 use ib_sel
20-- 2010-10-17 333 1.2 use ibus V2 interface
21-- 2009-05-30 220 1.1.4 final removal of snoopers (were already commented)
22-- 2008-08-22 161 1.1.3 rename ubf_ -> ibf_; use iblib
23-- 2008-03-02 121 1.1.2 remove snoopers
24-- 2008-01-05 110 1.1.1 rename IB_MREQ(ena->req) SRES(sel->ack, hold->busy)
25-- 2007-12-30 107 1.1 use IB_MREQ/IB_SRES interface now
26-- 2007-06-14 56 1.0.1 Use slvtypes.all
27-- 2007-05-12 26 1.0 Initial version
28------------------------------------------------------------------------------
29
30library ieee;
31use ieee.std_logic_1164.all;
32use ieee.numeric_std.all;
33
34use work.slvtypes.all;
35use work.iblib.all;
36use work.pdp11.all;
37
38-- ----------------------------------------------------------------------------
39
40entity pdp11_psr is -- processor status word register
41 port (
42 CLK : in slbit; -- clock
43 CRESET : in slbit; -- cpu reset
44 DIN : in slv16; -- input data
45 CCIN : in slv4; -- cc input
46 CCWE : in slbit; -- enable update cc
47 WE : in slbit; -- write enable (from DIN)
48 FUNC : in slv3; -- write function (from DIN)
49 PSW : out psw_type; -- current psw
50 IB_MREQ : in ib_mreq_type; -- ibus request
51 IB_SRES : out ib_sres_type -- ibus response
52 );
53end pdp11_psr;
54
55architecture syn of pdp11_psr is
56
57 constant ibaddr_psr : slv16 := slv(to_unsigned(8#177776#,16));
58
59 signal IBSEL_PSR : slbit := '0';
60 signal R_PSW : psw_type := psw_init; -- ps register
61 signal R_WE_1 : slbit := '0'; -- ps written in previous cycle
62
63begin
64
65 SEL : ib_sel
66 generic map (
68 port map (
69 CLK => CLK,
71 SEL => IBSEL_PSR
72 );
73
74 proc_ibres: process (IBSEL_PSR, IB_MREQ, R_PSW)
75 variable idout : slv16 := (others=>'0');
76 begin
77 idout := (others=>'0');
78 if IBSEL_PSR = '1' then
79 idout(psw_ibf_cmode) := R_PSW.cmode;
80 idout(psw_ibf_pmode) := R_PSW.pmode;
81 idout(psw_ibf_rset) := R_PSW.rset;
82 idout(psw_ibf_pri) := R_PSW.pri;
83 idout(psw_ibf_tflag) := R_PSW.tflag;
84 idout(psw_ibf_cc) := R_PSW.cc;
85 end if;
86 IB_SRES.dout <= idout;
87 IB_SRES.ack <= IBSEL_PSR and (IB_MREQ.re or IB_MREQ.we); -- ack all
88 IB_SRES.busy <= '0';
89 end process proc_ibres;
90
91 proc_psw : process (CLK)
92 begin
93
94 if rising_edge(CLK) then
95
96 R_WE_1 <= IBSEL_PSR and IB_MREQ.we; -- remember ps write
97
98 if CRESET = '1' then
99 R_PSW <= psw_init;
100
101 else
102
103 if CCWE='1' and R_WE_1='0' then -- update cc unless ps written
104 R_PSW.cc <= CCIN;
105 end if;
106
107 if WE = '1' then
108 case FUNC is
109 when c_psr_func_wspl => -- wspl
110 R_PSW.pri <= DIN(2 downto 0);
111
112 when c_psr_func_wcc => -- wcc
113 if DIN(4) = '1' then -- set cc opcodes
114 R_PSW.cc <= R_PSW.cc or DIN(3 downto 0);
115 else -- clear cc opcodes
116 R_PSW.cc <= R_PSW.cc and not DIN(3 downto 0);
117 end if;
118
119 when c_psr_func_wint => -- wint (interupt handling)
120 R_PSW.cmode <= DIN(psw_ibf_cmode);
121 R_PSW.pmode <= R_PSW.cmode; -- save current mode
122 R_PSW.rset <= DIN(psw_ibf_rset);
123 R_PSW.pri <= DIN(psw_ibf_pri);
124 R_PSW.tflag <= DIN(psw_ibf_tflag);
125 R_PSW.cc <= DIN(psw_ibf_cc);
126
127 when c_psr_func_wrti => -- wrti (rti/rtt in non-kernel mode)
128 R_PSW.cmode <= R_PSW.cmode or DIN(psw_ibf_cmode);
129 R_PSW.pmode <= R_PSW.pmode or DIN(psw_ibf_pmode);
130 R_PSW.rset <= R_PSW.rset or DIN(psw_ibf_rset);
131 R_PSW.tflag <= DIN(psw_ibf_tflag);
132 R_PSW.cc <= DIN(psw_ibf_cc);
133
134 when c_psr_func_wall => -- wall (rti/rtt kernel mode)
135 R_PSW.cmode <= DIN(psw_ibf_cmode);
136 R_PSW.pmode <= DIN(psw_ibf_pmode);
137 R_PSW.rset <= DIN(psw_ibf_rset);
138 R_PSW.pri <= DIN(psw_ibf_pri);
139 R_PSW.tflag <= DIN(psw_ibf_tflag);
140 R_PSW.cc <= DIN(psw_ibf_cc);
141
142 when others => null;
143 end case;
144 end if;
145 end if;
146
147 if IBSEL_PSR='1' and IB_MREQ.we='1' then
148 if IB_MREQ.be1 = '1' then
149 R_PSW.cmode <= IB_MREQ.din(psw_ibf_cmode);
150 R_PSW.pmode <= IB_MREQ.din(psw_ibf_pmode);
151 R_PSW.rset <= IB_MREQ.din(psw_ibf_rset);
152 end if;
153 if IB_MREQ.be0 = '1' then
154 R_PSW.pri <= IB_MREQ.din(psw_ibf_pri);
155 R_PSW.cc <= IB_MREQ.din(psw_ibf_cc);
156 end if;
157 end if;
158
159 end if;
160
161 end process proc_psw;
162
163 PSW <= R_PSW;
164
165end syn;
out SEL slbit
Definition: ib_sel.vhd:35
IB_ADDR slv16
Definition: ib_sel.vhd:29
in CLK slbit
Definition: ib_sel.vhd:32
in IB_MREQ ib_mreq_type
Definition: ib_sel.vhd:33
Definition: iblib.vhd:33
psw_type := psw_init R_PSW
Definition: pdp11_psr.vhd:60
slv16 := slv( to_unsigned( 8#177776#, 16) ) ibaddr_psr
Definition: pdp11_psr.vhd:57
slbit := '0' R_WE_1
Definition: pdp11_psr.vhd:61
slbit := '0' IBSEL_PSR
Definition: pdp11_psr.vhd:59
in FUNC slv3
Definition: pdp11_psr.vhd:48
in CLK slbit
Definition: pdp11_psr.vhd:42
in DIN slv16
Definition: pdp11_psr.vhd:44
in CRESET slbit
Definition: pdp11_psr.vhd:43
in IB_MREQ ib_mreq_type
Definition: pdp11_psr.vhd:50
out IB_SRES ib_sres_type
Definition: pdp11_psr.vhd:52
in CCWE slbit
Definition: pdp11_psr.vhd:46
in WE slbit
Definition: pdp11_psr.vhd:47
out PSW psw_type
Definition: pdp11_psr.vhd:49
in CCIN slv4
Definition: pdp11_psr.vhd:45
Definition: pdp11.vhd:123
std_logic_vector( 3 downto 0) slv4
Definition: slvtypes.vhd:36
std_logic_vector( 2 downto 0) slv3
Definition: slvtypes.vhd:35
std_logic_vector( 15 downto 0) slv16
Definition: slvtypes.vhd:48
std_logic slbit
Definition: slvtypes.vhd:30
std_logic_vector slv
Definition: slvtypes.vhd:31