1 |
13 |
wfjm |
-- $Id: pdp11_tmu.vhd 427 2011-11-19 21:04:11Z mueller $
|
2 |
2 |
wfjm |
--
|
3 |
13 |
wfjm |
-- Copyright 2008-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_tmu - sim
|
16 |
|
|
-- Description: pdp11: trace and monitor unit
|
17 |
|
|
--
|
18 |
|
|
-- Dependencies: -
|
19 |
|
|
--
|
20 |
|
|
-- Test bench: tb/tb_pdp11_core (implicit)
|
21 |
|
|
-- Target Devices: generic
|
22 |
13 |
wfjm |
-- Tool versions: ghdl 0.18-0.29
|
23 |
8 |
wfjm |
--
|
24 |
2 |
wfjm |
-- Revision History:
|
25 |
|
|
-- Date Rev Version Comment
|
26 |
13 |
wfjm |
-- 2011-11-18 427 1.0.7 now numeric_std clean
|
27 |
8 |
wfjm |
-- 2010-10-17 333 1.0.6 use ibus V2 interface
|
28 |
2 |
wfjm |
-- 2010-06-26 309 1.0.5 add ibmreq.dip,.cacc,.racc to trace
|
29 |
|
|
-- 2009-05-10 214 1.0.4 add ENA signal (trace enable)
|
30 |
|
|
-- 2008-12-14 177 1.0.3 write gpr_* of DM_STAT_DP and dp_ireg_we_last
|
31 |
|
|
-- 2008-12-13 176 1.0.2 write only cycle currently used by tmu_conf
|
32 |
|
|
-- 2008-08-22 161 1.0.1 rename ubf_ -> ibf_
|
33 |
|
|
-- 2008-04-19 137 1.0 Initial version
|
34 |
|
|
------------------------------------------------------------------------------
|
35 |
|
|
|
36 |
|
|
library ieee;
|
37 |
|
|
use ieee.std_logic_1164.all;
|
38 |
13 |
wfjm |
use ieee.numeric_std.all;
|
39 |
2 |
wfjm |
use ieee.std_logic_textio.all;
|
40 |
|
|
use std.textio.all;
|
41 |
|
|
|
42 |
|
|
use work.slvtypes.all;
|
43 |
|
|
use work.simlib.all;
|
44 |
|
|
use work.simbus.all;
|
45 |
|
|
use work.pdp11.all;
|
46 |
|
|
|
47 |
|
|
-- ----------------------------------------------------------------------------
|
48 |
|
|
|
49 |
|
|
entity pdp11_tmu is -- trace and monitor unit
|
50 |
|
|
port (
|
51 |
|
|
CLK : in slbit; -- clock
|
52 |
|
|
ENA : in slbit := '0'; -- enable trace output
|
53 |
|
|
DM_STAT_DP : in dm_stat_dp_type; -- DM dpath
|
54 |
|
|
DM_STAT_VM : in dm_stat_vm_type; -- DM vmbox
|
55 |
|
|
DM_STAT_CO : in dm_stat_co_type; -- DM core
|
56 |
|
|
DM_STAT_SY : in dm_stat_sy_type -- DM system
|
57 |
|
|
);
|
58 |
|
|
end pdp11_tmu;
|
59 |
|
|
|
60 |
|
|
|
61 |
|
|
architecture sim of pdp11_tmu is
|
62 |
|
|
|
63 |
|
|
signal R_FIRST : slbit := '1';
|
64 |
|
|
|
65 |
|
|
begin
|
66 |
|
|
|
67 |
|
|
proc_tm: process (CLK)
|
68 |
|
|
variable oline : line;
|
69 |
|
|
variable ipsw : slv16 := (others=>'0');
|
70 |
|
|
variable ibaddr : slv16 := (others=>'0');
|
71 |
|
|
variable emaddr : slv22 := (others=>'0');
|
72 |
|
|
variable dp_ireg_we_last : slbit := '0';
|
73 |
|
|
variable vm_ibsres_busy_last : slbit := '0';
|
74 |
|
|
variable vm_ibsres_ack_last : slbit := '0';
|
75 |
|
|
variable wcycle : boolean := false;
|
76 |
|
|
file ofile : text open write_mode is "tmu_ofile";
|
77 |
|
|
begin
|
78 |
|
|
|
79 |
|
|
|
80 |
13 |
wfjm |
if rising_edge(CLK) then
|
81 |
2 |
wfjm |
|
82 |
|
|
if R_FIRST = '1' then
|
83 |
|
|
R_FIRST <= '0';
|
84 |
|
|
write(oline, string'("#"));
|
85 |
|
|
write(oline, string'(" clkcycle:d"));
|
86 |
|
|
write(oline, string'(" cpu:o"));
|
87 |
|
|
write(oline, string'(" dp.pc:o"));
|
88 |
|
|
write(oline, string'(" dp.psw:o"));
|
89 |
|
|
write(oline, string'(" dp.ireg:o"));
|
90 |
|
|
write(oline, string'(" dp.ireg_we:b"));
|
91 |
|
|
write(oline, string'(" dp.ireg_we_last:b")); -- is ireg_we last cycle
|
92 |
|
|
write(oline, string'(" dp.dsrc:o"));
|
93 |
|
|
write(oline, string'(" dp.ddst:o"));
|
94 |
|
|
write(oline, string'(" dp.dtmp:o"));
|
95 |
|
|
write(oline, string'(" dp.dres:o"));
|
96 |
|
|
write(oline, string'(" dp.gpr_adst:o"));
|
97 |
|
|
write(oline, string'(" dp.gpr_mode:o"));
|
98 |
|
|
write(oline, string'(" dp.gpr_bytop:b"));
|
99 |
|
|
write(oline, string'(" dp.gpr_we:b"));
|
100 |
|
|
|
101 |
8 |
wfjm |
write(oline, string'(" vm.ibmreq.aval:b"));
|
102 |
|
|
write(oline, string'(" vm.ibmreq.re:b"));
|
103 |
2 |
wfjm |
write(oline, string'(" vm.ibmreq.we:b"));
|
104 |
8 |
wfjm |
write(oline, string'(" vm.ibmreq.rmw:b"));
|
105 |
2 |
wfjm |
write(oline, string'(" vm.ibmreq.be0:b"));
|
106 |
|
|
write(oline, string'(" vm.ibmreq.be1:b"));
|
107 |
|
|
write(oline, string'(" vm.ibmreq.cacc:b"));
|
108 |
|
|
write(oline, string'(" vm.ibmreq.racc:b"));
|
109 |
|
|
write(oline, string'(" vm.ibmreq.addr:o"));
|
110 |
|
|
write(oline, string'(" vm.ibmreq.din:o"));
|
111 |
|
|
write(oline, string'(" vm.ibsres.ack:b"));
|
112 |
|
|
write(oline, string'(" vm.ibsres.busy:b"));
|
113 |
|
|
write(oline, string'(" vm.ibsres.dout:o"));
|
114 |
|
|
|
115 |
|
|
write(oline, string'(" co.cpugo:b"));
|
116 |
|
|
write(oline, string'(" co.cpuhalt:b"));
|
117 |
|
|
|
118 |
|
|
write(oline, string'(" sy.emmreq.req:b"));
|
119 |
|
|
write(oline, string'(" sy.emmreq.we:b"));
|
120 |
|
|
write(oline, string'(" sy.emmreq.be:b"));
|
121 |
|
|
write(oline, string'(" sy.emmreq.cancel:b"));
|
122 |
|
|
write(oline, string'(" sy.emmreq.addr:o"));
|
123 |
|
|
write(oline, string'(" sy.emmreq.din:o"));
|
124 |
|
|
write(oline, string'(" sy.emsres.ack_r:b"));
|
125 |
|
|
write(oline, string'(" sy.emsres.ack_w:b"));
|
126 |
|
|
write(oline, string'(" sy.emsres.dout:o"));
|
127 |
|
|
write(oline, string'(" sy.chit:b"));
|
128 |
|
|
|
129 |
|
|
writeline(ofile, oline);
|
130 |
|
|
end if;
|
131 |
|
|
|
132 |
|
|
ipsw := (others=>'0');
|
133 |
|
|
ipsw(psw_ibf_cmode) := DM_STAT_DP.psw.cmode;
|
134 |
|
|
ipsw(psw_ibf_pmode) := DM_STAT_DP.psw.pmode;
|
135 |
|
|
ipsw(psw_ibf_rset) := DM_STAT_DP.psw.rset;
|
136 |
|
|
ipsw(psw_ibf_pri) := DM_STAT_DP.psw.pri;
|
137 |
|
|
ipsw(psw_ibf_tflag) := DM_STAT_DP.psw.tflag;
|
138 |
|
|
ipsw(psw_ibf_cc) := DM_STAT_DP.psw.cc;
|
139 |
|
|
|
140 |
|
|
ibaddr := "1110000000000000";
|
141 |
|
|
ibaddr(DM_STAT_VM.ibmreq.addr'range) := DM_STAT_VM.ibmreq.addr;
|
142 |
|
|
|
143 |
|
|
emaddr := (others=>'0');
|
144 |
|
|
emaddr(DM_STAT_SY.emmreq.addr'range) := DM_STAT_SY.emmreq.addr;
|
145 |
|
|
|
146 |
|
|
wcycle := false;
|
147 |
|
|
if dp_ireg_we_last='1' or
|
148 |
|
|
DM_STAT_DP.gpr_we='1' or
|
149 |
|
|
DM_STAT_SY.emmreq.req='1' or
|
150 |
|
|
DM_STAT_SY.emsres.ack_r='1' or
|
151 |
|
|
DM_STAT_SY.emsres.ack_w='1' or
|
152 |
|
|
DM_STAT_SY.emmreq.cancel='1' or
|
153 |
8 |
wfjm |
DM_STAT_VM.ibmreq.re='1' or
|
154 |
|
|
DM_STAT_VM.ibmreq.we='1' or
|
155 |
2 |
wfjm |
DM_STAT_VM.ibsres.ack='1'
|
156 |
|
|
then
|
157 |
|
|
wcycle := true;
|
158 |
|
|
end if;
|
159 |
|
|
|
160 |
|
|
if DM_STAT_VM.ibsres.busy='0' and
|
161 |
|
|
(vm_ibsres_busy_last='1' and vm_ibsres_ack_last='0')
|
162 |
|
|
then
|
163 |
|
|
wcycle := true;
|
164 |
|
|
end if;
|
165 |
|
|
|
166 |
|
|
if ENA = '0' then -- if not enabled
|
167 |
|
|
wcycle := false; -- force to not logged...
|
168 |
|
|
end if;
|
169 |
|
|
|
170 |
|
|
if wcycle then
|
171 |
13 |
wfjm |
write(oline, to_integer(unsigned(SB_CLKCYCLE)), right, 9);
|
172 |
2 |
wfjm |
write(oline, string'(" 0"));
|
173 |
|
|
writeoct(oline, DM_STAT_DP.pc, right, 7);
|
174 |
|
|
writeoct(oline, ipsw, right, 7);
|
175 |
|
|
writeoct(oline, DM_STAT_DP.ireg, right, 7);
|
176 |
|
|
write(oline, DM_STAT_DP.ireg_we, right, 2);
|
177 |
|
|
write(oline, dp_ireg_we_last, right, 2);
|
178 |
|
|
writeoct(oline, DM_STAT_DP.dsrc, right, 7);
|
179 |
|
|
writeoct(oline, DM_STAT_DP.ddst, right, 7);
|
180 |
|
|
writeoct(oline, DM_STAT_DP.dtmp, right, 7);
|
181 |
|
|
writeoct(oline, DM_STAT_DP.dres, right, 7);
|
182 |
|
|
writeoct(oline, DM_STAT_DP.gpr_adst, right, 2);
|
183 |
|
|
writeoct(oline, DM_STAT_DP.gpr_mode, right, 2);
|
184 |
|
|
write(oline, DM_STAT_DP.gpr_bytop, right, 2);
|
185 |
|
|
write(oline, DM_STAT_DP.gpr_we, right, 2);
|
186 |
|
|
|
187 |
8 |
wfjm |
write(oline, DM_STAT_VM.ibmreq.aval, right, 2);
|
188 |
|
|
write(oline, DM_STAT_VM.ibmreq.re, right, 2);
|
189 |
2 |
wfjm |
write(oline, DM_STAT_VM.ibmreq.we, right, 2);
|
190 |
8 |
wfjm |
write(oline, DM_STAT_VM.ibmreq.rmw, right, 2);
|
191 |
2 |
wfjm |
write(oline, DM_STAT_VM.ibmreq.be0, right, 2);
|
192 |
|
|
write(oline, DM_STAT_VM.ibmreq.be1, right, 2);
|
193 |
|
|
write(oline, DM_STAT_VM.ibmreq.cacc, right, 2);
|
194 |
|
|
write(oline, DM_STAT_VM.ibmreq.racc, right, 2);
|
195 |
|
|
writeoct(oline, ibaddr, right, 7);
|
196 |
|
|
writeoct(oline, DM_STAT_VM.ibmreq.din, right, 7);
|
197 |
|
|
write(oline, DM_STAT_VM.ibsres.ack, right, 2);
|
198 |
|
|
write(oline, DM_STAT_VM.ibsres.busy, right, 2);
|
199 |
|
|
writeoct(oline, DM_STAT_VM.ibsres.dout, right, 7);
|
200 |
|
|
|
201 |
|
|
write(oline, DM_STAT_CO.cpugo, right, 2);
|
202 |
|
|
write(oline, DM_STAT_CO.cpuhalt, right, 2);
|
203 |
|
|
|
204 |
|
|
write(oline, DM_STAT_SY.emmreq.req, right, 2);
|
205 |
|
|
write(oline, DM_STAT_SY.emmreq.we, right, 2);
|
206 |
|
|
write(oline, DM_STAT_SY.emmreq.be, right, 3);
|
207 |
|
|
write(oline, DM_STAT_SY.emmreq.cancel, right, 2);
|
208 |
|
|
writeoct(oline, emaddr, right, 9);
|
209 |
|
|
writeoct(oline, DM_STAT_SY.emmreq.din, right, 7);
|
210 |
|
|
write(oline, DM_STAT_SY.emsres.ack_r, right, 2);
|
211 |
|
|
write(oline, DM_STAT_SY.emsres.ack_w, right, 2);
|
212 |
|
|
writeoct(oline, DM_STAT_SY.emsres.dout, right, 7);
|
213 |
|
|
write(oline, DM_STAT_SY.chit, right, 2);
|
214 |
|
|
|
215 |
|
|
writeline(ofile, oline);
|
216 |
|
|
end if;
|
217 |
|
|
|
218 |
|
|
dp_ireg_we_last := DM_STAT_DP.ireg_we;
|
219 |
|
|
vm_ibsres_busy_last := DM_STAT_VM.ibsres.busy;
|
220 |
|
|
vm_ibsres_ack_last := DM_STAT_VM.ibsres.ack;
|
221 |
|
|
|
222 |
|
|
end if;
|
223 |
|
|
|
224 |
|
|
end process proc_tm;
|
225 |
|
|
|
226 |
|
|
end sim;
|