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

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.61/] [rtl/] [w11a/] [pdp11_sequencer.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_sequencer.vhd 335 2010-10-24 22:24:23Z mueller $
2 2 wfjm
--
3
-- Copyright 2006-2010 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_sequencer - syn
16
-- Description:    pdp11: CPU sequencer
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.4.1  use ib_sel
26
-- 2010-10-17   333   1.4    use ibus V2 interface
27
-- 2010-09-18   300   1.3.2  rename (adlm)box->(oalm)unit
28 2 wfjm
-- 2010-06-20   307   1.3.1  rename cpacc to cacc in vm_cntl_type
29
-- 2010-06-13   305   1.3    remove CPDIN_WE, CPDOUT_WE out ports; set
30
--                           CNTL.cpdout_we instead of CPDOUT_WE
31
-- 2010-06-12   304   1.2.8  signal cpuwait when spinning in s_op_wait
32
-- 2009-05-30   220   1.2.7  final removal of snoopers (were already commented)
33
-- 2009-05-09   213   1.2.6  BUGFIX: use is_dstkstack1246, stklim for mode=6
34
-- 2009-05-02   211   1.2.5  BUGFIX: 11/70 spl semantics again in kernel mode
35
-- 2009-04-26   209   1.2.4  BUGFIX: give interrupts priority over trap handling
36
-- 2008-12-14   177   1.2.3  BUGFIX: use is_dstkstack124, fix stklim check bug
37
-- 2008-12-13   176   1.2.2  BUGFIX: use is_pci in s_dstw_inc if DSTDEF='1'
38
-- 2008-11-30   174   1.2.1  BUGFIX: add updt_dstadsrc; prevent stale DSRC
39
-- 2008-08-22   161   1.2    rename ubf_ -> ibf_; use iblib
40
-- 2008-05-03   143   1.1.9  rename _cpursta->_cpurust; cp reset sets now
41
--                           c_cpurust_reset; proper c_cpurust_vfail handling
42
-- 2008-04-27   140   1.1.8  BUGFIX: halt cpu in case of a vector fetch error
43
--                           use cpursta to encode why cpu halts, remove cpufail
44
-- 2008-04-27   139   1.1.7  BUGFIX: correct bytop handling for address fetches;
45
--                           BUGFIX: redo mtp flow; add fork_dsta fork and ddst
46
--                                   reload in s_opa_mtp_pop_w;
47
-- 2008-04-19   137   1.1.6  BUGFIX: fix loop state in s_rti_getpc_w
48
-- 2008-03-30   131   1.1.5  BUGFIX: inc/dec by 2 for byte mode -(sp),(sp)+
49
--                             inc/dec by 2 for @(R)+ and @-(R) also for bytop's
50
-- 2008-03-02   121   1.1.4  remove snoopers; add waitsusp, redo WAIT handling
51
-- 2008-02-24   119   1.1.3  add lah,rps,wps command; revamp cp memory access
52
--                           change WAIT logic, now also bails out on cp command
53
-- 2008-01-20   112   1.1.2  rename PRESET->BRESET
54
-- 2008-01-05   110   1.1.1  rename IB_MREQ(ena->req) SRES(sel->ack, hold->busy)
55
-- 2007-12-30   107   1.1    use IB_MREQ/IB_SRES interface now
56
-- 2007-06-14    56   1.0.1  Use slvtypes.all
57
-- 2007-05-12    26   1.0    Initial version 
58
------------------------------------------------------------------------------
59
 
60
library ieee;
61
use ieee.std_logic_1164.all;
62
use ieee.std_logic_arith.all;
63
 
64
use work.slvtypes.all;
65
use work.iblib.all;
66
use work.pdp11.all;
67
 
68
-- ----------------------------------------------------------------------------
69
 
70
entity pdp11_sequencer is               -- CPU sequencer
71
  port (
72
    CLK : in slbit;                     -- clock
73
    GRESET : in slbit;                  -- global reset
74
    PSW : in psw_type;                  -- processor status
75
    PC : in slv16;                      -- program counter
76
    IREG : in slv16;                    -- IREG
77
    ID_STAT : in decode_stat_type;      -- instr. decoder status
78
    DP_STAT : in dpath_stat_type;       -- data path status
79
    CP_CNTL : in cp_cntl_type;          -- console port control
80
    VM_STAT : in vm_stat_type;          -- virtual memory status port
81
    INT_PRI : in slv3;                  -- interrupt priority
82
    INT_VECT : in slv9_2;               -- interrupt vector
83
    CRESET : out slbit;                 -- console reset
84
    BRESET : out slbit;                 -- ibus reset
85
    MMU_MONI : out mmu_moni_type;       -- mmu monitor port
86
    DP_CNTL : out dpath_cntl_type;      -- data path control
87
    VM_CNTL : out vm_cntl_type;         -- virtual memory control port
88
    CP_STAT : out cp_stat_type;         -- console port status
89
    INT_ACK : out slbit;                -- interrupt acknowledge
90
    IB_MREQ : in ib_mreq_type;          -- ibus request
91
    IB_SRES : out ib_sres_type          -- ibus response    
92
  );
93
end pdp11_sequencer;
94
 
95
architecture syn of pdp11_sequencer is
96
 
97
  constant ibaddr_cpuerr : slv16 := conv_std_logic_vector(8#177766#,16);
98
 
99
  constant cpuerr_ibf_illhlt : integer := 7;
100
  constant cpuerr_ibf_adderr : integer := 6;
101
  constant cpuerr_ibf_nxm : integer := 5;
102
  constant cpuerr_ibf_iobto : integer := 4;
103
  constant cpuerr_ibf_ysv : integer := 3;
104
  constant cpuerr_ibf_rsv : integer := 2;
105
 
106
  type state_type is (
107
    s_idle,
108
    s_cp_regread,
109
    s_cp_rps,
110
    s_cp_memr_w,
111
    s_cp_memw_w,
112
    s_ifetch,
113
    s_ifetch_w,
114
    s_idecode,
115
 
116
    s_srcr_def,
117
    s_srcr_def_w,
118
    s_srcr_inc,
119
    s_srcr_inc_w,
120
    s_srcr_dec,
121
    s_srcr_dec1,
122
    s_srcr_ind,
123
    s_srcr_ind1_w,
124
    s_srcr_ind2,
125
    s_srcr_ind2_w,
126
 
127
    s_dstr_def,
128
    s_dstr_def_w,
129
    s_dstr_inc,
130
    s_dstr_inc_w,
131
    s_dstr_dec,
132
    s_dstr_dec1,
133
    s_dstr_ind,
134
    s_dstr_ind1_w,
135
    s_dstr_ind2,
136
    s_dstr_ind2_w,
137
 
138
    s_dstw_def,
139
    s_dstw_def_w,
140
    s_dstw_inc,
141
    s_dstw_inc_w,
142
    s_dstw_incdef_w,
143
    s_dstw_dec,
144
    s_dstw_dec1,
145
    s_dstw_ind,
146
    s_dstw_ind_w,
147
    s_dstw_def246,
148
 
149
    s_dsta_inc,
150
    s_dsta_incdef_w,
151
    s_dsta_dec,
152
    s_dsta_dec1,
153
    s_dsta_ind,
154
    s_dsta_ind_w,
155
 
156
    s_op_halt,
157
    s_op_wait,
158
    s_op_trap,
159
    s_op_reset,
160
    s_op_rts,
161
    s_op_rts_pop,
162
    s_op_rts_pop_w,
163
    s_op_spl,
164
    s_op_mcc,
165
    s_op_br,
166
    s_op_mark,
167
    s_op_mark1,
168
    s_op_mark_pop,
169
    s_op_mark_pop_w,
170
    s_op_sob,
171
    s_op_sob1,
172
 
173
    s_opg_gen,
174
    s_opg_gen_rmw_w,
175
    s_opg_mul,
176
    s_opg_mul1,
177
    s_opg_div,
178
    s_opg_div_cn,
179
    s_opg_div_cr,
180
    s_opg_div_sq,
181
    s_opg_div_sr,
182
    s_opg_div_zero,
183
    s_opg_ash,
184
    s_opg_ash_cn,
185
    s_opg_ashc,
186
    s_opg_ashc_cn,
187
    s_opg_ashc_wl,
188
 
189
    s_opa_jsr,
190
    s_opa_jsr1,
191
    s_opa_jsr_push,
192
    s_opa_jsr_push_w,
193
    s_opa_jsr2,
194
    s_opa_jmp,
195
    s_opa_mtp,
196
    s_opa_mtp_pop_w,
197
    s_opa_mtp_reg,
198
    s_opa_mtp_mem,
199
    s_opa_mtp_mem_w,
200
    s_opa_mfp_reg,
201
    s_opa_mfp_mem,
202
    s_opa_mfp_mem_w,
203
    s_opa_mfp_dec,
204
    s_opa_mfp_push,
205
    s_opa_mfp_push_w,
206
 
207
    s_trap_4,
208
    s_trap_10,
209
    s_trap_disp,
210
 
211
    s_int_ext,
212
 
213
    s_int_getpc,
214
    s_int_getpc_w,
215
    s_int_getps,
216
    s_int_getps_w,
217
    s_int_getsp,
218
    s_int_decsp,
219
    s_int_pushps,
220
    s_int_pushps_w,
221
    s_int_pushpc,
222
    s_int_pushpc_w,
223
 
224
    s_rti_getpc,
225
    s_rti_getpc_w,
226
    s_rti_getps,
227
    s_rti_getps_w,
228
    s_rti_newpc,
229
 
230
    s_vmerr,
231
    s_cpufail
232
  );
233
 
234
  signal R_STATE : state_type := s_idle;  -- state register
235
  signal N_STATE : state_type := s_idle;
236
 
237
  signal R_STATUS : cpustat_type := cpustat_init;
238
  signal N_STATUS : cpustat_type := cpustat_init;
239
  signal R_CPUERR : cpuerr_type := cpuerr_init;
240
  signal N_CPUERR : cpuerr_type := cpuerr_init;
241
 
242
  signal R_IDSTAT : decode_stat_type := decode_stat_init;
243
  signal N_IDSTAT : decode_stat_type := decode_stat_init;
244
 
245
  signal R_VMSTAT : vm_stat_type := vm_stat_init;
246
 
247
  signal IBSEL_CPUERR : slbit := '0';
248
 
249
begin
250
 
251 8 wfjm
  SEL : ib_sel
252
    generic map (
253
      IB_ADDR => ibaddr_cpuerr)
254
    port map (
255
      CLK     => CLK,
256
      IB_MREQ => IB_MREQ,
257
      SEL     => IBSEL_CPUERR
258
    );
259 2 wfjm
 
260 8 wfjm
  proc_ibres : process (IBSEL_CPUERR, IB_MREQ, R_CPUERR)
261
    variable idout : slv16 := (others=>'0');
262 2 wfjm
  begin
263 8 wfjm
    idout := (others=>'0');
264 2 wfjm
    if IBSEL_CPUERR = '1' then
265 8 wfjm
      idout(cpuerr_ibf_illhlt) := R_CPUERR.illhlt;
266
      idout(cpuerr_ibf_adderr) := R_CPUERR.adderr;
267
      idout(cpuerr_ibf_nxm)    := R_CPUERR.nxm;
268
      idout(cpuerr_ibf_iobto)  := R_CPUERR.iobto;
269
      idout(cpuerr_ibf_ysv)    := R_CPUERR.ysv;
270
      idout(cpuerr_ibf_rsv)    := R_CPUERR.rsv;
271 2 wfjm
    end if;
272 8 wfjm
    IB_SRES.dout <= idout;
273
    IB_SRES.ack  <= IBSEL_CPUERR and (IB_MREQ.re or IB_MREQ.we); -- ack all
274
    IB_SRES.busy <= '0';
275
  end process proc_ibres;
276 2 wfjm
 
277
  proc_status: process (CLK)
278
  begin
279
    if CLK'event and CLK='1' then
280
      if GRESET = '1' then
281
        R_STATUS <= cpustat_init;
282
        R_CPUERR <= cpuerr_init;
283
        R_IDSTAT <= decode_stat_init;
284
        R_VMSTAT <= vm_stat_init;
285
      else
286
        R_STATUS <= N_STATUS;
287
        R_CPUERR <= N_CPUERR;
288
        R_IDSTAT <= N_IDSTAT;
289
        R_VMSTAT <= VM_STAT;
290
      end if;
291
    end if;
292
  end process proc_status;
293
 
294
  proc_state: process (CLK)
295
  begin
296
    if CLK'event and CLK='1' then
297
      if GRESET = '1' then
298
        R_STATE <= s_idle;
299
      else
300
        R_STATE <= N_STATE;
301
      end if;
302
    end if;
303
  end process proc_state;
304
 
305
  proc_next: process (R_STATE, R_STATUS, PSW, PC, CP_CNTL,
306
                      ID_STAT, R_IDSTAT, IREG, VM_STAT, DP_STAT,
307
                      R_CPUERR, R_VMSTAT, IB_MREQ, IBSEL_CPUERR,
308
                      INT_PRI, INT_VECT)
309
 
310
    variable nstate : state_type;
311
    variable nstatus : cpustat_type := cpustat_init;
312
    variable ncpuerr : cpuerr_type := cpuerr_init;
313
 
314
    variable ncreset : slbit := '0';
315
    variable nbreset : slbit := '0';
316
    variable nintack : slbit := '0';
317
 
318
    variable ndpcntl : dpath_cntl_type := dpath_cntl_init;
319
    variable nvmcntl : vm_cntl_type := vm_cntl_init;
320
    variable nidstat : decode_stat_type := decode_stat_init;
321
    variable nmmumoni : mmu_moni_type := mmu_moni_init;
322
 
323
    variable imemok : boolean;
324
    variable bytop : slbit := '0';           -- local bytop  access flag
325
    variable macc  : slbit := '0';           -- local modify access flag
326
 
327
    variable lvector : slv9_2 := (others=>'0'); -- local trap/interrupt vector
328
 
329
    variable brcode : slv4 := (others=>'0'); -- reduced br opcode (15,10-8)
330
    variable brcond : slbit := '0';          -- br condition value
331
 
332
    variable is_kmode : slbit := '0';        -- cmode is kernel mode
333
    variable is_dstkstack1246 : slbit := '0'; -- dest is k-stack & mode= 1,2,4,6
334
 
335
    variable int_pending : slbit := '0';     -- an interrupt is pending
336
 
337
    alias SRCMOD : slv2 is IREG(11 downto 10); -- src register mode high
338
    alias SRCDEF : slbit is IREG(9);           -- src register mode defered
339
    alias SRCREG : slv3 is IREG(8 downto 6);   -- src register number
340
    alias DSTMODF : slv3 is IREG(5 downto 3);  -- dst register full mode
341
    alias DSTMOD : slv2 is IREG(5 downto 4);   -- dst register mode high
342
    alias DSTDEF : slbit is IREG(3);           -- dst register mode defered
343
    alias DSTREG : slv3 is IREG(2 downto 0);   -- dst register number
344
 
345
    procedure do_memread_i(nstate  : inout state_type;
346
                           ndpcntl : inout dpath_cntl_type;
347
                           nvmcntl : inout vm_cntl_type;
348
                           wstate  : in state_type) is
349
    begin
350
      ndpcntl.vmaddr_sel := c_dpath_vmaddr_pc;       -- VA = PC
351
      nvmcntl.dspace := '0';
352
      nvmcntl.req := '1';
353
      ndpcntl.gpr_pcinc := '1';                      -- (pc)++
354
      nstate := wstate;
355
    end procedure do_memread_i;
356
 
357
    procedure do_memread_d(nstate  : inout state_type;
358
                           nvmcntl : inout vm_cntl_type;
359
                           wstate  : in state_type;
360
                           bytop   : in slbit := '0';
361
                           macc    : in slbit := '0';
362
                           is_pci  : in slbit := '0') is
363
    begin
364
      nvmcntl.dspace := not is_pci;        -- ispace if pc immediate modes
365
--      bytop := R_IDSTAT.is_bytop and not is_addr;
366
      nvmcntl.bytop := bytop;
367
      nvmcntl.macc  := macc;
368
      nvmcntl.req   := '1';
369
      nstate := wstate;
370
    end procedure do_memread_d;
371
 
372
    procedure do_memread_srcinc(nstate   : inout state_type;
373
                                ndpcntl  : inout dpath_cntl_type;
374
                                nvmcntl  : inout vm_cntl_type;
375
                                wstate   : in state_type;
376
                                nmmumoni : inout mmu_moni_type;
377
                                updt_sp  : in slbit := '0') is
378
    begin
379 8 wfjm
      ndpcntl.ounit_asel := c_ounit_asel_dsrc;   -- OUNIT A=DSRC
380
      ndpcntl.ounit_const := "000000010";        -- OUNIT const=2
381
      ndpcntl.ounit_bsel := c_ounit_bsel_const;  -- OUNIT B=const
382
      ndpcntl.dres_sel := c_dpath_res_ounit;     -- DRES = OUNIT
383 2 wfjm
      ndpcntl.dsrc_sel := c_dpath_dsrc_res;      -- DSRC = DRES
384
      ndpcntl.dsrc_we := '1';                    -- update DSRC
385
      if updt_sp = '1' then
386
        nmmumoni.regmod := '1';
387
        nmmumoni.isdec := '0';
388
        ndpcntl.gpr_adst := c_gpr_sp;            -- update SP too
389
        ndpcntl.gpr_we := '1';
390
      end if;
391
      ndpcntl.vmaddr_sel := c_dpath_vmaddr_dsrc; -- VA = DSRC
392
      nvmcntl.dspace := '1';
393
      nvmcntl.req := '1';
394
      nstate := wstate;
395
    end procedure do_memread_srcinc;
396
 
397
    procedure do_memwrite(nstate  : inout state_type;
398
                          nvmcntl : inout vm_cntl_type;
399
                          wstate  : in state_type;
400
                          macc    : in slbit :='0') is
401
    begin
402
      nvmcntl.dspace := '1';
403
      nvmcntl.bytop := R_IDSTAT.is_bytop;
404
      nvmcntl.wacc := '1';
405
      nvmcntl.macc := macc;
406
      nvmcntl.req := '1';
407
      nstate := wstate;
408
    end procedure do_memwrite;
409
 
410
    procedure do_memcheck(nstate  : inout state_type;
411
                          nstatus : inout cpustat_type;
412
                          mok     : out boolean) is
413
    begin
414
      mok := false;
415
      if VM_STAT.ack = '1' then
416
        mok := true;
417
        nstatus.trap_mmu := VM_STAT.trap_mmu;
418
        if R_CPUERR.ysv = '0' then      -- ysv trap when cpuerr not yet set
419
          nstatus.trap_ysv := VM_STAT.trap_ysv;
420
        end if;
421
      elsif VM_STAT.err='1' or VM_STAT.fail='1' then
422
        nstate := s_vmerr;
423
      end if;
424
    end procedure do_memcheck;
425
 
426
    procedure do_const_opsize(ndpcntl : inout dpath_cntl_type;
427
                              bytop   : in slbit;
428
                              isdef   : in slbit;
429
                              regnum  : in slv3) is
430
    begin
431
      if bytop='0' or isdef='1' or
432
         regnum=c_gpr_pc or regnum=c_gpr_sp then
433 8 wfjm
        ndpcntl.ounit_const := "000000010";
434 2 wfjm
      else
435 8 wfjm
        ndpcntl.ounit_const := "000000001";
436 2 wfjm
      end if;
437
    end procedure do_const_opsize;
438
 
439
    procedure do_fork_dstr(nstate : inout state_type;
440
                           idstat : in decode_stat_type) is
441
    begin
442
      case idstat.fork_dstr is
443
        when c_fork_dstr_def => nstate := s_dstr_def;
444
        when c_fork_dstr_inc => nstate := s_dstr_inc;
445
        when c_fork_dstr_dec => nstate := s_dstr_dec;
446
        when c_fork_dstr_ind => nstate := s_dstr_ind;
447
        when others => nstate := s_cpufail;
448
      end case;
449
    end procedure do_fork_dstr;
450
 
451
    procedure do_fork_opg(nstate : inout state_type;
452
                          idstat : in decode_stat_type) is
453
    begin
454
      case idstat.fork_opg is
455
        when c_fork_opg_gen  => nstate := s_opg_gen;
456
        when c_fork_opg_wdef => nstate := s_dstw_def;
457
        when c_fork_opg_winc => nstate := s_dstw_inc;
458
        when c_fork_opg_wdec => nstate := s_dstw_dec;
459
        when c_fork_opg_wind => nstate := s_dstw_ind;
460
        when c_fork_opg_mul  => nstate := s_opg_mul;
461
        when c_fork_opg_div  => nstate := s_opg_div;
462
        when c_fork_opg_ash  => nstate := s_opg_ash;
463
        when c_fork_opg_ashc => nstate := s_opg_ashc;
464
        when others => nstate := s_cpufail;
465
      end case;
466
    end procedure do_fork_opg;
467
 
468
    procedure do_fork_opa(nstate : inout state_type;
469
                          idstat : in decode_stat_type) is
470
    begin
471
      case idstat.fork_opa is
472
        when c_fork_opa_jmp => nstate := s_opa_jmp;
473
        when c_fork_opa_jsr => nstate := s_opa_jsr;
474
        when c_fork_opa_mtp => nstate := s_opa_mtp_mem;
475
        when c_fork_opa_mfp_reg => nstate := s_opa_mfp_reg;
476
        when c_fork_opa_mfp_mem => nstate := s_opa_mfp_mem;
477
        when others => nstate := s_cpufail;
478
      end case;
479
    end procedure do_fork_opa;
480
 
481
    procedure do_fork_next(nstate   : inout state_type;
482
                           nstatus  : inout cpustat_type;
483
                           nmmumoni : inout mmu_moni_type) is
484
    begin
485
      nmmumoni.idone := '1';
486
      if unsigned(INT_PRI) > unsigned(PSW.pri) then
487
        nstate := s_idle;
488
      elsif R_STATUS.trap_mmu='1' or nstatus.trap_mmu='1' or
489
            R_STATUS.trap_ysv='1' or nstatus.trap_ysv='1' or
490
            PSW.tflag='1' then
491
        nstate := s_trap_disp;
492
      elsif R_STATUS.cpugo='1' and not R_STATUS.cmdbusy='1' then
493
        nstate := s_ifetch;
494
      else
495
        nstate := s_idle;
496
      end if;
497
    end procedure do_fork_next;
498
 
499
    procedure do_fork_next_pref(nstate   : inout state_type;
500
                                nstatus  : inout cpustat_type;
501
                                ndpcntl  : inout dpath_cntl_type;
502
                                nvmcntl  : inout vm_cntl_type;
503
                                nmmumoni : inout mmu_moni_type) is
504
    begin
505
      nmmumoni.idone := '1';
506
      if unsigned(INT_PRI) > unsigned(PSW.pri) then
507
        nstate := s_idle;
508
      elsif R_STATUS.trap_mmu='1' or nstatus.trap_mmu='1' or
509
            R_STATUS.trap_ysv='1' or nstatus.trap_ysv='1' or
510
            PSW.tflag='1' then
511
        nstate := s_trap_disp;
512
      elsif R_STATUS.cpugo='1' and not R_STATUS.cmdbusy='1' then
513
        nvmcntl.req := '1';
514
        ndpcntl.gpr_pcinc := '1';
515
        nmmumoni.istart := '1';
516
        nstate := s_ifetch_w;
517
      else
518
        nstate := s_idle;
519
      end if;
520
    end procedure do_fork_next_pref;
521
 
522
    procedure do_start_int(nstate  : inout state_type;
523
                           ndpcntl : inout dpath_cntl_type;
524
                           vector  : in slv9_2) is
525
    begin
526
      ndpcntl.dtmp_sel := c_dpath_dtmp_psw;    -- DTMP = PSW 
527
      ndpcntl.dtmp_we := '1';
528 8 wfjm
      ndpcntl.ounit_azero := '1';              -- OUNIT A = 0
529
      ndpcntl.ounit_const := vector & "00";    -- vector
530
      ndpcntl.ounit_bsel := c_ounit_bsel_const;-- OUNIT B=const(vector)
531
      ndpcntl.dres_sel := c_dpath_res_ounit;   -- DRES = OUNIT
532 2 wfjm
      ndpcntl.dsrc_sel := c_dpath_dsrc_res;    -- DSRC = DRES
533
      ndpcntl.dsrc_we := '1';                  -- DSRC = vector
534
      nstate := s_int_getpc;
535
    end procedure do_start_int;
536
 
537
  begin
538
 
539
    nstate  := R_STATE;
540
    nstatus := R_STATUS;
541
    ncpuerr := R_CPUERR;
542
 
543
    nstatus.cpuwait := '0';             -- wait flag 0 unless set in s_op_wait
544
 
545
    ncreset := '0';
546
    nbreset := '0';
547
    nintack := '0';
548
 
549
    nidstat := R_IDSTAT;
550
 
551 8 wfjm
    if IBSEL_CPUERR='1' and IB_MREQ.we='1' then -- write to CPUERR clears it !
552 2 wfjm
      ncpuerr := cpuerr_init;
553
    end if;
554
 
555
    int_pending := '0';
556
    if unsigned(INT_PRI) > unsigned(PSW.pri) then
557
      int_pending := '1';
558
    end if;
559
 
560
    imemok := false;
561
 
562
    nmmumoni := mmu_moni_init;
563
    nmmumoni.pc := PC;
564
 
565
    macc  := '0';
566
    bytop := '0';
567
    brcode := IREG(15) & IREG(10 downto 8);
568
    brcond := '1';
569
 
570
    is_kmode := '0';
571
    is_dstkstack1246 := '0';
572
 
573
    if PSW.cmode = c_psw_kmode then
574
      is_kmode := '1';
575
      if DSTREG = c_gpr_sp and
576
         (DSTMODF="001" or DSTMODF="010" or
577
          DSTMODF="100" or DSTMODF="110") then
578
        is_dstkstack1246 := '1';
579
      end if;
580
    end if;
581
 
582
    lvector := (others=>'0');
583
 
584
    nvmcntl := vm_cntl_init;
585
    nvmcntl.dspace := '1';                -- DEFAULT
586
    nvmcntl.mode := PSW.cmode;            -- DEFAULT
587
    nvmcntl.intrsv := R_STATUS.do_intrsv; -- DEFAULT
588
 
589
    ndpcntl := dpath_cntl_init;
590
    ndpcntl.gpr_asrc := SRCREG;           -- DEFAULT
591
    ndpcntl.gpr_adst := DSTREG;           -- DEFAULT
592
    ndpcntl.gpr_mode := PSW.cmode;        -- DEFAULT
593
    ndpcntl.gpr_rset := PSW.rset;         -- DEFAULT
594
    ndpcntl.gpr_we := '0';                -- DEFAULT
595
    ndpcntl.gpr_bytop := '0';             -- DEFAULT
596
    ndpcntl.gpr_pcinc := '0';             -- DEFAULT
597
 
598
    ndpcntl.psr_ccwe := '0';              -- DEFAULT
599
    ndpcntl.psr_we := '0';                -- DEFAULT
600
    ndpcntl.psr_func := "000";            -- DEFAULT
601
 
602
    ndpcntl.dsrc_sel := c_dpath_dsrc_src;
603
    ndpcntl.dsrc_we := '0';
604
    ndpcntl.ddst_sel := c_dpath_ddst_dst;
605
    ndpcntl.ddst_we := '0';
606
    ndpcntl.dtmp_sel := c_dpath_dtmp_dsrc;
607
    ndpcntl.dtmp_we := '0';
608
 
609 8 wfjm
    ndpcntl.ounit_asel  := c_ounit_asel_ddst;
610
    ndpcntl.ounit_azero := '0';            -- DEFAULT
611
    ndpcntl.ounit_const := (others=>'0');  -- DEFAULT
612
    ndpcntl.ounit_bsel  := c_ounit_bsel_const;
613
    ndpcntl.ounit_opsub := '0';            -- DEFAULT
614 2 wfjm
 
615 8 wfjm
    ndpcntl.aunit_srcmod := R_IDSTAT.aunit_srcmod; -- STATIC
616
    ndpcntl.aunit_dstmod := R_IDSTAT.aunit_dstmod; -- STATIC
617
    ndpcntl.aunit_cimod  := R_IDSTAT.aunit_cimod;  -- STATIC
618
    ndpcntl.aunit_cc1op  := R_IDSTAT.aunit_cc1op;  -- STATIC
619
    ndpcntl.aunit_ccmode := R_IDSTAT.aunit_ccmode; -- STATIC
620
    ndpcntl.aunit_bytop  := R_IDSTAT.is_bytop;     -- STATIC
621 2 wfjm
 
622 8 wfjm
    ndpcntl.lunit_func   := R_IDSTAT.lunit_func;   -- STATIC
623
    ndpcntl.lunit_bytop  := R_IDSTAT.is_bytop;     -- STATIC
624 2 wfjm
 
625 8 wfjm
    ndpcntl.munit_func := R_IDSTAT.munit_func;     -- STATIC
626 2 wfjm
 
627
    ndpcntl.ireg_we := '0';
628
 
629
    ndpcntl.cres_sel := R_IDSTAT.res_sel;        -- DEFAULT
630 8 wfjm
    ndpcntl.dres_sel := c_dpath_res_ounit;
631 2 wfjm
    ndpcntl.vmaddr_sel := c_dpath_vmaddr_dsrc;
632
 
633
    if CP_CNTL.req='1' and R_STATUS.cmdbusy='0' then
634
      nstatus.cmdbusy := '1';
635
      nstatus.cpfunc  := CP_CNTL.func;
636
      nstatus.cprnum  := CP_CNTL.rnum;
637
    end if;
638
 
639
    if R_STATUS.cmdack = '1' then
640
      nstatus.cmdack  := '0';
641
      nstatus.cmderr  := '0';
642
      nstatus.cmdmerr := '0';
643
    end if;
644
 
645
    case R_STATE is
646
 
647
  -- idle and command port states ---------------------------------------------
648
 
649
      -- Note: s_idle was entered from suspended WAIT when waitsusp='1'
650
      -- --> all exits must check this and either return to s_op_wait
651
      --     or abort the WAIT and set waitsusp='0'
652
 
653
      when s_idle =>
654
 
655
        ndpcntl.vmaddr_sel := c_dpath_vmaddr_ddst;   -- VA = DDST (do mux early)
656
        nstatus.cpustep := '0';
657
 
658
        if R_STATUS.cmdbusy = '1' then
659
          case R_STATUS.cpfunc is
660
 
661
            when c_cpfunc_noop =>       -- noop : no operation --------
662
              nstatus.cmdack   := '1';
663
              nstate := s_idle;
664
 
665
            when c_cpfunc_sta =>        -- sta  : cpu start -----------
666
              ncreset          := '1';
667
              nstatus.cmdack   := '1';
668
              nstatus.cpugo    := '1';
669
              nstatus.cpuhalt  := '0';
670
              nstatus.cpurust  := c_cpurust_runs;
671
              nstatus.waitsusp := '0';
672
              nstate := s_idle;
673
 
674
            when c_cpfunc_sto =>        -- sto  : cpu stop ------------
675
              nstatus.cmdack   := '1';
676
              nstatus.cpugo    := '0';
677
              nstatus.cpurust  := c_cpurust_stop;
678
              nstatus.waitsusp := '0';
679
              nstate := s_idle;
680
 
681
            when c_cpfunc_cont =>       -- cont : cpu continue --------
682
              nstatus.cmdack   := '1';
683
              nstatus.cpugo    := '1';
684
              nstatus.cpuhalt  := '0';
685
              nstatus.cpurust  := c_cpurust_runs;
686
              nstatus.waitsusp := '0';
687
              nstate := s_idle;
688
 
689
            when c_cpfunc_step =>       -- step : cpu step ------------
690
              nstatus.cmdack   := '1';
691
              nstatus.cpustep  := '1';
692
              nstatus.cpuhalt  := '0';
693
              nstatus.cpurust  := c_cpurust_step;
694
              nstatus.waitsusp := '0';
695
              if int_pending = '1' then
696
                nintack := '1';
697
                nstatus.intvect := INT_VECT;
698
                nstate := s_int_ext;
699
              else
700
                nstate := s_ifetch;
701
              end if;
702
 
703
            when c_cpfunc_rst =>        -- rst  : cpu reset (soft) ----
704
              ncreset := '1';
705
              nstatus.cmdack   := '1';
706
              nstatus.cpugo    := '0';
707
              nstatus.cpuhalt  := '0';
708
              nstatus.cpurust  := c_cpurust_reset;
709
              nstatus.waitsusp := '0';
710
              nstate := s_idle;
711
 
712
            when c_cpfunc_rreg =>       -- rreg : read register ------
713
              ndpcntl.gpr_adst := R_STATUS.cprnum;
714
              ndpcntl.ddst_sel := c_dpath_ddst_dst;
715
              ndpcntl.ddst_we := '1';
716
              nstate := s_cp_regread;
717
 
718
            when c_cpfunc_wreg =>       -- wreg : write register -----
719
              ndpcntl.dres_sel := c_dpath_res_cpdin;  -- DRES = CPDIN
720
              ndpcntl.gpr_adst := R_STATUS.cprnum;
721
              ndpcntl.gpr_we := '1';
722
              nstatus.cmdack := '1';
723
              nstate := s_idle;
724
 
725
            when c_cpfunc_rpsw =>       -- rpsw : read psw -----------
726
              ndpcntl.dtmp_sel := c_dpath_dtmp_psw;   -- DTMP = PSW 
727
              ndpcntl.dtmp_we := '1';
728
              nstate := s_cp_rps;
729
 
730
            when c_cpfunc_wpsw =>       -- wpsw : write psw ----------
731
              ndpcntl.dres_sel := c_dpath_res_cpdin;  -- DRES = CPDIN
732
              ndpcntl.psr_func := c_psr_func_wall;    -- write all fields
733
              ndpcntl.psr_we := '1';                  -- load new PS
734
              nstatus.cmdack := '1';
735
              nstate := s_idle;
736
 
737
            when c_cpfunc_rmem =>       -- rmem : read memory --------
738
              nvmcntl.cacc := '1';
739
              nvmcntl.req  := '1';
740
              nstate := s_cp_memr_w;
741
 
742
            when c_cpfunc_wmem =>       -- wmem : write memory -------
743
              ndpcntl.dres_sel := c_dpath_res_cpdin;     -- DRES = CPDIN
744
              nvmcntl.wacc := '1';                       -- write mem
745
              nvmcntl.cacc := '1';
746
              nvmcntl.req  := '1';
747
              nstate := s_cp_memw_w;
748
 
749
            when others =>
750
              nstatus.cmdack := '1';
751
              nstatus.cmderr := '1';
752
              nstate := s_idle;
753
 
754
          end case;
755
 
756
        elsif R_STATUS.waitsusp = '1' then
757
          nstatus.waitsusp := '0';
758
          nstate := s_op_wait;
759
 
760
        elsif R_STATUS.cpugo = '1' then
761
          if int_pending = '1' then
762
            nintack := '1';
763
            nstatus.intvect := INT_VECT;
764
            nstate := s_int_ext;
765
          else
766
            nstate := s_ifetch;
767
          end if;
768
 
769
        end if;
770
 
771
      when s_cp_regread =>
772 8 wfjm
        ndpcntl.ounit_asel := c_ounit_asel_ddst;  -- OUNIT A = DDST
773
        ndpcntl.ounit_bsel := c_ounit_bsel_const; -- OUNIT B = const(0)
774
        ndpcntl.dres_sel  := c_dpath_res_ounit;   -- DRES = OUNIT
775 2 wfjm
        nstatus.cmdack := '1';
776
        nstate := s_idle;
777
 
778
      when s_cp_rps =>
779 8 wfjm
        ndpcntl.ounit_asel := c_ounit_asel_dtmp;  -- OUNIT A = DTMP
780
        ndpcntl.ounit_bsel := c_ounit_bsel_const; -- OUNIT B = const(0)
781
        ndpcntl.dres_sel  := c_dpath_res_ounit;   -- DRES = OUNIT
782 2 wfjm
        nstatus.cmdack := '1';
783
        nstate := s_idle;
784
 
785
      when s_cp_memr_w =>
786
        nstate := s_cp_memr_w;
787
        ndpcntl.dres_sel := c_dpath_res_vmdout;  -- DRES = VMDOUT
788
        if (VM_STAT.ack or VM_STAT.err or VM_STAT.fail)='1' then
789
          nstatus.cmdack   := '1';
790
          nstatus.trap_ysv := '0';               -- suppress traps on console
791
          nstatus.trap_mmu := '0';
792
          nstatus.cmdmerr  := VM_STAT.err or VM_STAT.fail;
793
          nstate := s_idle;
794
        end if;
795
 
796
      when s_cp_memw_w =>
797
        nstate := s_cp_memw_w;
798
        if (VM_STAT.ack or VM_STAT.err or VM_STAT.fail)='1' then
799
          nstatus.cmdack   := '1';
800
          nstatus.trap_ysv := '0';               -- suppress traps on console
801
          nstatus.trap_mmu := '0';
802
          nstatus.cmdmerr  := VM_STAT.err or VM_STAT.fail;
803
          nstate := s_idle;
804
        end if;
805
 
806
  -- instruction fetch and decode ---------------------------------------------
807
 
808
      when s_ifetch =>
809
        nmmumoni.istart := '1';         -- do here; memread_i inc PC ! 
810
        do_memread_i(nstate, ndpcntl, nvmcntl, s_ifetch_w);
811
 
812
      when s_ifetch_w =>
813
        nstate := s_ifetch_w;
814
        do_memcheck(nstate, nstatus, imemok);
815
        if imemok then
816
          ndpcntl.ireg_we := '1';
817
          nstate := s_idecode;
818
        end if;
819
 
820
      when s_idecode =>
821
        nidstat := ID_STAT;             -- register decode status
822
        if ID_STAT.force_srcsp = '1' then
823
          ndpcntl.gpr_asrc := c_gpr_sp;
824
        end if;
825
        ndpcntl.dsrc_sel := c_dpath_dsrc_src;
826
        ndpcntl.dsrc_we := '1';
827
        ndpcntl.ddst_sel := c_dpath_ddst_dst;
828
        ndpcntl.ddst_we := '1';
829
 
830
        nvmcntl.dspace := '0';
831
        ndpcntl.vmaddr_sel := c_dpath_vmaddr_pc;       -- VA = PC
832
 
833
        if ID_STAT.do_pref_dec='1' and PSW.tflag='0' and int_pending='0' and
834
           R_STATUS.cpugo='1' and not R_STATUS.cmdbusy='1'
835
        then
836
          nvmcntl.req := '1';
837
          ndpcntl.gpr_pcinc := '1';                    -- (pc)++
838
          nmmumoni.istart := '1';
839
          nstatus.prefdone := '1';
840
        end if;
841
 
842
        if ID_STAT.do_fork_op = '1' then
843
          case ID_STAT.fork_op is
844
            when c_fork_op_halt => nstate := s_op_halt;
845
            when c_fork_op_wait => nstate := s_op_wait;
846
            when c_fork_op_rtti => nstate := s_rti_getpc;
847
            when c_fork_op_trap => nstate := s_op_trap;
848
            when c_fork_op_reset=> nstate := s_op_reset;
849
            when c_fork_op_rts  => nstate := s_op_rts;
850
            when c_fork_op_spl  => nstate := s_op_spl;
851
            when c_fork_op_mcc  => nstate := s_op_mcc;
852
            when c_fork_op_br   => nstate := s_op_br;
853
            when c_fork_op_mark => nstate := s_op_mark;
854
            when c_fork_op_sob  => nstate := s_op_sob;
855
            when c_fork_op_mtp  => nstate := s_opa_mtp;
856
            when others => nstate := s_cpufail;
857
          end case;
858
        elsif ID_STAT.do_fork_srcr = '1' then
859
          case ID_STAT.fork_srcr is
860
            when c_fork_srcr_def => nstate := s_srcr_def;
861
            when c_fork_srcr_inc => nstate := s_srcr_inc;
862
            when c_fork_srcr_dec => nstate := s_srcr_dec;
863
            when c_fork_srcr_ind => nstate := s_srcr_ind;
864
            when others => nstate := s_cpufail;
865
          end case;
866
        elsif ID_STAT.do_fork_dstr = '1' then
867
          do_fork_dstr(nstate, ID_STAT);
868
        elsif ID_STAT.do_fork_dsta = '1' then
869
          case ID_STAT.fork_dsta is         -- 2nd dsta fork in s_opa_mtp_pop_w
870
            when c_fork_dsta_def => do_fork_opa(nstate, ID_STAT);
871
            when c_fork_dsta_inc => nstate := s_dsta_inc;
872
            when c_fork_dsta_dec => nstate := s_dsta_dec;
873
            when c_fork_dsta_ind => nstate := s_dsta_ind;
874
            when others => nstate := s_cpufail;
875
          end case;
876
        elsif ID_STAT.do_fork_opg = '1' then
877
          do_fork_opg(nstate, ID_STAT);
878
        elsif ID_STAT.is_res = '1' then
879
          nstate := s_trap_10;           -- do trap 10;
880
        else
881
          nstate := s_cpufail;           -- catch mistakes here...
882
        end if;
883
 
884
  -- source read states -------------------------------------------------------
885
  --   flows:
886
  --     1  (r)    s_srcr_def           req (r)
887
  --               s_srcr_def_w         get (r)
888
  --               -> do_fork_dstr or do_fork_opg
889
  --              
890
  --     2  (r)+   s_srcr_inc           req (r); r+=s
891
  --               s_srcr_inc_w         get (r)
892
  --               -> do_fork_dstr or do_fork_opg
893
  --
894
  --     3  @(r)+  s_srcr_inc           req (r); r+=s
895
  --               s_srcr_inc_w         get (r)
896
  --               s_srcr_def           req @(r)
897
  --               s_srcr_def_w         get @(r)
898
  --               -> do_fork_dstr or do_fork_opg
899
  --
900
  --     4  -(r)   s_srcr_dec           r-=s
901
  --               s_srcr_dec1          req (r)
902
  --               s_srcr_inc_w         get (r)
903
  --               -> do_fork_dstr or do_fork_opg
904
  --
905
  --     5  @-(r)  s_srcr_dec           r-=s
906
  --               s_srcr_dec1          req (r)
907
  --               s_srcr_inc_w         get (r)
908
  --               s_srcr_def           req @(r)
909
  --               s_srcr_def_w         get @(r)
910
  --               -> do_fork_dstr or do_fork_opg
911
  --
912
  --     6  n(r)   s_srcr_ind           req n
913
  --               s_srcr_ind1_w        get n; ea=r+n
914
  --               s_srcr_ind2          req n(r)
915
  --               s_srcr_ind2_w        get n(r)
916
  --               -> do_fork_dstr or do_fork_opg
917
  --
918
  --     7  @n(r)  s_srcr_ind           req n
919
  --               s_srcr_ind1_w        get n; ea=r+n
920
  --               s_srcr_ind2          req n(r)
921
  --               s_srcr_ind2_w        get n(r)
922
  --               s_srcr_def           req @n(r)
923
  --               s_srcr_def_w         get @n(r)
924
  --               -> do_fork_dstr or do_fork_opg
925
 
926
      when s_srcr_def =>
927
        ndpcntl.vmaddr_sel := c_dpath_vmaddr_dsrc; -- VA = DSRC
928
        do_memread_d(nstate, nvmcntl, s_srcr_def_w,
929
                     bytop=>R_IDSTAT.is_bytop,
930
                     is_pci=>R_IDSTAT.is_srcpcmode1);
931
 
932
      when s_srcr_def_w =>
933
        nstate := s_srcr_def_w;
934
        do_memcheck(nstate, nstatus, imemok);
935
        ndpcntl.dres_sel := c_dpath_res_vmdout;  -- DRES = VMDOUT
936
        ndpcntl.dsrc_sel := c_dpath_dsrc_res;    -- DSRC = DRES
937
        if imemok then
938
          ndpcntl.dsrc_we := '1';                -- update DSRC
939
          if R_IDSTAT.do_fork_dstr = '1' then
940
            do_fork_dstr(nstate, R_IDSTAT);
941
          else
942
            do_fork_opg(nstate, R_IDSTAT);
943
          end if;
944
        end if;
945
 
946
      when s_srcr_inc =>
947 8 wfjm
        ndpcntl.ounit_asel := c_ounit_asel_dsrc;  -- OUNIT A=DSRC
948 2 wfjm
        do_const_opsize(ndpcntl, R_IDSTAT.is_bytop, SRCDEF, SRCREG);
949 8 wfjm
        ndpcntl.ounit_bsel := c_ounit_bsel_const; -- OUNIT B=const
950
        ndpcntl.dres_sel := c_dpath_res_ounit;    -- DRES = OUNIT
951 2 wfjm
        ndpcntl.gpr_adst := SRCREG;
952
        ndpcntl.gpr_we := '1';
953
        nmmumoni.regmod := '1';
954
        nmmumoni.isdec := '0';
955
        ndpcntl.ddst_sel := c_dpath_ddst_res;    -- DDST = DRES (for if)
956
        if DSTREG = SRCREG then                  -- prevent stale DDST copy 
957
          ndpcntl.ddst_we := '1';                -- update DDST
958
        end if;
959
        ndpcntl.vmaddr_sel := c_dpath_vmaddr_dsrc; -- VA = DSRC
960
        bytop := R_IDSTAT.is_bytop and not SRCDEF;
961
        do_memread_d(nstate, nvmcntl, s_srcr_inc_w,
962
                     bytop=>bytop, is_pci=>R_IDSTAT.is_srcpc);
963
 
964
      when s_srcr_inc_w =>
965
        nstate := s_srcr_inc_w;
966
        ndpcntl.dres_sel := c_dpath_res_vmdout;  -- DRES = VMDOUT
967
        ndpcntl.dsrc_sel := c_dpath_dsrc_res;    -- DSRC = DRES
968
        do_memcheck(nstate, nstatus, imemok);
969
        if imemok then
970
          ndpcntl.dsrc_we := '1';                -- update DSRC
971
          if SRCDEF = '1' then
972
            nstate := s_srcr_def;
973
          else
974
            if R_IDSTAT.do_fork_dstr = '1' then
975
              do_fork_dstr(nstate, R_IDSTAT);
976
            else
977
              do_fork_opg(nstate, R_IDSTAT);
978
            end if;
979
          end if;
980
        end if;
981
 
982
      when s_srcr_dec =>
983 8 wfjm
        ndpcntl.ounit_asel := c_ounit_asel_dsrc; -- OUNIT A=DSRC
984 2 wfjm
        do_const_opsize(ndpcntl, R_IDSTAT.is_bytop, SRCDEF, SRCREG);
985 8 wfjm
        ndpcntl.ounit_bsel := c_ounit_bsel_const;-- OUNIT B=const
986
        ndpcntl.ounit_opsub := '1';              -- OUNIT = A-B
987
        ndpcntl.dres_sel := c_dpath_res_ounit;   -- DRES = OUNIT
988 2 wfjm
        ndpcntl.dsrc_sel := c_dpath_dsrc_res;    -- DSRC = DRES
989
        ndpcntl.dsrc_we := '1';                  -- update DSRC
990
        ndpcntl.gpr_adst := SRCREG;
991
        ndpcntl.gpr_we := '1';
992
        nmmumoni.regmod := '1';
993
        nmmumoni.isdec := '1';
994
        ndpcntl.ddst_sel := c_dpath_ddst_res;    -- DDST = DRES (for if)
995
        if DSTREG = SRCREG then                  -- prevent stale DDST copy
996
          ndpcntl.ddst_we := '1';                -- update DDST
997
        end if;
998
        nstate := s_srcr_dec1;
999
 
1000
      when s_srcr_dec1 =>
1001
        ndpcntl.vmaddr_sel := c_dpath_vmaddr_dsrc; -- VA = DSRC
1002
        bytop := R_IDSTAT.is_bytop and not SRCDEF;
1003
        do_memread_d(nstate, nvmcntl, s_srcr_inc_w, bytop=>bytop);
1004
 
1005
      when s_srcr_ind =>
1006
        do_memread_i(nstate, ndpcntl, nvmcntl, s_srcr_ind1_w);
1007
 
1008
      when s_srcr_ind1_w =>
1009
        nstate := s_srcr_ind1_w;
1010
        if R_IDSTAT.is_srcpc = '0' then
1011 8 wfjm
          ndpcntl.ounit_asel := c_ounit_asel_dsrc; -- OUNIT A = DSRC
1012 2 wfjm
        else
1013 8 wfjm
          ndpcntl.ounit_asel := c_ounit_asel_pc;   -- OUNIT A = PC (for nn(pc))
1014 2 wfjm
        end if;
1015 8 wfjm
        ndpcntl.ounit_bsel := c_ounit_bsel_vmdout; -- OUNIT B = VMDOUT
1016
        ndpcntl.dres_sel := c_dpath_res_ounit;   -- DRES = OUNIT
1017 2 wfjm
        ndpcntl.dsrc_sel := c_dpath_dsrc_res;    -- DSRC = DRES
1018
        ndpcntl.ddst_sel := c_dpath_ddst_dst;    -- DDST = R(DST)
1019
        do_memcheck(nstate, nstatus, imemok);
1020
        if imemok then
1021
          ndpcntl.dsrc_we := '1';                -- update DSRC
1022
          ndpcntl.ddst_we := '1';                -- update DDST (to reload PC)
1023
          nstate := s_srcr_ind2;
1024
        end if;
1025
 
1026
      when s_srcr_ind2 =>
1027
        ndpcntl.vmaddr_sel := c_dpath_vmaddr_dsrc; -- VA = DSRC
1028
        bytop := R_IDSTAT.is_bytop and not SRCDEF;
1029
        do_memread_d(nstate, nvmcntl, s_srcr_ind2_w, bytop=>bytop);
1030
 
1031
      when s_srcr_ind2_w =>
1032
        nstate := s_srcr_ind2_w;
1033
        ndpcntl.dres_sel := c_dpath_res_vmdout;  -- DRES = VMDOUT
1034
        ndpcntl.dsrc_sel := c_dpath_dsrc_res;    -- DSRC = DRES
1035
        do_memcheck(nstate, nstatus, imemok);
1036
        if imemok then
1037
          ndpcntl.dsrc_we := '1';                -- update DSRC
1038
          if SRCDEF = '1' then
1039
            nstate := s_srcr_def;
1040
          else
1041
            if R_IDSTAT.do_fork_dstr = '1' then
1042
              do_fork_dstr(nstate, R_IDSTAT);
1043
            else
1044
              do_fork_opg(nstate, R_IDSTAT);
1045
            end if;
1046
          end if;
1047
        end if;
1048
 
1049
  -- destination read states --------------------------------------------------
1050
  --   flows:
1051
  --     1  (r)    s_dstr_def           req (r) (rmw if rmw op)
1052
  --               s_dstr_def_w         get (r)
1053
  --               -> do_fork_opg
1054
  --              
1055
  --     2  (r)+   s_dstr_inc           req (r); r+=s (rmw if rmw op)
1056
  --               s_dstr_inc_w         get (r)
1057
  --               -> do_fork_opg
1058
  --
1059
  --     3  @(r)+  s_dstr_inc           req (r); r+=s
1060
  --               s_dstr_inc_w         get (r)
1061
  --               s_dstr_def           req @(r) (rmw if rmw op)
1062
  --               s_dstr_def_w         get @(r)
1063
  --               -> do_fork_opg
1064
  --
1065
  --     4  -(r)   s_dstr_dec           r-=s
1066
  --               s_dstr_dec1          req (r) (rmw if rmw op)
1067
  --               s_dstr_inc_w         get (r)
1068
  --               -> do_fork_opg
1069
  --
1070
  --     5  @-(r)  s_dstr_dec           r-=s
1071
  --               s_dstr_dec1          req (r)
1072
  --               s_dstr_inc_w         get (r)
1073
  --               s_dstr_def           req @(r) (rmw if rmw op)
1074
  --               s_dstr_def_w         get @(r)
1075
  --               -> do_fork_opg
1076
  --
1077
  --     6  n(r)   s_dstr_ind           req n
1078
  --               s_dstr_ind1_w        get n; ea=r+n
1079
  --               s_dstr_ind2          req n(r) (rmw if rmw op)
1080
  --               s_dstr_ind2_w        get n(r)
1081
  --               -> do_fork_opg
1082
  --
1083
  --     7  @n(r)  s_dstr_ind           req n
1084
  --               s_dstr_ind1_w        get n; ea=r+n
1085
  --               s_dstr_ind2          req n(r)
1086
  --               s_dstr_ind2_w        get n(r)
1087
  --               s_dstr_def           req @n(r) (rmw if rmw op)
1088
  --               s_dstr_def_w         get @n(r)
1089
  --               -> do_fork_opg
1090
 
1091
      when s_dstr_def =>
1092
        ndpcntl.vmaddr_sel := c_dpath_vmaddr_ddst; -- VA = DDST
1093
        do_memread_d(nstate, nvmcntl, s_dstr_def_w,
1094
                     bytop=>R_IDSTAT.is_bytop, macc=>R_IDSTAT.is_rmwop);
1095
 
1096
      when s_dstr_def_w =>
1097
        nstate := s_dstr_def_w;
1098
        do_memcheck(nstate, nstatus, imemok);
1099
        ndpcntl.dres_sel := c_dpath_res_vmdout;  -- DRES = VMDOUT
1100
        ndpcntl.ddst_sel := c_dpath_ddst_res;    -- DDST = DRES
1101
        if imemok then
1102
          ndpcntl.ddst_we := '1';                -- update DDST
1103
          do_fork_opg(nstate, R_IDSTAT);
1104
        end if;
1105
 
1106
      when s_dstr_inc =>
1107 8 wfjm
        ndpcntl.ounit_asel := c_ounit_asel_ddst; -- OUNIT A=DDST
1108 2 wfjm
        do_const_opsize(ndpcntl, R_IDSTAT.is_bytop, DSTDEF, DSTREG);
1109 8 wfjm
        ndpcntl.ounit_bsel := c_ounit_bsel_const;-- OUNIT B=const
1110
        ndpcntl.dres_sel := c_dpath_res_ounit;   -- DRES = OUNIT
1111 2 wfjm
        ndpcntl.gpr_adst := DSTREG;
1112
        ndpcntl.gpr_we := '1';
1113
        nmmumoni.regmod := '1';
1114
        nmmumoni.isdec := '0';
1115
        ndpcntl.vmaddr_sel := c_dpath_vmaddr_ddst; -- VA = DDST
1116
        macc  := R_IDSTAT.is_rmwop and not DSTDEF;
1117
        bytop := R_IDSTAT.is_bytop and not DSTDEF;
1118
        do_memread_d(nstate, nvmcntl, s_dstr_inc_w,
1119
                     bytop=>bytop, macc=>macc, is_pci=>R_IDSTAT.is_dstpc);
1120
 
1121
      when s_dstr_inc_w =>
1122
        nstate := s_dstr_inc_w;
1123
        ndpcntl.dres_sel := c_dpath_res_vmdout;  -- DRES = VMDOUT
1124
        ndpcntl.ddst_sel := c_dpath_ddst_res;    -- DDST = DRES
1125
        do_memcheck(nstate, nstatus, imemok);
1126
        if imemok then
1127
          ndpcntl.ddst_we := '1';                -- update DDST
1128
          if DSTDEF = '1' then
1129
            nstate := s_dstr_def;
1130
          else
1131
            do_fork_opg(nstate, R_IDSTAT);
1132
          end if;
1133
        end if;
1134
 
1135
      when s_dstr_dec =>
1136 8 wfjm
        ndpcntl.ounit_asel := c_ounit_asel_ddst; -- OUNIT A=DDST
1137 2 wfjm
        do_const_opsize(ndpcntl, R_IDSTAT.is_bytop, DSTDEF, DSTREG);
1138 8 wfjm
        ndpcntl.ounit_bsel := c_ounit_bsel_const;-- OUNIT B=const
1139
        ndpcntl.ounit_opsub := '1';              -- OUNIT = A-B
1140
        ndpcntl.dres_sel := c_dpath_res_ounit;   -- DRES = OUNIT
1141 2 wfjm
        ndpcntl.ddst_sel := c_dpath_ddst_res;    -- DDST = DRES
1142
        ndpcntl.ddst_we := '1';                  -- update DDST
1143
        ndpcntl.gpr_adst := DSTREG;
1144
        ndpcntl.gpr_we := '1';
1145
        nmmumoni.regmod := '1';
1146
        nmmumoni.isdec := '1';
1147
        nstate := s_dstr_dec1;
1148
 
1149
      when s_dstr_dec1 =>
1150
        ndpcntl.vmaddr_sel := c_dpath_vmaddr_ddst; -- VA = DDST
1151
        macc  := R_IDSTAT.is_rmwop and not DSTDEF;
1152
        bytop := R_IDSTAT.is_bytop and not DSTDEF;
1153
        do_memread_d(nstate, nvmcntl, s_dstr_inc_w,
1154
                     bytop=>bytop, macc=>macc);
1155
 
1156
      when s_dstr_ind =>
1157
        do_memread_i(nstate, ndpcntl, nvmcntl, s_dstr_ind1_w);
1158
 
1159
      when s_dstr_ind1_w =>
1160
        nstate := s_dstr_ind1_w;
1161
        if R_IDSTAT.is_dstpc = '0' then
1162 8 wfjm
          ndpcntl.ounit_asel := c_ounit_asel_ddst; -- OUNIT A = DDST
1163 2 wfjm
        else
1164 8 wfjm
          ndpcntl.ounit_asel := c_ounit_asel_pc;   -- OUNIT A = PC (for nn(pc))
1165 2 wfjm
        end if;
1166 8 wfjm
        ndpcntl.ounit_bsel := c_ounit_bsel_vmdout;-- OUNIT B = VMDOUT
1167
        ndpcntl.dres_sel := c_dpath_res_ounit;   -- DRES = OUNIT
1168 2 wfjm
        ndpcntl.ddst_sel := c_dpath_ddst_res;    -- DDST = DRES
1169
        do_memcheck(nstate, nstatus, imemok);
1170
        if imemok then
1171
          ndpcntl.ddst_we := '1';                -- update DDST
1172
          nstate := s_dstr_ind2;
1173
        end if;
1174
 
1175
      when s_dstr_ind2 =>
1176
        ndpcntl.vmaddr_sel := c_dpath_vmaddr_ddst; -- VA = DDST
1177
        macc  := R_IDSTAT.is_rmwop and not DSTDEF;
1178
        bytop := R_IDSTAT.is_bytop and not DSTDEF;
1179
        do_memread_d(nstate, nvmcntl, s_dstr_ind2_w,
1180
                     bytop=>bytop, macc=>macc);
1181
 
1182
      when s_dstr_ind2_w =>
1183
        nstate := s_dstr_ind2_w;
1184
        ndpcntl.dres_sel := c_dpath_res_vmdout;  -- DRES = VMDOUT
1185
        ndpcntl.ddst_sel := c_dpath_ddst_res;    -- DDST = DRES
1186
        do_memcheck(nstate, nstatus, imemok);
1187
        if imemok then
1188
          ndpcntl.ddst_we := '1';                -- update DDST
1189
          if DSTDEF = '1' then
1190
            nstate := s_dstr_def;
1191
          else
1192
            do_fork_opg(nstate, R_IDSTAT);
1193
          end if;
1194
        end if;
1195
 
1196
  -- destination write states -------------------------------------------------
1197
  --   flows:
1198
  --     1  (r)    s_dstw_def           wreq (r)            check kstack
1199
  --               s_dstw_def_w         ack  (r)
1200
  --               -> do_fork_next
1201
  --              
1202
  --     2  (r)+   s_dstw_inc           wreq (r)            check kstack
1203
  --               s_dstw_inc_w         ack  (r); r+=s
1204
  --               -> do_fork_next
1205
  --
1206
  --     3  @(r)+  s_dstw_inc           rreq (r); r+=s
1207
  --               s_dstw_incdef_w      get  (r)
1208
  --               s_dstw_def246        wreq @(r)
1209
  --               s_dstw_def_w         ack  @(r)
1210
  --               -> do_fork_next
1211
  --
1212
  --     4  -(r)   s_dstw_dec           r-=s
1213
  --               s_dstw_dec1          wreq (r)            check kstack
1214
  --               s_dstw_def_w         ack  (r)
1215
  --               -> do_fork_next
1216
  --
1217
  --     5  @-(r)  s_dstw_dec           r-=s
1218
  --               s_dstw_dec1          rreq (r)
1219
  --               s_dstw_incdef_w      get  (r)
1220
  --               s_dstw_def246        wreq @(r)
1221
  --               s_dstw_def_w         ack  @(r)
1222
  --               -> do_fork_next
1223
  --
1224
  --     6  n(r)   s_dstw_ind           rreq n
1225
  --               s_dstw_ind_w         get  n; ea=r+n
1226
  --               s_dstw_dec1          wreq n(r)           check kstack
1227
  --               s_dstw_def_w         ack  n(r)
1228
  --               -> do_fork_next
1229
  --
1230
  --     7  @n(r)  s_dstw_ind           rreq n
1231
  --               s_dstw_ind_w         get  n; ea=r+n
1232
  --               s_dstw_dec1          rreq n(r)
1233
  --               s_dstw_incdef_w      get  n(r)
1234
  --               s_dstw_def246        wreq @n(r)
1235
  --               s_dstw_def_w         ack  @n(r)
1236
  --               -> do_fork_next
1237
 
1238
      when s_dstw_def =>
1239
        ndpcntl.psr_ccwe := '1';
1240
        ndpcntl.dres_sel := R_IDSTAT.res_sel;      -- DRES = choice of idec
1241
        ndpcntl.vmaddr_sel := c_dpath_vmaddr_ddst; -- VA = DDST
1242
        nvmcntl.kstack := is_dstkstack1246;
1243
        do_memwrite(nstate, nvmcntl, s_dstw_def_w);
1244
 
1245
      when s_dstw_def_w =>
1246
        nstate := s_dstw_def_w;
1247
        do_memcheck(nstate, nstatus, imemok);
1248
        if imemok then
1249
          do_fork_next(nstate, nstatus, nmmumoni);
1250
        end if;
1251
 
1252
      when s_dstw_inc =>
1253
        ndpcntl.psr_ccwe := '1';
1254
        ndpcntl.vmaddr_sel := c_dpath_vmaddr_ddst;   -- VA = DDST
1255 8 wfjm
        ndpcntl.ounit_asel := c_ounit_asel_ddst;     -- OUNIT A=DDST  (for else)
1256 2 wfjm
        do_const_opsize(ndpcntl, R_IDSTAT.is_bytop, DSTDEF, DSTREG);  --(...)
1257 8 wfjm
        ndpcntl.ounit_bsel := c_ounit_bsel_const;    -- OUNIT B=const (for else)
1258 2 wfjm
        if DSTDEF = '0' then
1259
          ndpcntl.dres_sel := R_IDSTAT.res_sel;      -- DRES = choice of idec
1260
          nvmcntl.kstack := is_dstkstack1246;
1261
          do_memwrite(nstate, nvmcntl, s_dstw_inc_w);
1262
          nstatus.do_gprwe := '1';
1263
        else
1264 8 wfjm
          ndpcntl.dres_sel := c_dpath_res_ounit;     -- DRES = OUNIT
1265 2 wfjm
          ndpcntl.gpr_adst := DSTREG;
1266
          ndpcntl.gpr_we := '1';
1267
          nmmumoni.regmod := '1';
1268
          nmmumoni.isdec := '0';
1269
          do_memread_d(nstate, nvmcntl, s_dstw_incdef_w,
1270
                       is_pci=>R_IDSTAT.is_dstpc);
1271
        end if;
1272
 
1273
      when s_dstw_inc_w =>
1274
        nstate := s_dstw_inc_w;
1275 8 wfjm
        ndpcntl.ounit_asel := c_ounit_asel_ddst;   -- OUNIT A=DDST
1276 2 wfjm
        do_const_opsize(ndpcntl, R_IDSTAT.is_bytop, DSTDEF, DSTREG);
1277 8 wfjm
        ndpcntl.ounit_bsel := c_ounit_bsel_const;  -- OUNIT B=const
1278
        ndpcntl.dres_sel := c_dpath_res_ounit;     -- DRES = OUNIT
1279 2 wfjm
        ndpcntl.gpr_adst := DSTREG;
1280
        if R_STATUS.do_gprwe = '1' then
1281
          nmmumoni.regmod := '1';
1282
          nmmumoni.isdec := '0';
1283
          nmmumoni.trace_prev := '1';              -- ssr freeze of prev state
1284
          ndpcntl.gpr_we := '1';                   -- update DST reg
1285
        end if;
1286
        nstatus.do_gprwe := '0';
1287
        do_memcheck(nstate, nstatus, imemok);
1288
        if imemok then
1289
          do_fork_next(nstate, nstatus, nmmumoni);
1290
        end if;
1291
 
1292
      when s_dstw_incdef_w =>
1293
        nstate := s_dstw_incdef_w;
1294
        ndpcntl.dres_sel := c_dpath_res_vmdout;  -- DRES = VMDOUT
1295
        ndpcntl.ddst_sel := c_dpath_ddst_res;    -- DDST = DRES
1296
        do_memcheck(nstate, nstatus, imemok);
1297
        if imemok then
1298
          ndpcntl.ddst_we := '1';                -- update DDST
1299
          nstate := s_dstw_def246;
1300
        end if;
1301
 
1302
      when s_dstw_dec =>
1303
        ndpcntl.psr_ccwe := '1';
1304 8 wfjm
        ndpcntl.ounit_asel := c_ounit_asel_ddst; -- OUNIT A=DDST
1305 2 wfjm
        do_const_opsize(ndpcntl, R_IDSTAT.is_bytop, DSTDEF, DSTREG);
1306 8 wfjm
        ndpcntl.ounit_bsel := c_ounit_bsel_const;-- OUNIT B=const
1307
        ndpcntl.ounit_opsub := '1';              -- OUNIT = A-B
1308
        ndpcntl.dres_sel := c_dpath_res_ounit;   -- DRES = OUNIT
1309 2 wfjm
        ndpcntl.ddst_sel := c_dpath_ddst_res;    -- DDST = DRES
1310
        ndpcntl.ddst_we := '1';                  -- update DDST
1311
        ndpcntl.gpr_adst := DSTREG;
1312
        ndpcntl.gpr_we := '1';
1313
        nmmumoni.regmod := '1';
1314
        nmmumoni.isdec := '1';
1315
        nstate := s_dstw_dec1;
1316
 
1317
      when s_dstw_dec1 =>
1318
        ndpcntl.vmaddr_sel := c_dpath_vmaddr_ddst; -- VA = DDST
1319
        ndpcntl.dres_sel := R_IDSTAT.res_sel;      -- DRES = from idec (for if)
1320
        if DSTDEF = '0' then
1321
          nvmcntl.kstack := is_dstkstack1246;
1322
          do_memwrite(nstate, nvmcntl, s_dstw_def_w);
1323
        else
1324
          do_memread_d(nstate, nvmcntl, s_dstw_incdef_w);
1325
        end if;
1326
 
1327
      when s_dstw_ind =>
1328
        ndpcntl.psr_ccwe := '1';
1329
        do_memread_i(nstate, ndpcntl, nvmcntl, s_dstw_ind_w);
1330
 
1331
      when s_dstw_ind_w =>
1332
        nstate := s_dstw_ind_w;
1333
        if R_IDSTAT.is_dstpc = '0' then
1334 8 wfjm
          ndpcntl.ounit_asel := c_ounit_asel_ddst; -- OUNIT A = DDST
1335 2 wfjm
        else
1336 8 wfjm
          ndpcntl.ounit_asel := c_ounit_asel_pc;   -- OUNIT A = PC (for nn(pc))
1337 2 wfjm
        end if;
1338 8 wfjm
        ndpcntl.ounit_bsel := c_ounit_bsel_vmdout;-- OUNIT B = VMDOUT
1339
        ndpcntl.dres_sel := c_dpath_res_ounit;   -- DRES = OUNIT
1340 2 wfjm
        ndpcntl.ddst_sel := c_dpath_ddst_res;    -- DDST = DRES
1341
        do_memcheck(nstate, nstatus, imemok);
1342
        if imemok then
1343
          ndpcntl.ddst_we := '1';                -- update DDST
1344
          nstate := s_dstw_dec1;
1345
        end if;
1346
 
1347
      when s_dstw_def246 =>
1348
        ndpcntl.dres_sel := R_IDSTAT.res_sel;      -- DRES = choice of idec
1349
        ndpcntl.vmaddr_sel := c_dpath_vmaddr_ddst; -- VA = DDST
1350
        do_memwrite(nstate, nvmcntl, s_dstw_def_w);
1351
 
1352
  -- destination address states -----------------------------------------------
1353
  --   flows:
1354
  --     1  (r)    -> do_fork_opa
1355
  --              
1356
  --     2  (r)+   s_dsta_inc           r+=2
1357
  --               -> do_fork_opa
1358
  --
1359
  --     3  @(r)+  s_dsta_inc           req (r); r+=s
1360
  --               s_dsta_incdef_w      get (r)
1361
  --               -> do_fork_opa
1362
  --
1363
  --     4  -(r)   s_dsta_dec           r-=s
1364
  --               s_dsta_dec1          ?? FIXME ?? what is done here ??
1365
  --               -> do_fork_opa
1366
  --
1367
  --     5  @-(r)  s_dsta_dec           r-=s
1368
  --               s_dsta_dec1          req (r)
1369
  --               s_dsta_incdef_w      get (r)
1370
  --               -> do_fork_opa
1371
  --
1372
  --     6  n(r)   s_dsta_ind           req n
1373
  --               s_dsta_ind_w         get n; ea=r+n
1374
  --               s_dsta_dec1          ?? FIXME ?? what is done here ??
1375
  --               -> do_fork_opa
1376
  --
1377
  --     7  @n(r)  s_dsta_ind           req n
1378
  --               s_dsta_ind_w         get n; ea=r+n
1379
  --               s_dsta_dec1          req n(r)
1380
  --               s_dsta_incdef_w      get n(r)
1381
  --               -> do_fork_opa
1382
 
1383
      when s_dsta_inc =>
1384 8 wfjm
        ndpcntl.ounit_asel := c_ounit_asel_ddst;   -- OUNIT A=DDST
1385
        ndpcntl.ounit_const := "000000010";
1386
        ndpcntl.ounit_bsel := c_ounit_bsel_const;  -- OUNIT B=const(2)
1387
        ndpcntl.dres_sel := c_dpath_res_ounit;     -- DRES = OUNIT
1388 2 wfjm
        ndpcntl.gpr_adst := DSTREG;
1389
        ndpcntl.gpr_we := '1';
1390
        nmmumoni.regmod := '1';
1391
        nmmumoni.isdec := '0';
1392
        ndpcntl.dsrc_sel := c_dpath_dsrc_res;      -- DSRC = DRES (for if)
1393
        if R_IDSTAT.updt_dstadsrc = '1' then       -- prevent stale DSRC copy 
1394
          ndpcntl.dsrc_we := '1';                    -- update DSRC
1395
        end if;
1396
        ndpcntl.vmaddr_sel := c_dpath_vmaddr_ddst; -- VA = DDST
1397
        if DSTDEF = '0' then
1398
          do_fork_opa(nstate, R_IDSTAT);
1399
        else
1400
          do_memread_d(nstate, nvmcntl, s_dsta_incdef_w,
1401
                       is_pci=>R_IDSTAT.is_dstpc);
1402
        end if;
1403
 
1404
      when s_dsta_incdef_w =>
1405
        nstate := s_dsta_incdef_w;
1406
        ndpcntl.dres_sel := c_dpath_res_vmdout;  -- DRES = VMDOUT
1407
        ndpcntl.ddst_sel := c_dpath_ddst_res;    -- DDST = DRES
1408
        do_memcheck(nstate, nstatus, imemok);
1409
        if imemok then
1410
          ndpcntl.ddst_we := '1';                -- update DDST
1411
          do_fork_opa(nstate, R_IDSTAT);
1412
        end if;
1413
 
1414
      when s_dsta_dec =>
1415 8 wfjm
        ndpcntl.ounit_asel := c_ounit_asel_ddst; -- OUNIT A=DDST
1416
        ndpcntl.ounit_const := "000000010";
1417
        ndpcntl.ounit_bsel := c_ounit_bsel_const;-- OUNIT B=const(2)
1418
        ndpcntl.ounit_opsub := '1';              -- OUNIT = A-B
1419
        ndpcntl.dres_sel := c_dpath_res_ounit;   -- DRES = OUNIT
1420 2 wfjm
        ndpcntl.ddst_sel := c_dpath_ddst_res;    -- DDST = DRES
1421
        ndpcntl.ddst_we := '1';                  -- update DDST
1422
        ndpcntl.gpr_adst := DSTREG;
1423
        ndpcntl.gpr_we := '1';
1424
        nmmumoni.regmod := '1';
1425
        nmmumoni.isdec := '1';
1426
        ndpcntl.dsrc_sel := c_dpath_dsrc_res;    -- DSRC = DRES (for if)
1427
        if R_IDSTAT.updt_dstadsrc = '1' then     -- prevent stale DSRC copy 
1428
          ndpcntl.dsrc_we := '1';                -- update DSRC
1429
        end if;
1430
        nstate := s_dsta_dec1;
1431
 
1432
      when s_dsta_dec1 =>
1433
        ndpcntl.vmaddr_sel := c_dpath_vmaddr_ddst; -- VA = DDST
1434
        if DSTDEF = '0' then                       -- check here used also by
1435
          do_fork_opa(nstate, R_IDSTAT);           -- s_dsta_ind flow !!
1436
        else
1437
          do_memread_d(nstate, nvmcntl, s_dsta_incdef_w);
1438
        end if;
1439
 
1440
      when s_dsta_ind =>
1441
        do_memread_i(nstate, ndpcntl, nvmcntl, s_dsta_ind_w);
1442
 
1443
      when s_dsta_ind_w =>
1444
        nstate := s_dsta_ind_w;
1445
        if R_IDSTAT.is_dstpc = '0' then
1446 8 wfjm
          ndpcntl.ounit_asel := c_ounit_asel_ddst; -- OUNIT A = DDST
1447 2 wfjm
        else
1448 8 wfjm
          ndpcntl.ounit_asel := c_ounit_asel_pc;   -- OUNIT A = PC (for nn(pc))
1449 2 wfjm
        end if;
1450 8 wfjm
        ndpcntl.ounit_bsel := c_ounit_bsel_vmdout;-- OUNIT B = VMDOUT
1451
        ndpcntl.dres_sel := c_dpath_res_ounit;   -- DRES = OUNIT
1452 2 wfjm
        ndpcntl.ddst_sel := c_dpath_ddst_res;    -- DDST = DRES
1453
        do_memcheck(nstate, nstatus, imemok);
1454
        if imemok then
1455
          ndpcntl.ddst_we := '1';                -- update DDST
1456
          nstate := s_dsta_dec1;
1457
        end if;
1458
 
1459
  -- instruction operate states -----------------------------------------------
1460
 
1461
      when s_op_halt =>                 -- HALT
1462
        if is_kmode = '1' then          -- if in kernel mode execute
1463
          nmmumoni.idone := '1';
1464
          nstatus.cpugo := '0';
1465
          nstatus.cpuhalt := '1';
1466
          nstatus.cpurust := c_cpurust_halt;
1467
          nstate := s_idle;
1468
        else                            -- otherwise trap
1469
          ncpuerr.illhlt := '1';
1470
          nstate := s_trap_4;           -- trap 4 like 11/70
1471
        end if;
1472
 
1473
      when s_op_wait =>                 -- WAIT
1474
        nstate := s_op_wait;            -- spin here
1475
        if is_kmode = '0' then          -- but act as nop if not in kernel
1476
          nstate := s_idle;
1477
        elsif int_pending = '1' or      -- bail out if pending interrupt
1478
          R_STATUS.cpustep='1' then     --  or the instruction is only stepped
1479
          nstate := s_idle;
1480
        elsif R_STATUS.cmdbusy = '1' then -- suspend if a cp command is pending
1481
          nstatus.waitsusp := '1';
1482
          nstate := s_idle;
1483
        else
1484
          nstatus.cpuwait := '1';       -- if spinning here, signal with cpuwait
1485
        end if;
1486
 
1487
      when s_op_trap =>                 -- traps
1488
        lvector := "0000" & R_IDSTAT.trap_vec; -- vector
1489
        do_start_int(nstate, ndpcntl, lvector);
1490
 
1491
      when s_op_reset =>                -- RESET
1492
        if is_kmode = '1' then          -- if in kernel mode execute
1493
          nbreset := '1';
1494
        end if;
1495
        nstate := s_idle;
1496
 
1497
      when s_op_rts =>                  -- RTS
1498 8 wfjm
        ndpcntl.ounit_asel := c_ounit_asel_ddst;   -- OUNIT A=DDST
1499
        ndpcntl.ounit_bsel := c_ounit_bsel_const;  -- OUNIT B=const(0)
1500
        ndpcntl.dres_sel := c_dpath_res_ounit;     -- DRES = OUNIT
1501 2 wfjm
        ndpcntl.gpr_adst := c_gpr_pc;
1502
        ndpcntl.gpr_we := '1';                     -- load PC with reg(dst)
1503
        nstate := s_op_rts_pop;
1504
 
1505
      when s_op_rts_pop =>
1506
        do_memread_srcinc(nstate, ndpcntl, nvmcntl, s_op_rts_pop_w,
1507
                          nmmumoni, updt_sp=>'1');
1508
 
1509
      when s_op_rts_pop_w =>
1510
        nstate := s_op_rts_pop_w;
1511
        ndpcntl.dres_sel := c_dpath_res_vmdout;   -- DRES = VMDOUT
1512
        ndpcntl.gpr_adst := DSTREG;
1513
        do_memcheck(nstate, nstatus, imemok);
1514
        if imemok then
1515
          ndpcntl.gpr_we := '1';                  -- load R with (SP)+
1516
          do_fork_next(nstate, nstatus, nmmumoni);
1517
        end if;
1518
 
1519
      when s_op_spl =>                  -- SPL
1520
        ndpcntl.dres_sel := c_dpath_res_ireg;    -- DRES = IREG
1521
        ndpcntl.psr_func := c_psr_func_wspl;
1522
        if is_kmode = '1' then                   -- active only in kernel mode
1523
          ndpcntl.psr_we := '1';
1524
          nstate := s_ifetch;                    -- unconditionally fetch next
1525
                                                 -- instruction like a 11/70
1526
                                                 -- no interrupt recognition !
1527
        else
1528
          do_fork_next(nstate, nstatus, nmmumoni);  -- in non-kernel, noop
1529
        end if;
1530
 
1531
      when s_op_mcc =>                  -- CLx/SEx
1532
        ndpcntl.dres_sel := c_dpath_res_ireg;    -- DRES = IREG
1533
        ndpcntl.psr_func := c_psr_func_wcc;
1534
        ndpcntl.psr_we := '1';
1535
        do_fork_next(nstate, nstatus, nmmumoni);
1536
 
1537
      when s_op_br =>                   -- BR
1538
        nvmcntl.dspace := '0';                   -- prepare do_fork_next_pref
1539
        ndpcntl.vmaddr_sel := c_dpath_vmaddr_pc; -- VA = PC
1540 8 wfjm
        ndpcntl.ounit_asel := c_ounit_asel_pc;   -- OUNIT A = PC
1541
        ndpcntl.ounit_bsel := c_ounit_bsel_ireg8;-- OUNIT B = IREG8
1542
        ndpcntl.dres_sel := c_dpath_res_ounit;   -- DRES = OUNIT
1543 2 wfjm
        -- note: cc are NZVC
1544
        case brcode(3 downto 1) is
1545
          when "000" =>                 -- BR
1546
            brcond := '1';
1547
          when "001" =>                 -- BNE/BEQ: if Z = x
1548
            brcond := PSW.cc(2);
1549
          when "010" =>                 -- BGE/BLT: if N xor V = x
1550
            brcond := PSW.cc(3) xor PSW.cc(1);
1551
          when "011" =>                 -- BGT/BLE: if Z or (N xor V) = x
1552
            brcond := PSW.cc(2) or (PSW.cc(3) xor PSW.cc(1));
1553
          when "100" =>                 -- BPL/BMI: if N = x
1554
            brcond := PSW.cc(3);
1555
          when "101" =>                 -- BHI/BLOS:if C or Z = x
1556
            brcond := PSW.cc(2) or PSW.cc(0);
1557
          when "110" =>                 -- BVC/BVS: if V = x
1558
            brcond := PSW.cc(1);
1559
          when "111" =>                 -- BCC/BCS: if C = x
1560
            brcond := PSW.cc(0);
1561
          when others => null;
1562
        end case;
1563
 
1564
        ndpcntl.gpr_adst := c_gpr_pc;
1565
        if brcond = brcode(0) then      -- this coding creates redundant code
1566
          ndpcntl.gpr_we := '1';        --   but synthesis optimizes this way !
1567
          do_fork_next(nstate, nstatus, nmmumoni);
1568
        else
1569
          do_fork_next_pref(nstate, nstatus, ndpcntl, nvmcntl, nmmumoni);
1570
        end if;
1571
 
1572
      when s_op_mark =>                 -- MARK 
1573 8 wfjm
        ndpcntl.ounit_asel := c_ounit_asel_pc;   -- OUNIT A = PC
1574
        ndpcntl.ounit_bsel := c_ounit_bsel_ireg6;-- OUNIT B = IREG6
1575
        ndpcntl.dres_sel := c_dpath_res_ounit;   -- DRES = OUNIT
1576 2 wfjm
        ndpcntl.dsrc_sel := c_dpath_dsrc_res;    -- DSRC = DRES
1577
        ndpcntl.dsrc_we := '1';                  -- update DSRC (with PC+2*nn)
1578
        ndpcntl.gpr_adst := c_gpr_r5;            -- fetch r5
1579
        ndpcntl.ddst_sel := c_dpath_ddst_dst;
1580
        ndpcntl.ddst_we := '1';
1581
        nstate := s_op_mark1;
1582
 
1583
      when s_op_mark1 =>
1584 8 wfjm
        ndpcntl.ounit_asel := c_ounit_asel_ddst; -- OUNIT A = DDST
1585
        ndpcntl.ounit_bsel := c_ounit_bsel_const;-- OUNIT B = const(0)
1586
        ndpcntl.dres_sel := c_dpath_res_ounit;   -- DRES = OUNIT
1587 2 wfjm
        ndpcntl.gpr_adst := c_gpr_pc;
1588
        ndpcntl.gpr_we := '1';                   -- load PC with r5
1589
        nstate := s_op_mark_pop;
1590
 
1591
      when s_op_mark_pop =>
1592
        do_memread_srcinc(nstate, ndpcntl, nvmcntl, s_op_mark_pop_w,
1593
                          nmmumoni, updt_sp=>'1');
1594
 
1595
      when s_op_mark_pop_w =>
1596
        nstate := s_op_mark_pop_w;
1597
        ndpcntl.dres_sel := c_dpath_res_vmdout;  -- DRES = VMDOUT
1598
        ndpcntl.gpr_adst := c_gpr_r5;
1599
        do_memcheck(nstate, nstatus, imemok);
1600
        if imemok then
1601
          ndpcntl.gpr_we := '1';                 -- load R5 with (sp)+
1602
          do_fork_next(nstate, nstatus, nmmumoni);
1603
        end if;
1604
 
1605
      when s_op_sob =>                  -- SOB (dec)
1606
        -- comment fork_next_pref out (blog 2006-10-02) due to synthesis impact
1607
        --nvmcntl.dspace := '0';                   -- prepare do_fork_next_pref
1608
        --ndpcntl.vmaddr_sel := c_dpath_vmaddr_pc; -- VA = PC
1609
        ndpcntl.dres_sel := R_IDSTAT.res_sel;
1610
        ndpcntl.gpr_adst := SRCREG;
1611
        ndpcntl.gpr_we := '1';
1612
 
1613
        if DP_STAT.ccout_z = '0' then   -- if z=0 branch, if z=1 fall thru
1614
          nstate := s_op_sob1;
1615
        else
1616
          --do_fork_next_pref(nstate, ndpcntl, nvmcntl, nmmumoni);
1617
          do_fork_next(nstate, nstatus, nmmumoni);
1618
        end if;
1619
 
1620
      when s_op_sob1 =>                 -- SOB (br) 
1621 8 wfjm
        ndpcntl.ounit_asel := c_ounit_asel_pc;   -- OUNIT A = PC
1622
        ndpcntl.ounit_bsel := c_ounit_bsel_ireg6;-- OUNIT B = IREG6
1623
        ndpcntl.ounit_opsub := '1';              -- OUNIT = A - B
1624
        ndpcntl.dres_sel := c_dpath_res_ounit;   -- DRES = OUNIT
1625 2 wfjm
        ndpcntl.gpr_adst := c_gpr_pc;
1626
        ndpcntl.gpr_we := '1';
1627
        do_fork_next(nstate, nstatus, nmmumoni);
1628
 
1629
      when s_opg_gen =>
1630
        nvmcntl.dspace := '0';                   -- prepare do_fork_next_pref
1631
        ndpcntl.vmaddr_sel := c_dpath_vmaddr_pc; -- VA = PC
1632
        ndpcntl.gpr_bytop := R_IDSTAT.is_bytop;
1633
        ndpcntl.dres_sel := R_IDSTAT.res_sel;    -- DRES = choice of idec
1634
 
1635
        if R_IDSTAT.op_mov = '1' then            -- in case of MOV xx,R
1636
          ndpcntl.gpr_bytop := '0';              --  no bytop, do sign extend
1637
        end if;
1638
 
1639
        ndpcntl.psr_ccwe := '1';
1640
 
1641
        if R_IDSTAT.is_dstw_reg = '1' then
1642
          ndpcntl.gpr_we := '1';
1643
        end if;
1644
 
1645
        if R_IDSTAT.is_rmwop = '1' then
1646
          do_memwrite(nstate, nvmcntl, s_opg_gen_rmw_w, macc=>'1');
1647
        else
1648
          if R_STATUS.prefdone = '1' then
1649
            nstatus.prefdone :='0';
1650
            nstate := s_ifetch_w;
1651
            do_memcheck(nstate, nstatus, imemok);
1652
            if imemok then
1653
              ndpcntl.ireg_we := '1';
1654
              nstate := s_idecode;
1655
            end if;
1656
          else
1657
            if R_IDSTAT.is_dstw_pc = '1' then
1658
              nstate := s_idle;
1659
            else
1660
              do_fork_next_pref(nstate, nstatus, ndpcntl, nvmcntl, nmmumoni);
1661
            end if;
1662
          end if;
1663
        end if;
1664
 
1665
      when s_opg_gen_rmw_w =>
1666
        nstate := s_opg_gen_rmw_w;
1667
        do_memcheck(nstate, nstatus, imemok);
1668
        if imemok then
1669
          do_fork_next(nstate, nstatus, nmmumoni);
1670
        end if;
1671
 
1672
      when s_opg_mul =>                 -- MUL (oper)
1673
        ndpcntl.dres_sel := R_IDSTAT.res_sel;   -- DRES = choice of idec
1674
        ndpcntl.gpr_adst := SRCREG;             -- write high order result
1675
        ndpcntl.gpr_we := '1';
1676
        ndpcntl.dsrc_sel := c_dpath_dsrc_res;   -- DSRC = DRES
1677
        ndpcntl.dsrc_we := '1';                 -- capture high order part
1678
        ndpcntl.dtmp_sel := c_dpath_dtmp_drese; -- DTMP = DRESE
1679
        ndpcntl.dtmp_we := '1';                 -- capture low order part
1680
        nstate := s_opg_mul1;
1681
 
1682
      when s_opg_mul1 =>                -- MUL (write odd reg)
1683 8 wfjm
        ndpcntl.ounit_asel := c_ounit_asel_dtmp; -- OUNIT A = DTMP
1684
        ndpcntl.ounit_bsel := c_ounit_bsel_const;-- OUNIT B = const(0)
1685
        ndpcntl.dres_sel := c_dpath_res_ounit;   -- DRES = OUNIT
1686 2 wfjm
        ndpcntl.gpr_adst := SRCREG(2 downto 1) & "1";-- write odd reg !
1687
        ndpcntl.gpr_we := '1';
1688
        ndpcntl.psr_ccwe := '1';
1689
        do_fork_next(nstate, nstatus, nmmumoni);
1690
 
1691
      when s_opg_div =>                 -- DIV (load dd_low)
1692 8 wfjm
        ndpcntl.munit_s_div := '1';
1693 2 wfjm
        ndpcntl.gpr_asrc := SRCREG(2 downto 1) & "1";-- read odd reg !
1694
        ndpcntl.dtmp_sel := c_dpath_dtmp_dsrc;
1695
        ndpcntl.dtmp_we := '1';
1696
        nstate := s_opg_div_cn;
1697
 
1698
      when s_opg_div_cn =>              -- DIV (1st...16th cycle)
1699 8 wfjm
        ndpcntl.munit_s_div_cn := '1';
1700 2 wfjm
        ndpcntl.dres_sel := R_IDSTAT.res_sel;     -- DRES = choice of idec
1701
        ndpcntl.dsrc_sel := c_dpath_dsrc_res;     -- DSRC = DRES
1702
        ndpcntl.dtmp_sel := c_dpath_dtmp_drese;   -- DTMP = DRESE
1703
        nstate := s_opg_div_cn;
1704
        if DP_STAT.div_zero='1' or DP_STAT.div_ovfl='1' then
1705
          nstate := s_opg_div_zero;
1706
        else
1707
          ndpcntl.dsrc_we := '1';                 -- update DSRC
1708
          ndpcntl.dtmp_we := '1';                 -- update DTMP
1709
        end if;
1710
        if DP_STAT.shc_tc = '1' then
1711
          nstate := s_opg_div_cr;
1712
        end if;
1713
 
1714
      when s_opg_div_cr =>              -- DIV (reminder correction)
1715 8 wfjm
        ndpcntl.munit_s_div_cr := '1';
1716 2 wfjm
        ndpcntl.dres_sel := R_IDSTAT.res_sel;     -- DRES = choice of idec
1717
        ndpcntl.dsrc_sel := c_dpath_dsrc_res;     -- DSRC = DRES
1718
        ndpcntl.dsrc_we := DP_STAT.div_cr;        -- update DSRC
1719
        nstate := s_opg_div_sq;
1720
 
1721
      when s_opg_div_sq =>              -- DIV (store quotient)
1722 8 wfjm
        ndpcntl.ounit_asel := c_ounit_asel_dtmp;  -- OUNIT A=DTMP
1723
        ndpcntl.ounit_const := "00000000"&DP_STAT.div_cq;-- OUNIT const = Q corr.
1724
        ndpcntl.ounit_bsel := c_ounit_bsel_const; -- OUNIT B=const (q cor)
1725
        ndpcntl.dres_sel := c_dpath_res_ounit;    -- DRES = OUNIT
1726 2 wfjm
        ndpcntl.gpr_adst := SRCREG;               -- write result
1727
        ndpcntl.gpr_we := '1';
1728
        ndpcntl.dtmp_sel := c_dpath_dtmp_dres;    -- DTMP = DRES
1729
        ndpcntl.dtmp_we := '1';                   -- update DTMP (Q)
1730
        nstate := s_opg_div_sr;
1731
 
1732
      when s_opg_div_sr =>              -- DIV (store reminder)
1733 8 wfjm
        ndpcntl.ounit_asel := c_ounit_asel_dsrc;  -- OUNIT A=DSRC
1734
        ndpcntl.ounit_bsel := c_ounit_bsel_const; -- OUNIT B=const (0)
1735
        ndpcntl.dres_sel := c_dpath_res_ounit;    -- DRES = OUNIT
1736 2 wfjm
        ndpcntl.gpr_adst := SRCREG(2 downto 1) & "1";-- write odd reg !
1737
        ndpcntl.gpr_we := '1';
1738
        ndpcntl.psr_ccwe := '1';
1739
        do_fork_next(nstate, nstatus, nmmumoni);
1740
 
1741
      when s_opg_div_zero =>            -- DIV (/0 or 0/ abort)
1742
        ndpcntl.psr_ccwe := '1';
1743
        do_fork_next(nstate, nstatus, nmmumoni);
1744
 
1745
      when s_opg_ash =>                 -- ASH (load shc)
1746 8 wfjm
        ndpcntl.munit_s_ash := '1';
1747 2 wfjm
        nstate := s_opg_ash_cn;
1748
 
1749
      when s_opg_ash_cn =>              -- ASH (shift cycles)
1750
        nvmcntl.dspace := '0';                    -- prepare do_fork_next_pref
1751
        ndpcntl.dsrc_sel := c_dpath_dsrc_res;     -- DSRC = DRES
1752 8 wfjm
        ndpcntl.ounit_asel := c_ounit_asel_dsrc;  -- OUNIT A=DSRC
1753
        ndpcntl.ounit_bsel := c_ounit_bsel_const; -- OUNIT B=const(0)
1754 2 wfjm
        ndpcntl.gpr_adst := SRCREG;               -- write result
1755 8 wfjm
        ndpcntl.munit_s_ash_cn := '1';
1756 2 wfjm
        ndpcntl.vmaddr_sel := c_dpath_vmaddr_pc;  -- VA = PC
1757
        nstate := s_opg_ash_cn;
1758
        if DP_STAT.shc_tc = '0' then
1759
          ndpcntl.dres_sel := R_IDSTAT.res_sel;   -- DRES = choice of idec
1760
          ndpcntl.dsrc_we := '1';                 -- update DSRC
1761
        else
1762 8 wfjm
          ndpcntl.dres_sel := c_dpath_res_ounit;  -- DRES = OUNIT
1763 2 wfjm
          ndpcntl.gpr_we := '1';
1764
          ndpcntl.psr_ccwe := '1';
1765
          do_fork_next_pref(nstate, nstatus, ndpcntl, nvmcntl, nmmumoni);
1766
        end if;
1767
 
1768
      when s_opg_ashc =>                -- ASHC (load low, load shc)
1769
        ndpcntl.gpr_asrc := SRCREG(2 downto 1) & "1";-- read odd reg !
1770
        ndpcntl.dtmp_sel := c_dpath_dtmp_dsrc;
1771
        ndpcntl.dtmp_we := '1';
1772 8 wfjm
        ndpcntl.munit_s_ashc := '1';
1773 2 wfjm
        nstate := s_opg_ashc_cn;
1774
 
1775
      when s_opg_ashc_cn =>             -- ASHC (shift cycles)
1776
        ndpcntl.dsrc_sel := c_dpath_dsrc_res;     -- DSRC = DRES
1777
        ndpcntl.dtmp_sel := c_dpath_dtmp_drese;   -- DTMP = DRESE
1778 8 wfjm
        ndpcntl.ounit_asel := c_ounit_asel_dsrc;  -- OUNIT A=DSRC
1779
        ndpcntl.ounit_bsel := c_ounit_bsel_const; -- OUNIT B=const(0)
1780 2 wfjm
        ndpcntl.gpr_adst := SRCREG;               -- write result
1781 8 wfjm
        ndpcntl.munit_s_ashc_cn := '1';
1782 2 wfjm
        nstate := s_opg_ashc_cn;
1783
        if DP_STAT.shc_tc = '0' then
1784
          ndpcntl.dres_sel := R_IDSTAT.res_sel;   -- DRES = choice of idec
1785
          ndpcntl.dsrc_we := '1';                 -- update DSRC
1786
          ndpcntl.dtmp_we := '1';                 -- update DTMP
1787
        else
1788 8 wfjm
          ndpcntl.dres_sel := c_dpath_res_ounit;  -- DRES = OUNIT
1789 2 wfjm
          ndpcntl.gpr_we := '1';
1790
          ndpcntl.psr_ccwe := '1';
1791
          nstate := s_opg_ashc_wl;
1792
        end if;
1793
 
1794
      when s_opg_ashc_wl =>             -- ASHC (write low)
1795 8 wfjm
        ndpcntl.ounit_asel := c_ounit_asel_dtmp; -- OUNIT A = DTMP
1796
        ndpcntl.ounit_bsel := c_ounit_bsel_const;-- OUNIT B = const(0)
1797
        ndpcntl.dres_sel := c_dpath_res_ounit;   -- DRES = OUNIT
1798 2 wfjm
        ndpcntl.gpr_adst := SRCREG(2 downto 1) & "1";-- write odd reg !
1799
        ndpcntl.gpr_we := '1';
1800
        do_fork_next(nstate, nstatus, nmmumoni);
1801
 
1802
  -- dsta mode operations -----------------------------------------------------
1803
 
1804
      when s_opa_jsr =>
1805
        ndpcntl.gpr_asrc := c_gpr_sp;              --                (for else)
1806
        ndpcntl.dsrc_sel := c_dpath_dsrc_src;      -- DSRC = regfile (for else)
1807
        if R_IDSTAT.is_dstmode0 = '1' then
1808
          nstate := s_trap_10;                     -- trap 10 like 11/70
1809
        else
1810
          ndpcntl.dsrc_we := '1';
1811
          nstate := s_opa_jsr1;
1812
        end if;
1813
 
1814
      when s_opa_jsr1 =>
1815
        ndpcntl.gpr_asrc := SRCREG;
1816
        ndpcntl.dtmp_sel := c_dpath_dtmp_dsrc;     -- DTMP = regfile
1817
        ndpcntl.dtmp_we := '1';
1818
 
1819 8 wfjm
        ndpcntl.ounit_asel := c_ounit_asel_dsrc;   -- OUNIT A=DSRC
1820
        ndpcntl.ounit_const := "000000010";
1821
        ndpcntl.ounit_bsel := c_ounit_bsel_const;  -- OUNIT B=const(2)
1822
        ndpcntl.ounit_opsub := '1';                -- OUNIT = A-B
1823
        ndpcntl.dres_sel := c_dpath_res_ounit;     -- DRES = OUNIT
1824 2 wfjm
        ndpcntl.dsrc_sel := c_dpath_dsrc_res;      -- DDST = DRES
1825
        ndpcntl.dsrc_we := '1';                    -- update DDST
1826
        ndpcntl.gpr_adst := c_gpr_sp;
1827
        ndpcntl.gpr_we := '1';                     -- update SP
1828
        nmmumoni.regmod := '1';
1829
        nmmumoni.isdec := '1';
1830
        nstate := s_opa_jsr_push;
1831
 
1832
      when s_opa_jsr_push =>
1833 8 wfjm
        ndpcntl.ounit_asel := c_ounit_asel_dtmp;   -- OUNIT A=DTMP
1834
        ndpcntl.ounit_bsel := c_ounit_bsel_const;  -- OUNIT B=const(0)
1835
        ndpcntl.dres_sel := c_dpath_res_ounit;     -- DRES = OUNIT
1836 2 wfjm
        ndpcntl.vmaddr_sel := c_dpath_vmaddr_dsrc; -- VA = DSRC
1837
        nvmcntl.dspace := '1';
1838
        nvmcntl.kstack := is_kmode;
1839
        nvmcntl.wacc := '1';
1840
        nvmcntl.req := '1';
1841
        nstate := s_opa_jsr_push_w;
1842
 
1843
      when s_opa_jsr_push_w =>
1844
        nstate := s_opa_jsr_push_w;
1845 8 wfjm
        ndpcntl.ounit_asel := c_ounit_asel_pc;     -- OUNIT A=PC
1846
        ndpcntl.ounit_bsel := c_ounit_bsel_const;  -- OUNIT B=const(0)
1847
        ndpcntl.dres_sel := c_dpath_res_ounit;     -- DRES = OUNIT
1848 2 wfjm
        ndpcntl.gpr_adst := SRCREG;
1849
        do_memcheck(nstate, nstatus, imemok);
1850
        if imemok then
1851
          ndpcntl.gpr_we := '1';                   -- load R with PC
1852
          nstate := s_opa_jsr2;
1853
        end if;
1854
 
1855
      when s_opa_jsr2 =>
1856 8 wfjm
        ndpcntl.ounit_asel := c_ounit_asel_ddst;   -- OUNIT A=DDST
1857
        ndpcntl.ounit_bsel := c_ounit_bsel_const;  -- OUNIT B=const(0)
1858
        ndpcntl.dres_sel := c_dpath_res_ounit;     -- DRES = OUNIT
1859 2 wfjm
        ndpcntl.gpr_adst := c_gpr_pc;
1860
        ndpcntl.gpr_we := '1';                     -- load PC with dsta
1861
        do_fork_next(nstate, nstatus, nmmumoni);
1862
 
1863
      when s_opa_jmp =>
1864 8 wfjm
        ndpcntl.ounit_asel := c_ounit_asel_ddst;   -- OUNIT A=DDST
1865
        ndpcntl.ounit_bsel := c_ounit_bsel_const;  -- OUNIT B=const(0)
1866
        ndpcntl.dres_sel := c_dpath_res_ounit;     -- DRES = OUNIT
1867 2 wfjm
        ndpcntl.gpr_adst := c_gpr_pc;
1868
        if R_IDSTAT.is_dstmode0 = '1' then
1869
          nstate := s_trap_10;                     -- trap 10 like 11/70
1870
        else
1871
          ndpcntl.gpr_we := '1';                   -- load PC with dsta
1872
          do_fork_next(nstate, nstatus, nmmumoni);
1873
        end if;
1874
 
1875
      when s_opa_mtp =>
1876
        do_memread_srcinc(nstate, ndpcntl, nvmcntl, s_opa_mtp_pop_w,
1877
                          nmmumoni, updt_sp=>'1');
1878
 
1879
      when s_opa_mtp_pop_w =>
1880
        nstate := s_opa_mtp_pop_w;
1881
        ndpcntl.dres_sel := c_dpath_res_vmdout;   -- DRES = VMDOUT
1882
        ndpcntl.dtmp_sel := c_dpath_dtmp_dres;    -- DTMP = DRES
1883
        do_memcheck(nstate, nstatus, imemok);
1884
        if imemok then
1885
          ndpcntl.dtmp_we := '1';                 -- load DTMP
1886
          if R_IDSTAT.is_dstmode0 = '1' then      -- handle register access
1887
            nstate := s_opa_mtp_reg;
1888
          else
1889
            case R_IDSTAT.fork_dsta is            -- 2nd dsta fork in s_idecode
1890
              when c_fork_dsta_def => nstate := s_opa_mtp_mem;
1891
              when c_fork_dsta_inc => nstate := s_dsta_inc;
1892
              when c_fork_dsta_dec => nstate := s_dsta_dec;
1893
              when c_fork_dsta_ind => nstate := s_dsta_ind;
1894
              when others => nstate := s_cpufail;
1895
            end case;
1896
          end if;
1897
        end if;
1898
        ndpcntl.ddst_sel := c_dpath_ddst_dst;     -- DDST = R(DST)
1899
        ndpcntl.ddst_we  := '1';                  -- update DDST (needed for sp)
1900
 
1901
      when s_opa_mtp_reg =>
1902 8 wfjm
        ndpcntl.ounit_asel := c_ounit_asel_dtmp;  -- OUNIT A = DTMP
1903
        ndpcntl.ounit_bsel := c_ounit_bsel_const; -- OUNIT B = const(0)
1904
        ndpcntl.dres_sel := c_dpath_res_ounit;    -- DRES = OUNIT
1905
        ndpcntl.psr_ccwe := '1';                  -- set cc (from ounit too)
1906 2 wfjm
        ndpcntl.gpr_mode := PSW.pmode;            -- load reg in pmode
1907
        ndpcntl.gpr_we := '1';
1908
        do_fork_next(nstate, nstatus, nmmumoni);
1909
 
1910
      when s_opa_mtp_mem =>
1911 8 wfjm
        ndpcntl.ounit_asel := c_ounit_asel_dtmp;  -- OUNIT A = DTMP
1912
        ndpcntl.ounit_bsel := c_ounit_bsel_const; -- OUNIT B = const(0)
1913
        ndpcntl.dres_sel := c_dpath_res_ounit;    -- DRES = OUNIT
1914
        ndpcntl.psr_ccwe := '1';                  -- set cc (from ounit too)
1915 2 wfjm
        ndpcntl.vmaddr_sel := c_dpath_vmaddr_ddst;-- VA = DDST
1916
        nvmcntl.dspace := IREG(15);            -- msb indicates I/D: 0->I, 1->D
1917
        nvmcntl.mode := PSW.pmode;
1918
        nvmcntl.wacc := '1';
1919
        nvmcntl.req := '1';
1920
        nstate := s_opa_mtp_mem_w;
1921
 
1922
      when s_opa_mtp_mem_w =>
1923
        nstate := s_opa_mtp_mem_w;
1924
        do_memcheck(nstate, nstatus, imemok);
1925
        if imemok then
1926
          do_fork_next(nstate, nstatus, nmmumoni);
1927
        end if;
1928
 
1929
      when s_opa_mfp_reg =>
1930
        ndpcntl.gpr_mode := PSW.pmode;           -- fetch reg in pmode
1931
        ndpcntl.ddst_sel := c_dpath_ddst_dst;    -- DDST = reg(dst)
1932
        ndpcntl.ddst_we := '1';
1933
        nstate := s_opa_mfp_dec;
1934
 
1935
      when s_opa_mfp_mem =>
1936
        ndpcntl.vmaddr_sel := c_dpath_vmaddr_ddst;   -- VA = DDST
1937
        if PSW.cmode=c_psw_umode and                 -- if cm=pm=user then
1938
           PSW.cmode=c_psw_umode then                -- MFPI works like it
1939
          nvmcntl.dspace := '1';                     -- were MFPD
1940
        else
1941
          nvmcntl.dspace := IREG(15);          -- msb indicates I/D: 0->I, 1->D
1942
        end if;
1943
        nvmcntl.mode := PSW.pmode;
1944
        nvmcntl.req := '1';
1945
        nstate := s_opa_mfp_mem_w;
1946
 
1947
      when s_opa_mfp_mem_w =>
1948
        nstate := s_opa_mfp_mem_w;
1949
        do_memcheck(nstate, nstatus, imemok);
1950
        ndpcntl.dres_sel := c_dpath_res_vmdout;  -- DRES = VMDOUT
1951
        ndpcntl.ddst_sel := c_dpath_ddst_res;    -- DDST = DRES
1952
        if imemok then
1953
          ndpcntl.ddst_we := '1';
1954
          nstate := s_opa_mfp_dec;
1955
        end if;
1956
 
1957
      when s_opa_mfp_dec =>
1958 8 wfjm
        ndpcntl.ounit_asel := c_ounit_asel_dsrc;   -- OUNIT A=DSRC
1959
        ndpcntl.ounit_const := "000000010";
1960
        ndpcntl.ounit_bsel := c_ounit_bsel_const;  -- OUNIT B=const(2)
1961
        ndpcntl.ounit_opsub := '1';                -- OUNIT = A-B
1962
        ndpcntl.dres_sel := c_dpath_res_ounit;     -- DRES = OUNIT
1963 2 wfjm
        ndpcntl.dsrc_sel := c_dpath_dsrc_res;      -- DSRC = DRES
1964
        ndpcntl.dsrc_we := '1';                    -- update DSRC
1965
        ndpcntl.gpr_adst := c_gpr_sp;
1966
        ndpcntl.gpr_we := '1';                     -- update SP
1967
        nmmumoni.regmod := '1';
1968
        nmmumoni.isdec := '1';
1969
        nstate := s_opa_mfp_push;
1970
 
1971
      when s_opa_mfp_push =>
1972 8 wfjm
        ndpcntl.ounit_asel := c_ounit_asel_ddst;   -- OUNIT A=DDST
1973
        ndpcntl.ounit_bsel := c_ounit_bsel_const;  -- OUNIT B=const(0)
1974
        ndpcntl.dres_sel := c_dpath_res_ounit;     -- DRES = OUNIT
1975
        ndpcntl.psr_ccwe := '1';                   -- set cc (from ounit too)
1976 2 wfjm
        ndpcntl.vmaddr_sel := c_dpath_vmaddr_dsrc; -- VA = DSRC
1977
        nvmcntl.dspace := '1';
1978
        nvmcntl.kstack := is_kmode;
1979
        nvmcntl.wacc := '1';
1980
        nvmcntl.req := '1';
1981
        nstate := s_opa_mfp_push_w;
1982
 
1983
      when s_opa_mfp_push_w =>
1984
        nstate := s_opa_mfp_push_w;
1985
        do_memcheck(nstate, nstatus, imemok);
1986
        if imemok then
1987
          do_fork_next(nstate, nstatus, nmmumoni);
1988
        end if;
1989
 
1990
  -- trap and interrupt handling states ---------------------------------------
1991
 
1992
      when s_trap_4 =>
1993
        lvector := "0000001";           -- vector (4)
1994
        do_start_int(nstate, ndpcntl, lvector);
1995
 
1996
      when s_trap_10 =>
1997
        lvector := "0000010";           -- vector (10)
1998
        do_start_int(nstate, ndpcntl, lvector);
1999
 
2000
      when s_trap_disp =>
2001
        if R_STATUS.trap_mmu = '1' then
2002
          nvmcntl.trap_done := '1';     -- mmu trap taken: set ssr0 trap bit
2003
          lvector := "0101010";         -- mmu trap: vector (250)
2004
        elsif R_STATUS.trap_ysv = '1' then
2005
          lvector := "0000001";         -- ysv trap: vector (4)          
2006
          ncpuerr.ysv := '1';
2007
        else
2008
          lvector := "0000011";         -- trace trap: vector (14)
2009
        end if;
2010
        nstatus.trap_mmu := '0';        -- clear pending trap flags
2011
        nstatus.trap_ysv := '0';        -- 
2012
        do_start_int(nstate, ndpcntl, lvector);
2013
 
2014
      when s_int_ext =>
2015
        lvector := R_STATUS.intvect;    -- external vector
2016
        do_start_int(nstate, ndpcntl, lvector);
2017
 
2018
      when s_int_getpc =>
2019
        nvmcntl.mode := c_psw_kmode;    -- fetch PC from kernel D space
2020
        do_memread_srcinc(nstate, ndpcntl, nvmcntl, s_int_getpc_w, nmmumoni);
2021
 
2022
      when s_int_getpc_w =>
2023
        nstate := s_int_getpc_w;
2024
        ndpcntl.dres_sel := c_dpath_res_vmdout;   -- DRES = VMDOUT
2025
        ndpcntl.ddst_sel := c_dpath_ddst_res;     -- DDST = DRES
2026
        do_memcheck(nstate, nstatus, imemok);
2027
        if VM_STAT.err = '1' then                 -- in case of vm-err
2028
          nstatus.cpugo   := '0';                 -- non-recoverable error
2029
          nstatus.cpurust := c_cpurust_vecfet;    -- halt CPU
2030
          nstate := s_idle;
2031
        end if;
2032
        if imemok then
2033
          ndpcntl.ddst_we := '1';                 -- DDST = new PC
2034
          nstate := s_int_getps;
2035
        end if;
2036
 
2037
      when s_int_getps =>
2038
        nvmcntl.mode := c_psw_kmode;    -- fetch PS from kernel D space
2039
        do_memread_srcinc(nstate, ndpcntl, nvmcntl, s_int_getps_w, nmmumoni);
2040
 
2041
      when s_int_getps_w =>
2042
        nstate := s_int_getps_w;
2043
        ndpcntl.dres_sel := c_dpath_res_vmdout;   -- DRES = VMDOUT
2044
        ndpcntl.psr_func := c_psr_func_wint;      -- interupt mode write
2045
        do_memcheck(nstate, nstatus, imemok);
2046
        if VM_STAT.err = '1' then                 -- in case of vm-err
2047
          nstatus.cpugo   := '0';                 -- non-recoverable error
2048
          nstatus.cpurust := c_cpurust_vecfet;    -- halt CPU
2049
          nstate := s_idle;
2050
        end if;
2051
        if imemok then
2052
          ndpcntl.psr_we := '1';                  -- store new PS
2053
          nstate := s_int_getsp;
2054
        end if;
2055
 
2056
      when s_int_getsp =>
2057
        ndpcntl.gpr_asrc := c_gpr_sp;
2058
        ndpcntl.dsrc_we := '1';                  -- DSRC = SP (in new mode)
2059
        nstate := s_int_decsp;
2060
 
2061
      when s_int_decsp =>
2062 8 wfjm
        ndpcntl.ounit_asel := c_ounit_asel_dsrc; -- OUNIT A=DSRC
2063
        ndpcntl.ounit_const := "000000010";      -- OUNIT const=2
2064
        ndpcntl.ounit_bsel := c_ounit_bsel_const;-- OUNIT B=const
2065
        ndpcntl.ounit_opsub := '1';              -- OUNIT = A-B
2066
        ndpcntl.dres_sel := c_dpath_res_ounit;   -- DRES = OUNIT
2067 2 wfjm
        ndpcntl.dsrc_sel := c_dpath_dsrc_res;    -- DSRC = DRES
2068
        ndpcntl.dsrc_we := '1';                  -- update DSRC
2069
        ndpcntl.gpr_adst := c_gpr_sp;
2070
        ndpcntl.gpr_we := '1';                   -- update SP too
2071
        nstate := s_int_pushps;
2072
 
2073
      when s_int_pushps =>
2074 8 wfjm
        ndpcntl.ounit_asel := c_ounit_asel_dtmp;   -- OUNIT A=DTMP (old PS)
2075
        ndpcntl.ounit_bsel := c_ounit_bsel_const;  -- OUNIT B=const (0)
2076
        ndpcntl.dres_sel := c_dpath_res_ounit;     -- DRES = OUNIT
2077 2 wfjm
        ndpcntl.vmaddr_sel := c_dpath_vmaddr_dsrc; -- VA = DSRC
2078
        nvmcntl.wacc := '1';                       -- write mem
2079
        nvmcntl.dspace := '1';
2080
        nvmcntl.kstack := is_kmode;
2081
        nvmcntl.req := '1';
2082
        nstate := s_int_pushps_w;
2083
 
2084
      when s_int_pushps_w =>
2085 8 wfjm
        ndpcntl.ounit_asel := c_ounit_asel_dsrc; -- OUNIT A=DSRC
2086
        ndpcntl.ounit_const := "000000010";      -- OUNIT const=2
2087
        ndpcntl.ounit_bsel := c_ounit_bsel_const;-- OUNIT B=const
2088
        ndpcntl.ounit_opsub := '1';              -- OUNIT = A-B
2089
        ndpcntl.dres_sel := c_dpath_res_ounit;   -- DRES = OUNIT
2090 2 wfjm
        ndpcntl.dsrc_sel := c_dpath_dsrc_res;    -- DSRC = DRES
2091
        ndpcntl.gpr_adst := c_gpr_sp;
2092
 
2093
        nstate := s_int_pushps_w;
2094
        do_memcheck(nstate, nstatus, imemok);
2095
        if imemok then
2096
          ndpcntl.dsrc_we := '1';                -- update DSRC
2097
          ndpcntl.gpr_we := '1';                 -- update SP too
2098
          nstate := s_int_pushpc;
2099
        end if;
2100
 
2101
      when s_int_pushpc =>
2102 8 wfjm
        ndpcntl.ounit_asel := c_ounit_asel_pc;     -- OUNIT A=PC
2103
        ndpcntl.ounit_bsel := c_ounit_bsel_const;  -- OUNIT B=const (0)
2104
        ndpcntl.dres_sel := c_dpath_res_ounit;     -- DRES = OUNIT
2105 2 wfjm
        ndpcntl.vmaddr_sel := c_dpath_vmaddr_dsrc; -- VA = DSRC
2106
        nvmcntl.wacc := '1';                       -- write mem
2107
        nvmcntl.dspace := '1';
2108
        nvmcntl.kstack := is_kmode;
2109
        nvmcntl.req := '1';
2110
        nstate := s_int_pushpc_w;
2111
 
2112
      when s_int_pushpc_w =>
2113 8 wfjm
        ndpcntl.ounit_asel := c_ounit_asel_ddst;   -- OUNIT A=DDST
2114
        ndpcntl.ounit_bsel := c_ounit_bsel_const;  -- OUNIT B=const (0)
2115
        ndpcntl.dres_sel := c_dpath_res_ounit;     -- DRES = OUNIT
2116 2 wfjm
        ndpcntl.gpr_adst := c_gpr_pc;
2117
 
2118
        nstate := s_int_pushpc_w;
2119
        do_memcheck(nstate, nstatus, imemok);
2120
        if imemok then
2121
          nstatus.do_intrsv := '0';                -- signal end of rsv
2122
          ndpcntl.gpr_we := '1';                   -- load new PC
2123
          do_fork_next(nstate, nstatus, nmmumoni);         -- ???
2124
        end if;
2125
 
2126
  -- return from trap or interrupt handling states ----------------------------
2127
 
2128
      when s_rti_getpc =>
2129
        do_memread_srcinc(nstate, ndpcntl, nvmcntl, s_rti_getpc_w,
2130
                          nmmumoni, updt_sp=>'1');
2131
 
2132
      when s_rti_getpc_w =>
2133
        nstate := s_rti_getpc_w;
2134
        ndpcntl.dres_sel := c_dpath_res_vmdout;   -- DRES = VMDOUT
2135
        ndpcntl.ddst_sel := c_dpath_ddst_res;     -- DDST = DRES
2136
        do_memcheck(nstate, nstatus, imemok);
2137
        if imemok then
2138
          ndpcntl.ddst_we := '1';                 -- DDST = new PC
2139
          nstate := s_rti_getps;
2140
        end if;
2141
 
2142
      when s_rti_getps =>
2143
        do_memread_srcinc(nstate, ndpcntl, nvmcntl, s_rti_getps_w,
2144
                          nmmumoni, updt_sp=>'1');
2145
 
2146
      when s_rti_getps_w =>
2147
        nstate := s_rti_getps_w;
2148
        do_memcheck(nstate, nstatus, imemok);
2149
        ndpcntl.dres_sel := c_dpath_res_vmdout;   -- DRES = VMDOUT
2150
        if is_kmode = '1' then                    -- if in kernel mode
2151
          ndpcntl.psr_func := c_psr_func_wall;    --   write all fields
2152
        else
2153
          ndpcntl.psr_func := c_psr_func_wrti;    --   otherwise filter
2154
        end if;
2155
        if imemok then
2156
          ndpcntl.psr_we := '1';                  -- load new PS
2157
          nstate := s_rti_newpc;
2158
        end if;
2159
 
2160
      when s_rti_newpc =>
2161 8 wfjm
        ndpcntl.ounit_asel := c_ounit_asel_ddst;  -- OUNIT A=DDST
2162
        ndpcntl.ounit_bsel := c_ounit_bsel_const; -- OUNIT B=const (0)
2163
        ndpcntl.dres_sel := c_dpath_res_ounit;    -- DRES = OUNIT
2164 2 wfjm
        ndpcntl.gpr_adst := c_gpr_pc;
2165 8 wfjm
        ndpcntl.gpr_we := '1';                    -- load new PC
2166
        if R_IDSTAT.op_rtt = '1' then             -- if RTT instruction
2167
          nstate := s_ifetch;                       --   force fetch
2168
        else                                      -- otherwise RTI
2169 2 wfjm
          do_fork_next(nstate, nstatus, nmmumoni);
2170
        end if;
2171
 
2172
  -- exception abort states ---------------------------------------------------
2173
 
2174
      when s_vmerr =>
2175
        nstate := s_cpufail;
2176
 
2177
                                            -- setup for R_VMSTAT.err_rsv='1'
2178 8 wfjm
        ndpcntl.ounit_azero := '1';               -- OUNIT A = 0
2179
        ndpcntl.ounit_const := "000000100";       -- emergency stack pointer
2180
        ndpcntl.ounit_bsel := c_ounit_bsel_const; -- OUNIT B=const(vector)
2181
        ndpcntl.dres_sel := c_dpath_res_ounit;    -- DRES = OUNIT
2182
        ndpcntl.gpr_mode := c_psw_kmode;          -- set kmode SP to 4
2183 2 wfjm
        ndpcntl.gpr_adst := c_gpr_sp;
2184
 
2185 8 wfjm
        nstatus.trap_mmu :='0';                   -- drop pending mmu trap
2186 2 wfjm
 
2187 8 wfjm
        if R_VMSTAT.fail = '1' then               -- vmbox failure
2188
          nstatus.cpugo   := '0';                   -- halt cpu
2189 2 wfjm
          nstatus.cpurust := c_cpurust_vfail;
2190
          nstate := s_idle;
2191
 
2192 8 wfjm
        elsif R_STATUS.do_intrsv = '1' then       -- double error
2193
          nstatus.cpugo := '0';                     -- give up, HALT cpu
2194 2 wfjm
          nstatus.cpurust := c_cpurust_recrsv;
2195
          nstate := s_idle;
2196
 
2197
        elsif R_VMSTAT.err = '1' then            -- normal vm errors
2198
          if R_VMSTAT.err_rsv = '1' then
2199
            nstatus.do_intrsv := '1';              -- signal start of rsv
2200
            ndpcntl.gpr_we := '1';
2201
 
2202
            if R_VMSTAT.err_odd='1' or R_VMSTAT.err_mmu='1' then
2203
              ncpuerr.adderr := '1';
2204
            elsif R_VMSTAT.err_nxm = '1' then
2205
              ncpuerr.nxm := '1';
2206
            elsif R_VMSTAT.err_iobto = '1' then
2207
              ncpuerr.iobto := '1';
2208
            end if;
2209
            ncpuerr.rsv := '1';
2210
            nstate := s_trap_4;
2211
 
2212
          elsif R_VMSTAT.err_odd = '1' then
2213
            ncpuerr.adderr := '1';
2214
            nstate := s_trap_4;
2215
          elsif R_VMSTAT.err_nxm = '1' then
2216
            ncpuerr.nxm := '1';
2217
            nstate := s_trap_4;
2218
          elsif R_VMSTAT.err_iobto = '1' then
2219
            ncpuerr.iobto := '1';
2220
            nstate := s_trap_4;
2221
 
2222
          elsif R_VMSTAT.err_mmu = '1' then
2223
            lvector := "0101010";                    -- vector (250)
2224
            do_start_int(nstate, ndpcntl, lvector);
2225
          end if;
2226
        end if;
2227
 
2228
      when s_cpufail =>
2229
        nstatus.cpugo   := '0';
2230
        nstatus.cpurust := c_cpurust_sfail;
2231
        nstate := s_idle;
2232
 
2233
      when others =>
2234
        nstate := s_cpufail;             --!!! catch undefined states !!!
2235
 
2236
    end case;
2237
 
2238
    if nstatus.cmdack = '1' then        -- cmdack in next cycle ? Yes we test
2239
                                           -- nstatus here !!
2240
      nstatus.cmdbusy := '0';
2241
      ndpcntl.cpdout_we := '1';
2242
    end if;
2243
 
2244
    N_STATE  <= nstate;
2245
    N_STATUS <= nstatus;
2246
    N_CPUERR <= ncpuerr;
2247
    N_IDSTAT <= nidstat;
2248
 
2249
    CRESET <= ncreset;
2250
    BRESET <= nbreset;
2251
    INT_ACK <= nintack;
2252
 
2253
    DP_CNTL <= ndpcntl;
2254
    VM_CNTL <= nvmcntl;
2255
 
2256
    nmmumoni.regnum := ndpcntl.gpr_adst;
2257 8 wfjm
    nmmumoni.delta  := ndpcntl.ounit_const(3 downto 0);
2258 2 wfjm
    MMU_MONI <= nmmumoni;
2259
 
2260
  end process proc_next;
2261
 
2262
  proc_cpstat : process (R_STATUS)
2263
  begin
2264
    CP_STAT         <= cp_stat_init;
2265
    CP_STAT.cmdbusy <= R_STATUS.cmdbusy;
2266
    CP_STAT.cmdack  <= R_STATUS.cmdack;
2267
    CP_STAT.cmderr  <= R_STATUS.cmderr;
2268
    CP_STAT.cmdmerr <= R_STATUS.cmdmerr;
2269
    CP_STAT.cpugo   <= R_STATUS.cpugo;
2270
    CP_STAT.cpustep <= R_STATUS.cpustep;
2271
    CP_STAT.cpuhalt <= R_STATUS.cpuhalt;
2272
    CP_STAT.cpuwait <= R_STATUS.cpuwait;
2273
    CP_STAT.cpurust <= R_STATUS.cpurust;
2274
  end process proc_cpstat;
2275
 
2276
end syn;
2277
 

powered by: WebSVN 2.1.0

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