1 |
34 |
wfjm |
-- $Id: pdp11_dmhbpt_unit.vhd 722 2015-12-30 19:45:46Z mueller $
|
2 |
|
|
--
|
3 |
|
|
-- Copyright 2015- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
4 |
|
|
--
|
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_dmhbpt_unit - syn
|
16 |
|
|
-- Description: pdp11: dmhbpt - individual unit
|
17 |
|
|
--
|
18 |
|
|
-- Dependencies: -
|
19 |
|
|
-- Test bench: -
|
20 |
|
|
--
|
21 |
|
|
-- Target Devices: generic
|
22 |
|
|
-- Tool versions: ise 14.7; viv 2014.4; ghdl 0.31
|
23 |
|
|
--
|
24 |
|
|
-- Synthesized (xst):
|
25 |
|
|
-- Date Rev ise Target flop lutl lutm slic t peri
|
26 |
|
|
-- 2015-07-12 700 14.7 131013 xc6slx16-2 39 67 0 21 s 3.8
|
27 |
|
|
--
|
28 |
|
|
-- Revision History: -
|
29 |
|
|
-- Date Rev Version Comment
|
30 |
|
|
-- 2015-07-19 702 1.0 Initial version
|
31 |
|
|
-- 2015-07-05 698 0.1 First draft
|
32 |
|
|
------------------------------------------------------------------------------
|
33 |
|
|
--
|
34 |
|
|
-- rbus registers:
|
35 |
|
|
--
|
36 |
|
|
-- Addr Bits Name r/w/f Function
|
37 |
|
|
-- 00 cntl r/w/- Control register
|
38 |
|
|
-- 05:04 mode r/w/- mode select (k=00,s=01,u=11; 10->all)
|
39 |
|
|
-- 02 irena r/w/- enable instruction read bpt
|
40 |
|
|
-- 01 dwena r/w/- enable data write bpt
|
41 |
|
|
-- 00 drena r/w/- enable data read bpt
|
42 |
|
|
-- 01 stat r/w/- Status register
|
43 |
|
|
-- 01 dwseen r/w/- dw bpt seen
|
44 |
|
|
-- 02 irseen r/w/- ir bpt seen
|
45 |
|
|
-- 00 drseen r/w/- dr bpt seen
|
46 |
|
|
-- 10 15:01 hilim r/w/- upper address limit, inclusive (def: 000000)
|
47 |
|
|
-- 11 15:01 lolim r/w/- lower address limit, inclusive (def: 000000)
|
48 |
|
|
--
|
49 |
|
|
|
50 |
|
|
library ieee;
|
51 |
|
|
use ieee.std_logic_1164.all;
|
52 |
|
|
use ieee.numeric_std.all;
|
53 |
|
|
|
54 |
|
|
use work.slvtypes.all;
|
55 |
|
|
use work.rblib.all;
|
56 |
|
|
use work.pdp11.all;
|
57 |
|
|
|
58 |
|
|
-- ----------------------------------------------------------------------------
|
59 |
|
|
|
60 |
|
|
entity pdp11_dmhbpt_unit is -- dmhbpt - indivitial unit
|
61 |
|
|
generic (
|
62 |
|
|
RB_ADDR : slv16 := slv(to_unsigned(16#0050#,16));
|
63 |
|
|
INDEX : natural := 0);
|
64 |
|
|
port (
|
65 |
|
|
CLK : in slbit; -- clock
|
66 |
|
|
RESET : in slbit; -- reset
|
67 |
|
|
RB_MREQ : in rb_mreq_type; -- rbus: request
|
68 |
|
|
RB_SRES : out rb_sres_type; -- rbus: response
|
69 |
|
|
DM_STAT_SE : in dm_stat_se_type; -- debug and monitor status - sequencer
|
70 |
|
|
DM_STAT_DP : in dm_stat_dp_type; -- debug and monitor status - data path
|
71 |
|
|
DM_STAT_VM : in dm_stat_vm_type; -- debug and monitor status - vmbox
|
72 |
|
|
DM_STAT_CO : in dm_stat_co_type; -- debug and monitor status - core
|
73 |
|
|
HBPT : out slbit -- hw break flag
|
74 |
|
|
);
|
75 |
|
|
end pdp11_dmhbpt_unit;
|
76 |
|
|
|
77 |
|
|
|
78 |
|
|
architecture syn of pdp11_dmhbpt_unit is
|
79 |
|
|
|
80 |
|
|
constant rbaddr_cntl : slv2 := "00"; -- cntl address offset
|
81 |
|
|
constant rbaddr_stat : slv2 := "01"; -- stat address offset
|
82 |
|
|
constant rbaddr_hilim : slv2 := "10"; -- hilim address offset
|
83 |
|
|
constant rbaddr_lolim : slv2 := "11"; -- lolim address offset
|
84 |
|
|
|
85 |
|
|
subtype cntl_rbf_mode is integer range 5 downto 4;
|
86 |
|
|
constant cntl_rbf_irena : integer := 2;
|
87 |
|
|
constant cntl_rbf_dwena : integer := 1;
|
88 |
|
|
constant cntl_rbf_drena : integer := 0;
|
89 |
|
|
|
90 |
|
|
constant stat_rbf_irseen : integer := 2;
|
91 |
|
|
constant stat_rbf_dwseen : integer := 1;
|
92 |
|
|
constant stat_rbf_drseen : integer := 0;
|
93 |
|
|
|
94 |
|
|
-- the mode 10 is used a wildcard, cpu only uses 00 (k) 01 (s) and 11 (u)
|
95 |
|
|
constant cntl_mode_all : slv2 := "10";
|
96 |
|
|
|
97 |
|
|
subtype lim_rbf is integer range 15 downto 1;
|
98 |
|
|
|
99 |
|
|
type regs_type is record
|
100 |
|
|
rbsel : slbit; -- rbus select
|
101 |
|
|
mode : slv2; -- mode select
|
102 |
|
|
irena : slbit; -- ir enable
|
103 |
|
|
dwena : slbit; -- dw enable
|
104 |
|
|
drena : slbit; -- dr enable
|
105 |
|
|
irseen : slbit; -- ir seen
|
106 |
|
|
dwseen : slbit; -- dw seen
|
107 |
|
|
drseen : slbit; -- dr seen
|
108 |
|
|
hilim : slv16_1; -- hilim
|
109 |
|
|
lolim : slv16_1; -- lolim
|
110 |
|
|
end record regs_type;
|
111 |
|
|
|
112 |
|
|
constant regs_init : regs_type := (
|
113 |
|
|
'0', -- rbsel
|
114 |
|
|
"00", -- mode
|
115 |
|
|
'0','0','0', -- *ena
|
116 |
|
|
'0','0','0', -- *seen
|
117 |
|
|
(others=>'0'), -- hilim
|
118 |
|
|
(others=>'0') -- lolim
|
119 |
|
|
);
|
120 |
|
|
|
121 |
|
|
signal R_REGS : regs_type := regs_init; -- state registers
|
122 |
|
|
signal N_REGS : regs_type := regs_init; -- next value state regs
|
123 |
|
|
|
124 |
|
|
begin
|
125 |
|
|
|
126 |
|
|
proc_regs: process (CLK)
|
127 |
|
|
begin
|
128 |
|
|
|
129 |
|
|
if rising_edge(CLK) then
|
130 |
|
|
if RESET = '1' then
|
131 |
|
|
R_REGS <= regs_init;
|
132 |
|
|
else
|
133 |
|
|
R_REGS <= N_REGS;
|
134 |
|
|
end if;
|
135 |
|
|
end if;
|
136 |
|
|
|
137 |
|
|
end process proc_regs;
|
138 |
|
|
|
139 |
|
|
proc_next: process (R_REGS, RB_MREQ, DM_STAT_SE, DM_STAT_DP,
|
140 |
|
|
DM_STAT_VM, DM_STAT_VM.vmcntl, -- xst needs sub-records
|
141 |
|
|
DM_STAT_CO)
|
142 |
|
|
|
143 |
|
|
variable r : regs_type := regs_init;
|
144 |
|
|
variable n : regs_type := regs_init;
|
145 |
|
|
variable irb_ack : slbit := '0';
|
146 |
|
|
variable irb_err : slbit := '0'; -- FIXME: needed ??
|
147 |
|
|
variable irb_busy : slbit := '0'; -- FIXME: needed ??
|
148 |
|
|
variable irb_dout : slv16 := (others=>'0');
|
149 |
|
|
variable irbena : slbit := '0';
|
150 |
|
|
variable ihbpt : slbit := '0';
|
151 |
|
|
|
152 |
|
|
begin
|
153 |
|
|
|
154 |
|
|
r := R_REGS;
|
155 |
|
|
n := R_REGS;
|
156 |
|
|
|
157 |
|
|
irb_ack := '0';
|
158 |
|
|
irb_err := '0';
|
159 |
|
|
irb_busy := '0';
|
160 |
|
|
irb_dout := (others=>'0');
|
161 |
|
|
irbena := RB_MREQ.re or RB_MREQ.we;
|
162 |
|
|
|
163 |
|
|
-- rbus address decoder
|
164 |
|
|
n.rbsel := '0';
|
165 |
|
|
if RB_MREQ.aval='1' and -- address valid
|
166 |
|
|
RB_MREQ.addr(12 downto 4)=RB_ADDR(12 downto 4) and -- block address
|
167 |
|
|
RB_MREQ.addr( 3 downto 2)=slv(to_unsigned(INDEX,2)) -- unit address
|
168 |
|
|
then
|
169 |
|
|
n.rbsel := '1';
|
170 |
|
|
end if;
|
171 |
|
|
|
172 |
|
|
-- rbus transactions
|
173 |
|
|
if r.rbsel = '1' then
|
174 |
|
|
irb_ack := irbena; -- ack all accesses
|
175 |
|
|
case RB_MREQ.addr(1 downto 0) is
|
176 |
|
|
when rbaddr_cntl => -- cntl ------------------
|
177 |
|
|
if RB_MREQ.we = '1' then
|
178 |
|
|
n.mode := RB_MREQ.din(cntl_rbf_mode);
|
179 |
|
|
n.irena := RB_MREQ.din(cntl_rbf_irena);
|
180 |
|
|
n.dwena := RB_MREQ.din(cntl_rbf_dwena);
|
181 |
|
|
n.drena := RB_MREQ.din(cntl_rbf_drena);
|
182 |
|
|
end if;
|
183 |
|
|
|
184 |
|
|
when rbaddr_stat => -- stat ------------------
|
185 |
|
|
if RB_MREQ.we = '1' then
|
186 |
|
|
n.irseen := RB_MREQ.din(stat_rbf_irseen);
|
187 |
|
|
n.dwseen := RB_MREQ.din(stat_rbf_dwseen);
|
188 |
|
|
n.drseen := RB_MREQ.din(stat_rbf_drseen);
|
189 |
|
|
end if;
|
190 |
|
|
|
191 |
|
|
when rbaddr_hilim => -- hilim -----------------
|
192 |
|
|
if RB_MREQ.we = '1' then
|
193 |
|
|
n.hilim := RB_MREQ.din(lim_rbf);
|
194 |
|
|
end if;
|
195 |
|
|
|
196 |
|
|
when rbaddr_lolim => -- lolim -----------------
|
197 |
|
|
if RB_MREQ.we = '1' then
|
198 |
|
|
n.lolim := RB_MREQ.din(lim_rbf);
|
199 |
|
|
end if;
|
200 |
|
|
|
201 |
|
|
when others => null; -- <> --------------------
|
202 |
|
|
end case;
|
203 |
|
|
end if;
|
204 |
|
|
|
205 |
|
|
-- rbus output driver
|
206 |
|
|
if r.rbsel = '1' then
|
207 |
|
|
case RB_MREQ.addr(1 downto 0) is
|
208 |
|
|
when rbaddr_cntl => -- cntl ------------------
|
209 |
|
|
irb_dout(cntl_rbf_mode) := r.mode;
|
210 |
|
|
irb_dout(cntl_rbf_irena) := r.irena;
|
211 |
|
|
irb_dout(cntl_rbf_dwena) := r.dwena;
|
212 |
|
|
irb_dout(cntl_rbf_drena) := r.drena;
|
213 |
|
|
when rbaddr_stat => -- stat ------------------
|
214 |
|
|
irb_dout(stat_rbf_irseen) := r.irseen;
|
215 |
|
|
irb_dout(stat_rbf_dwseen) := r.dwseen;
|
216 |
|
|
irb_dout(stat_rbf_drseen) := r.drseen;
|
217 |
|
|
when rbaddr_hilim => -- hilim -----------------
|
218 |
|
|
irb_dout(lim_rbf) := r.hilim;
|
219 |
|
|
when rbaddr_lolim => -- lolim -----------------
|
220 |
|
|
irb_dout(lim_rbf) := r.lolim;
|
221 |
|
|
when others => null;
|
222 |
|
|
end case;
|
223 |
|
|
end if;
|
224 |
|
|
|
225 |
|
|
-- breakpoint unit logic
|
226 |
|
|
ihbpt := '0';
|
227 |
|
|
if DM_STAT_VM.vmcntl.req = '1' and
|
228 |
|
|
DM_STAT_VM.vmcntl.cacc = '0' and
|
229 |
|
|
(DM_STAT_VM.vmcntl.mode = r.mode or r.mode = cntl_mode_all )and
|
230 |
|
|
unsigned(DM_STAT_VM.vmaddr(lim_rbf))>=unsigned(r.lolim) and
|
231 |
|
|
unsigned(DM_STAT_VM.vmaddr(lim_rbf))<=unsigned(r.hilim) then
|
232 |
|
|
|
233 |
|
|
if r.irena = '1' then
|
234 |
|
|
if DM_STAT_SE.istart = '1' and -- only for instruction fetches !
|
235 |
|
|
DM_STAT_VM.vmcntl.dspace = '0' and
|
236 |
|
|
DM_STAT_VM.vmcntl.wacc = '0' then
|
237 |
|
|
ihbpt := '1';
|
238 |
|
|
n.irseen := '1';
|
239 |
|
|
end if;
|
240 |
|
|
end if;
|
241 |
|
|
|
242 |
|
|
if r.dwena = '1' then
|
243 |
|
|
if DM_STAT_VM.vmcntl.dspace = '1' and
|
244 |
|
|
DM_STAT_VM.vmcntl.wacc = '1' then
|
245 |
|
|
ihbpt := '1';
|
246 |
|
|
n.dwseen := '1';
|
247 |
|
|
end if;
|
248 |
|
|
end if;
|
249 |
|
|
|
250 |
|
|
if r.drena = '1' then
|
251 |
|
|
if DM_STAT_VM.vmcntl.dspace = '1' and
|
252 |
|
|
DM_STAT_VM.vmcntl.wacc = '0' then
|
253 |
|
|
ihbpt := '1';
|
254 |
|
|
n.drseen := '1';
|
255 |
|
|
end if;
|
256 |
|
|
end if;
|
257 |
|
|
|
258 |
|
|
end if;
|
259 |
|
|
|
260 |
|
|
N_REGS <= n;
|
261 |
|
|
|
262 |
|
|
HBPT <= ihbpt;
|
263 |
|
|
|
264 |
|
|
RB_SRES.ack <= irb_ack;
|
265 |
|
|
RB_SRES.err <= irb_err;
|
266 |
|
|
RB_SRES.busy <= irb_busy;
|
267 |
|
|
RB_SRES.dout <= irb_dout;
|
268 |
|
|
|
269 |
|
|
end process proc_next;
|
270 |
|
|
|
271 |
|
|
end syn;
|