w11 - vhd 0.794
W11 CPU core and support modules
Loading...
Searching...
No Matches
pdp11_dpath.vhd
Go to the documentation of this file.
1-- $Id: pdp11_dpath.vhd 1342 2023-01-02 15:18:19Z mueller $
2-- SPDX-License-Identifier: GPL-3.0-or-later
3-- Copyright 2006-2023 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4--
5------------------------------------------------------------------------------
6-- Module Name: pdp11_dpath - syn
7-- Description: pdp11: CPU datapath
8--
9-- Dependencies: pdp11_gr
10-- pdp11_psr
11-- pdp11_ounit
12-- pdp11_aunit
13-- pdp11_lunit
14-- pdp11_munit
15--
16-- Test bench: tb/tb_pdp11_core (implicit)
17-- Target Devices: generic
18-- Tool versions: ise 8.2-14.7; viv 2014.4-2022.1; ghdl 0.18-2.0.0
19--
20-- Revision History:
21-- Date Rev Version Comment
22-- 2023-01-01 1342 1.2.8 use c_dpath_dsrc_src,c_dpath_ddst_dst
23-- 2022-12-27 1339 1.2.7 remove PCOUT port
24-- 2022-10-25 1309 1.2.6 rename _gpr -> _gr
25-- 2015-07-19 702 1.2.5 set new DM_STAT_DP fields
26-- 2014-08-10 581 1.2.4 use c_cc_f_*
27-- 2014-07-12 569 1.2.3 use DIV_QUIT and S_DIV_SR for pdp11_munit
28-- 2011-11-18 427 1.2.2 now numeric_std clean
29-- 2010-09-18 300 1.2.1 rename (adlm)box->(oalm)unit
30-- 2010-06-13 305 1.2 rename CPDIN -> CP_DIN; add CP_DOUT out port;
31-- remove CPADDR out port; drop R_CPADDR, proc_cpaddr;
32-- added R_CPDOUT, proc_cpdout
33-- 2009-05-30 220 1.1.6 final removal of snoopers (were already commented)
34-- 2008-12-14 177 1.1.5 fill gpr_* fields in DM_STAT_DP
35-- 2008-08-22 161 1.1.4 rename ubf_ -> ibf_; use iblib
36-- 2008-04-19 137 1.1.3 add DM_STAT_DP port
37-- 2008-03-02 121 1.1.2 remove snoopers
38-- 2008-02-24 119 1.1.1 add CPADDR register, remove R_MDIN (not needed)
39-- 2007-12-30 107 1.1 use IB_MREQ/IB_SRES interface now (for psr access)
40-- 2007-06-14 56 1.0.1 Use slvtypes.all
41-- 2007-05-12 26 1.0 Initial version
42------------------------------------------------------------------------------
43
44library ieee;
45use ieee.std_logic_1164.all;
46use ieee.numeric_std.all;
47
48use work.slvtypes.all;
49use work.iblib.all;
50use work.pdp11.all;
51
52-- ----------------------------------------------------------------------------
53
54entity pdp11_dpath is -- CPU datapath
55 port (
56 CLK : in slbit; -- clock
57 CRESET : in slbit; -- cpu reset
58 CNTL : in dpath_cntl_type; -- control interface
59 STAT : out dpath_stat_type; -- status interface
60 CP_DIN : in slv16; -- console port data in
61 CP_DOUT : out slv16; -- console port data out
62 PSWOUT : out psw_type; -- current psw
63 IREG : out slv16; -- ireg out
64 VM_ADDR : out slv16; -- virt. memory address
65 VM_DOUT : in slv16; -- virt. memory data out
66 VM_DIN : out slv16; -- virt. memory data in
67 IB_MREQ : in ib_mreq_type; -- ibus request
68 IB_SRES : out ib_sres_type; -- ibus response
69 DM_STAT_DP : out dm_stat_dp_type -- debug and monitor status
70 );
71end pdp11_dpath;
72
73architecture syn of pdp11_dpath is
74
75 signal R_DSRC : slv16 := (others=>'0'); -- SRC register
76 signal R_DDST : slv16 := (others=>'0'); -- DST register
77 signal R_DTMP : slv16 := (others=>'0'); -- TMP register
78
79 signal R_IREG : slv16 := (others=>'0'); -- IREG register
80
81 signal R_CPDOUT : slv16 := (others=>'0'); -- cp dout buffer
82
83 signal GR_DSRC : slv16 := (others=>'0'); -- source register
84 signal GR_DDST : slv16 := (others=>'0'); -- destination register
85 signal GR_PC : slv16 := (others=>'0'); -- program counter
86
87 signal PSW : psw_type := psw_init; --
88 signal CCIN : slv4 := (others=>'0'); -- cc input to xbox's
89 signal CCOUT : slv4 := (others=>'0'); -- cc output from xbox's
90
91 signal DRES : slv16 := (others=>'0'); -- result bus
92 signal DRESE : slv16 := (others=>'0'); -- result bus extra
93
94 signal OUNIT_DOUT : slv16 := (others=>'0'); -- result ounit
95 signal AUNIT_DOUT : slv16 := (others=>'0'); -- result aunit
96 signal LUNIT_DOUT : slv16 := (others=>'0'); -- result lunit
97 signal MUNIT_DOUT : slv16 := (others=>'0'); -- result munit
98
99 signal OUNIT_NZOUT : slv2 := (others=>'0'); -- nz flags ounit
100 signal OUNIT_CCOUT : slv4 := (others=>'0'); -- cc flags ounit
101 signal AUNIT_CCOUT : slv4 := (others=>'0'); -- cc flags aunit
102 signal LUNIT_CCOUT : slv4 := (others=>'0'); -- cc flags lunit
103 signal MUNIT_CCOUT : slv4 := (others=>'0'); -- cc flags munit
104
105 subtype lal_ibf_addr is integer range 15 downto 1;
106 subtype lah_ibf_addr is integer range 5 downto 0;
107 constant lah_ibf_ena_22bit: integer := 6;
108 constant lah_ibf_ena_ubmap: integer := 7;
109
110begin
111
112 GR : pdp11_gr port map (
113 CLK => CLK,
114 DIN => DRES,
115 ASRC => CNTL.gr_asrc,
116 ADST => CNTL.gr_adst,
117 MODE => CNTL.gr_mode,
118 RSET => CNTL.gr_rset,
119 WE => CNTL.gr_we,
120 BYTOP => CNTL.gr_bytop,
121 PCINC => CNTL.gr_pcinc,
122 DSRC => GR_DSRC,
123 DDST => GR_DDST,
124 PC => GR_PC
125 );
126
127 PSR : pdp11_psr port map(
128 CLK => CLK,
129 CRESET => CRESET,
130 DIN => DRES,
131 CCIN => CCOUT,
132 CCWE => CNTL.psr_ccwe,
133 WE => CNTL.psr_we,
134 FUNC => CNTL.psr_func,
135 PSW => PSW,
136 IB_MREQ => IB_MREQ,
138 );
139
140 OUNIT : pdp11_ounit port map (
141 DSRC => R_DSRC,
142 DDST => R_DDST,
143 DTMP => R_DTMP,
144 PC => GR_PC,
145 ASEL => CNTL.ounit_asel,
146 AZERO => CNTL.ounit_azero,
147 IREG8 => R_IREG(7 downto 0),
148 VMDOUT => VM_DOUT,
149 CONST => CNTL.ounit_const,
150 BSEL => CNTL.ounit_bsel,
151 OPSUB => CNTL.ounit_opsub,
152 DOUT => OUNIT_DOUT,
154 );
155
156 AUNIT : pdp11_aunit port map (
157 DSRC => R_DSRC,
158 DDST => R_DDST,
159 CI => CCIN(c_cc_f_c),
160 SRCMOD => CNTL.aunit_srcmod,
161 DSTMOD => CNTL.aunit_dstmod,
162 CIMOD => CNTL.aunit_cimod,
163 CC1OP => CNTL.aunit_cc1op,
164 CCMODE => CNTL.aunit_ccmode,
165 BYTOP => CNTL.aunit_bytop,
166 DOUT => AUNIT_DOUT,
168 );
169
170 LUNIT : pdp11_lunit port map (
171 DSRC => R_DSRC,
172 DDST => R_DDST,
173 CCIN => CCIN,
174 FUNC => CNTL.lunit_func,
175 BYTOP => CNTL.lunit_bytop,
176 DOUT => LUNIT_DOUT,
178 );
179
180 MUNIT : pdp11_munit port map (
181 CLK => CLK,
182 DSRC => R_DSRC,
183 DDST => R_DDST,
184 DTMP => R_DTMP,
185 GR_DSRC => GR_DSRC,
186 FUNC => CNTL.munit_func,
187 S_DIV => CNTL.munit_s_div,
188 S_DIV_CN => CNTL.munit_s_div_cn,
189 S_DIV_CR => CNTL.munit_s_div_cr,
190 S_DIV_SR => CNTL.munit_s_div_sr,
191 S_ASH => CNTL.munit_s_ash,
192 S_ASH_CN => CNTL.munit_s_ash_cn,
193 S_ASHC => CNTL.munit_s_ashc,
194 S_ASHC_CN => CNTL.munit_s_ashc_cn,
195 SHC_TC => STAT.shc_tc,
196 DIV_CR => STAT.div_cr,
197 DIV_CQ => STAT.div_cq,
198 DIV_QUIT => STAT.div_quit,
199 DOUT => MUNIT_DOUT,
200 DOUTE => DRESE,
202 );
203
204 CCIN <= PSW.cc;
205
206 OUNIT_CCOUT <= OUNIT_NZOUT & "0" & CCIN(c_cc_f_c); -- clear v, keep c
207
208 proc_dres_sel: process (OUNIT_DOUT, AUNIT_DOUT, LUNIT_DOUT, MUNIT_DOUT,
210 begin
211 case CNTL.dres_sel is
212 when c_dpath_res_ounit => DRES <= OUNIT_DOUT;
213 when c_dpath_res_aunit => DRES <= AUNIT_DOUT;
214 when c_dpath_res_lunit => DRES <= LUNIT_DOUT;
215 when c_dpath_res_munit => DRES <= MUNIT_DOUT;
216 when c_dpath_res_vmdout => DRES <= VM_DOUT;
217 when c_dpath_res_fpdout => DRES <= (others=>'0');
218 when c_dpath_res_ireg => DRES <= R_IREG;
219 when c_dpath_res_cpdin => DRES <= CP_DIN;
220 when others => null;
221 end case;
222 end process proc_dres_sel;
223
224 proc_cres_sel: process (OUNIT_CCOUT, AUNIT_CCOUT, LUNIT_CCOUT, MUNIT_CCOUT,
225 CCIN, CNTL)
226 begin
227 case CNTL.cres_sel is
228 when c_dpath_res_ounit => CCOUT <= OUNIT_CCOUT;
229 when c_dpath_res_aunit => CCOUT <= AUNIT_CCOUT;
230 when c_dpath_res_lunit => CCOUT <= LUNIT_CCOUT;
231 when c_dpath_res_munit => CCOUT <= MUNIT_CCOUT;
232 when c_dpath_res_vmdout => CCOUT <= CCIN;
233 when c_dpath_res_fpdout => CCOUT <= "0000";
234 when c_dpath_res_ireg => CCOUT <= CCIN;
235 when c_dpath_res_cpdin => CCOUT <= CCIN;
236 when others => null;
237 end case;
238 end process proc_cres_sel;
239
240 proc_dregs: process (CLK)
241 begin
242
243 if rising_edge(CLK) then
244
245 if CNTL.dsrc_we = '1' then
246 if CNTL.dsrc_sel = c_dpath_dsrc_src then
247 R_DSRC <= GR_DSRC;
248 else
249 R_DSRC <= DRES;
250 end if;
251 end if;
252
253 if CNTL.ddst_we = '1' then
254 if CNTL.ddst_sel = c_dpath_ddst_dst then
255 R_DDST <= GR_DDST;
256 else
257 R_DDST <= DRES;
258 end if;
259 end if;
260
261 if CNTL.dtmp_we = '1' then
262 case CNTL.dtmp_sel is
263 when c_dpath_dtmp_dsrc => R_DTMP <= GR_DSRC;
264 when c_dpath_dtmp_psw =>
265 R_DTMP <= (others=>'0');
266 R_DTMP(psw_ibf_cmode) <= PSW.cmode;
267 R_DTMP(psw_ibf_pmode) <= PSW.pmode;
268 R_DTMP(psw_ibf_rset) <= PSW.rset;
269 R_DTMP(psw_ibf_pri) <= PSW.pri;
270 R_DTMP(psw_ibf_tflag) <= PSW.tflag;
271 R_DTMP(psw_ibf_cc) <= PSW.cc;
272 when c_dpath_dtmp_dres => R_DTMP <= DRES;
273 when c_dpath_dtmp_drese => R_DTMP <= DRESE;
274 when others => null;
275 end case;
276 end if;
277
278 end if;
279
280 end process proc_dregs;
281
282 proc_mregs: process (CLK)
283 begin
284
285 if rising_edge(CLK) then
286
287 if CNTL.ireg_we = '1' then
288 R_IREG <= VM_DOUT;
289 end if;
290
291 end if;
292 end process proc_mregs;
293
294 proc_cpdout: process (CLK)
295 begin
296 if rising_edge(CLK) then
297 if CRESET = '1' then
298 R_CPDOUT <= (others=>'0');
299 else
300 if CNTL.cpdout_we = '1' then
301 R_CPDOUT <= DRES;
302 end if;
303 end if;
304 end if;
305 end process proc_cpdout;
306
307 proc_vmaddr_sel: process (R_DSRC, R_DDST, R_DTMP, GR_PC, CNTL)
308 begin
309 case CNTL.vmaddr_sel is
310 when c_dpath_vmaddr_dsrc => VM_ADDR <= R_DSRC;
311 when c_dpath_vmaddr_ddst => VM_ADDR <= R_DDST;
312 when c_dpath_vmaddr_dtmp => VM_ADDR <= R_DTMP;
313 when c_dpath_vmaddr_pc => VM_ADDR <= GR_PC;
314 when others => null;
315 end case;
316 end process proc_vmaddr_sel;
317
318 STAT.ccout_z <= CCOUT(c_cc_f_z); -- current Z cc flag
319
320 PSWOUT <= PSW;
321 IREG <= R_IREG;
322 VM_DIN <= DRES;
323 CP_DOUT <= R_CPDOUT;
324
325 DM_STAT_DP.pc <= GR_PC;
326 DM_STAT_DP.psw <= PSW;
327 DM_STAT_DP.psr_we <= CNTL.psr_we;
328 DM_STAT_DP.ireg <= R_IREG;
329 DM_STAT_DP.ireg_we <= CNTL.ireg_we;
330 DM_STAT_DP.dsrc <= R_DSRC;
331 DM_STAT_DP.dsrc_we <= CNTL.dsrc_we;
332 DM_STAT_DP.ddst <= R_DDST;
333 DM_STAT_DP.ddst_we <= CNTL.ddst_we;
334 DM_STAT_DP.dtmp <= R_DTMP;
335 DM_STAT_DP.dtmp_we <= CNTL.dtmp_we;
336 DM_STAT_DP.dres <= DRES;
337 DM_STAT_DP.cpdout_we <= CNTL.cpdout_we;
338 DM_STAT_DP.gr_adst <= CNTL.gr_adst;
339 DM_STAT_DP.gr_mode <= CNTL.gr_mode;
340 DM_STAT_DP.gr_bytop <= CNTL.gr_bytop;
341 DM_STAT_DP.gr_we <= CNTL.gr_we;
342
343end syn;
Definition: iblib.vhd:33
out CCOUT slv4
Definition: pdp11_aunit.vhd:58
in CC1OP slbit
Definition: pdp11_aunit.vhd:53
in SRCMOD slv2
Definition: pdp11_aunit.vhd:50
in DDST slv16
Definition: pdp11_aunit.vhd:48
in CCMODE slv3
Definition: pdp11_aunit.vhd:54
in CI slbit
Definition: pdp11_aunit.vhd:49
in DSTMOD slv2
Definition: pdp11_aunit.vhd:51
in CIMOD slv2
Definition: pdp11_aunit.vhd:52
in BYTOP slbit
Definition: pdp11_aunit.vhd:55
in DSRC slv16
Definition: pdp11_aunit.vhd:47
out DOUT slv16
Definition: pdp11_aunit.vhd:56
slv16 :=( others => '0') AUNIT_DOUT
Definition: pdp11_dpath.vhd:95
slv16 :=( others => '0') GR_DSRC
Definition: pdp11_dpath.vhd:83
integer range 5 downto 0 lah_ibf_addr
slv2 :=( others => '0') OUNIT_NZOUT
Definition: pdp11_dpath.vhd:99
slv16 :=( others => '0') R_IREG
Definition: pdp11_dpath.vhd:79
slv4 :=( others => '0') LUNIT_CCOUT
integer := 6 lah_ibf_ena_22bit
slv4 :=( others => '0') AUNIT_CCOUT
slv16 :=( others => '0') OUNIT_DOUT
Definition: pdp11_dpath.vhd:94
psw_type := psw_init PSW
Definition: pdp11_dpath.vhd:87
slv4 :=( others => '0') CCIN
Definition: pdp11_dpath.vhd:88
slv16 :=( others => '0') DRESE
Definition: pdp11_dpath.vhd:92
slv4 :=( others => '0') CCOUT
Definition: pdp11_dpath.vhd:89
slv16 :=( others => '0') R_DTMP
Definition: pdp11_dpath.vhd:77
slv4 :=( others => '0') MUNIT_CCOUT
slv16 :=( others => '0') DRES
Definition: pdp11_dpath.vhd:91
slv16 :=( others => '0') MUNIT_DOUT
Definition: pdp11_dpath.vhd:97
slv16 :=( others => '0') LUNIT_DOUT
Definition: pdp11_dpath.vhd:96
slv16 :=( others => '0') R_CPDOUT
Definition: pdp11_dpath.vhd:81
integer := 7 lah_ibf_ena_ubmap
slv16 :=( others => '0') R_DSRC
Definition: pdp11_dpath.vhd:75
slv16 :=( others => '0') R_DDST
Definition: pdp11_dpath.vhd:76
slv4 :=( others => '0') OUNIT_CCOUT
slv16 :=( others => '0') GR_PC
Definition: pdp11_dpath.vhd:85
slv16 :=( others => '0') GR_DDST
Definition: pdp11_dpath.vhd:84
integer range 15 downto 1 lal_ibf_addr
out DM_STAT_DP dm_stat_dp_type
Definition: pdp11_dpath.vhd:70
out PSWOUT psw_type
Definition: pdp11_dpath.vhd:62
in CNTL dpath_cntl_type
Definition: pdp11_dpath.vhd:58
in VM_DOUT slv16
Definition: pdp11_dpath.vhd:65
in CLK slbit
Definition: pdp11_dpath.vhd:56
out CP_DOUT slv16
Definition: pdp11_dpath.vhd:61
in CRESET slbit
Definition: pdp11_dpath.vhd:57
in IB_MREQ ib_mreq_type
Definition: pdp11_dpath.vhd:67
out VM_ADDR slv16
Definition: pdp11_dpath.vhd:64
out IB_SRES ib_sres_type
Definition: pdp11_dpath.vhd:68
in CP_DIN slv16
Definition: pdp11_dpath.vhd:60
out VM_DIN slv16
Definition: pdp11_dpath.vhd:66
out IREG slv16
Definition: pdp11_dpath.vhd:63
out STAT dpath_stat_type
Definition: pdp11_dpath.vhd:59
in MODE slv2
Definition: pdp11_gr.vhd:42
out DSRC slv16
Definition: pdp11_gr.vhd:47
out DDST slv16
Definition: pdp11_gr.vhd:48
in CLK slbit
Definition: pdp11_gr.vhd:38
in ADST slv3
Definition: pdp11_gr.vhd:41
in DIN slv16
Definition: pdp11_gr.vhd:39
in RSET slbit
Definition: pdp11_gr.vhd:43
in ASRC slv3
Definition: pdp11_gr.vhd:40
in BYTOP slbit
Definition: pdp11_gr.vhd:45
in WE slbit
Definition: pdp11_gr.vhd:44
in PCINC slbit
Definition: pdp11_gr.vhd:46
out PC slv16
Definition: pdp11_gr.vhd:50
out CCOUT slv4
Definition: pdp11_lunit.vhd:41
in DDST slv16
Definition: pdp11_lunit.vhd:35
in BYTOP slbit
Definition: pdp11_lunit.vhd:38
in DSRC slv16
Definition: pdp11_lunit.vhd:34
in FUNC slv4
Definition: pdp11_lunit.vhd:37
out DOUT slv16
Definition: pdp11_lunit.vhd:39
in CCIN slv4
Definition: pdp11_lunit.vhd:36
out DOUTE slv16
Definition: pdp11_munit.vhd:64
out CCOUT slv4
Definition: pdp11_munit.vhd:66
in S_DIV slbit
Definition: pdp11_munit.vhd:51
in S_DIV_CN slbit
Definition: pdp11_munit.vhd:52
out DIV_CR slbit
Definition: pdp11_munit.vhd:60
in S_ASHC_CN slbit
Definition: pdp11_munit.vhd:58
out DIV_QUIT slbit
Definition: pdp11_munit.vhd:62
out DIV_CQ slbit
Definition: pdp11_munit.vhd:61
in S_DIV_CR slbit
Definition: pdp11_munit.vhd:53
in DDST slv16
Definition: pdp11_munit.vhd:47
in CLK slbit
Definition: pdp11_munit.vhd:45
in S_ASH slbit
Definition: pdp11_munit.vhd:55
out SHC_TC slbit
Definition: pdp11_munit.vhd:59
in S_ASHC slbit
Definition: pdp11_munit.vhd:57
in DSRC slv16
Definition: pdp11_munit.vhd:46
in FUNC slv2
Definition: pdp11_munit.vhd:50
in S_DIV_SR slbit
Definition: pdp11_munit.vhd:54
in S_ASH_CN slbit
Definition: pdp11_munit.vhd:56
in GR_DSRC slv16
Definition: pdp11_munit.vhd:49
out DOUT slv16
Definition: pdp11_munit.vhd:63
in DTMP slv16
Definition: pdp11_munit.vhd:48
in VMDOUT slv16
Definition: pdp11_ounit.vhd:39
in OPSUB slbit
Definition: pdp11_ounit.vhd:42
in DDST slv16
Definition: pdp11_ounit.vhd:33
in AZERO slbit
Definition: pdp11_ounit.vhd:37
in ASEL slv2
Definition: pdp11_ounit.vhd:36
in IREG8 slv8
Definition: pdp11_ounit.vhd:38
out NZOUT slv2
Definition: pdp11_ounit.vhd:45
in DSRC slv16
Definition: pdp11_ounit.vhd:32
in CONST slv9
Definition: pdp11_ounit.vhd:40
in PC slv16
Definition: pdp11_ounit.vhd:35
in BSEL slv2
Definition: pdp11_ounit.vhd:41
out DOUT slv16
Definition: pdp11_ounit.vhd:43
in DTMP slv16
Definition: pdp11_ounit.vhd:34
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( 15 downto 0) slv16
Definition: slvtypes.vhd:48
std_logic slbit
Definition: slvtypes.vhd:30
std_logic_vector( 1 downto 0) slv2
Definition: slvtypes.vhd:34