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

Subversion Repositories pdp8

[/] [pdp8/] [trunk/] [pdp8/] [cpu/] [cpu.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 trurl
--------------------------------------------------------------------------------
2
--!
3
--! PDP-8 Processor
4
--!
5
--! \brief
6
--!      CPU Processor
7
--!
8
--! \details
9
--!      I hope you like state machines because this is implemented as one big
10
--!      state machine.
11
--!
12
--! \file
13
--!      cpu.vhd
14
--!
15
--! \author
16
--!      Rob Doyle - doyle (at) cox (dot) net
17
--!
18
--------------------------------------------------------------------------------
19
--
20
--  Copyright (C) 2009, 2010, 2011, 2012 Rob Doyle
21
--
22
-- This source file may be used and distributed without restriction provided
23
-- that this copyright statement is not removed from the file and that any
24
-- derivative work contains the original copyright notice and the associated
25
-- disclaimer.
26
--
27
-- This source file is free software; you can redistribute it and/or modify it
28
-- under the terms of the GNU Lesser General Public License as published by the
29
-- Free Software Foundation; version 2.1 of the License.
30
--
31
-- This source is distributed in the hope that it will be useful, but WITHOUT
32
-- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
33
-- FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
34
-- details.
35
--
36
-- You should have received a copy of the GNU Lesser General Public License
37
-- along with this source; if not, download it from
38
-- http://www.gnu.org/licenses/lgpl.txt
39
--
40
--------------------------------------------------------------------------------
41
--
42
-- Comments are formatted for doxygen
43
--
44
 
45
library ieee;                                   --! IEEE Library
46
use ieee.std_logic_1164.all;                    --! IEEE 1164
47
use ieee.numeric_std.all;                       --! IEEE Numeric Standard
48
use work.cpu_types.all;
49
-- synthesis translate_off
50
use std.textio.all;                             --! std textio
51
use ieee.std_logic_textio.all;                  --! IEEE std_logic_textio
52
-- synthesis translate_on
53
 
54
--
55
--! CPU Entity
56
--
57
 
58
entity eCPU is port (
59
    sys     : in  sys_t;                        --! Clock/Reset
60
    swCPU   : in  swCPU_t;                      --! CPU Configuration
61
    swOPT   : in  swOPT_t;                      --! Options Configuration
62
    swDATA  : in  swDATA_t;                     --! Data Switch Inputs
63
    swCNTL  : in  swCNTL_t;                     --! Control Switch Inputs
64
    dev     : in  dev_t;                        --! Device Output
65
    cpu     : out cpu_t                         --! CPU Output
66
);
67
end eCPU;
68
 
69
--
70
--! CPU RTL
71
--
72
 
73
architecture rtl of eCPU is
74
 
75
    --
76
    -- Registers
77
    --
78
 
79
    signal LAC      : ldata_t;                  --! Link and Accumulator
80
    alias  L        : std_logic is LAC (0);     --! Link Bit
81
    alias  AC       : data_t is LAC(1 to 12);   --! Accumulator
82
    signal IR       : data_t;                   --! Instruction Register
83
    signal PC       : addr_t;                   --! Program Counter
84
    signal MA       : addr_t;                   --! Memory Address Register
85
    signal MB       : data_t;                   --! Memory Buffer (output)
86
    signal MD       : data_t;                   --! Memory Data Register (input)
87
    signal MQ       : data_t;                   --! MQ Register
88
    signal MQA      : data_t;                   --! MQA Register
89
    signal SC       : sc_t;                     --! SC Register
90
    signal SP1      : addr_t;                   --! Stack Pointer
91
    signal SP2      : addr_t;                   --! Stack Pointer
92
    signal SR       : data_t;                   --! Switch Register
93
 
94
    --
95
    -- Register Operation
96
    --
97
 
98
    signal acOP     : acOP_t;                   --! AC operation
99
    signal pcOP     : pcOP_t;                   --! PC operation
100
    signal irOP     : irOP_t;                   --! IR operation
101
    signal maOP     : maOP_t;                   --! MA operation
102
    signal mbOP     : mbOP_t;                   --! MB operation
103
    signal mqOP     : mqOP_t;                   --! MQ operation
104
    signal mqaOP    : mqaOP_t;                  --! MQA operation
105
    signal scOP     : scOP_t;                   --! SC operation
106
    signal sp1OP    : spOP_t;                   --! SP1 operation
107
    signal sp2OP    : spOP_t;                   --! SP2 operation
108
    signal srOP     : srOP_t;                   --! SR operation
109
 
110
    --
111
    -- Memory Extension Control Registers
112
    --
113
 
114
    signal IB       : field_t;                  --! Instruction Buffer
115
    signal INF      : field_t;                  --! Instruction Field
116
    signal DF       : field_t;                  --! Data Field
117
    signal SF       : sf_t;                     --! Save Field
118
 
119
    --
120
    -- Memory Extension Control Register Operations
121
    --
122
 
123
    signal ibOP     : ibOP_t;                   --! IB operation
124
    signal ifOP     : ifOP_t;                   --! IF operation
125
    signal dfOP     : dfOP_t;                   --! DF operation
126
    signal sfOP     : sfOP_t;                   --! SF operation
127
    signal IRQ      : std_logic;                --! IRQ Flag
128
 
129
    --
130
    -- KM8x Time Share Registers
131
    --
132
 
133
    signal UB       : std_logic;                --! User Buffer Flag
134
    signal UF       : std_logic;                --! User Flag
135
 
136
    --
137
    -- KM8x Time Share Register Operations
138
    --
139
 
140
    signal ubOP     : ubOP_t;                   --! User Buffer operation
141
    signal ufOP     : ufOP_t;                   --! USER Flag operation
142
 
143
    --
144
    -- BTSTRP:
145
    --
146
 
147
    signal BTSTRP   : std_logic;                --! BTSTRP Register
148
    signal btstrpOP : btstrpOP_t;               --! BTSTRP operation
149
 
150
    --
151
    -- CTRLFF:
152
    -- The Control Panel Register (CTRLFF), is set when the CPREQ is granted.
153
    -- CTRLFF prevents further CPREQs from being granted, bypasses the
154
    -- interrupt enable system and redefines several of the internal control
155
    -- instructions.  As long as the CTRLFF is set, LXPAR is used for all
156
    -- instruction, direct data and indirect pointer references.  Also, while
157
    -- CTRLFF is set, the INTGNT line is held inactive but the Interrupt Grant
158
    -- Flip Flop is not cleared.  IOTs executed while CTRLFF is set do not clear
159
    -- the Interrupt grant flip flop.
160
    --
161
 
162
    signal CTRLFF   : std_logic;                --! CTRLFF
163
    signal ctrlffOP : ctrlffOP_t;               --! CTRLFF operation
164
 
165
    --
166
    -- EAE:
167
    -- EAE Long Operations
168
    --
169
 
170
    signal EAE      : eae_t;                    --! EAE Register
171
    signal eaeOP    : eaeOP_t;                  --! EAE operation
172
 
173
    --
174
    -- EMODE:
175
    -- The EMODE bit is set at reset and is set by the SWAB and cleared by the
176
    -- SWBA instructions.  This enables EAE Mode A and EAE Mode B instructions.
177
    --
178
 
179
    signal EMODE    : std_logic;                --! EAE Mode
180
    signal emodeOP  : emodeOP_t;                --! EAE Mode operation
181
 
182
    --
183
    -- FZ:
184
    -- The Force Zero Flag (FZ) is used to implement Extended memory operations
185
    -- for Panel Mode instructions.  When set, forces control panel instruction
186
    -- field access to field zero.  Indirect data accesses are not affected.
187
    --
188
 
189
    signal FZ       : std_logic;                --! Force Zero
190
    signal fzOP     : fzOP_t;                   --! FZ operation
191
 
192
    --
193
    -- HLTTRP:
194
    -- The HLTTRP flip-flop allows the cpu to single step through code.
195
    -- The HLTTRP flip-flop is set by a HLT instruction.
196
    --
197
 
198
    signal HLTTRP   : std_logic;                --! HLTTRP Register
199
    signal hlttrpOP : hlttrpOP_t;               --! HLTTRP operation
200
 
201
    --
202
    -- GTF:
203
    --
204
 
205
    signal GTF      : std_logic;                --! Greater than Flag
206
    signal gtfOP    : gtfOP_t;                  --! GTF operation
207
 
208
    --
209
    --! ID:
210
    --! The ION Delay (ID) register delays the effect of the ION
211
    --! instruction until the instruction after the ION
212
    --! instruction has executed.   This will allow a return
213
    --! from interrupt to be executed before the next interrupt
214
    --! request is serviced.
215
    --
216
 
217
    signal ID       : std_logic;                --! ION Delay Flip-flop
218
    signal idOP     : idOP_t;                   --! ION Delay Operation
219
 
220
    --
221
    -- IE:
222
    -- The Interrupt Enable Register (IE) enables and disables interrupts.
223
    --
224
 
225
    signal IE       : std_logic;                --! Interrupt Enable
226
    signal ieOP     : ieOP_t;                   --! IE operation
227
 
228
    --
229
    -- II:
230
    -- The Interrupt Inhibit (II) Register is set whenever there is an
231
    -- instruction executed that could change the Instruction Field.  These
232
    -- include CIF, CDI, RMF, RTF, CAF, CUF, SUF.  The II Register is
233
    -- cleared when the next JMP, JMS, RTN1, or RTN2 instruction is executed.
234
    -- This prevents an interrupt from occuring between the CIF (or like)
235
    -- instruction and the return (or like) instruction.
236
    --
237
 
238
    signal II       : std_logic;                -- Interrupt Inhibit Register
239
    signal iiOP     : iiOP_t;                   -- Interrupt Inhibit Operation
240
 
241
    --
242
    -- PDF:
243
    -- The Panel Data Flag (PDF) is used to contol whether indirectly addressed
244
    -- data references by Control Panel AND, TAD, ISZ or DCA instructions
245
    -- reference panel memory or main memory.  If PDF is set, this flag causes
246
    -- indirect references from control panel memory to address control panel
247
    -- memory by asserting LXPAR.  If PDF is cleared, this flag causes indirect
248
    -- references from control panel memory to address main memory by asserting
249
    -- LXMAR.  The PDF is cleared unconditionally whenever the panel mode is
250
    -- entered for any reason.  It is also cleared by the Clear Panel Data
251
    -- (CPD) instruction.  The PDF is set by the Set Panel Data (SPD)
252
    -- instruction. The state of the Panel Data flag is ignored when not
253
    -- operating in panel mode.
254
    --
255
 
256
    signal PDF      : std_logic;                --! Panel Data Flag
257
    signal pdfOP    : pdfOP_t;                  --! PDF operation
258
 
259
    --
260
    -- PEX:
261
    -- The Panel Exit Delay (PEX) Register is set by the PEX instruction.
262
    -- When a JMP, JMS, RET1, or RET2 instruction is executed with the PEX
263
    -- Register set, the CPU will exit panel mode.  The PEX Register is
264
    -- cleared by the JMP, JMS, RET1, or RET2 instruction.
265
    --
266
 
267
    signal PEX      : std_logic;                -- PEX Register
268
    signal pexOP    : pexOP_t;                  -- PEX Operation
269
 
270
    --
271
    -- PNLTRP:
272
    -- A Panel Trap is one of the many ways to enter panel mode.  The Panel Trap
273
    -- Register (PNLTRP) is set by any of the PR0, PR1, PR2, PR3 instructions.
274
    -- The PNLTRP flag can be examined and cleared by the PRS instruction.
275
    --
276
 
277
    signal PNLTRP   : std_logic;                --! PNLTRP Flag
278
    signal pnltrpOP : pnltrpOP_t;               --! PNLTRP operation
279
 
280
    --
281
    -- PRWON:
282
    -- The Power-On Trap Register (PWRTRP) is set when STRTUP is negated during
283
    -- RESET, The Power-On Register (PWRTRP) is reset by a PRS or PEX
284
    -- instruction.
285
    --
286
 
287
    signal PWRTRP   : std_logic;                --! PWRTRP Register
288
    signal pwrtrpOP : pwrtrpOP_t;               --! PWRTRP operation
289
 
290
    --
291
    -- USRTRP:
292
    -- User Mode Trap.
293
    --
294
 
295
    signal USRTRP   : std_logic;                --! USR Interrupt
296
    signal usrtrpOP : usrtrpOP_t;               --! USR Interrupt operation
297
 
298
    --
299
    -- XMA
300
    --
301
 
302
    signal XMA      : field_t;                  --! XMA Register
303
    signal xmaOP    : xmaOP_t;                  --! XMA operation
304
 
305
    --
306
    -- Bus Control Signals
307
    --
308
 
309
    signal busb     : busOP_t;                  --! Bus Operation output
310
    signal busOP    : busOP_t;                  --! Bus Operation input
311
    signal ioclrb   : std_logic;                --! IOCLR register output
312
    signal ioclrOP  : std_logic;                --! IOCLR register input
313
    signal wrb      : std_logic;                --! WR signal register input
314
    signal wrOP     : std_logic;                --! WR signal register output
315
    signal rdb      : std_logic;                --! RD signal register output
316
    signal rdOP     : std_logic;                --! RD signal register input
317
    signal ifetchb  : std_logic;                --! IFETCH signal register output
318
    signal ifetchOP : std_logic;                --! IFETCH signal register input
319
    signal datafb   : std_logic;                --! DATAF signal register output
320
    signal datafOP  : std_logic;                --! DATAF signal register input
321
    signal lxdarb   : std_logic;                --! LXDAR signal register output
322
    signal lxdarOP  : std_logic;                --! LXDAR signal register input
323
    signal lxmarb   : std_logic;                --! LXMAR signal register output
324
    signal lxmarOP  : std_logic;                --! LXMAR signal register input
325
    signal lxparb   : std_logic;                --! LXPAR signal register output
326
    signal lxparOP  : std_logic;                --! LXPAR signal register input
327
    signal memselb  : std_logic;                --! MEMSEL signal register output
328
    signal memselOP : std_logic;                --! MEMSEL signal register input
329
    signal intgntb  : std_logic;                --! INTGNT signal register output
330
    signal dmagnt   : std_logic;                --! DMAGNT signal register input
331
    signal intgntOP : std_logic;                --! INTGNT signal register input
332
    signal waitfb   : std_logic;                --! WAITF signal register output
333
    signal waitfOP  : std_logic;                --! WAITF signal register input
334
 
335
    signal oops     : std_logic;
336
 
337
    --
338
    -- State Information
339
    --
340
 
341
    type state_t is (
342
        stateReset,
343
        stateInit,
344
        stateCheckReq,
345
        stateFetchAddr,
346
        stateFetchData,
347
        stateLoadIR,
348
        stateDecodeInstruction,
349
 
350
        --
351
        -- MRI States
352
        --
353
 
354
        stateMRIreadAddr,
355
        stateMRIreadDataIND,
356
        stateMRIreadIncAddr,
357
        stateMRIreadIndData,
358
        stateMRIexecute,
359
 
360
        --
361
        -- IOT states
362
        --
363
 
364
        stateIOTdecode,
365
        stateIOT,
366
 
367
        --
368
        -- Stack Operation States
369
        --
370
 
371
        statePOPaddr,
372
        statePOPdata,
373
        stateRTN1,
374
        stateRTN2,
375
        stateRTNaddr,
376
        stateRTNdata,
377
 
378
        --
379
        -- OPR Groups
380
        --
381
 
382
        stateOprGroup1Seq3,
383
        stateOprGroup1Seq4,
384
        stateOprGroup2Seq2,
385
        stateOprGroup3Seq3,
386
 
387
        --
388
        -- Front Panel States
389
        --
390
 
391
        stateHalt,
392
        stateContinue,
393
        stateLoadADDR,
394
        stateLoadEXTD,
395
        stateClear,
396
        stateDepositWriteData,
397
        stateDeposit,
398
        stateExamine,
399
        stateExamineReadAddr,
400
        stateExamineReadData,
401
        stateHaltDone,
402
 
403
        --
404
        -- EAE States
405
        --
406
 
407
        stateEAEfetchAddr,
408
        stateEAEfetchData,
409
        stateEAEindWrite,
410
        stateEAEindReadAddr,
411
        stateEAEindReadData,
412
        stateEAEshift,
413
        stateEAEwait,
414
        stateEAEnmi,
415
        stateEAEshiftDVI,
416
        stateEAEsubDVI,
417
        stateEAEmuy,
418
        stateEAEreadDADaddr0,
419
        stateEAEreadDADaddr1,
420
        stateEAEreadDADdata0,
421
        stateEAEreadDADdata1,
422
        stateEAEdst,
423
 
424
        --
425
        -- HALT states
426
        --
427
 
428
        stateDone,
429
        stateLALA
430
    );
431
 
432
 
433
    signal   state      : state_t;
434
    signal   nextState  : state_t;
435
    constant maAutoIncr : std_logic_vector(3 to 11) := o"001";
436
 
437
    --
438
    -- Output files for state dumpState
439
    --
440
 
441
    -- synthesis translate_off
442
    file     FIL        : text is out "STD_OUTPUT";
443
    file     STDOUT     : text is out "STD_OUTPUT";
444
  --file     FIL        : text is out "trace.txt";
445
    -- synthesis translate_on
446
 
447
    --
448
    -- vectorize
449
    --
450
 
451
    function vectorize(s: std_logic) return std_logic_vector is
452
        variable v: std_logic_vector(0 to 0);
453
    begin
454
        v(0) := s;
455
        return v;
456
    end;
457
 
458
    --
459
    -- dumpState()
460
    --
461
 
462
    procedure dumpState(PC : in addr_t) is
463
        -- synthesis translate_off
464
        variable LIN : line;
465
        -- synthesis translate_on
466
    begin
467
        -- synthesis translate_off
468
        write (LIN, string'("ST:"));
469
        write (LIN, string'(" PC="));
470
        owrite(LIN, PC);
471
        write (LIN, string'(", IR="));
472
        owrite(LIN, IR);
473
        write (LIN, string'(", LAC="));
474
        owrite(LIN, "00" & LAC);
475
        write (LIN, string'(", MQ="));
476
        owrite(LIN, MQ);
477
        write (LIN, string'(", SR="));
478
        owrite(LIN, SR);
479
        write (LIN, string'(", IF="));
480
        owrite(LIN, INF);
481
        write (LIN, string'(", DF="));
482
        owrite(LIN, DF);
483
        write (LIN, string'(", IB="));
484
        owrite(LIN, IB);
485
        write (LIN, string'(", UB="));
486
        owrite(LIN, "00" & vectorize(UB));
487
        write (LIN, string'(", UF="));
488
        owrite(LIN, "00" &  vectorize(UF));
489
        write (LIN, string'(", USF="));
490
        owrite(LIN, "00" &  SF(0 to 0));
491
        write (LIN, string'(", ISF="));
492
        owrite(LIN, SF(1 to 3));
493
        write (LIN, string'(", DSF="));
494
        owrite(LIN, SF(4 to 6));
495
        write (LIN, string'(", SC="));
496
        owrite(LIN, '0' & SC);
497
        write (LIN, string'(", GTF="));
498
        owrite(LIN, "00" & vectorize(GTF));
499
        write (LIN, string'(", EMODE="));
500
        owrite(LIN, "00" & vectorize(EMODE));
501
        write (LIN, string'(", IEFF="));
502
        owrite(LIN, "00" & vectorize(IE));
503
        write (LIN, string'(", IDFF="));
504
        owrite(LIN, "00" & vectorize(ID));
505
        write (LIN, string'(", IIFF="));
506
        owrite(LIN, "00" & vectorize(II));
507
        write (LIN, string'(", IRQ="));
508
        owrite(LIN, "00" & vectorize(IRQ));
509
        write (LIN, string'(", SP1="));
510
        owrite(LIN, SP2);
511
        write (LIN, string'(", SP2="));
512
        owrite(LIN, SP1);
513
        write (LIN, string'("; MA=00000"));
514
        --owrite(LIN, XMA & MA);
515
        writeline(FIL, LIN);
516
        -- synthesis translate_on
517
    end dumpState;
518
 
519
    --
520
    -- dispHALT
521
    --
522
 
523
    procedure dispHALT(signal PC : in addr_t) is
524
        -- synthesis translate_off
525
       variable LIN : line;
526
        -- synthesis translate_on
527
    begin
528
        -- synthesis translate_off
529
        write (LIN, string'("CPU Halted at PC = "));
530
        owrite(LIN, PC);
531
        writeline(STDOUT, LIN);
532
        -- synthesis translate_on
533
    end dispHALT;
534
 
535
    --
536
    -- dispCONT
537
    --
538
 
539
    procedure dispCONT(signal PC : in addr_t) is
540
        -- synthesis translate_off
541
        variable LIN : line;
542
        -- synthesis translate_on
543
    begin
544
        -- synthesis translate_off
545
        write (LIN, string'("CPU Continued at PC = "));
546
        owrite(LIN, PC);
547
        writeline(STDOUT, LIN);
548
        -- synthesis translate_on
549
    end dispCONT;
550
 
551
begin
552
 
553
    IRQ <= '1' when ((dev.intr = '1') or
554
                     (USRTRP = '1' and swOPT.TSD = '0') or
555
                     (usrtrpOP = usrtrpopSET and swOPT.TSD = '0')) else '0';
556
 
557
    --
558
    --  ALU
559
    --
560
 
561
    iALU : entity work.eALU (rtl) port map (
562
        sys     => sys,
563
        acOP    => acOP,
564
        BTSTRP  => BTSTRP,
565
        GTF     => GTF,
566
        HLTTRP  => HLTTRP,
567
        IE      => IE,
568
        IRQ     => IRQ,
569
        PNLTRP  => PNLTRP,
570
        PWRTRP  => PWRTRP,
571
        DF      => DF,
572
        EAE     => EAE,
573
        INF     => INF,
574
        IR      => IR,
575
        MA      => MA,
576
        MD      => MD,
577
        MQ      => MQ,
578
        PC      => PC,
579
        SC      => SC,
580
        SF      => SF,
581
        SP1     => SP1,
582
        SP2     => SP2,
583
        SR      => SR,
584
        UF      => UF,
585
        LAC     => LAC
586
    );
587
 
588
    --
589
    -- CTRLFF
590
    --
591
 
592
    iCTRLFF : entity work.eCTRLFF (rtl) port map (
593
        sys      => sys,
594
        ctrlffOP => ctrlffOP,
595
        CTRLFF   => CTRLFF
596
    );
597
 
598
    --
599
    -- EAE Register
600
    --
601
 
602
    iEAE : entity work.eEAE (rtl) port map (
603
        sys     => sys,
604
        eaeOP   => eaeOP,
605
        MD      => MD,
606
        MQ      => MQ,
607
        AC      => AC,
608
        EAE     => EAE
609
    );
610
 
611
    --
612
    -- EAE Mode A
613
    --
614
 
615
    iEMODE : entity work.eEMODE (rtl) port map (
616
        sys     => sys,
617
        emodeOP => emodeOP,
618
        EMODE   => EMODE
619
    );
620
 
621
    --
622
    -- FZ Flip Flop
623
    --
624
 
625
    iFZ : entity work.eFZ (rtl) port map (
626
        sys  => sys,
627
        fzOP => fzOP,
628
        FZ   => FZ
629
    );
630
 
631
    --
632
    -- GTF
633
    --
634
 
635
    iGTF : entity work.eGTF (rtl) port map (
636
        sys   => sys,
637
        gtfOP => gtfOP,
638
        AC    => AC,
639
        GTF   => GTF
640
    );
641
 
642
    --
643
    -- HLTTRP
644
    --
645
 
646
    iHLTTRP : entity work.eHLTTRP (rtl) port map (
647
        sys      => sys,
648
        hlttrpOP => hlttrpOP,
649
        HLTTRP   => HLTTRP
650
    );
651
 
652
    --
653
    -- Program Counter (PC)
654
    --
655
 
656
    iPC : entity work.ePC (rtl) port map (
657
        sys  => sys,
658
        pcOP => pcOP,
659
        IR   => IR,
660
        MA   => MA,
661
        MB   => MB,
662
        MD   => MD,
663
        SR   => SR,
664
        PC   => PC
665
    );
666
 
667
    --
668
    -- Multiplier Quotient Register (MQ)
669
    --
670
 
671
    iMQ : entity work.eMQ (rtl) port map (
672
        sys  => sys,
673
        mqOP => mqOP,
674
        AC   => AC,
675
        MD   => MD,
676
        EAE  => EAE,
677
        MQ   => MQ
678
    );
679
 
680
    --
681
    -- Auxillary Multiplier Quotient Register (MQA)
682
    --
683
 
684
    iMQA : entity work.eMQA (rtl) port map (
685
        sys   => sys,
686
        mqaOP => mqaOP,
687
        MQ    => MQ,
688
        MQA   => MQA
689
    );
690
 
691
    --
692
    -- Interrupt Enable Register
693
    --
694
 
695
    iIE : entity work.eIE (rtl) port map (
696
        sys  => sys,
697
        ieOP => ieOP,
698
        IE   => IE
699
    );
700
 
701
    --
702
    -- Interrupt Inhibit Register
703
    --
704
 
705
    iII : entity work.eII (rtl) port map (
706
        sys  => sys,
707
        iiOP => iiOP,
708
        II   => II
709
    );
710
 
711
    --
712
    -- USRTRP Register
713
    --
714
 
715
    iUSRTRP : entity work.eUSRTRP (rtl) port map (
716
        sys      => sys,
717
        usrtrpOP => usrtrpOP,
718
        USRTRP   => USRTRP
719
    );
720
 
721
    --
722
    -- Instruction Register (IR)
723
    --
724
 
725
    iIR: entity work.eIR (rtl) port map (
726
        sys   => sys,
727
        irOP  => irOP,
728
        MD    => MD,
729
        IR    => IR
730
    );
731
 
732
    --
733
    -- Memory Address Register (MA)
734
    --
735
 
736
    iMA : entity work.eMA (rtl) port map (
737
        sys  => sys,
738
        maOP => maOP,
739
        IR   => IR,
740
        MB   => MB,
741
        MD   => MD,
742
        PC   => PC,
743
        SP1  => SP1,
744
        SP2  => SP2,
745
        SR   => SR,
746
        MA   => MA
747
    );
748
 
749
    --
750
    -- Memory Buffer Register (MB)
751
    --
752
 
753
    iMB : entity work.eMB (rtl) port map (
754
        sys  => sys,
755
        mbOP => mbOP,
756
        AC   => AC,
757
        MA   => MA,
758
        MD   => MD,
759
        MQ   => MQ,
760
        PC   => PC,
761
        SR   => SR,
762
        MB   => MB
763
    );
764
 
765
    --
766
    -- Instruction Buffer Address Extension Register (IB)
767
    --
768
 
769
    iIB : entity work.eIB (rtl) port map (
770
        sys  => sys,
771
        ibOP => ibOP,
772
        SF   => SF,
773
        AC   => AC,
774
        IR   => IR,
775
        IB   => IB
776
    );
777
 
778
    --
779
    -- Instruction Field Address Extension Register (IF/INF)
780
    --
781
 
782
    iIF : entity work.eIF (rtl) port map (
783
        sys  => sys,
784
        ifOP => ifOP,
785
        IB   => IB,
786
        SR   => SR,
787
        INF  => INF
788
    );
789
 
790
    --
791
    -- ION Delay Register
792
    --
793
 
794
    iID : entity work.eID (rtl) port map (
795
        sys  => sys,
796
        idOP => idOP,
797
        ID   => ID
798
    );
799
 
800
    --
801
    -- Data Field Address Extension Register (DF)
802
    --
803
 
804
    iDF : entity work.eDF (rtl) port map (
805
        sys  => sys,
806
        dfOP => dfOP,
807
        AC   => AC,
808
        IR   => IR,
809
        SF   => SF,
810
        SR   => SR,
811
        DF   => DF
812
    );
813
 
814
    --
815
    --! BTSTRP Register
816
    --
817
 
818
    iBTSTRP : entity work.eBTSTRP (rtl) port map (
819
        sys      => sys,
820
        btstrpOP => btstrpOP,
821
        BTSTRP   => BTSTRP
822
    );
823
 
824
    --
825
    -- PDF Register
826
    --
827
 
828
    iPDF : entity work.ePDF (rtl) port map (
829
        sys   => sys,
830
        pdfOP => pdfOP,
831
        PDF   => PDF
832
    );
833
 
834
    --
835
    -- PEX Register
836
    --
837
 
838
    iPEX : entity work.ePEX (rtl) port map (
839
        sys   => sys,
840
        pexOP => pexOP,
841
        PEX   => PEX
842
    );
843
 
844
    --
845
    -- PNLTRP Register
846
    --
847
 
848
    iPNLTRP : entity work.ePNLTRP (rtl) port map (
849
        sys      => sys,
850
        pnltrpOP => pnltrpOP,
851
        PNLTRP   => PNLTRP
852
    );
853
 
854
    --
855
    -- PWRTRP Register
856
    -- When set during reset, the unit will enter panel mode before executing
857
    -- the first instruction.
858
    --
859
 
860
    iPWRTRP : entity work.ePWRTRP (rtl) port map (
861
        sys      => sys,
862
        pwrtrpOP => pwrtrpOP,
863
        PWRTRP   => PWRTRP
864
    );
865
 
866
    --
867
    -- SC
868
    -- Step Counter
869
    --
870
 
871
    iSC : entity work.eeSC (rtl) port map (
872
        sys  => sys,
873
        scOP => scOP,
874
        AC   => AC,
875
        MD   => MD,
876
        SC   => SC
877
    );
878
 
879
    --
880
    -- SF
881
    -- Save Field Address Extension Register (SF)
882
    --
883
 
884
    iSF : entity work.eSF (rtl) port map (
885
        sys  => sys,
886
        sfOP => sfOP,
887
        DF   => DF,
888
        IB   => IB,
889
        UB   => UB,
890
        SF   => SF
891
    );
892
 
893
    --
894
    -- SP1
895
    -- Stack Pointer #1
896
    --
897
 
898
    iSP1 : entity work.eSP (rtl) port map (
899
        sys  => sys,
900
        spOP => sp1OP,
901
        AC   => AC,
902
        SP   => SP1
903
    );
904
 
905
    --
906
    -- SP2
907
    -- Stack Pointer #2
908
    --
909
 
910
    iSP2: entity work.eSP (rtl) port map (
911
        sys  => sys,
912
        spOP => sp2OP,
913
        AC   => AC,
914
        SP   => SP2
915
    );
916
 
917
    --
918
    -- SR
919
    -- Switch Register
920
    --
921
 
922
    iSR : entity work.eSR (rtl) port map (
923
        sys   => sys,
924
        swCPU => swCPU,
925
        srOP  => srOP,
926
        AC    => AC,
927
        SRD   => swDATA,
928
        SR    => SR
929
    );
930
 
931
    --
932
    -- UB
933
    -- User Buffer Flag
934
    --
935
 
936
    iUB : entity work.eUB (rtl) port map (
937
        sys  => sys,
938
        ubOP => ubOP,
939
        AC5  => AC(5),
940
        SF0  => SF(0),
941
        UB   => UB
942
    );
943
 
944
    --
945
    -- UF
946
    -- User Flag
947
    --
948
 
949
    iUF : entity work.eUF (rtl) port map (
950
        sys  => sys,
951
        ufOP => ufOP,
952
        UB   => UB,
953
        UF   => UF
954
    );
955
 
956
    --
957
    -- XMA
958
    -- XMA is disabled by disabling the KM8E option
959
    --
960
 
961
    iXMA : entity work.eXMA (rtl) port map (
962
        sys   => sys,
963
        xmaOP => xmaOP,
964
        sWCPU => swCPU,
965
        DF    => DF,
966
        INF   => INF,
967
        IB    => IB,
968
        XMA   => XMA
969
    );
970
 
971
    --
972
    --! CPU Next State Decoder
973
    --
974
 
975
    NEXT_STATE : process(swOPT, dev, IRQ, state, USRTRP, AC, L, MQA, BTSTRP,
976
                         CTRLFF, EMODE, GTF, HLTTRP, ID, IE, II, LAC, MA, MD, MQ,
977
                         PC, PEX, PNLTRP, PWRTRP, IR, SC, UF, swCPU, swCNTL)
978
 
979
        variable EAEIR : std_logic_vector(0 to 3);
980
 
981
    begin
982
 
983
        --
984
        -- Control signal defaults
985
        --
986
 
987
        busOP      <= busopNOP;
988
        ioclrOP    <= '0';
989
        wrOP       <= '0';
990
        rdOP       <= '0';
991
        ifetchOP   <= '0';
992
        datafOP    <= '0';
993
        lxdarOP    <= '0';
994
        memselOP   <= '0';
995
        intgntOP   <= '0';
996
 
997
        --
998
        -- Operation defaults
999
        --
1000
 
1001
        acOP       <= acopNOP;
1002
        busOP      <= busopNOP;
1003
        btstrpOP   <= btstrpopNOP;
1004
        ctrlffOP   <= ctrlffopNOP;
1005
        dfOP       <= dfopNOP;
1006
        eaeOP      <= eaeopNOP;
1007
        emodeOP    <= emodeopNOP;
1008
        fzOP       <= fzopNOP;
1009
        gtfOP      <= gtfopNOP;
1010
        hlttrpOP   <= hlttrpopNOP;
1011
        idOP       <= idopNOP;
1012
        ieOP       <= ieopNOP;
1013
        iiOP       <= iiopNOP;
1014
        ibOP       <= ibopNOP;
1015
        ifOP       <= ifopNOP;
1016
        irOP       <= iropNOP;
1017
        maOP       <= maopNOP;
1018
        mbOP       <= mbopNOP;
1019
        mqOP       <= mqopNOP;
1020
        mqaOP      <= mqaopNOP;
1021
        pcOP       <= pcopNOP;
1022
        pdfOP      <= pdfopNOP;
1023
        pexOP      <= pexopNOP;
1024
        pnltrpOP   <= pnltrpopNOP;
1025
        pwrtrpOP   <= pwrtrpopNOP;
1026
        scOP       <= scopNOP;
1027
        sfOP       <= sfopNOP;
1028
        sp1OP      <= spopNOP;
1029
        sp2OP      <= spopNOP;
1030
        srOP       <= sropNOP;
1031
        ubOP       <= ubopNOP;
1032
        ufOP       <= ufopNOP;
1033
        usrtrpOP   <= usrtrpopNOP;
1034
        xmaOP      <= xmaopNOP;
1035
 
1036
        --
1037
        -- Default Next State
1038
        --
1039
 
1040
        nextState <= stateLALA;
1041
 
1042
        --
1043
        -- BTSTRP set when CPREQ is asserted
1044
        --
1045
 
1046
        if dev.cpreq = '1' and swCPU = swHD6120 then
1047
            btstrpOP <= btstrpOPSET;
1048
        end if;
1049
 
1050
        --
1051
        -- The State Machine
1052
        --
1053
 
1054
        case state is
1055
 
1056
            --
1057
            -- Reset State
1058
            --
1059
 
1060
            when stateRESET =>
1061
                ioclrOP   <= '1';
1062
                busOP     <= busopRESET;
1063
                nextState <= stateInit;
1064
 
1065
            --
1066
            --
1067
            -- Startup States
1068
            --
1069
 
1070
            when stateInit =>
1071
                if swCPU = swHD6120 then
1072
 
1073
                    --
1074
                    -- HD6120 Mode with STARTUP asserted.
1075
                    -- Boot to front panel mode (PC=7777)
1076
                    --
1077
 
1078
                    if swOPT.STARTUP = '1' then
1079
                        pwrtrpOP  <= pwrtrpopSET;
1080
                        nextState <= stateCheckReq;
1081
 
1082
                    --
1083
                    -- HD6120 Mode with STARTUP negated.
1084
                    -- Begin executing at PC=0000
1085
                    --
1086
 
1087
                    else
1088
                        pwrtrpOP  <= pwrtrpopCLR;
1089
                        nextState <= stateCheckReq;
1090
 
1091
                    end if;
1092
                else
1093
 
1094
                    --
1095
                    -- PDP8 Mode with STARTUP asserted.
1096
                    -- Set PC to contents of switch register and start
1097
                    -- execution.
1098
                    --
1099
 
1100
                    if swOPT.STARTUP = '1' then
1101
                        pcOP      <= pcopSR;
1102
                        nextState <= stateFetchAddr;
1103
 
1104
                    --
1105
                    -- PDP8 Mode with STARTUP negated.
1106
                    -- Start in HALT state.  User must interact with front
1107
                    -- panel.
1108
                    --
1109
 
1110
                    else
1111
                        nextState <= stateHalt;
1112
 
1113
                    end if;
1114
                end if;
1115
 
1116
            --
1117
            -- This state occurs at the very top of the processing loop.
1118
            -- The priority hierarchy is:
1119
            -- 1.  RESET -   Clears Accummulator and Link registers and clears the
1120
            --               RUN output signal.
1121
            -- 2.  CPREQ -   If not RESET and CPREQ is asserted, the processor
1122
            --               enters Panel Mode.
1123
            -- 3.  RUN/HLT - If neither RESET or CPREQ is asserted and HLT is
1124
            --               asserted (HLTFLAG = '1'), the processor should enter
1125
            --               the HALT state and the end of the current cycle.
1126
            -- 4.  DEV.INTR -  If no higher priority signal is asserted and IRQ is
1127
            --               asserted an interrup may be processed.
1128
            --
1129
 
1130
            when stateCheckReq =>
1131
 
1132
                --
1133
                -- HD6120:
1134
                -- Panel mode is entered because of the occurrence of any of
1135
                -- four events.  Each of these events sets a status flag, as
1136
                -- well as causing the entry into panel mode. It should be
1137
                -- noted that more than one event might happen simultaneously.
1138
                --
1139
                -- These events are:
1140
                --  1. PWRTRP  - Power-up Trap
1141
                --  2. PNLTRP  - Panel Trap
1142
                --  3. HLTTRP  - HLT insruction
1143
                --  4. BTSTRP  - CPREQ asserted.
1144
                --  5. Not already in panel mode
1145
                --
1146
                -- When a panel request is granted, the PC is stored in
1147
                -- location 0000 of the control panel memory and the CPU
1148
                -- resumes operation at location 7777 (octal) of the panel
1149
                -- memory. During the PC write, 0 appears on EMA0, EMA1 and
1150
                -- EMA2. The states of the IB, IF/INF, OF, ISF and DSF
1151
                -- registers are not disturbed by entry into the control
1152
                -- panel mode but execution is forced to commence in field
1153
                -- zero.
1154
                --
1155
                -- See also description of ID, IE, and II.
1156
                --
1157
 
1158
                if (((swCPU = swHD6120) and (ID = '0') and (II = '0') and (CTRLFF = '0') and (PWRTRP = '1')) or
1159
                    ((swCPU = swHD6120) and (ID = '0') and (II = '0') and (CTRLFF = '0') and (PNLTRP = '1')) or
1160
                    ((swCPU = swHD6120) and (ID = '0') and (II = '0') and (CTRLFF = '0') and (BTSTRP = '1')) or
1161
                    ((swCPU = swHD6120) and (ID = '0') and (II = '0') and (CTRLFF = '0') and (HLTTRP = '1'))) then
1162
 
1163
                    wrOP      <= '1';
1164
                    ctrlffOP  <= ctrlffopSET;
1165
                    fzOP      <= fzopSET;
1166
                    pdfOP     <= pdfopCLR;
1167
                    maOP      <= maop0000;
1168
                    mbOP      <= mbopPC;
1169
                    pcOP      <= pcop7777;
1170
                    xmaOP     <= xmaopCLR;
1171
                    memselOP  <= '1';
1172
                    busOP     <= busopWRZF;
1173
                    assert false report "---------------------> Panel Trap <---------------------" severity note;
1174
                    nextState <= stateFetchAddr;
1175
 
1176
                --
1177
                -- HALT Mode is entered if the HLTTRP is set or the RUN/HALT
1178
                -- Switch is in the HALT position.
1179
                --
1180
 
1181
                elsif (((swCPU /= swHD6120) and (HLTTRP = '1')) or
1182
                       ((swCPU /= swHD6120) and (swCNTL.halt = '1') and (swCNTL.lock = '0')) or
1183
                       ((swCPU /= swHD6120) and (swCNTL.step = '1') and (swCNTL.lock = '0'))) then
1184
                    hlttrpOP  <= hlttrpopCLR;
1185
                    dispHALT(PC);
1186
                    nextState <= stateHalt;
1187
 
1188
                --
1189
                -- Interrupt Request
1190
                -- When an External Interrupt is asserted, the following occurs:
1191
                --   1.  The PC is stored in location 0000 of field 0.
1192
                --   2.  The Interrupt Enable Register (IE) is disabled
1193
                --       which precludes automatically nested interupts.
1194
                --   3.  The INTGNT signal is is asserted.
1195
                --   4.  UF, IF/INF, DF is loaded into SF.
1196
                --   5.  IF/INF is cleared.
1197
                --   6.  IB is cleared.
1198
                --   7.  DF is cleared.
1199
                --   8.  UF is cleared.
1200
                --   9.  UB is cleared.
1201
                --  10.  The PC is set to "0001" of main memory field 0 so
1202
                --       that the next instruction is fetched from there.
1203
                --
1204
                -- See also description of ID, IE, and II.
1205
                --
1206
 
1207
                elsif (IRQ = '1') and (ID = '0') and (IE = '1') and (II = '0') then
1208
                    wrOP      <= '1';
1209
                    intgntOP  <= '1';
1210
                    maOP      <= maop0000;
1211
                    mbOP      <= mbopPC;
1212
                    ieOP      <= ieopCLR;
1213
                    sfOP      <= sfopUBIBDF;
1214
                    dfOP      <= dfopCLR;
1215
                    ifOP      <= ifopCLR;
1216
                    ibOP      <= ibopCLR;
1217
                    ufOP      <= ufopCLR;
1218
                    ubOP      <= ubopCLR;
1219
                    pcOP      <= pcop0001;
1220
                    xmaOP     <= xmaopCLR;
1221
                    memselOP  <= '1';
1222
                    busOP     <= busopWRZF;
1223
                    assert false report "---------------------> Interrupt <---------------------" severity note;
1224
                    nextState <= stateFetchAddr;
1225
 
1226
                --
1227
                -- No interrupts, halt, single step, or anthing else.
1228
                -- Just start to fetch the next instruction.
1229
                --
1230
 
1231
                else
1232
                    nextState <= stateFetchAddr;
1233
 
1234
                end if;
1235
 
1236
            --
1237
            -- HALT State
1238
            -- An HD6120 will never get to this state since halts are trapped
1239
            -- by the front panel.
1240
            --
1241
 
1242
            when stateHalt =>
1243
 
1244
                --
1245
                -- Continue Switch Pressed
1246
                --
1247
 
1248
                if ((swCNTL.cont = '1' and swCNTL.lock = '0') or
1249
                    (swCNTL.step = '1' and swCNTL.lock = '0')) then
1250
                    dispCONT(PC);
1251
                    nextState <= stateContinue;
1252
 
1253
                --
1254
                -- Load Address Switch Pressed
1255
                -- This sets MA and PC to the contents of the switch register.
1256
                --  MA <- SR
1257
                --  PC <- SR
1258
                --
1259
 
1260
                elsif swCNTL.loadADDR = '1' and swCNTL.lock = '0' then
1261
                    pcOP      <= pcopSR;
1262
                    maOP      <= maopSR;
1263
                    nextState <= stateLoadADDR;
1264
 
1265
                --
1266
                -- Load Extended Address Switch Pressed
1267
                -- This sets IF and DF to the contents of the switch register.
1268
                --  IF <- SR[6:8]
1269
                --  DF <- SR[9:11]
1270
                --
1271
 
1272
                elsif swCNTL.loadEXTD = '1' and swCNTL.lock = '0' then
1273
                    ifOP      <= ifopSR6to8;
1274
                    dfOP      <= dfopSR9to11;
1275
                    nextState <= stateLoadEXTD;
1276
 
1277
                --
1278
                -- Clear Switch Pressed
1279
                --
1280
 
1281
                elsif swCNTL.clear = '1' and swCNTL.lock = '0' then
1282
                    acOP      <= acopCLACLL;
1283
                    mqOP      <= mqopCLR;
1284
                    ifOP      <= ifopCLR;
1285
                    ibOP      <= ibopCLR;
1286
                    dfOP      <= dfopCLR;
1287
                    ubOP      <= ubopCLR;
1288
                    ufOP      <= ufopCLR;
1289
                    sp1OP     <= spopCLR;
1290
                    sp2OP     <= spopCLR;
1291
                    ioclrOP   <= '1';
1292
                    lxdarOP   <= '1';
1293
                    datafOP   <= '1';
1294
                    gtfOP     <= gtfopCLR;
1295
                    emodeOP   <= emodeopCLR;
1296
                    ieOP      <= ieopCLR;
1297
                    idOP      <= idopSET;
1298
                    usrtrpOP  <= usrtrpopCLR;
1299
                    busOP     <= busopIOCLR;
1300
                    nextState <= stateClear;
1301
 
1302
                --
1303
                -- Examine Switch Pressed
1304
                -- This loads the contents of the memory location addressed by
1305
                -- the MA register into the MD register and increments the MA
1306
                -- and PC registers.
1307
                --  MD <- MEM[IF'MA]
1308
                --
1309
 
1310
                elsif swCNTL.exam = '1' and swCNTL.lock = '0' then
1311
                    maOP      <= maopPC;
1312
                    xmaOP     <= xmaopIF;
1313
                    memselOP  <= '1';
1314
                    busOP     <= busopRDIFaddr;
1315
                    nextState <= stateExamineReadAddr;
1316
 
1317
                --
1318
                -- Deposit Switch Pressed
1319
                -- This writes the contents of the Switch Register into the
1320
                -- memory location addressed by the MA register.
1321
                --  MEM[IF'MA] <- SR
1322
                --
1323
 
1324
                elsif swCNTL.dep = '1' and swCNTL.lock = '0' then
1325
                    wrOP      <= '1';
1326
                    maOP      <= maopPC;
1327
                    mbOP      <= mbopSR;
1328
                    xmaOP     <= xmaopIF;
1329
                    memselOP  <= '1';
1330
                    busOP     <= busopWRIF;
1331
                    nextState <= stateDepositWriteData;
1332
 
1333
                else
1334
                    nextState <= stateHalt;
1335
 
1336
                end if;
1337
 
1338
            --
1339
            -- Wait for Continue button to negate
1340
            --
1341
 
1342
            when stateContinue =>
1343
                if swCNTL.cont = '1' then
1344
                    nextState <= stateContinue;
1345
                else
1346
                    nextState <= stateFetchAddr;
1347
                end if;
1348
 
1349
            --
1350
            -- Wait for LoadADDR button to negate
1351
            --
1352
 
1353
            when stateLoadADDR =>
1354
                if swCNTL.loadADDR = '1' then
1355
                    nextState <= stateLoadADDR;
1356
                else
1357
                    nextState <= stateHaltDone;
1358
                end if;
1359
 
1360
            --
1361
            -- Wait for LoadEXTD button to negate
1362
            --
1363
 
1364
            when stateLoadEXTD =>
1365
                if swCNTL.loadEXTD = '1' then
1366
                    nextState <= stateLoadEXTD;
1367
                else
1368
                    nextState <= stateHaltDone;
1369
                end if;
1370
 
1371
            --
1372
            -- Wait for Clear button to negate
1373
            --
1374
 
1375
            when stateClear =>
1376
                if swCNTL.clear = '1' then
1377
                    nextState <= stateClear;
1378
                else
1379
                    nextState <= stateHaltDone;
1380
                end if;
1381
 
1382
            --
1383
            -- Examine Read Addr
1384
            -- This is the address phase of the read cycle.
1385
            --
1386
 
1387
            when stateExamineReadAddr =>
1388
                rdOP      <= '1';
1389
                xmaOP     <= xmaopIF;
1390
                memselOP  <= '1';
1391
                busOP     <= busopRDIFdata;
1392
                nextState <= stateExamineReadData;
1393
 
1394
            --
1395
            -- Examine Read Data
1396
            -- This is the data phase of the read cycle.
1397
            -- At the end of this cycle, MD will have the data that was read.
1398
            -- This state increments the PC and MA register after the examine.
1399
            --  MD <- MEM[IF'MA]
1400
            --  MA <- MA + 1
1401
            --  PC <- PC + 1
1402
            --
1403
 
1404
            when stateExamineReadData =>
1405
                maOP      <= maopINC;
1406
                pcOP      <= pcopINC;
1407
                nextState <= stateExamine;
1408
 
1409
            --
1410
            -- Wait for Examine button to negate
1411
            --
1412
 
1413
            when stateExamine =>
1414
                if swCNTL.exam = '1' then
1415
                    nextState <= stateExamine;
1416
                else
1417
                    nextState <= stateHaltDone;
1418
                end if;
1419
 
1420
            --
1421
            -- This cycle writes data to memory.  Once written
1422
            -- this state increments PC and MA.
1423
            --  MA <- MA + 1
1424
            --  PC <- PC + 1
1425
            --
1426
 
1427
            when stateDepositWriteData =>
1428
                maOP      <= maopINC;
1429
                pcOP      <= pcopINC;
1430
                nextState <= stateDeposit;
1431
 
1432
            --
1433
            -- Wait for Deposit button to negate
1434
            --
1435
 
1436
            when stateDeposit =>
1437
                if swCNTL.dep = '1' then
1438
                    nextState <= stateDeposit;
1439
                else
1440
                    nextState <= stateHaltDone;
1441
                end if;
1442
 
1443
            --
1444
            -- Update Front Panel display
1445
            --
1446
 
1447
            when stateHaltDone =>
1448
                nextState <= stateHalt;
1449
 
1450
            --
1451
            -- Begin Instruction Fetch.  Perform Read Address Cycle.
1452
            --  MA <- PC
1453
            --  MD <- MEM[IF'MA]
1454
            --
1455
 
1456
            when stateFetchAddr =>
1457
                maOP      <= maopPC;
1458
                xmaOP     <= xmaopIF;
1459
                ifetchOP  <= '1';
1460
                memselOP  <= '1';
1461
                busOP     <= busopFETCHaddr;
1462
                nextState <= stateFetchData;
1463
 
1464
            --
1465
            -- Continue Instruction Fetch.  Perform Read Data Cycle.
1466
            -- The Interrupt Enable Delay Register (ID) is cleared.
1467
            -- If the ID was set at the beginning of this instruction,
1468
            -- an interrupt, if present, was deferred.  We clear it now.
1469
            -- Therefore this instruction will complete and then that
1470
            -- interrupt, if present, will be recognized.
1471
            --  MD <- MEM[IF'MA]
1472
            --
1473
 
1474
            when stateFetchData =>
1475
                rdOP      <= '1';
1476
                pcOP      <= pcopINC;
1477
                idOP      <= idopCLR;
1478
                xmaOP     <= xmaopIF;
1479
                ifetchOP  <= '1';
1480
                memselOP  <= '1';
1481
                busOP     <= busopFETCHdata;
1482
                nextState <= stateLoadIR;
1483
 
1484
            --
1485
            -- Load IR with the instruction that was fetched.
1486
            -- Note: This state is a wasted state.  We could have decoded the MD
1487
            -- and loaded the IR simultaneously.
1488
            --  IR <- MD
1489
            --
1490
 
1491
            when stateLoadIR =>
1492
                irOP      <= iropMD;
1493
                nextState <= stateDecodeInstruction;
1494
 
1495
            --
1496
            -- Decode Instruction in IR
1497
            --
1498
 
1499
            when stateDecodeInstruction =>
1500
 
1501
                --
1502
                -- Default Next State
1503
                --
1504
 
1505
                nextState <= stateLALA;
1506
 
1507
                --
1508
                -- Parse OPCODE
1509
                --
1510
 
1511
                case IR(0 to 2) is
1512
 
1513
                    --
1514
                    -- AND Instruction
1515
                    --
1516
 
1517
                    when opAND =>
1518
 
1519
                        case IR(3 to 4) is
1520
 
1521
                            --
1522
                            -- AND, direct, zero page.  Start Read Addr Cycle
1523
                            --  MA <- 00000'IR(5:11)
1524
                            --
1525
 
1526
                            when amDZ =>
1527
                                maOP      <= maopZP;
1528
                                xmaOP     <= xmaopIF;
1529
                                memselOP  <= '1';
1530
                                busOP     <= busopRDIFaddr;
1531
                                nextState <= stateMRIreadAddr;
1532
 
1533
                            --
1534
                            -- AND, direct, curr page.  Start Read Addr Cycle
1535
                            --  MA <- MA(0:4)'IR(5:11)
1536
                            --
1537
 
1538
                            when amDC =>
1539
                                maOP      <= maopCP;
1540
                                xmaOP     <= xmaopIF;
1541
                                memselOP  <= '1';
1542
                                busOP     <= busopRDIFaddr;
1543
                                nextState <= stateMRIreadAddr;
1544
 
1545
                            --
1546
                            -- AND, indirect, zero page.  Start Read Addr Cycle
1547
                            --  MA <- 00000'IR(5:11)
1548
                            --
1549
 
1550
                            when amIZ =>
1551
                                maOP      <= maopZP;
1552
                                xmaOP     <= xmaopIF;
1553
                                memselOP  <= '1';
1554
                                busOP     <= busopRDIFaddr;
1555
                                nextState <= stateMRIreadAddr;
1556
 
1557
                            --
1558
                            -- AND, indirect, curr page.  Start Read Addr Cycle
1559
                            --  MA <- MA(0:4)'IR(5:11)
1560
                            --
1561
 
1562
                            when amIC =>
1563
                                maOP      <= maopCP;
1564
                                xmaOP     <= xmaopIF;
1565
                                memselOP  <= '1';
1566
                                busOP     <= busopRDIFaddr;
1567
                                nextState <= stateMRIreadAddr;
1568
 
1569
                            --
1570
                            -- Everthing else
1571
                            --
1572
 
1573
                            when others =>
1574
                                null;
1575
 
1576
                        end case;
1577
 
1578
                    --
1579
                    -- TAD Instruction
1580
                    --
1581
 
1582
                    when opTAD =>
1583
 
1584
                        case IR(3 to 4) is
1585
 
1586
                            --
1587
                            -- TAD, direct, zero page.  Start Read Addr Cycle
1588
                            --  MA <- 00000'IR(5:11)
1589
                            --
1590
 
1591
                            when amDZ =>
1592
                                maOP      <= maopZP;
1593
                                xmaOP     <= xmaopIF;
1594
                                memselOP  <= '1';
1595
                                busOP     <= busopRDIFaddr;
1596
                                nextState <= stateMRIreadAddr;
1597
 
1598
                            --
1599
                            -- TAD, direct, curr page.  Start Read Addr Cycle
1600
                            --  MA <- MA(0:4)'IR(5:11)
1601
                            --
1602
 
1603
                            when amDC =>
1604
                                maOP      <= maopCP;
1605
                                xmaOP     <= xmaopIF;
1606
                                memselOP  <= '1';
1607
                                busOP     <= busopRDIFaddr;
1608
                                nextState <= stateMRIreadAddr;
1609
 
1610
                            --
1611
                            -- TAD, indirect, zero page.  Start Read Addr Cycle
1612
                            --  MA <- 00000'IR(5:11)
1613
                            --
1614
 
1615
                            when amIZ =>
1616
                                maOP      <= maopZP;
1617
                                xmaOP     <= xmaopIF;
1618
                                memselOP  <= '1';
1619
                                busOP     <= busopRDIFaddr;
1620
                                nextState <= stateMRIreadAddr;
1621
 
1622
                            --
1623
                            -- TAD, indirect, curr page.  Start Read Addr Cycle
1624
                            --  MA <- MA(0:4)'IR(5:11)
1625
                            --
1626
 
1627
                            when amIC =>
1628
                                maOP      <= maopCP;
1629
                                xmaOP     <= xmaopIF;
1630
                                memselOP  <= '1';
1631
                                busOP     <= busopRDIFaddr;
1632
                                nextState <= stateMRIreadAddr;
1633
 
1634
                            --
1635
                            -- Everything else
1636
                            --
1637
 
1638
                            when others =>
1639
                                null;
1640
 
1641
                        end case;
1642
 
1643
                    --
1644
                    -- ISZ Instruction
1645
                    --
1646
 
1647
                    when opISZ =>
1648
 
1649
                        case IR(3 to 4) is
1650
 
1651
                            --
1652
                            -- ISZ, direct, zero page.  Start Read Addr Cycle
1653
                            --  MA <- 00000'IR(5:11)
1654
                            --
1655
 
1656
                            when amDZ =>
1657
                                maOP      <= maopZP;
1658
                                xmaOP     <= xmaopIF;
1659
                                memselOP  <= '1';
1660
                                busOP     <= busopRDIFaddr;
1661
                                nextState <= stateMRIreadAddr;
1662
 
1663
                            --
1664
                            -- ISZ, direct, curr page.  Start Read Addr Cycle
1665
                            --  MA <- MA(0:4)'IR(5:11)
1666
                            --
1667
 
1668
                            when amDC =>
1669
                                maOP      <= maopCP;
1670
                                xmaOP     <= xmaopIF;
1671
                                memselOP  <= '1';
1672
                                busOP     <= busopRDIFaddr;
1673
                                nextState <= stateMRIreadAddr;
1674
 
1675
                            --
1676
                            -- ISZ, indirect, zero page.  Start Read Addr Cycle
1677
                            --  MA <- 00000'IR(5:11)
1678
                            --
1679
 
1680
                            when amIZ =>
1681
                                maOP      <= maopZP;
1682
                                xmaOP     <= xmaopIF;
1683
                                memselOP  <= '1';
1684
                                busOP     <= busopRDIFaddr;
1685
                                nextState <= stateMRIreadAddr;
1686
 
1687
                            --
1688
                            -- ISZ, indirect, curr page.  Start Read Addr Cycle
1689
                            --  MA <- MA(0:4)'IR(5:11)
1690
                            --
1691
 
1692
                            when amIC =>
1693
                                maOP      <= maopCP;
1694
                                xmaOP     <= xmaopIF;
1695
                                memselOP  <= '1';
1696
                                busOP     <= busopRDIFaddr;
1697
                                nextState <= stateMRIreadAddr;
1698
 
1699
                            --
1700
                            -- Everything else
1701
                            --
1702
 
1703
                            when others =>
1704
                                null;
1705
 
1706
                        end case;
1707
 
1708
                    --
1709
                    -- MRI DCA
1710
                    --
1711
 
1712
                    when opDCA =>
1713
 
1714
                        case IR(3 to 4) is
1715
 
1716
                            --
1717
                            -- DCA, direct, zero page.  Start Write Cycle
1718
                            --  MA <- 00000'IR(5:11)
1719
                            --
1720
 
1721
                            when amDZ =>
1722
                                wrOP      <= '1';
1723
                                acOP      <= acopCLA;
1724
                                maOP      <= maopZP;
1725
                                mbOP      <= mbopAC;
1726
                                xmaOP     <= xmaopIF;
1727
                                memselOP  <= '1';
1728
                                busOP     <= busopRDIFaddr;
1729
                                nextState <= stateDone;
1730
 
1731
                            --
1732
                            -- DCA, direct, curr page.  Start Write Cycle
1733
                            --  MA <- MA(0:4)'IR(5:11)
1734
                            --
1735
 
1736
                            when amDC =>
1737
                                wrOP      <= '1';
1738
                                acOP      <= acopCLA;
1739
                                maOP      <= maopCP;
1740
                                mbOP      <= mbopAC;
1741
                                xmaOP     <= xmaopIF;
1742
                                memselOP  <= '1';
1743
                                busOP     <= busopRDIFaddr;
1744
                                nextState <= stateDone;
1745
 
1746
                            --
1747
                            -- DCA, indirect, zero page.  Start Read Addr Cycle.
1748
                            --  MA <- 00000'IR(5:11)
1749
                            --
1750
 
1751
                            when amIZ =>
1752
                                maOP      <= maopZP;
1753
                                xmaOP     <= xmaopIF;
1754
                                memselOP  <= '1';
1755
                                busOP     <= busopRDIFaddr;
1756
                                nextState <= stateMRIreadAddr;
1757
 
1758
                            --
1759
                            -- DCA, indirect, curr page.  Start Read Addr Cycle.
1760
                            --  MA <- MA(0:4)'IR(5:11)
1761
                            --
1762
 
1763
                            when amIC =>
1764
                                maOP      <= maopCP;
1765
                                xmaOP     <= xmaopIF;
1766
                                memselOP  <= '1';
1767
                                busOP     <= busopRDIFaddr;
1768
                                nextState <= stateMRIreadAddr;
1769
 
1770
                            --
1771
                            -- Everything else
1772
                            --
1773
 
1774
                            when others =>
1775
                                 null;
1776
 
1777
                        end case;
1778
 
1779
                    --
1780
                    -- JMS Instruction
1781
                    --
1782
 
1783
                    when opJMS =>
1784
 
1785
                        --
1786
                        -- The II Register is cleared.
1787
                        -- The FZ Register is cleared
1788
                        --
1789
 
1790
                        iiOP <= iiopCLR;
1791
                        fzOP <= fzopCLR;
1792
 
1793
                        case IR(3 to 4) is
1794
 
1795
                            --
1796
                            -- JMS, direct, zero page.  Start write cycle.
1797
                            --  MA <- 00000'IR(5:11)
1798
                            --
1799
                            -- When the PEX Flip-flop is set, the CPU shall
1800
                            -- exit from Panel Mode to Main Memory (i.e., clear
1801
                            -- CTRLFF) during the next JMP, JMS, RTN1 or RTN2
1802
                            -- instruction.
1803
                            --
1804
                            -- PEX is cleared by the JMP, JMS, RTN1 or RTN2
1805
                            -- instruction.
1806
                            --
1807
 
1808
                            when amDZ =>
1809
                                ifOP      <= ifopIB;
1810
                                ufOP      <= ufopUB;
1811
                                wrOP      <= '1';
1812
                                maOP      <= maopZP;
1813
                                mbOP      <= mbopPC;
1814
                                pcOP      <= pcopZPP1;
1815
                                xmaOP     <= xmaopIB;
1816
                                memselOP  <= '1';
1817
                                busOP     <= busopWRIB;
1818
                                if PEX = '1' then
1819
                                    ctrlffOP <= ctrlffopCLR;
1820
                                    pexOP    <= pexopCLR;
1821
                                end if;
1822
                                nextState <= stateDone;
1823
 
1824
                            --
1825
                            -- JMS, direct, curr page.  Start write cycle.
1826
                            --  MA <- MA(0:4)'IR(5:11)
1827
                            --
1828
                            -- When the PEX Flip-flop is set, the CPU shall
1829
                            -- exit from Panel Mode to Main Memory (i.e., clear
1830
                            -- CTRLFF) during the next JMP, JMS, RTN1 or RTN2
1831
                            -- instruction.
1832
                            --
1833
                            -- PEX is cleared by the JMP, JMS, RTN1 or RTN2
1834
                            -- instruction.
1835
                            --
1836
 
1837
                            when amDC =>
1838
                                ifOP      <= ifopIB;
1839
                                ufOP      <= ufopUB;
1840
                                wrOP      <= '1';
1841
                                maOP      <= maopCP;
1842
                                mbOP      <= mbopPC;
1843
                                pcOP      <= pcopCPP1;
1844
                                xmaOP     <= xmaopIB;
1845
                                memselOP  <= '1';
1846
                                busOP     <= busopWRIB;
1847
                                if PEX = '1' then
1848
                                    ctrlffOP <= ctrlffopCLR;
1849
                                    pexOP    <= pexopCLR;
1850
                                end if;
1851
                                nextState <= stateDone;
1852
 
1853
                            --
1854
                            -- JMS, indirect, zero page.  Start Read Addr Cycle.
1855
                            --  MA <- 00000'IR(5:11)
1856
                            --
1857
 
1858
                            when amIZ =>
1859
                                maOP      <= maopZP;
1860
                                xmaOP     <= xmaopIF;
1861
                                memselOP  <= '1';
1862
                                busOP     <= busopRDIFaddr;
1863
                                nextState <= stateMRIreadAddr;
1864
 
1865
                            --
1866
                            -- JMS, indirect, curr page.  Start Read Addr Cycle.
1867
                            --  MA <- MA(0:4)'IR(5:11)
1868
                            --
1869
 
1870
                            when amIC =>
1871
                                maOP      <= maopCP;
1872
                                xmaOP     <= xmaopIF;
1873
                                memselOP  <= '1';
1874
                                busOP     <= busopRDIFaddr;
1875
                                nextState <= stateMRIreadAddr;
1876
 
1877
                            --
1878
                            -- Everthing else
1879
                            --
1880
 
1881
                            when others =>
1882
                                null;
1883
 
1884
                        end case;
1885
 
1886
                    --
1887
                    -- JMP Instruction
1888
                    --
1889
 
1890
                    when opJMP =>
1891
 
1892
                        --
1893
                        -- The II Register is cleared.
1894
                        -- The FZ Register is cleared
1895
                        --
1896
 
1897
                        iiOP <= iiopCLR;
1898
                        fzOP <= fzopCLR;
1899
 
1900
                        case IR(3 to 4) is
1901
 
1902
                            --
1903
                            -- JMP, direct, zero page.
1904
                            --  MA <- 00000'IR(5:11)
1905
                            --
1906
                            -- When the PEX Flip-flop is set, the CPU shall
1907
                            -- exit from Panel Mode to Main Memory (i.e., clear
1908
                            -- CTRLFF) during the next JMP, JMS, RTN1 or RTN2
1909
                            -- instruction.
1910
                            --
1911
                            -- PEX is cleared by the JMP, JMS, RTN1 or RTN2
1912
                            -- instruction.
1913
                            --
1914
 
1915
                            when amDZ =>
1916
                                maOP <= maopZP;
1917
                                pcOP <= pcopZP;
1918
                                ifOP <= ifopIB;
1919
                                ufOP <= ufopUB;
1920
                                if PEX = '1' then
1921
                                    ctrlffOP <= ctrlffopCLR;
1922
                                    pexOP    <= pexopCLR;
1923
                                end if;
1924
                                nextState <= stateDone;
1925
 
1926
                            --
1927
                            -- JMP, direct, curr page.
1928
                            --  MA <- MA(0:4)'IR(5:11)
1929
                            --
1930
                            -- When the PEX Flip-flop is set, the CPU shall
1931
                            -- exit from Panel Mode to Main Memory (i.e., clear
1932
                            -- CTRLFF) during the next JMP, JMS, RTN1 or RTN2
1933
                            -- instruction.
1934
                            --
1935
                            -- PEX is cleared by the JMP, JMS, RTN1 or RTN
1936
                            -- instruction.
1937
                            --
1938
 
1939
                            when amDC =>
1940
                                maOP <= maopCP;
1941
                                pcOP <= pcopCP;
1942
                                ifOP <= ifopIB;
1943
                                ufOP <= ufopUB;
1944
                                if PEX = '1' then
1945
                                    ctrlffOP <= ctrlffopCLR;
1946
                                    pexOP    <= pexopCLR;
1947
                                end if;
1948
                                nextState <= stateDone;
1949
 
1950
                            --
1951
                            -- JMP, indirect, zero page.  Start Read Addr Cycle.
1952
                            --  MA <- 00000'IR(5:11)
1953
                            --
1954
 
1955
                            when amIZ =>
1956
                                maOP      <= maopZP;
1957
                                xmaOP     <= xmaopIF;
1958
                                memselOP  <= '1';
1959
                                busOP     <= busopRDIFaddr;
1960
                                nextState <= stateMRIreadAddr;
1961
 
1962
                            --
1963
                            -- JMP, indirect, curr page.  Start Read Addr Cycle.
1964
                            --  MA <- MA(0:4)'IR(5:11)
1965
                            --
1966
 
1967
                            when amIC =>
1968
                                maOP      <= maopCP;
1969
                                xmaOP     <= xmaopIF;
1970
                                memselOP  <= '1';
1971
                                busOP     <= busopRDIFaddr;
1972
                                nextState <= stateMRIreadAddr;
1973
 
1974
                            --
1975
                            -- Everything else
1976
                            --
1977
 
1978
                            when others =>
1979
                                null;
1980
 
1981
                        end case;
1982
 
1983
                    --
1984
                    -- IOT Instructions
1985
                    --
1986
 
1987
                    when opIOT =>
1988
 
1989
                        --
1990
                        -- Default Next State
1991
                        --
1992
 
1993
                        nextState <= stateDone;
1994
 
1995
                        --
1996
                        -- Handle USR Mode interrupts
1997
                        --
1998
 
1999
                        if (UF = '1') then
2000
 
2001
                            usrtrpOP  <= usrtrpopSET;
2002
                            nextState <= stateDone;
2003
 
2004
                        else
2005
 
2006
                            --
2007
                            -- Internal IOT (CPU Control)
2008
                            --   600x, 62xx are internal IOTs
2009
                            --
2010
 
2011
                            case IR(0 to 11) is
2012
 
2013
                                --
2014
                                -- OP 6000: PRS/SKON
2015
                                --
2016
 
2017
                                when o"6000" =>
2018
 
2019
                                    --
2020
                                    -- HD6120 only
2021
                                    -- OP 6000: PRS - Panel Read Status Word.
2022
                                    -- Read panel status bits into AC<0-4>, 0
2023
                                    -- into AC<5:11>.  Following the reading of
2024
                                    -- the flags into the AC, the flags are
2025
                                    -- cleared, with the exception of HLTTRP.
2026
                                    -- BTSTR is cleared only if a 1 was read
2027
                                    -- into AC<0>.
2028
                                    --
2029
 
2030
                                    if swCPU = swHD6120 then
2031
                                        if CTRLFF = '1' then
2032
                                            acOP     <= acopPRS;
2033
                                            pnltrpOP <= pnltrpopCLR;
2034
                                            pwrtrpOP <= pwrtrpopCLR;
2035
                                            btstrpOP <= btstrpopCLR;
2036
                                        end if;
2037
 
2038
                                    --
2039
                                    -- PDP-8/E and later and HD-6120
2040
                                    -- SKON - Skip if interupt system is on,
2041
                                    -- turn it off.
2042
                                    --
2043
 
2044
                                    elsif ((swCPU = swPDP8E) or
2045
                                           (swCPU = swPDP8F) or
2046
                                           (swCPU = swPDP8A) or
2047
                                           (swCPU = swHD6120)) then
2048
                                        if IE = '1' then
2049
                                            pcOP <= pcopINC;
2050
                                        end if;
2051
                                        ieOP <= ieopCLR;
2052
 
2053
                                    --
2054
                                    -- Pre PDP8/E
2055
                                    -- This instruction was a NOP.
2056
                                    --
2057
 
2058
                                    else
2059
                                        null;
2060
 
2061
                                    end if;
2062
 
2063
                                --
2064
                                -- IOT 6001: ION - Enable Interrupts.
2065
                                -- The Interrupt Enable Register (IE) is set.
2066
                                -- The Interrupt Enable Delay Register (ID)
2067
                                -- is set.
2068
                                --
2069
                                -- Note: Setting the ID delays the interrupt
2070
                                -- enable by one instruction so that a return
2071
                                -- (from interrupt) may be executed before the
2072
                                -- next interrupt request is serviced.
2073
                                --
2074
 
2075
                                when o"6001" =>
2076
                                    ieOP <= ieopSET;
2077
                                    idOP <= idopSET;
2078
 
2079
                                --
2080
                                -- IOT 6002: IOF - Disable Interrupts
2081
                                -- The Interrupt Enable Flip Flop (IE) is cleared
2082
                                -- immediately. If IRQ is low while this
2083
                                -- instruction is being processed, the interrupt
2084
                                -- will not be recognized.
2085
                                --
2086
 
2087
                                when o"6002" =>
2088
                                    ieOP <= ieopCLR;
2089
 
2090
                                --
2091
                                -- OP 6003: PGO/SRQ
2092
                                --
2093
 
2094
                                when o"6003" =>
2095
 
2096
                                    --
2097
                                    -- HD6120 only
2098
                                    -- OP 6003: PGO - Panel Go.
2099
                                    --
2100
 
2101
                                    if swCPU = swHD6120 then
2102
                                        if CTRLFF = '1' then
2103
                                            hlttrpOP <= hlttrpopCLR;
2104
                                        end if;
2105
 
2106
                                    --
2107
                                    -- PDP-8/E and later and HD-6120
2108
                                    -- OP 6003: SRQ - Skip on Interupt Request
2109
                                    --
2110
 
2111
                                    elsif ((swCPU = swPDP8E) or
2112
                                           (swCPU = swPDP8F) or
2113
                                           (swCPU = swPDP8A) or
2114
                                           (swCPU = swHD6120)) then
2115
                                        if IRQ = '1' then
2116
                                            pcOP <= pcopINC;
2117
                                        end if;
2118
 
2119
                                    --
2120
                                    -- Pre PDP-8/E
2121
                                    -- OP 6003: ION - This was equivalent to
2122
                                    -- the ION instruction.
2123
                                    --
2124
 
2125
                                    else
2126
                                        ieOP <= ieopSET;
2127
                                        idOP <= idopSET;
2128
 
2129
                                    end if;
2130
 
2131
                                --
2132
                                -- IOT 6004: PEX/GTF
2133
                                --
2134
                                -- GTF - Get Flags
2135
                                --
2136
                                --  00 01 02 03 04 05 06 07 08 09 10 11
2137
                                -- +--+--+--+--+--+--+--------+--------+
2138
                                -- | L|GT|IR|0 |IE|UF|   IF   |   DF   |
2139
                                -- +--+--+--+--+--+--+--------+--------+
2140
                                --
2141
                                -- L  - The link bit.
2142
                                -- GT - The Greater Than bit
2143
                                -- IR - The interrupt request status, as tested by SRQ.
2144
                                -- IE - The state of the interrupt enable flip-flop (IE)
2145
                                -- UF - User Flag
2146
                                -- IF - The instruction field.
2147
                                -- DF - The data field.
2148
                                --
2149
                                -- PEX -  Panel Exit to Normal Mode
2150
                                -- Exit from panel mode into main memory at the end
2151
                                -- of the next JMP, JMS, RTN1 or RTN2 instruction.
2152
                                --
2153
 
2154
                                when o"6004" =>
2155
 
2156
                                    --
2157
                                    -- OP 6004: PEX - Panel Exit to Normal Mode
2158
                                    -- HD6120 in Panel Mode only
2159
                                    --
2160
                                    -- Set PEX Flip-flop
2161
                                    -- Clear PWRTRP and PNLTRP.
2162
                                    --
2163
 
2164
                                    if swCPU = swHD6120 and CTRLFF = '1' then
2165
                                        pwrtrpOP <= pwrtrpopCLR;
2166
                                        pnltrpOP <= pnltrpopCLR;
2167
                                        pexOP    <= pexopSET;
2168
 
2169
                                    --
2170
                                    -- OP 6004: GTF - Get Flags
2171
                                    -- HD6120 in Normal Mode only
2172
                                    -- AC(4) is always set.
2173
                                    -- AC(5) is always cleared.
2174
                                    --
2175
 
2176
                                    elsif swCPU = swHD6120 and CTRLFF = '0' then
2177
                                        acOP <= acopGTF1;
2178
 
2179
                                    --
2180
                                    -- OP 6004: GTF - Get Flags
2181
                                    -- PDP-8/E and later with KM8E installed
2182
                                    -- AC(4) is set to state of the interrupt
2183
                                    --
2184
 
2185
                                    elsif ((swCPU = swPDP8E and swOPT.KM8E = '1') or
2186
                                           (swCPU = swPDP8F and swOPT.KM8E = '1') or
2187
                                           (swCPU = swPDP8A and swOPT.KM8E = '1')) then
2188
                                        acOP <= acopGTF2;
2189
 
2190
                                    --
2191
                                    -- Pre PDP-8/E
2192
                                    -- OP 6004: This was and ADC operation or a
2193
                                    -- NOP.
2194
                                    --
2195
 
2196
                                    else
2197
                                        null;
2198
 
2199
                                    end if;
2200
 
2201
                                --
2202
                                -- IOT 6005: RTF - Restore Flags and Fields from AC.
2203
                                -- The flags are set as follows:
2204
                                --
2205
                                --  00 01 02 03 04 05 06 07 08 09 10 11
2206
                                -- +--+--+--+--+--+--+--------+--------+
2207
                                -- | L|GT|  |  |IE|UB|   IB   |   DF   |
2208
                                -- +--+--+--+--+--+--+--------+--------+
2209
                                --
2210
 
2211
                                when o"6005" =>
2212
                                    if ((swCPU = swPDP8E) or
2213
                                        (swCPU = swPDP8F) or
2214
                                        (swCPU = swPDP8A) or
2215
                                        (swCPU = swHD6120)) then
2216
 
2217
                                        --
2218
                                        -- HD6120: The AC is cleared following
2219
                                        -- the load operation.  The interrupt
2220
                                        -- is enabled per AC(4).  See HD6120
2221
                                        -- GTF instruction.
2222
                                        --
2223
 
2224
                                        if swCPU = swHD6120 then
2225
 
2226
                                            if AC(0) = '1' then
2227
                                                acOP <= acopCLACLLCML;
2228
                                            else
2229
                                                acOP <= acopCLACLL;
2230
                                            end if;
2231
 
2232
                                            if AC(4) = '1' then
2233
                                                ieOP <= ieopSET;
2234
                                                iiOP <= iiopSET;
2235
                                            end if;
2236
 
2237
                                        --
2238
                                        -- PDP8/E and later: AC is not modified by
2239
                                        -- the instruction. AC(4) is ignored and
2240
                                        -- interrupts are unconditionally
2241
                                        -- re-enabled.  AC(5) sets the UB bit.
2242
                                        -- See PDP/8 GTF instruction.
2243
                                        --
2244
 
2245
                                        else
2246
 
2247
                                            if AC(0) = '1' then
2248
                                                acOP <= acopCLLCML;
2249
                                            else
2250
                                                acOP <= acopCLL;
2251
                                            end if;
2252
                                            ieOP <= ieopSET;
2253
                                            iiOP <= iiopSET;
2254
                                            ubOP <= ubopAC5;
2255
                                        end if;
2256
 
2257
                                        gtfOP <= gtfopAC1;
2258
                                        ibOP  <= ibopAC6to8;
2259
                                        dfOP  <= dfopAC9to11;
2260
                                        fzop  <= fzopCLR;
2261
 
2262
                                    --
2263
                                    -- Pre PDP8/E
2264
                                    -- OP 6005: ION ORed with ADC
2265
                                    --
2266
 
2267
                                    else
2268
                                        ieOP <= ieopSET;
2269
                                        idOP <= idopSET;
2270
 
2271
                                    end if;
2272
 
2273
                                --
2274
                                -- OP 6006: SGT
2275
                                --
2276
 
2277
                                when o"6006" =>
2278
 
2279
                                    --
2280
                                    -- PDP8/E and later
2281
                                    -- OP 6006: SGT - Skip if the GT flag is set.
2282
                                    --
2283
 
2284
                                    if ((swCPU = swPDP8E) or
2285
                                        (swCPU = swPDP8F) or
2286
                                        (swCPU = swPDP8A) or
2287
                                        (swCPU = swHD6120)) then
2288
                                        if GTF = '1' then
2289
                                            pcOP <= pcopINC;
2290
                                        end if;
2291
 
2292
                                    --
2293
                                    -- Pre PDP8/E
2294
                                    -- OP 6006: This was equivalent to an IOF
2295
                                    -- ORed with and ADC op
2296
                                    --
2297
 
2298
                                    else
2299
                                        ieOP <= ieopCLR;
2300
 
2301
                                    end if;
2302
 
2303
                                --
2304
                                -- OP 6007: CAF - Clear all flags.
2305
                                --
2306
 
2307
                                when o"6007" =>
2308
 
2309
                                    --
2310
                                    -- PDP8/E and Later
2311
                                    -- IOT 6007: CAF - Clear all flags.
2312
                                    -- The AC, LINK and GT flag are cleared.
2313
                                    -- Interrupt Enable Flip Flop (IE) is cleared.
2314
                                    -- IOCLR is generated with LXDAR high, causing
2315
                                    -- peripheral devices to clear their flags.
2316
                                    --
2317
 
2318
                                    if ((swCPU = swPDP8E) or
2319
                                        (swCPU = swPDP8F) or
2320
                                        (swCPU = swPDP8A) or
2321
                                        (swCPU = swHD6120)) then
2322
                                        ioclrOP   <= '1';
2323
                                        lxdarOP   <= '1';
2324
                                        datafOP   <= '1';
2325
                                        gtfOP     <= gtfopCLR;
2326
                                        acOP      <= acopCLACLL;
2327
                                        emodeOP   <= emodeopCLR;
2328
                                        ieOP      <= ieopCLR;
2329
                                        idOP      <= idopSET;
2330
                                        busOP     <= busopIOCLR;
2331
                                        usrtrpOP  <= usrtrpopCLR;
2332
 
2333
                                    --
2334
                                    -- Pre PDP8/E
2335
                                    -- OP 6007: ION ORed with ADC
2336
                                    --
2337
 
2338
                                    else
2339
                                        ieOP <= ieopSET;
2340
                                        idOP <= idopSET;
2341
 
2342
                                    end if;
2343
 
2344
                                --
2345
                                -- IOT 6200: LXM - Load Extended Mode Register
2346
                                -- On all machines without KT8-A this is executed
2347
                                -- as a NOP instruction.
2348
                                --
2349
 
2350
                                when o"6200" =>
2351
                                    null;
2352
 
2353
                                --
2354
                                -- IOT 62x1: CDF - Change Data Field
2355
                                -- The Data Field Register (DF) is loaded with IR<6:8>
2356
                                -- of this instruction.
2357
                                --
2358
 
2359
                                when o"6201" | o"6211" | o"6221" | o"6231" | o"6241" | o"6251" | o"6261" | o"6271" =>
2360
                                    dfOP <= dfopIR6to8;
2361
 
2362
                                --
2363
                                -- IOT 62x2: CIF - Change Instruction Field
2364
                                -- The Instruction Buffer (IB/IB) is loaded with
2365
                                -- IR<6:8> of this instruction and the Interrupt
2366
                                -- Inhibit Flip Flop (II) is set.
2367
                                --
2368
                                -- Note: Setting the II causes the CPU to ignore
2369
                                -- interrupt requests until the next JMP, JMS,
2370
                                -- RTN1 or RTN2 Instruction is executed.  At that
2371
                                -- time the contents of IB/IB are loaded into the
2372
                                -- IF/INF and the II cleared.
2373
                                --
2374
 
2375
                                when o"6202" | o"6212" | o"6222" | o"6232" | o"6242" | o"6252" | o"6262" | o"6272" =>
2376
                                    ibOP <= ibopIR6to8;
2377
                                    iiOP <= iiopSET;
2378
                                    fzop <= fzopCLR;
2379
 
2380
                                --
2381
                                -- IOT 62x2: CIF/CDF (CDI) - Change Instruction
2382
                                -- and Data Field.
2383
                                -- A microprogrammed combination of CDF and CIF.
2384
                                -- Both fields are set to X.
2385
                                --
2386
 
2387
                                when o"6203" | o"6213" | o"6223" | o"6233" | o"6243" | o"6253" | o"6263" | o"6273" =>
2388
                                    dfOP <= dfopIR6to8;
2389
                                    ibOP <= ibopIR6to8;
2390
                                    iiOP <= iiopSET;
2391
                                    fzop <= fzopCLR;
2392
 
2393
                                --
2394
                                -- IOT 6204: CINT - Clear User Interrupt Flag
2395
                                --
2396
 
2397
                                when o"6204" =>
2398
                                    usrtrpOP <= usrtrpopCLR;
2399
 
2400
                                --
2401
                                -- IOT 6205: PPC1 - Push (PC+1) to Stack 1
2402
                                -- The contents of the PC are incremented by
2403
                                -- one and the result is loaded into the memory
2404
                                -- location pointed to by the contents of SP1.
2405
                                -- SP1 is then decremented by 1.
2406
                                --
2407
                                -- The stacks are located in field 0 of memory.
2408
                                --
2409
 
2410
                                when o"6205" =>
2411
                                    if swCPU = swHD6120 then
2412
                                        wrOP     <= '1';
2413
                                        maOP     <= maopSP1;
2414
                                        mbOP     <= mbopPCP1;
2415
                                        sp1OP    <= spopDEC;
2416
                                        xmaOP    <= xmaopCLR;
2417
                                        memselOP <= '1';
2418
                                        busOP    <= busopWRZF;
2419
                                    end if;
2420
 
2421
                                --
2422
                                -- IOT 6206: PR0 - Panel Request 0
2423
                                -- The PNLTRP flag is set.  If the Interrupt Inhibit
2424
                                -- Register (ION) is not set, the CPU will enter
2425
                                -- panel mode instead of executing the next
2426
                                -- instruction.  If the Interrupt Inhibit Flip Flop
2427
                                -- is set, panel mode will be entered following the
2428
                                -- next JMP, JMS, RTN1 or RTN2 which clears the
2429
                                -- Interrupt inhibit flip flop.  This is a NOP in
2430
                                -- panel mode.
2431
                                --
2432
 
2433
                                when o"6206" =>
2434
                                    if swCPU = swHD6120 then
2435
                                        if CTRLFF = '0' then
2436
                                            pnltrpOP <= pnltrpopSET;
2437
                                        end if;
2438
                                    end if;
2439
 
2440
                                --
2441
                                -- IOT 6207: RSP1 - Read Stack 1 Pointer to AC
2442
                                -- The contents of SP1 is loaded Into the AC.
2443
                                --
2444
 
2445
                                when o"6207" =>
2446
                                    if swCPU = swHD6120 then
2447
                                        acOP <= acopSP1;
2448
                                    end if;
2449
 
2450
                                --
2451
                                -- IOT 6214: RDF - Read Data Field to AC<6:8>
2452
                                -- PDP8: The RDF ors the DF register with AC<6:8>.
2453
                                -- HD6120: The RDF replaces AC<6:8> with DF<0:2>.
2454
                                -- The other bits of the accumulator are unaffected
2455
                                --
2456
 
2457
                                when o"6214" =>
2458
                                    if swCPU = swHD6120 then
2459
                                        acOP <= acopRDF0;
2460
                                    else
2461
                                        acOP <= acopRDF1;
2462
                                    end if;
2463
 
2464
                                --
2465
                                -- IOT 6215: PAC1 - Push AC to Stack 1.
2466
                                -- The contents of the AC is loaded into the
2467
                                -- memory location pointed to by the contents
2468
                                -- of SP1. The contents of SP1 is then
2469
                                -- decremented by 1.
2470
                                --
2471
                                -- The stacks are located in field 0 of memory.
2472
                                --
2473
 
2474
                                when o"6215" =>
2475
                                    if swCPU = swHD6120 then
2476
                                        wrOP     <= '1';
2477
                                        maOP     <= maopSP1;
2478
                                        mbOP     <= mbopAC;
2479
                                        sp1OP    <= spopDEC;
2480
                                        xmaOP    <= xmaopCLR;
2481
                                        memselOP <= '1';
2482
                                        busOP    <= busopWRZF;
2483
                                    end if;
2484
 
2485
                                --
2486
                                -- IOT 6216: PR1 - Panel Request 1.
2487
                                -- The PNLTRP flag is set.  If the Interrupt Inhibit
2488
                                -- Register (ION) is not set, the CPU will enter
2489
                                -- panel mode instead of executing the next
2490
                                -- instruction.  If the Interrupt Inhibit Flip Flop
2491
                                -- is set, panel mode will be entered following the
2492
                                -- next JMP, JMS, RTN1 or RTN2 which clears the
2493
                                -- Interrupt inhibit flip flop.  This is a NOP in
2494
                                -- panel mode.
2495
                                --
2496
 
2497
                                when o"6216" =>
2498
                                    if swCPU = swHD6120 then
2499
                                        if CTRLFF = '0' then
2500
                                            pnltrpOP  <= pnltrpopSET;
2501
                                        end if;
2502
                                    end if;
2503
 
2504
                                --
2505
                                -- IOT 6217: LSP1 - Load Stack 1 Pointer from AC.
2506
                                -- The contents of the AC is loaded into SP1.
2507
                                -- The AC is cleared.
2508
                                --
2509
 
2510
                                when o"6217" =>
2511
                                    if swCPU = swHD6120 then
2512
                                        sp1OP <= spopAC;
2513
                                        acOP  <= acopCLA;
2514
                                    end if;
2515
 
2516
                                --
2517
                                -- IOT 6224: RIF - Read Instruction Field into AC<6:8>.
2518
                                -- PDP8: The RIF ors the IF/INF register with AC<6:8>.
2519
                                -- HD6120: The RIF replaces AC<6:8> with IF/INF<0:2>.
2520
                                -- The other bits of the accumulator are unaffected
2521
                                --
2522
 
2523
                                when o"6224" =>
2524
                                    if swCPU = swHD6120 then
2525
                                        acOP <= acopRIF0;
2526
                                    else
2527
                                        acOP <= acopRIF1;
2528
                                    end if;
2529
 
2530
                                --
2531
                                -- IOT 6225: RTN1 - Pop top of Stack 1 to PC
2532
                                --
2533
                                -- The contents of the stack pointer (SP1) is
2534
                                -- incremented by one.  The contents of the
2535
                                -- memory location pointed to by SP1 is loaded
2536
                                -- into the PC.
2537
                                --
2538
 
2539
                                when o"6225" =>
2540
                                    if swCPU = swHD6120 then
2541
                                        sp1OP     <= spopINC;
2542
                                        nextState <= stateRTN1;
2543
                                    end if;
2544
 
2545
                                --
2546
                                -- IOT 6226: PR2 - Panel Request 2.
2547
                                -- The PNLTRP flag is set.  If the Interrupt Inhibit
2548
                                -- Register (ION) is not set, the CPU will enter
2549
                                -- panel mode instead of executing the next
2550
                                -- instruction.  If the Interrupt Inhibit Flip Flop
2551
                                -- is set, panel mode will be entered following the
2552
                                -- next JMP, JMS, RTN1 or RTN2 which clears the
2553
                                -- Interrupt inhibit flip flop.  This is a NOP in
2554
                                -- panel mode.
2555
                                --
2556
 
2557
                                when o"6226" =>
2558
                                    if swCPU = swHD6120 then
2559
                                        if CTRLFF = '0' then
2560
                                            pnltrpOP <= pnltrpopSET;
2561
                                        end if;
2562
                                    end if;
2563
 
2564
                                --
2565
                                -- IOT 6227: RSP2 - Read Stack 2 Pointer to AC
2566
                                -- The contents of SP2 is loaded Into the AC.
2567
                                --
2568
 
2569
                                when o"6227" =>
2570
                                    if swCPU = swHD6120 then
2571
                                        acOP <= acopSP2;
2572
                                    end if;
2573
 
2574
                                --
2575
                                -- IOT 6234: RIB - Read Instruction Save Field into AC<6:8>
2576
                                -- and Data Save Field into AC<9:11>.
2577
                                -- PDP8: The RIB ors the ISF/DSF register with AC<6:11>.
2578
                                -- HD6120: The RIB replaces AC<6:11> with ISF/DSF.
2579
                                -- The other bits of the accumulator are unaffected
2580
                                --
2581
 
2582
                                when o"6234" =>
2583
                                    if swCPU = swHD6120 then
2584
                                        acOP <= acopRIB0;
2585
                                    else
2586
                                        acOP <= acopRIB1;
2587
                                    end if;
2588
 
2589
                                --
2590
                                -- IOT 6235: POP1 - Pop top of Stack 1 to AC
2591
                                -- The contents of SP1 is incremented by 1. The
2592
                                -- contents of the memory location pointed to
2593
                                -- by SP1 is then loaded into the AC.
2594
                                --
2595
                                -- The stacks are located in field 0 of memory.
2596
                                --
2597
 
2598
                                when o"6235" =>
2599
                                    if swCPU = swHD6120 then
2600
                                        maOP      <= maopSP1P1;
2601
                                        sp1OP     <= spopINC;
2602
                                        xmaOP     <= xmaopCLR;
2603
                                        memselOP  <= '1';
2604
                                        busOP     <= busopRDZFaddr;
2605
                                        nextState <= statePOPaddr;
2606
                                    end if;
2607
 
2608
                                --
2609
                                -- IOT 6236: PR3 - Panel Request 3.
2610
                                -- The PNLTRP flag is set.  If the Interrupt Inhibit
2611
                                -- Register (ION) is not set, the CPU will enter
2612
                                -- panel mode instead of executing the next
2613
                                -- instruction.  If the Interrupt Inhibit Flip Flop
2614
                                -- is set, panel mode will be entered following the
2615
                                -- next JMP, JMS, RTN1 or RTN2 which clears the
2616
                                -- Interrupt inhibit flip flop.  This is a NOP in
2617
                                -- panel mode.
2618
                                --
2619
 
2620
                                when o"6236" =>
2621
                                    if swCPU = swHD6120 then
2622
                                        if CTRLFF = '0' then
2623
                                            pnltrpOP <= pnltrpopSET;
2624
                                        end if;
2625
                                    end if;
2626
 
2627
                                --
2628
                                -- IOT 6237: LSP2 - Load Stack 2 Pointer from AC.
2629
                                -- The contents of the AC is loaded into SP2.
2630
                                -- The AC is cleared.
2631
                                --
2632
 
2633
                                when o"6237" =>
2634
                                    if swCPU = swHD6120 then
2635
                                        sp2OP <= spopAC;
2636
                                        acOP  <= acopCLA;
2637
                                    end if;
2638
 
2639
                                --
2640
                                -- IOT 6244: RMF - Restore Memory Fields.
2641
                                -- Load the contents of ISF into IB, OSF into OF,
2642
                                -- and set the Interrupt Inhibit Flip Flop. This instruction
2643
                                -- is used to restore the contents of the memory
2644
                                -- field registers to their values before an
2645
                                -- interrupt occurred.
2646
                                --
2647
                                -- Note: Setting the II causes the CPU to ignore
2648
                                -- interrupt requests until the next JMP, JMS,
2649
                                -- RTN1 or RTN2 Instruction is executed.  At that
2650
                                -- time the contents of IB are loaded into the
2651
                                -- IF/INF and the II cleared.
2652
                                --
2653
 
2654
                                when o"6244" =>
2655
                                    ubOP <= ubopSF;
2656
                                    ibOP <= ibopSF1to3;
2657
                                    dfOP <= dfopSF4to6;
2658
                                    iiOP <= iiopSET;
2659
                                    fzop <= fzopCLR;
2660
 
2661
                                --
2662
                                -- IOT 6245: PPC2 - Push (PC+1) to Stack 2
2663
                                -- The contents of the PC are Incremented by
2664
                                -- one and the result is loaded into the memory
2665
                                -- location pointed to by the contents of SP2.
2666
                                -- SP2 is then decremented by 1.
2667
                                --
2668
                                -- The stacks are located in field 0 of memory.
2669
                                --
2670
 
2671
                                when o"6245" =>
2672
                                    if swCPU = swHD6120 then
2673
                                        wrOP     <= '1';
2674
                                        maOP     <= maopSP2;
2675
                                        mbOP     <= mbopPCP1;
2676
                                        sp2OP    <= spopDEC;
2677
                                        xmaOP    <= xmaopCLR;
2678
                                        memselOP <= '1';
2679
                                        busOP    <= busopWRZF;
2680
                                    end if;
2681
 
2682
                                --
2683
                                -- IOT 6246: WSR - Write to Switch Register
2684
                                -- The contents of AC are written to the switch
2685
                                -- register and the AC is cleared.  This allows
2686
                                -- the switch register to be 'virtualized' in
2687
                                -- from panel mode for units without front panel
2688
                                -- interfaces.
2689
                                --
2690
 
2691
                                when o"6246" =>
2692
                                    if swCPU = swHD6120 then
2693
                                        srOP <= sropAC;
2694
                                        acOP <= acopCLA;
2695
                                    end if;
2696
 
2697
                                --
2698
                                -- IOT 6254: SINT - Skip on User Interrupt Flag
2699
                                --
2700
 
2701
                                when o"6254" =>
2702
                                    if USRTRP = '1' then
2703
                                        pcOP <= pcopINC;
2704
                                    end if;
2705
 
2706
                                --
2707
                                -- IOT 6255: PAC2 - Push AC to Stack 2.
2708
                                -- The contents of the AC is loaded into the
2709
                                -- memory location pointed to by the contents
2710
                                -- of SP2. The contents of SP2 is then
2711
                                -- decremented by 1.
2712
                                --
2713
                                -- The stacks are located in field 0 of memory.
2714
                                --
2715
 
2716
                                when o"6255" =>
2717
                                    if swCPU = swHD6120 then
2718
                                        wrOP     <= '1';
2719
                                        maOP     <= maopSP2;
2720
                                        mbOP     <= mbopAC;
2721
                                        sp1OP    <= spopDEC;
2722
                                        xmaOP    <= xmaopCLR;
2723
                                        memselOP <= '1';
2724
                                        busOP    <= busopWRZF;
2725
                                    end if;
2726
 
2727
                                --
2728
                                -- IOT 6256: GCF
2729
                                -- Get current fields and flags
2730
                                --
2731
 
2732
                                when o"6256" =>
2733
                                    acOP <= acopGCF;
2734
 
2735
                                --
2736
                                -- IOF 6264: CUF - Clear User Flag
2737
                                -- The CUF instruction clears the User Flag (UF) and
2738
                                -- sets the Interrupt Inhibit Register (II).
2739
                                --
2740
 
2741
                                when o"6264" =>
2742
                                    ubOP <= ubopCLR;
2743
                                    iiOP <= iiopSET;
2744
 
2745
                                --
2746
                                -- IOT 6265: RTN2 - Pop top of Stack 2 to PC
2747
                                --
2748
                                -- The contents of the stack pointer (SP2) is
2749
                                -- incremented by one.  The contents of the
2750
                                -- memory location pointed to by SP2 is loaded
2751
                                -- into the PC.
2752
                                --
2753
 
2754
                                when o"6265" =>
2755
                                    if swCPU = swHD6120 then
2756
                                        sp2op     <= spopINC;
2757
                                        nextState <= stateRTN2;
2758
                                    end if;
2759
 
2760
                                --
2761
                                -- IOT 6266: CPD - Clear Panel Data Flag
2762
                                -- Clears the Panel Data Flag (PDF) so that indirect
2763
                                -- data operands of panel mode instructions are
2764
                                -- obtained from main memory.
2765
                                --
2766
 
2767
                                when o"6266" =>
2768
                                    if swCPU = swHD6120 then
2769
                                        if CTRLFF = '1' then
2770
                                            pdfOP <= pdfopCLR;
2771
                                        end if;
2772
                                    end if;
2773
 
2774
                                --
2775
                                -- IOT 6274: SUF - Set User Flag
2776
                                -- The SUF instruction sets the User Flag (UF) and
2777
                                -- sets the Interrupt Inhibit Flip Flop (II).
2778
                                --
2779
 
2780
                                when o"6274" =>
2781
                                    ubOP <= ubopSET;
2782
                                    iiOP <= iiopSET;
2783
 
2784
                                --
2785
                                -- IOT 6275: POP2 - Pop top of Stack 2 to AC
2786
                                -- The contents of SP2 is incremented by 1. The contents
2787
                                -- of the memory location pointed to by SP2 is then
2788
                                -- loaded into the AC.
2789
                                --
2790
                                -- The stacks are located in field 0 of memory.
2791
                                --
2792
 
2793
                                when o"6275" =>
2794
                                    if swCPU = swHD6120 then
2795
                                        maOP      <= maopSP2P1;
2796
                                        sp2OP     <= spopINC;
2797
                                        xmaOP     <= xmaopCLR;
2798
                                        memselOP  <= '1';
2799
                                        busOP     <= busopRDZFaddr;
2800
                                        nextState <= statePOPaddr;
2801
                                     end if;
2802
 
2803
                                --
2804
                                -- IOT 6276: SPD - Set Panel Data Flag
2805
                                -- Sets the Panel Data Flag (PDF) so that indirect
2806
                                -- data operands of panel mode instructions are
2807
                                -- obtained from panel memory.
2808
                                --
2809
 
2810
                                when o"6276" =>
2811
                                    if swCPU = swHD6120 then
2812
                                        if CTRLFF = '1' then
2813
                                            pdfOP <= pdfopSET;
2814
                                        end if;
2815
                                    end if;
2816
 
2817
                                --
2818
                                -- Unhandled IOTs
2819
                                --
2820
 
2821
                                when others =>
2822
 
2823
                                    if (IR(0 to 8) = o"600") or (IR(0 to 5)  = o"62") then
2824
 
2825
                                        --
2826
                                        -- Internal IOTS (600x and 62xx) that are
2827
                                        -- not handled above.
2828
                                        --
2829
 
2830
                                        assert false report "Unhandled Internal IOT" severity warning;
2831
                                        nextState <= stateLaLa;
2832
 
2833
                                    else
2834
 
2835
                                        --
2836
                                        -- External IOTS.  Handled by external
2837
                                        -- devices.
2838
                                        --
2839
 
2840
                                        wrOP      <= '1';
2841
                                        datafOP   <= '1';
2842
                                        lxdarOP   <= '1';
2843
                                        maOP      <= maopIR;
2844
                                        mbOP      <= mbopAC;
2845
                                        busOP     <= busopWRIOT;
2846
                                        nextState <= stateIOTdecode;
2847
 
2848
                                    end if;
2849
                            end case;
2850
                        end if;
2851
 
2852
                    --
2853
                    -- Operate Instructions
2854
                    --
2855
 
2856
                    when opOPR =>
2857
 
2858
                        if IR(3) = '0' then
2859
 
2860
                            --
2861
                            -- Operate Group 1
2862
                            --
2863
                            --                        Group 1
2864
                            --  |           |           |           |           |
2865
                            --  |---|---|---|---|---|---|---|---|---|---|---|---|
2866
                            --  | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10| 11|
2867
                            --  | 1 | 1 | 1 | 0 |CLA|CLL|CMA|CML| R1| R2| R3|IAC|
2868
                            --  |---|---|---|---|---|---|---|---|---|---|---|---|
2869
                            --                    |   |   |   |   |   |   |   |
2870
                            --        Sequence:   1   1   2   2   4   4   4   3
2871
                            --
2872
                            --
2873
 
2874
                            --
2875
                            -- Operate Group 1 Sequence 1 and Sequence 2
2876
                            -- This state executes all combinations of Sequence 1
2877
                            -- and Sequence 2 operations
2878
                            --
2879
 
2880
                            case IR(4 to 7) is
2881
 
2882
                                --
2883
                                -- OP 7000: NOP
2884
                                --
2885
 
2886
                                when "0000" =>
2887
                                    null;
2888
 
2889
                                --
2890
                                -- OP 7020: CML - Complement Link Register
2891
                                -- The contents of the LINK is complemented.
2892
                                --
2893
 
2894
                                when "0001" =>
2895
                                    acop <= acopCML;
2896
 
2897
                                --
2898
                                -- OP 7040: CMA - Complement accumulator.
2899
                                -- The contents of the AC is replaced by its
2900
                                -- 1's  complement.
2901
                                --
2902
 
2903
                                when "0010" =>
2904
                                    acop <= acopCMA;
2905
 
2906
                                --
2907
                                -- OP 7060: CMA CML
2908
                                -- The contents of the LINK is complemented.
2909
                                -- The contents of the AC is replaced by its
2910
                                -- 1's complement.
2911
 
2912
                                when "0011" =>
2913
                                    acOP <= acopCMACML;
2914
 
2915
                                --
2916
                                -- OP 7100: CLL - Clear LINK
2917
                                -- The LINK is set to zero.
2918
                                --
2919
 
2920
                                when "0100" =>  -- CLL
2921
                                    acOP <= acopCLL;
2922
 
2923
                                --
2924
                                -- OP 7120: CLL CML (STL) - Set LINK.
2925
                                -- Clear LINK then Complement LINK.  The LINK
2926
                                -- is set to one.
2927
                                --
2928
 
2929
                                when "0101" =>
2930
                                    acop <= acopCLLCML;
2931
 
2932
                                --
2933
                                -- OP 7140: CLL CMA -
2934
                                -- Clear LINK and Complement accumulator,
2935
                                --
2936
 
2937
                                when "0110" =>
2938
                                    acOP <= acopCLLCMA;
2939
                                --
2940
                                -- OP 7160: CLL CMA CML - STL CMA
2941
                                -- Set LINK and Complement accumulator,
2942
                                --
2943
 
2944
                                when "0111" =>
2945
                                    acOP <= acopCLLCMACML;
2946
 
2947
                                --
2948
                                -- OP 7200: CLA - Clear accumulator
2949
                                -- Load AC with "0000".
2950
                                --
2951
 
2952
                                when "1000" =>
2953
                                    acOP <= acopCLA;
2954
 
2955
                                --
2956
                                -- OP 7220: CLA CML
2957
                                -- Clear Accumulator and Complement LINK
2958
                                --
2959
 
2960
                                when "1001" =>
2961
                                    acOP <= acopCLACML;
2962
 
2963
                                --
2964
                                -- OP 7240: CLA CMA (STA)
2965
                                -- Clear Accumulator then Complement
2966
                                -- Accumulator, or Set Accumulator.
2967
                                --
2968
 
2969
                                when "1010" =>
2970
                                    acOP <= acopCLACMA;
2971
 
2972
                                --
2973
                                -- OP 7260: CLA CMA CML (STA CML)
2974
                                -- Set Accumulator and Complement LINK.
2975
                                --
2976
 
2977
                                when "1011" =>
2978
                                    acOP <= acopCLACMACML;
2979
 
2980
                                --
2981
                                -- OP 7300: CLA CLL
2982
                                -- Clear AC and Clear LINK.
2983
                                --
2984
 
2985
                                when "1100" =>
2986
                                    acOP <= acopCLACLL;
2987
 
2988
                                --
2989
                                -- OP 7320: CLA CLL CML
2990
                                -- Clear AC and Set LINK
2991
                                --
2992
 
2993
                                when "1101" =>
2994
                                    acOP <= acopCLACLLCML;
2995
 
2996
                                --
2997
                                -- OP 7340: CLA CLL CMA, STA CLL
2998
                                -- Set Accumulator and Clear LINK
2999
                                --
3000
 
3001
                                when "1110" =>
3002
                                    acOP <= acopCLACLLCMA;
3003
 
3004
                                --
3005
                                -- OP 7360: CLA CLL CMA CML, STA STL
3006
                                -- Set Accumulator and Set LINK
3007
                                --
3008
 
3009
                                when "1111" =>
3010
                                    acOP <= acopCLACLLCMACML;
3011
 
3012
                                --
3013
                                -- Everything else
3014
                                --
3015
 
3016
                                when others =>
3017
                                    null;
3018
 
3019
                            end case;
3020
 
3021
                            --
3022
                            -- Determine the next state.  Skip states if
3023
                            -- possible.
3024
                            --
3025
 
3026
                            if IR(11) = '1' then
3027
                                nextState <= stateOprGroup1Seq3;
3028
                            else
3029
                                if IR(8) = '1' or IR(9) = '1' or IR(10) = '1' then
3030
                                    nextState <= stateOprGroup1Seq4;
3031
                                else
3032
                                    nextState <= stateDone;
3033
                                end if;
3034
                            end if;
3035
 
3036
                        else    -- IR(3) = '1'
3037
 
3038
                            if IR(11) = '0' then
3039
 
3040
                                --
3041
                                -- Operate Group 2
3042
                                --
3043
                                --                        Group 2
3044
                                --  |           |           |           |           |
3045
                                --  |---|---|---|---|---|---|---|---|---|---|---|---|
3046
                                --  | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10| 11|
3047
                                --  | 1 | 1 | 1 | 1 |CLA|SMA|SZA|SNL| 0 |OSR|HLT| 0 |
3048
                                --  | 1 | 1 | 1 | 1 |CLA|SPA|SNA|SZL| 1 |OSR|HLT| 0 |
3049
                                --  |---|---|---|---|---|---|---|---|---|---|---|---|
3050
                                --                    |   |   |   |       |   |
3051
                                --        Sequence:   2   1   1   1       3   3
3052
                                --
3053
                                --
3054
 
3055
                                --
3056
                                -- This state handles Operating Group 2
3057
                                -- Sequence 1
3058
                                --
3059
 
3060
                                case IR(5 to 8) is
3061
 
3062
                                    --
3063
                                    -- OP 7400: NOP
3064
                                    --
3065
 
3066
                                    when "0000" =>
3067
                                        null;
3068
 
3069
                                    --
3070
                                    -- OP 7410: SKP - SKIP
3071
                                    -- The content of the PC is incremented by 1,
3072
                                    -- to skip the next Instruction.
3073
                                    --
3074
 
3075
                                    when "0001" =>
3076
                                        pcop <= pcopINC;
3077
 
3078
                                    --
3079
                                    -- OP 7420: SNL
3080
                                    -- Skip if LINK = 1
3081
                                    --
3082
 
3083
                                    when "0010" =>
3084
                                        if L = '1' then
3085
                                            pcop <= pcopINC;
3086
                                        end if;
3087
 
3088
                                    --
3089
                                    -- OP 7430: SZL
3090
                                    -- Skip if LINK = 0
3091
                                    --
3092
 
3093
                                    when "0011" =>
3094
                                        if L = '0' then
3095
                                            pcop <= pcopINC;
3096
                                        end if;
3097
 
3098
                                    --
3099
                                    -- OP 7440: SZA
3100
                                    -- Skip on zero accumulator (AC = "0000")
3101
                                    --
3102
 
3103
                                    when "0100" =>
3104
                                        if AC = o"0000" then
3105
                                            pcop <= pcopINC;
3106
                                        end if;
3107
 
3108
                                    --
3109
                                    -- OP 7450: SNA
3110
                                    -- Skip on non-zero accumulator
3111
                                    --
3112
 
3113
                                    when "0101" =>
3114
                                        if AC /= o"0000" then
3115
                                            pcop <= pcopINC;
3116
                                        end if;
3117
 
3118
                                    --
3119
                                    -- OP 7460: SZA SNL
3120
                                    -- Skip if AC="0000" or if LINK = 1
3121
                                    --
3122
 
3123
                                    when "0110" =>
3124
                                        if ((AC = o"0000") or (L = '1')) then
3125
                                            pcop <= pcopINC;
3126
                                        end if;
3127
 
3128
                                    --
3129
                                    -- OP 7470: SNA SZL
3130
                                    -- Skip if AC not "0000" and if LINK = 1
3131
                                    --
3132
 
3133
                                    when "0111" =>
3134
                                        if ((AC /= o"0000") and (L = '0')) then
3135
                                            pcop <= pcopINC;
3136
                                        end if;
3137
 
3138
                                    --
3139
                                    -- OP 7500: SMA
3140
                                    -- Skip on negative (minus) accumulator (AC0=1)
3141
                                    --
3142
 
3143
                                    when "1000" =>
3144
                                        if AC(0) = '1' then
3145
                                            pcop <= pcopINC;
3146
                                        end if;
3147
 
3148
                                    --
3149
                                    -- OP 7510: SPA
3150
                                    -- Skip on positive accumulator (AC0=0)
3151
                                    --
3152
 
3153
                                    when "1001" =>
3154
                                        if AC(0) = '0' then
3155
                                            pcop <= pcopINC;
3156
                                        end if;
3157
 
3158
                                    --
3159
                                    -- OP 7520: SMA SNL
3160
                                    -- Skip if AC is negative (minus) or if LINK is 1
3161
                                    --
3162
 
3163
                                    when "1010" =>
3164
                                        if ((AC(0) = '1') or (L = '1')) then
3165
                                            pcop <= pcopINC;
3166
                                        end if;
3167
 
3168
                                    --
3169
                                    -- OP 7530: SPA SZL
3170
                                    -- Skip if AC is positive and if LINK is 0
3171
                                    --
3172
 
3173
                                    when "1011" =>
3174
                                        if ((AC(0) = '0') and (L = '0')) then
3175
                                            pcop <= pcopINC;
3176
                                        end if;
3177
 
3178
                                    --
3179
                                    -- OP 7540: SMA SZA - Skip if AC is minus or zero
3180
                                    --
3181
 
3182
                                    when "1100" =>
3183
                                        if ((AC(0) = '1') or (AC = o"0000")) then
3184
                                            pcop <= pcopINC;
3185
                                        end if;
3186
 
3187
                                    --
3188
                                    -- OP 7550: SPA SNA
3189
                                    -- Skip if AC is positive and non-zero
3190
                                    --
3191
 
3192
                                    when "1101" =>
3193
                                        if ((AC(0) = '0') and (AC /= o"0000")) then
3194
                                            pcop <= pcopINC;
3195
                                        end if;
3196
 
3197
                                    --
3198
                                    -- OP 7560: SMA SZA SNL
3199
                                    -- Skip if AC is minus or if AC="0000" or if LINK is 1
3200
                                    --
3201
 
3202
                                    when "1110" =>
3203
                                        if ((AC(0) = '1') or (AC = o"0000") or (L = '1')) then
3204
                                            pcop <= pcopINC;
3205
                                        end if;
3206
 
3207
                                    --
3208
                                    -- OP 7570: SPA SNA SZL
3209
                                    -- Skip if AC is positive, nonzero, and if LINK is zero.
3210
                                    --
3211
 
3212
                                    when "1111" =>
3213
                                        if ((AC(0) = '0') and (AC /= o"0000") and (L = '0')) then
3214
                                            pcop <= pcopINC;
3215
                                        end if;
3216
 
3217
                                    --
3218
                                    -- Everything else
3219
                                    --
3220
 
3221
                                    when others =>
3222
                                        null;
3223
 
3224
                                end case;
3225
 
3226
                                --
3227
                                -- Determine if there are any Group 2 Sequence
3228
                                -- 2 operations to perform.  Skip states if not.
3229
                                --
3230
 
3231
                                if IR(4) = '1' or IR(9) = '1' or IR(10) = '1' then
3232
                                    nextState <= stateOprGroup2Seq2;
3233
                                else
3234
                                    nextstate <= stateDone;
3235
                                end if;
3236
 
3237
                            else  -- IR(11) = '1'
3238
 
3239
                                --
3240
                                --
3241
                                -- Decode Group 3 Sequence 1,2 Opcode
3242
                                --
3243
                                --                        Group 3
3244
                                --  |           |           |           |           |
3245
                                --  |---|---|---|---|---|---|---|---|---|---|---|---|
3246
                                --  | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10| 11|
3247
                                --  | 1 | 1 | 1 | 1 |CLA|MQA| 0 |MQL| 0 | 0 | 0 | 1 |
3248
                                --  |---|---|---|---|---|---|---|---|---|---|---|---|
3249
                                --                    |   |       |
3250
                                --        Sequence:   1   2       2
3251
                                --
3252
                                -- Note: In the state machine, Sequence 1 and Sequence 2
3253
                                -- are handled together to save time (cycles).
3254
                                --
3255
                                -- Operate Group 3, 3A and 3B instructions.
3256
                                --
3257
                                -- HD6120: If bits 6, 8, 9 or 10 are set to a
3258
                                -- one, instruction execution is not altered but the
3259
                                -- instruction becomes uninterruptable by either
3260
                                -- panel or normal interrupts.  That is, the next
3261
                                -- instruction is guaranteed to be fetched barring
3262
                                -- a reset, DMAREQ or RUN/HLT flip flop in the
3263
                                -- HLT state.
3264
                                --
3265
 
3266
                                if ((swCPU = swHD6120 and IR( 6) = '1') or
3267
                                    (swCPU = swHD6120 and IR( 8) = '1') or
3268
                                    (swCPU = swHD6120 and IR( 9) = '1') or
3269
                                    (swCPU = swHD6120 and IR(10) = '1')) then
3270
                                    idOP <= idopSET;
3271
                                end if;
3272
 
3273
                                --
3274
                                -- OP 74x1: EAE Instructions
3275
                                --
3276
                                -- The PDP8/L had no provision for EAE
3277
                                --
3278
                                -- These instructions were only available pre
3279
                                -- PDP8/E if EAE was added.
3280
                                --
3281
                                -- These instruction work on PDP8/E and later
3282
                                -- with or without EAE.
3283
                                --
3284
 
3285
                                if ((swCPU = swPDP8  and swOPT.KE8 = '1') or
3286
                                    (swCPU = swPDP8S and swOPT.KE8 = '1') or
3287
                                    (swCPU = swPDP8I and swOPT.KE8 = '1') or
3288
                                    -- PDP8L never supported EAE
3289
                                    (swCPU = swPDP8E) or
3290
                                    (swCPU = swPDP8F) or
3291
                                    (swCPU = swPDP8M) or
3292
                                    (swCPU = swPDP8A) or
3293
                                    (swCPU = swHD6120)) then
3294
 
3295
                                    EAEIR := IR(4) & IR(5) & IR(7) & '0';
3296
                                    case EAEIR(0 to 2) is
3297
 
3298
                                        --
3299
                                        -- OP 7401: NOP
3300
                                        --
3301
 
3302
                                        when "000" =>
3303
                                            null;
3304
 
3305
                                        --
3306
                                        -- OP 7421: MQL - MQ register load
3307
                                        -- The MQ is loaded with the contents of the
3308
                                        -- AC and the AC is cleared. The original
3309
                                        -- contents of the MQ is lost.
3310
                                        --
3311
 
3312
                                        when "001" =>
3313
                                            mqOP <= mqopAC;
3314
                                            acOP <= acopCLA;
3315
 
3316
                                        --
3317
                                        -- OP 7501: MQA - MQ "OR" with accumulator.
3318
                                        -- OR the contents of the MQ is "OR"ed with
3319
                                        -- the contents of the AC, and the result left
3320
                                        -- in the AC.  The MQ is not modified.
3321
                                        --
3322
 
3323
                                        when "010" =>
3324
                                            acOP <= acopORMQ;
3325
 
3326
                                        --
3327
                                        -- OP 7521: SWP - Swap contents of AC and MQ.
3328
                                        -- The contents of the AC and MQ are exchanged
3329
                                        --
3330
                                        -- The SWP instruction does not work on
3331
                                        -- Straight 8 (PDP8)
3332
 
3333
                                        when "011" =>
3334
                                            if ((swCPU = swPDP8) or
3335
                                                (swCPU = swPDP8I)) then
3336
                                                -- What should this do?
3337
                                                acOP <= acopNOP;
3338
                                                mqOP <= mqopNOP;
3339
                                            else
3340
                                                acOP <= acopMQ;
3341
                                                mqOP <= mqopAC;
3342
                                            end if;
3343
 
3344
                                        --
3345
                                        -- OP 7601: CLA - Clear Accumulator
3346
                                        -- The accumulator may be cleared prior to other
3347
                                        -- group three microcoded operations. Unless
3348
                                        -- microcoded with other group three instructions,
3349
                                        -- PDP-8 assemblers generally assume that the CLA
3350
                                        -- mnemonic refers to the group one instruction.
3351
                                        --
3352
 
3353
                                        when "100" =>
3354
                                            acOP <= acopCLA;
3355
 
3356
                                        --
3357
                                        -- OP 7621: CLA/MQL - CAM - Clear AC and MQ
3358
                                        -- This instruction first clears AC, so the
3359
                                        -- result is to clear both AC and MQ.
3360
                                        --
3361
 
3362
                                        when "101" =>
3363
                                            acOP <= acopCLA;
3364
                                            mqOP <= mqopCLR;
3365
 
3366
                                        --
3367
                                        -- OP 7701: CLA MQA - ACL - Microcode CLA MQA
3368
                                        -- This instruction first clears AC, so the
3369
                                        -- result is to load AC with the contents
3370
                                        -- of MQ.
3371
                                        --
3372
 
3373
                                        when "110" =>
3374
                                            acOP <= acopMQ;
3375
 
3376
                                        --
3377
                                        -- OP 7721: CLA SWP - Clear AC, then swap.
3378
                                        -- The MQ is loaded into the AC;
3379
                                        -- "0000" is loaded into the MQ.
3380
                                        --
3381
 
3382
                                        when "111" =>
3383
                                            acOP <= acopMQ;
3384
                                            mqOP <= mqopCLR;
3385
 
3386
                                        --
3387
                                        -- Everything else
3388
                                        --
3389
 
3390
                                        when others =>
3391
                                            null;
3392
 
3393
                                    end case;
3394
 
3395
                                    --
3396
                                    -- Group 3 Sequence 3 instruction are
3397
                                    -- supported with EAE installed.
3398
                                    --
3399
 
3400
                                    if swOPT.KE8 = '1' then
3401
                                        nextState <= stateOprGroup3Seq3;
3402
                                    else
3403
                                        nextstate <= stateDone;
3404
                                    end if;
3405
 
3406
                                end if;  -- Group 3
3407
                            end if;  -- IR(11)
3408
                        end if;  -- IR(3)
3409
 
3410
                    --
3411
                    -- Everything else
3412
                    --
3413
 
3414
                    when others =>
3415
                        null;
3416
 
3417
                end case;
3418
 
3419
            --
3420
            -- IOT Decode State
3421
            -- The previous state peformed an IOT write cycle.  This state
3422
            -- decides the devc and skip that is return by the IOT interface.
3423
            --
3424
 
3425
            when stateIOTdecode =>
3426
 
3427
                --
3428
                -- Handle Skip
3429
                --
3430
 
3431
                if dev.skip = '1' then
3432
                    pcOP <= pcopINC;
3433
                end if;
3434
 
3435
                --
3436
                -- Handle CLA
3437
                --
3438
 
3439
                if dev.devc = devWRCLR or dev.devc = devRDCLR then
3440
                    acOP <= acopCLA;
3441
                end if;
3442
 
3443
                --
3444
                -- Handle RD and WR
3445
                --
3446
 
3447
                if dev.devc = devRD or dev.devc = devRDCLR then
3448
                    rdOP      <= '1';
3449
                    datafOP   <= '1';
3450
                    lxdarOP   <= '1';
3451
                    busOP     <= busopRDIOT;
3452
                    nextState <= stateIOT;
3453
                else
3454
                    nextState <= stateDone;
3455
                end if;
3456
 
3457
            --
3458
            -- stateIOT:
3459
            -- The previous state performed a Read Data Cycle.  OR the IOT data
3460
            -- that was read with AC.
3461
            --
3462
 
3463
            when stateIOT =>
3464
                acOP      <= acopORMD;
3465
                nextState <= stateDone;
3466
 
3467
            --
3468
            -- Operate Group1 Sequence 3 State
3469
            --
3470
 
3471
            when stateOprGroup1Seq3 =>
3472
 
3473
                --
3474
                -- OP 7001: IAC - Increment accumulator.
3475
                -- The contents of the AC is incremented by 1.
3476
                -- Carry out complements the LINK.
3477
                --
3478
 
3479
                if IR(11) = '1' then
3480
                    acOP <= acopIAC;
3481
                end if;
3482
 
3483
                --
3484
                -- Determine the next state
3485
                --
3486
 
3487
                if IR(8) = '1' or IR(9) = '1' or IR(10) = '1' then
3488
                    nextState <= stateOprGroup1Seq4;
3489
                else
3490
                    nextState <= stateDone;
3491
                end if;
3492
 
3493
            --
3494
            -- Operate Group1 Sequence 4 State
3495
            --
3496
 
3497
            when stateOprGroup1Seq4 =>
3498
 
3499
                case IR(8 to 10) is
3500
 
3501
                    --
3502
                    -- OP 7000: NOP
3503
                    --
3504
 
3505
                    when "000" =>
3506
                        null;
3507
 
3508
                    --
3509
                    -- OP 7002: BSW - Byte swap
3510
                    --
3511
 
3512
                    when "001" =>
3513
 
3514
                        --
3515
                        -- PDP-8/E and later
3516
                        -- OP 7002: BSW - Byte swap
3517
                        -- AC<O-5> are exchanged with AC<6-11> respectively.
3518
                        -- The LINK is not changed.
3519
                        --
3520
 
3521
                        if ((swCPU = swPDP8E) or
3522
                            (swCPU = swPDP8F) or
3523
                            (swCPU = swPDP8A) or
3524
                            (swCPU = swHD6120)) then
3525
                            acOP <= acopBSW;
3526
 
3527
                        --
3528
                        -- Pre PDP8/E
3529
                        -- OP 7002: Equivalent to a NOP
3530
                        --
3531
 
3532
                        else
3533
                            null;
3534
 
3535
                        end if;
3536
 
3537
                    --
3538
                    -- OP 7004: RAL - Rotate accumulator left.
3539
                    -- The contents of the AC and LINK are rotated one
3540
                    -- binary position to the left. AC(O) is shifted to
3541
                    -- LINK and LINK is shifted to AC(11).
3542
                    --
3543
                    -- RAL combined with IAC only works on PDP8I and later
3544
                    -- RAL combined with CMA is broke on on PDP8S
3545
                    --
3546
 
3547
                    when "010" =>
3548
                        if ((swCPU = swPDP8  and IR(11) = '1') or
3549
                            (swCPU = swPDP8S and IR(11) = '1')) then
3550
                            -- What should this do?
3551
                            acOP <= acopNOP;
3552
                        elsif swCPU = swPDP8S and IR(6) = '1' then
3553
                            -- What should this do?
3554
                            acOP <= acopNOP;
3555
                        else
3556
                            acOP <= acopRAL;
3557
                        end if;
3558
 
3559
                    --
3560
                    -- OP 7006: RTL - Rotate two left.
3561
                    -- Equivalent to two RAL's.
3562
                    --
3563
                    -- RTL combined with IAC only works on PDP8I and later
3564
                    -- RTL combined with CMA is broke on on PDP8S
3565
                    --
3566
 
3567
                    when "011" =>
3568
                        if ((swCPU = swPDP8  and IR(11) = '1') or
3569
                            (swCPU = swPDP8S and IR(11) = '1')) then
3570
                            -- What should this do?
3571
                            acOP <= acopNOP;
3572
                        elsif swCPU = swPDP8S and IR(6) = '1' then
3573
                            -- What should this do?
3574
                            acOP <= acopNOP;
3575
                        else
3576
                            acOP <= acopRTL;
3577
                        end if;
3578
 
3579
                    --
3580
                    -- OP 7010: RAR - Rotate accumulator right.
3581
                    -- The contents of the AC and LINK are rotated one
3582
                    -- binary position to the right.  AC(11) is shifted
3583
                    -- into the LINK, and LINK is shifted to AC(O).
3584
                    --
3585
                    -- RAR combined with IAC only works on PDP8I and later
3586
                    -- RAR combined with CMA is broke on on PDP8S
3587
                    --
3588
 
3589
                    when "100" =>
3590
                        if ((swCPU = swPDP8  and IR(11) = '1') or
3591
                            (swCPU = swPDP8S and IR(11) = '1')) then
3592
                            -- What should this do?
3593
                            acOP <= acopNOP;
3594
                        elsif swCPU = swPDP8S and IR(6) = '1' then
3595
                            -- What should this do?
3596
                            acOP <= acopNOP;
3597
                        else
3598
                            acOP <= acopRAR;
3599
                        end if;
3600
 
3601
                    --
3602
                    -- OP 7012: RTR - Rotate two right.
3603
                    -- Equivalent to two RAR's.
3604
                    --
3605
                    -- RTR combined with IAC only works on PDP8I and later
3606
                    -- RTR combined with CMA is broke on on PDP8S
3607
                    --
3608
 
3609
                    when "101" =>
3610
                        if ((swCPU = swPDP8  and IR(11) = '1') or
3611
                            (swCPU = swPDP8S and IR(11) = '1')) then
3612
                            -- What should this do?
3613
                            acOP <= acopNOP;
3614
                        elsif swCPU = swPDP8S and IR(6) = '1' then
3615
                            -- What should this do?
3616
                            acOP <= acopNOP;
3617
                        else
3618
                            acOP <= acopRTR;
3619
                        end if;
3620
 
3621
                    --
3622
                    -- OP 7014: RAL RAR: This instruction did a lot
3623
                    -- of different things...
3624
                    --
3625
                    -- HD6120: R3L - Rotate 3 Left
3626
                    -- HD6100: NOP
3627
                    -- PDP8/A: Load AC with the next address (PC)
3628
                    -- PDP8/E: ANDs AC with OPCODE
3629
                    -- PDP8/I: What should this do?
3630
                    -- PDP8/S: What should this do?
3631
                    -- PDP8/L: What should this do?
3632
                    -- PDP8:   What should this do?
3633
                    --
3634
 
3635
                    when "110" =>
3636
                        case swCPU is
3637
                            when swHD6120 =>
3638
                                acOP <= acopR3L;
3639
                            when swHD6100 =>
3640
                                acOP <= acopNOP;
3641
                            when swPDP8A =>
3642
                                acOP <= acopPC;
3643
                            when swPDP8E =>
3644
                                acOP <= acopUNDEF1;
3645
                            when swPDP8I =>
3646
                                acOP <= acopNOP;
3647
                            when swPDP8S =>
3648
                                acOP <= acopNOP;
3649
                            when swPDP8L =>
3650
                                acOP <= acopNOP;
3651
                            when swPDP8 =>
3652
                                acOP <= acopNOP;
3653
                            when others =>
3654
                                acOP <= acopNOP;
3655
                        end case;
3656
 
3657
                    --
3658
                    -- OP 7016: RTL RTR: This instruction did a lot
3659
                    -- of different things...
3660
                    --
3661
                    -- HD6120: NOP
3662
                    -- HD6100: NOP
3663
                    -- PDP8/A: Load AC with the next address (PC)
3664
                    -- PDP8/E: Load AC with 5 MSB of addr and 7 LSB of opcode
3665
                    -- PDP8/I: What should this do?
3666
                    -- PDP8/S: What should this do?
3667
                    -- PDP8/L: What should this do?
3668
                    -- PDP8:   What should this do?
3669
                    --
3670
 
3671
                    when "111" =>
3672
                        case swCPU is
3673
                            when swHD6120 =>
3674
                                acOP <= acopNOP;
3675
                            when swHD6100 =>
3676
                                acOP <= acopNOP;
3677
                            when swPDP8A =>
3678
                                acOP <= acopPC;
3679
                            when swPDP8E =>
3680
                                acOP <= acopUNDEF2;
3681
                            when swPDP8I =>
3682
                                acOP <= acopNOP;
3683
                            when swPDP8S =>
3684
                                acOP <= acopNOP;
3685
                            when swPDP8L =>
3686
                                acOP <= acopNOP;
3687
                            when swPDP8 =>
3688
                                acOP <= acopNOP;
3689
                            when others =>
3690
                                acOP <= acopNOP;
3691
                        end case;
3692
 
3693
                    --
3694
                    -- Everything else
3695
                    --
3696
 
3697
                    when others =>
3698
                        null;
3699
 
3700
                end case;
3701
                nextState <= stateDone;
3702
 
3703
            --
3704
            -- Operate Group 2 Sequence 2 State
3705
            --
3706
 
3707
            when stateOprGroup2Seq2 =>
3708
 
3709
                --
3710
                -- In USER mode, the OSR and HLT instructions are privledged
3711
                -- and generate a User Mode interrupt.
3712
                --
3713
 
3714
                if ((UF = '1' and IR( 9) = '1') or
3715
                    (UF = '1' and IR(10) = '1')) then
3716
                    if IR(4) = '1' then
3717
                        acOP <= acopCLA;
3718
                    end if;
3719
                    usrtrpOP  <= usrtrpopSET;
3720
 
3721
                else
3722
 
3723
                    --
3724
                    -- OP 7402: HLT - HALT
3725
                    -- OP 7406: OSR HLT - HALT
3726
                    -- OP 7606: CLA OSR HLT, LAS HLT - HALT
3727
                    -- The HALT Operation is not particularly sequence
3728
                    -- sensitive so it is decoded here.  The CPU will halt at
3729
                    -- the end of the current instruction.
3730
                    --
3731
 
3732
                    if IR(10) = '1' then
3733
                        hlttrpOP <= hlttrpopSET;
3734
                    end if;
3735
 
3736
                    if IR(9) = '1' then
3737
 
3738
                        --
3739
                        -- OP 7604: LAS : Load AC with Switches.
3740
                        --
3741
 
3742
                        if IR(4) = '1' then
3743
                            acOP <= acopLAS;
3744
 
3745
                        --
3746
                        -- OP 7404: OSR : OR Switch Register with accumulator.
3747
                        --
3748
 
3749
                        else
3750
                            acOP <= acopOSR;
3751
 
3752
                        end if;
3753
 
3754
                    else
3755
 
3756
                        --
3757
                        -- OP 7600: CLA - Clear Accumulator
3758
                        --
3759
 
3760
                        if IR(4) = '1' then
3761
                            acOP <= acopCLA;
3762
 
3763
                        end if;
3764
 
3765
                    end if;
3766
 
3767
                end if;
3768
                nextState <= stateDone;
3769
 
3770
            --
3771
            -- Operate Group 3 Sequence 3 Mode A State
3772
            --
3773
 
3774
            when stateOprGroup3Seq3 =>
3775
 
3776
                --
3777
                --                    Group 3 Mode A
3778
                --
3779
                --  |           |           |           |           |
3780
                --  |---|---|---|---|---|---|---|---|---|---|---|---|
3781
                --  | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10| 11|
3782
                --  | 1 | 1 | 1 | 1 |CLA|MQA|SCA|MQL|   |   |   | 1 |
3783
                --  |---|---|---|---|---|---|---|---|---|---|---|---|
3784
                --                    |   |       | |           |
3785
                --      Sequence:     1   2       2  \____3____/
3786
                --                                        V
3787
                --                              0 = NOP       4 = NMI
3788
                --                              1 = SCL       5 = SHL
3789
                --                              2 = MUY       6 = ASR
3790
                --                              3 = DVI       7 = LSR
3791
                --
3792
                --
3793
                --                    Group 3 Mode B
3794
                --
3795
                --  |           |           |           |           |
3796
                --  |---|---|---|---|---|---|---|---|---|---|---|---|
3797
                --  | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10| 11|
3798
                --  | 1 | 1 | 1 | 1 |CLA|MQA|   |MQL|   |   |   | 1 |
3799
                --  |---|---|---|---|---|---|---|---|---|---|---|---|
3800
                --                    |   | |     |             |
3801
                --      Sequence:     1   2  \    2            /
3802
                --                            \_______3_______/
3803
                --                                    V
3804
                --                          0 = NOP       10 = SCA
3805
                --                          1 = ACS       11 = DAD
3806
                --                          2 = MUY       12 = DST
3807
                --                          3 = DVI       13 = SWBA
3808
                --                          4 = NMI       14 = DPSZ
3809
                --                          5 = SHL       15 = DPIC (MQL & MQA set)
3810
                --                          6 = ASR       16 = DCM  (MQL & MQA set)
3811
                --                          7 = LSR       17 = SAM
3812
                --
3813
 
3814
                if IR = o"7431" then
3815
 
3816
                    --
3817
                    -- OP 7431: SWAB - Switch from A to B.  The SWAB
3818
                    -- instruction cannot be microprogrammed with any of the
3819
                    -- Mode 3A or Mode 3B instructions.
3820
                    --
3821
                    -- EAE Mode B was only available on PDP8/E, PDP8/F, PDP8/M,
3822
                    -- PDP8/A with EAE.
3823
                    --
3824
 
3825
                    if ((swCPU = swPDP8E) or
3826
                        (swCPU = swPDP8F) or
3827
                        (swCPU = swPDP8M) or
3828
                        (swCPU = swPDP8A)) then
3829
                        emodeOP   <= emodeopSET;
3830
                        nextState <= stateDone;
3831
                    end if;
3832
 
3833
                elsif IR = o"7447" then
3834
 
3835
                    --
3836
                    -- SWBA - Switch from B to A.   Clear GTF.  The SWBA
3837
                    -- instruction cannot be microprogrammed with any of the
3838
                    -- Mode 3A or Mode 3B instructions.
3839
                    --
3840
 
3841
                    emodeOP   <= emodeopCLR;
3842
                    gtfOP     <= gtfopCLR;
3843
                    nextState <= stateDone;
3844
 
3845
                else
3846
 
3847
                    --
3848
                    -- EAE Mode A Operations clear GTF
3849
                    --
3850
 
3851
                    if EMODE = '0' then
3852
                        gtfOP <= gtfopCLR;
3853
                    end if;
3854
 
3855
                    --
3856
                    -- All the Mode 3A and Mode 3B instructions
3857
                    --
3858
 
3859
                    EAEIR := IR(6) & IR(8) & IR(9) & IR(10);
3860
                    case EAEIR is
3861
 
3862
                        --
3863
                        -- OP 7401: NOP
3864
                        --
3865
 
3866
                        when opEAENOP =>
3867
                            nextState <= stateDone;
3868
 
3869
                        --
3870
                        -- OP 7403: MODEA: SCL
3871
                        --          MODEB: ACS
3872
                        --
3873
 
3874
                        when "0001" =>
3875
 
3876
                            if EMODE = '0' then
3877
 
3878
                                --
3879
                                -- SCL - Step Counter Load from Memory.  The SCL
3880
                                -- instruction is a two-word instruction.  The
3881
                                -- value to load is contained in the operand
3882
                                -- which is located at the next memory
3883
                                -- location. Begin the fetch of the operand.
3884
                                --
3885
 
3886
                                maOP      <= maopPC;
3887
                                pcOP      <= pcopINC;
3888
                                xmaOP     <= xmaopIF;
3889
                                memselOP  <= '1';
3890
                                busOP     <= busopRDIFaddr;
3891
                                nextState <= stateEAEfetchAddr;
3892
 
3893
                            else
3894
 
3895
                                --
3896
                                -- ACS - Accumulator to Step Count.
3897
                                -- AC(7 to 11) are loaded into the Step Counter
3898
                                -- then the AC is cleared.
3899
                                --
3900
 
3901
                                scOP      <= scopAC7to11;
3902
                                acOP      <= acopCLA;
3903
                                nextState <= stateDone;
3904
 
3905
                            end if;
3906
 
3907
                        --
3908
                        -- OP 7405: MUY - Multiply.  The Multiply instruction
3909
                        -- is a two-word instruction.  The second word is
3910
                        -- either the multiplier or the address of the multiplier
3911
                        -- depending on the mode.  Begin the fetch of the operand.
3912
                        --
3913
 
3914
                        when opEAEMUY =>
3915
                            maOP      <= maopPC;
3916
                            pcOP      <= pcopINC;
3917
                            xmaOP     <= xmaopIF;
3918
                            memselOP  <= '1';
3919
                            busOP     <= busopRDIFaddr;
3920
                            nextState <= stateEAEfetchAddr;
3921
 
3922
                        --
3923
                        -- OP 7407: DVI - Divide.  The Divide instruction
3924
                        -- is a two-word instruction.  The second word is
3925
                        -- either the divisor or the address of the divisor
3926
                        -- depending on the mode.  Begin the fetch of the operand.
3927
                        --
3928
 
3929
                        when opEAEDVI =>
3930
                            maOP      <= maopPC;
3931
                            pcOP      <= pcopINC;
3932
                            xmaOP     <= xmaopIF;
3933
                            memselOP  <= '1';
3934
                            busOP     <= busopRDIFaddr;
3935
                            nextState <= stateEAEfetchAddr;
3936
 
3937
                        --
3938
                        -- OP 7411: NMI
3939
                        -- The Step Counter is initially cleared.
3940
                        --
3941
 
3942
                        when opEAENMI =>
3943
                            scOP      <= scopCLR;
3944
                            nextState <= stateEAEnmi;
3945
 
3946
                        --
3947
                        -- OP 7413: SHL - Shift Left.  The shift left
3948
                        -- instruction is a two-word instruction. The number of
3949
                        -- shifts is contained in operand which is located at
3950
                        -- the next memory location.  Begin the fetch of the operand.
3951
                        --
3952
 
3953
                        when opEAESHL =>
3954
                            maOP      <= maopPC;
3955
                            xmaOP     <= xmaopIF;
3956
                            pcOP      <= pcopINC;
3957
                            memselOP  <= '1';
3958
                            xmaOP     <= xmaopIF;
3959
                            busOP     <= busopRDIFaddr;
3960
                            nextState <= stateEAEfetchAddr;
3961
 
3962
                        --
3963
                        -- OP 7415: ASR - Arithmetic Shift Right.
3964
                        -- The number of shifts is contained in operand which
3965
                        -- is contained in the next memory location.  Begin the
3966
                        -- fetch of the operand.
3967
                        --
3968
 
3969
                        when opEAEASR =>
3970
                            maOP      <= maopPC;
3971
                            xmaOP     <= xmaopIF;
3972
                            pcOP      <= pcopINC;
3973
                            memselOP  <= '1';
3974
                            busOP     <= busopRDIFaddr;
3975
                            nextState <= stateEAEfetchAddr;
3976
 
3977
                        --
3978
                        -- OP 7417: LSR - Logical Shift Right
3979
                        -- The number of shifts is contained in operand which
3980
                        -- is located at the next memory location.  Begin the
3981
                        -- fetch of the operand.
3982
                        --
3983
 
3984
                        when opEAELSR =>
3985
                            maOP      <= maopPC;
3986
                            xmaOP     <= xmaopIF;
3987
                            pcOP      <= pcopINC;
3988
                            memselOP  <= '1';
3989
                            busOP     <= busopRDIFaddr;
3990
                            nextState <= stateEAEfetchAddr;
3991
 
3992
                        --
3993
                        -- OP 7441: SCA - Step Count OR with AC
3994
                        --
3995
 
3996
                        when opEAESCA =>
3997
                            acop      <= acopSCA;
3998
                            nextState <= stateDone;
3999
 
4000
                        --
4001
                        -- OP 7443: MODEA SCA/SCL
4002
                        --          MODEB DAD
4003
                        --
4004
 
4005
                        when opEAEDAD =>
4006
 
4007
                            if EMODE = '0' then
4008
 
4009
                                --
4010
                                -- SCA/SCL - Step Counter Load from Memory.  The SCL
4011
                                -- instruction is a two-word instruction.  The
4012
                                -- value to load is contained in the operand
4013
                                -- which is located at the next memory
4014
                                -- location.  Begin the fetch of the operand.
4015
                                --
4016
 
4017
                                acop      <= acopSCA;
4018
                                pcOP      <= pcopINC;
4019
                                maOP      <= maopPC;
4020
                                xmaOP     <= xmaopIF;
4021
                                memselOP  <= '1';
4022
                                busOP     <= busopRDIFaddr;
4023
                                nextState <= stateEAEfetchAddr;
4024
 
4025
                            else
4026
 
4027
                                --
4028
                                -- DAD - Double Precision Add.  The DAD
4029
                                -- instruction is a three-word instruction. The
4030
                                -- second word is the first operand which is
4031
                                -- the address of the LSW of the addend.  Begin
4032
                                -- the fetch of the first operand.
4033
                                --
4034
 
4035
                                pcOP      <= pcopINC;
4036
                                maOP      <= maopPC;
4037
                                xmaOP     <= xmaopIF;
4038
                                memselOP  <= '1';
4039
                                busOP     <= busopRDIFaddr;
4040
                                nextState <= stateEAEfetchAddr;
4041
 
4042
                            end if;
4043
 
4044
                        --
4045
                        -- OP 7445: MODEA: SCA/MUY
4046
                        --          MODEB: DST
4047
 
4048
                        when opEAEDST =>
4049
 
4050
                            if EMODE = '0' then
4051
 
4052
                                --
4053
                                -- SCA/MUY - Multiply.  The Multiply instruction
4054
                                -- is a two-word instruction.  The second word is
4055
                                -- either the multiplier or the address of the multiplier
4056
                                -- depending on the mode.  Begin the fetch of the operand.
4057
                                --
4058
 
4059
                                acop      <= acopSCA;
4060
                                pcOP      <= pcopINC;
4061
                                maOP      <= maopPC;
4062
                                xmaOP     <= xmaopIF;
4063
                                memselOP  <= '1';
4064
                                busOP     <= busopRDIFaddr;
4065
                                nextState <= stateEAEfetchAddr;
4066
 
4067
                            else
4068
 
4069
                                --
4070
                                -- DST - Double Precision Store.
4071
                                --
4072
 
4073
                                pcOP      <= pcopINC;
4074
                                maOP      <= maopPC;
4075
                                xmaOP     <= xmaopIF;
4076
                                memselOP  <= '1';
4077
                                busOP     <= busopRDIFaddr;
4078
                                nextState <= stateEAEfetchAddr;
4079
 
4080
                            end if;
4081
 
4082
                        --
4083
                        -- OP 7451: MODEA: SCA/NMI
4084
                        --          MODEB: DPSZ
4085
                        --
4086
 
4087
                        when opEAEDPSZ =>
4088
 
4089
                            if EMODE = '0' then
4090
 
4091
                                --
4092
                                -- SCA/NMI -
4093
                                -- The Step Counter is initially cleared.
4094
                                --
4095
 
4096
                                acop      <= acopSCA;
4097
                                scOP      <= scopCLR;
4098
                                nextState <= stateDone;
4099
 
4100
                            else
4101
 
4102
                                --
4103
                                -- DPSZ - Double Precision Skip if Zero
4104
                                --
4105
 
4106
                                if AC = o"0000" and MQ = o"0000" then
4107
                                    pcop  <= pcopINC;
4108
                                end if;
4109
                                nextState <= stateDone;
4110
 
4111
                            end if;
4112
 
4113
                        --
4114
                        -- OP 7453: MODEA: SCA/SHL
4115
                        --          MODEB: DPIC
4116
                        --
4117
 
4118
                        when opEAEDPIC =>
4119
 
4120
                            if EMODE = '0' then
4121
 
4122
                                --
4123
                                -- SCA/SHL - SCA combined with SHL
4124
                                --
4125
 
4126
                                acOP      <= acopSCA;
4127
                                maOP      <= maopPC;
4128
                                xmaOP     <= xmaopIF;
4129
                                pcOP      <= pcopINC;
4130
                                memselOP  <= '1';
4131
                                busOP     <= busopRDIFaddr;
4132
                                nextState <= stateEAEfetchAddr;
4133
 
4134
                            else
4135
 
4136
                                --
4137
                                -- DPIC - Double Precision Increment
4138
                                -- Note: AC and MQ were previously swapped because
4139
                                -- this instruction must be micro-coded with MQL and MQA.
4140
                                --
4141
 
4142
                                if AC = o"7777" then
4143
                                    mqOP <= mqopCLR;
4144
                                    if MQ = o"7777" then
4145
                                       acOP <= acopCLACLLCML;
4146
                                    else
4147
                                       acOP <= acopMQP1;
4148
                                    end if;
4149
                                else
4150
                                    mqOP <= mqopACP1;
4151
                                    acOP <= acopZMQ;
4152
                                end if;
4153
                                nextState <= stateDone;
4154
 
4155
                            end if;
4156
 
4157
                        --
4158
                        -- OP 7455: MODEA: SCA/ASR
4159
                        --          MODEB: DCM
4160
                        --
4161
 
4162
                        when opEAEDCM =>
4163
 
4164
                            if EMODE = '0' then
4165
 
4166
                                --
4167
                                -- SCA/ASR - SCA combined with ASR
4168
                                --
4169
 
4170
                                maOP      <= maopPC;
4171
                                xmaOP     <= xmaopIF;
4172
                                acOP      <= acopSCA;
4173
                                pcOP      <= pcopINC;
4174
                                memselOP  <= '1';
4175
                                busOP     <= busopRDIFaddr;
4176
                                nextState <= stateEAEfetchAddr;
4177
 
4178
                            else
4179
 
4180
                                --
4181
                                -- DCM - Double Precision Complement.
4182
                                -- The 24-bit number in AC and MQ is complemented and
4183
                                -- incremented. This has the effect of two complementing
4184
                                -- the 24-bit number.  The high-order carry is propigated
4185
                                -- into the link register.
4186
                                -- Note: AC and MQ were previously swapped because
4187
                                -- this instruction must be micro-coded with MQL and MQA.
4188
                                --
4189
 
4190
                                if AC = o"0000" then
4191
                                    mqOP <= mqopCLR;
4192
                                    if MQ = o"0000" then
4193
                                        acOP <= acopCLACLLCML;
4194
                                    else
4195
                                        acOP <= acopNEGMQ;
4196
                                    end if;
4197
                                else
4198
                                    mqOP <= mqopNEGAC;
4199
                                    acOP <= acopNOTMQ;
4200
                                end if;
4201
                                nextState <= stateDone;
4202
 
4203
                            end if;
4204
 
4205
                        --
4206
                        -- OP 7457: MODEA: SCA/LSR
4207
                        --          MODEB: SAM
4208
                        --
4209
 
4210
                        when opEAESAM =>
4211
 
4212
                            if EMODE = '0' then
4213
 
4214
                                --
4215
                                -- SCA/LSR - SCA combined with LSR
4216
                                --
4217
 
4218
                                maOP      <= maopPC;
4219
                                xmaOP     <= xmaopIF;
4220
                                pcOP      <= pcopINC;
4221
                                acOP      <= acopSCA;
4222
                                memselOP  <= '1';
4223
                                busOP     <= busopRDIFaddr;
4224
                                nextState <= stateEAEfetchAddr;
4225
 
4226
                            else
4227
 
4228
                                --
4229
                                -- SAM - Subtract AC from MQ.
4230
                                -- GTF is set if signed MQ >= signed AC
4231
                                -- otherwise GTF is cleared.
4232
                                --
4233
 
4234
                                acOP  <= acopMQSUB;
4235
                                if signed(MQ) >= signed(AC) then
4236
                                    gtfOP <= gtfopSET;
4237
                                else
4238
                                    gtfOP <= gtfopCLR;
4239
                                end if;
4240
                                nextState <= stateDone;
4241
 
4242
                            end if;
4243
 
4244
                        --
4245
                        -- Everything else
4246
                        --
4247
 
4248
                        when others =>
4249
                            assert false report "stateOprGroup3Seq3: Undecoded instruction" severity warning;
4250
                            nextState <= stateDone;
4251
 
4252
                    end case;
4253
 
4254
                end if;
4255
 
4256
            --
4257
            -- This state performs a read address cycle.
4258
            -- The next state will do a read data bus.
4259
            --
4260
 
4261
            when stateMRIreadAddr =>
4262
                rdOP     <= '1';
4263
                xmaOP    <= xmaopIF;
4264
                memselOP <= '1';
4265
                busOP    <= busopRDIFaddr;
4266
                if ((IR(3 to 4) = amDZ) or IR(3 to 4) = amDC) then
4267
                    nextState <= stateMRIexecute;
4268
                else
4269
                    nextState <= stateMRIreadDataIND;
4270
                end if;
4271
 
4272
            --
4273
            -- This state perfored a read data bus cycle.
4274
            -- The data that was read is in MD.
4275
            --
4276
 
4277
            when stateMRIreadDataIND =>
4278
 
4279
                if MA(0 to 8) = maAutoIncr then
4280
 
4281
                    --
4282
                    -- Writeback auto incremented data.
4283
                    --  MB <- MD + 1
4284
                    --  MEM[IF'MA] <- MB
4285
                    --
4286
 
4287
                    wrOP      <= '1';
4288
                    mbOP      <= mbopMDP1;
4289
                    xmaOP     <= xmaopIF;
4290
                    memselOP  <= '1';
4291
                    busOP     <= busopWRIF;
4292
                    nextState <= stateMRIreadINCaddr;
4293
 
4294
                else
4295
 
4296
                    --
4297
                    -- Non-autoincrement addresses
4298
                    -- Start address phase of indirect data read
4299
                    -- Address input is in MD
4300
                    --
4301
 
4302
                    case IR(0 to 2) is
4303
 
4304
                        --
4305
                        -- MA <- MD
4306
                        -- MD <- MEM[IB'MA]
4307
                        --
4308
 
4309
                        when opJMS | opJMP =>
4310
                            maOP      <= maopMD;
4311
                            xmaOP     <= xmaopIB;
4312
                            memselOP  <= '1';
4313
                            busOP     <= busopRDIBaddr;
4314
                            nextState <= stateMRIexecute;
4315
 
4316
                            --
4317
                            -- MA <- MB
4318
                            -- MD <- MEM[DF'MA]
4319
                            --
4320
 
4321
                        when others =>
4322
                            maOP      <= maopMD;
4323
                            xmaOP     <= xmaopDF;
4324
                            datafOP   <= '1';
4325
                            memselOP  <= '1';
4326
                            busOP     <= busopRDDFaddr;
4327
                            nextState <= stateMRIreadINDdata;
4328
                    end case;
4329
 
4330
                end if;
4331
 
4332
            --
4333
            -- Start address phase of indirect data read
4334
            -- Address input is in MB
4335
            --
4336
 
4337
            when stateMRIreadINCaddr =>
4338
                case IR(0 to 2) is
4339
 
4340
                    --
4341
                    -- MA <- MB
4342
                    -- MD <- MEM[IB'MA]
4343
                    --
4344
 
4345
                    when opJMS | opJMP =>
4346
                        maOP      <= maopMB;
4347
                        xmaOP     <= xmaopIB;
4348
                        memselOP  <= '1';
4349
                        busOP     <= busopRDIBaddr;
4350
                        nextState <= stateMRIexecute;
4351
 
4352
                    --
4353
                    -- MA <- MB
4354
                    -- MD <- MEM[DF'MA]
4355
                    --
4356
 
4357
                    when others =>
4358
                        maOP      <= maopMB;
4359
                        xmaOP     <= xmaopDF;
4360
                        datafOP   <= '1';
4361
                        memselOP  <= '1';
4362
                        busOP     <= busopRDDFaddr;
4363
                        nextState <= stateMRIreadINDdata;
4364
                end case;
4365
 
4366
            --
4367
            -- Start data phase of indirect data read
4368
            --  MD <- MEM[DF'MA]
4369
            --
4370
 
4371
            when stateMRIreadINDdata =>
4372
                rdOP      <= '1';
4373
                xmaOP     <= xmaopDF;
4374
                datafOP   <= '1';
4375
                memselOP  <= '1';
4376
                busOP     <= busopRDDFdata;
4377
                nextState <= stateMRIexecute;
4378
 
4379
            --
4380
            -- Dispatch the MRI ops.   The previous state was a read data cycle.
4381
            --  The data is in MD and the address is MA.
4382
            --
4383
 
4384
            when stateMRIexecute =>
4385
                case IR(0 to 2) is
4386
 
4387
                    --
4388
                    --  AC <- AC and MD
4389
                    --
4390
 
4391
                    when opAND =>
4392
                        acOP      <= acopANDMD;
4393
                        nextState <= stateDone;
4394
 
4395
                    --
4396
                    -- AC <- AC + MD
4397
                    --
4398
 
4399
                    when opTAD =>
4400
                        acOP      <= acopADDMD;
4401
                        nextState <= stateDone;
4402
 
4403
                    --
4404
                    -- MB <- MD + 1
4405
                    -- IF MD = 7777 (or MB = 0000) Then
4406
                    --    PC <- PC + 1;
4407
                    -- ENDIF
4408
                    -- IF ISZ DIRECT THEN
4409
                    --    MEM[IF'MA] <- MB
4410
                    -- ELSE
4411
                    --    MEM[DF'MA] <- MB
4412
                    -- ENDIF
4413
                    -- Note: Checking MD against 7777 saves a state...
4414
                    --
4415
 
4416
                    when opISZ =>
4417
                        mbOP <= mbopMDP1;
4418
                        if MD = o"7777" then
4419
                            pcOP <= pcopINC;
4420
                        end if;
4421
                        if ((IR(3 to 4) = amDZ) or IR(3 to 4) = amDC) then
4422
                            wrOP     <= '1';
4423
                            xmaOP    <= xmaopIF;
4424
                            memselOP <= '1';
4425
                            busOP    <= busopWRIF;
4426
                        else
4427
                            wrOP     <= '1';
4428
                            xmaOP    <= xmaopDF;
4429
                            datafOP  <= '1';
4430
                            memselOP <= '1';
4431
                            busOP    <= busopWRDF;
4432
                        end if;
4433
                        nextState <= stateDone;
4434
 
4435
                    --
4436
                    -- MB <- AC
4437
                    -- AC <- 0000
4438
                    -- IF DCA DIRECT THEN
4439
                    --    MEM[IF'MA] <- MB
4440
                    -- ELSE
4441
                    --    MEM[DF'MA] <- MB
4442
                    -- ENDIF
4443
                    --
4444
 
4445
                    when opDCA =>
4446
                        mbOP <= mbopAC;
4447
                        acOP <= acopCLA;
4448
                        if ((IR(3 to 4) = amDZ) or IR(3 to 4) = amDC) then
4449
                            wrOP     <= '1';
4450
                            xmaOP    <= xmaopIF;
4451
                            memselOP <= '1';
4452
                            busOP    <= busopWRIF;
4453
                        else
4454
                            wrOP     <= '1';
4455
                            xmaOP    <= xmaopDF;
4456
                            datafOP  <= '1';
4457
                            memselOP <= '1';
4458
                            busOP    <= busopWRDF;
4459
                        end if;
4460
                        nextState <= stateDone;
4461
 
4462
                    --
4463
                    -- opJMS
4464
                    --
4465
                    -- When the PEX Flip-flop is set, the CPU shall exit from
4466
                    -- Panel Mode to Main Memory (i.e., clear CTRLFF) during
4467
                    -- the next JMP, JMS, RTN1 or RTN2 instruction.  PEX is
4468
                    -- cleared by the JMP, JMS, RTN1 or RTN instruction.
4469
                    --
4470
                    -- IF <- IB
4471
                    -- UF <- UB
4472
                    -- IIFF <- '0'
4473
                    -- MB <- PC
4474
                    -- MEM[IB'MA] <- MB
4475
                    -- IF PEX = '1' THEN
4476
                    --    CTRLFF <- '0'
4477
                    --    PEX    <- '0'
4478
                    -- ENDIF
4479
                    --
4480
 
4481
                    when opJMS =>
4482
                        ifOP     <= ifopIB;
4483
                        ufOP     <= ufopUB;
4484
                        wrOP     <= '1';
4485
                        mbOP     <= mbopPC;
4486
                        pcOP     <= pcopMAP1;
4487
                        xmaOP    <= xmaopIB;
4488
                        memselOP <= '1';
4489
                        busOP    <= busopWRIB;
4490
                        if PEX = '1' then
4491
                            ctrlffOP <= ctrlffopCLR;
4492
                            pexOP    <= pexopCLR;
4493
                        end if;
4494
                        nextState <= stateDone;
4495
 
4496
                    --
4497
                    -- opJMP
4498
                    --
4499
                    -- When the PEX Flip-flop is set, the CPU shall exit from
4500
                    -- Panel Mode to Main Memory (i.e., clear CTRLFF) during
4501
                    -- the next JMP, JMS, RTN1 or RTN2 instruction.  PEX is
4502
                    -- cleared by the JMP, JMS, RTN1 or RTN instruction.
4503
                    --
4504
                    -- IF <- IB
4505
                    -- UF <- UB
4506
                    -- PC <- MA
4507
                    -- IF PEX = '1' THEN
4508
                    --    CTRLFF <- '0'
4509
                    --    PEX    <- '0'
4510
                    -- ENDIF
4511
                    --
4512
 
4513
                    when opJMP =>
4514
                        ifOP <= ifopIB;
4515
                        ufOP <= ufopUB;
4516
                        pcOP <= pcopMA;
4517
                        if PEX = '1' then
4518
                            ctrlffOP <= ctrlffopCLR;
4519
                            pexOP    <= pexopCLR;
4520
                        end if;
4521
                        nextState <= stateDone;
4522
 
4523
                    --
4524
                    -- Can't get to any of these
4525
                    --
4526
 
4527
                    when opIOT =>
4528
                        assert false report "stateMRIexecute: IOT direct." severity warning;
4529
                        nextState <= stateDone;
4530
                    when opOPR =>
4531
                        assert false report "stateMRIexecute: OPR direct." severity warning;
4532
                        nextState <= stateDone;
4533
                    when others =>
4534
                        assert false report "stateMRIexecute: Others direct." severity warning;
4535
                        nextState <= stateDone;
4536
                end case;
4537
 
4538
            --
4539
            -- The previous state set the MA register
4540
            -- This state handles the address phase of the read cycle.
4541
            --  MD <- MEM[IF,MA]
4542
            --
4543
 
4544
            when stateEAEfetchAddr =>
4545
                rdOP      <= '1';
4546
                memselOP  <= '1';
4547
                busOP     <= busopRDIFdata;
4548
                nextState <= stateEAEfetchData;
4549
 
4550
            --
4551
            -- This is the data phase of the EAE second word read.
4552
            -- At the end of this cycle, the second word is in the MD register.
4553
            --  MD <- MEM[IF,MA]
4554
            --
4555
            -- This state will re-dispatch EAE ops that have a single operand
4556
            -- that is used as 'immediate data'.  This state will begin the
4557
            -- fetch of indirect data for EAE ops with indirect operands.
4558
            --
4559
 
4560
            when stateEAEfetchData =>
4561
 
4562
                EAEIR := IR(6) & IR(8) & IR(9) & IR(10);
4563
                case EAEIR is
4564
 
4565
                    --
4566
                    -- OP 7401: NOP
4567
                    --
4568
 
4569
                    when opEAENOP =>
4570
                        nextState <= stateDone;
4571
 
4572
                    --
4573
                    -- OP 7403: MODEA: SCL
4574
                    --          MODEB: ACS
4575
                    --
4576
 
4577
                    when opEAEACS =>
4578
 
4579
                        if EMODE = '0' then
4580
 
4581
                            --
4582
                            -- SCL - The ones complement of the last five bits
4583
                            -- of this operand are loaded into the Step Counter
4584
                            -- and the program resumes at the instruction word
4585
                            -- following the operand.
4586
                            --
4587
 
4588
                            scOP      <= scopNOTMD7to11;
4589
                            nextState <= stateDone;
4590
 
4591
                        else
4592
 
4593
                            --
4594
                            -- ACS - Accumulator to Step Count.
4595
                            -- The ACS instruction doesn't re-dispatch here.
4596
                            -- You shouldn't get here.
4597
                            --
4598
 
4599
                            assert false report "stateEAEfetchData: ACS should not re-dispatch here" severity warning;
4600
                            nextState <= stateLALA;
4601
 
4602
                        end if;
4603
 
4604
                    --
4605
                    -- OP 7405: MUY - Multiply.
4606
                    -- In MODEA, the operand is the multiplier.
4607
                    -- In MODEB, the operand is the address of the multipler,
4608
                    -- which is possibly pre-incremented before use.  Start the
4609
                    -- multiply operation.
4610
                    --
4611
 
4612
                    when opEAEMUY =>
4613
                        if EMODE = '0' then
4614
 
4615
                            EAEop     <= eaeopMUY;
4616
                            nextState <= stateEAEmuy;
4617
 
4618
                        else
4619
 
4620
                            if MA(3 to 11) = maAutoIncr then
4621
 
4622
                                --
4623
                                -- Start the writeback of the incremented data
4624
                                --
4625
 
4626
                                wrOP      <= '1';
4627
                                mbOP      <= mbopMDP1;
4628
                                --XMAOPTBD
4629
                                datafOP   <= '1';
4630
                                memselOP  <= '1';
4631
                                nextState <= stateEAEindWrite;
4632
 
4633
                            else
4634
 
4635
                                --
4636
                                -- Start address phase of indirect data read
4637
                                --
4638
 
4639
                                maOP      <= maopMD;
4640
                                --XMAOPTBD
4641
                                datafOP   <= '1';
4642
                                memselOP  <= '1';
4643
                                nextState <= stateEAEindReadAddr;
4644
 
4645
                            end if;
4646
                        end if;
4647
 
4648
                    --
4649
                    -- OP 7407: DVI - Divide
4650
                    -- In MODEA, the operand is the divisor
4651
                    -- In MODEB, the operand is the address of the divisor
4652
                    -- which is possibly pre-incremented before use.  The
4653
                    -- divisor is in MD.
4654
                    --
4655
 
4656
                    when opEAEDVI =>
4657
                        if EMODE = '0' then
4658
 
4659
                            --
4660
                            -- Handle divide overflow condition
4661
                            --
4662
 
4663
                            if AC >= MD then
4664
                                scOP      <= scopCLR;
4665
                                acOP      <= acopCLLCML;
4666
                                mqOP      <= mqopSHL1;
4667
                                nextState <= stateDone;
4668
 
4669
                            --
4670
                            -- Handle normal divide condition
4671
                            --
4672
 
4673
                            else
4674
                                mqaOP     <= mqaopMQ;
4675
                                scOP      <= scopCLR;
4676
                                acOP      <= acopCLL;
4677
                                nextState <= stateEAEsubDVI;
4678
 
4679
                            end if;
4680
 
4681
                        else
4682
                            if MA(3 to 11) = maAutoIncr then
4683
 
4684
                                --
4685
                                -- Start the writeback of the incremented data
4686
                                --
4687
 
4688
                                wrOP      <= '1';
4689
                                mbOP      <= mbopMDP1;
4690
                                --XMAOPTBD
4691
                                --DATAFOP OR IFETCHOP
4692
                                memselOP  <= '1';
4693
                                nextState <= stateEAEindWrite;
4694
 
4695
                            else
4696
 
4697
                                --
4698
                                -- Start address phase of indirect data read
4699
                                --
4700
 
4701
                                maOP      <= maopMD;
4702
                                --XMAOPTBD
4703
                                datafOP   <= '1';
4704
                                memselOP  <= '1';
4705
                                nextState <= stateEAEindReadAddr;
4706
 
4707
                            end if;
4708
                        end if;
4709
 
4710
                    --
4711
                    -- OP 7411: NMI - Normalize
4712
                    -- The NMI instruction doesn't re-dispatch here.
4713
                    -- You shouldn't get here.
4714
                    --
4715
 
4716
                    when opEAENMI =>
4717
                        assert false report "stateEAEfetchData: NMI should not re-dispatch here" severity warning;
4718
                        nextState <= stateLALA;
4719
 
4720
                    --
4721
                    -- OP 7413: SHL - Shift Left.
4722
                    -- The second word of the two-word instruction defines the
4723
                    -- number of shifts to be performed. In Mode A, the number
4724
                    -- of shifts performed is equal to one more than the number
4725
                    -- in the last five bits of the second word.  In Mode B,
4726
                    -- the number of shifts performed is equal to the number in
4727
                    -- the last five bits of the second word.  A shift count of
4728
                    -- zero is legal, and leaves the link, AC, and MQ registers
4729
                    -- unchaged.
4730
                    --
4731
 
4732
                    when opEAESHL =>
4733
                        if EMODE = '0' then
4734
 
4735
                            --
4736
                            -- Mode A:
4737
                            -- Handle case where SHL Shift count is maxed out.
4738
                            --
4739
 
4740
                            if unsigned(MD(7 to 11)) > 24 then
4741
                                scOP      <= scopCLR;
4742
                                mqOP      <= mqopCLR;
4743
                                acOP      <= acopCLACLL;
4744
                                nextState <= stateDone;
4745
 
4746
                            --
4747
                            -- Mode A:
4748
                            -- Normal case where SHL shift count not maxed out.
4749
                            --
4750
 
4751
                            else
4752
                                scOP      <= scopMDP1;
4753
                                nextState <= stateEAEshift;
4754
 
4755
                            end if;
4756
 
4757
                        else
4758
 
4759
                            --
4760
                            -- Mode B:
4761
                            -- Handle case where SHL Shift count is maxed out.
4762
                            --
4763
 
4764
                            if unsigned(MD(7 to 11)) > 25 then
4765
                                scOP      <= scopSET;
4766
                                mqOP      <= mqopCLR;
4767
                                acOP      <= acopCLACLL;
4768
                                nextState <= stateDone;
4769
 
4770
                            --
4771
                            -- Mode B:
4772
                            -- Handle case where SHL Shift count is zero
4773
                            --
4774
 
4775
                            elsif unsigned(MD(7 to 11)) = 0 then
4776
                                scOP      <= scopSET;
4777
                                nextState <= stateDone;
4778
 
4779
                            --
4780
                            -- Mode B:
4781
                            -- Normal case where SHL shift count not maxed out.
4782
                            --
4783
 
4784
                            else
4785
                                scOP      <= scopMD7to11;
4786
                                nextState <= stateEAEshift;
4787
 
4788
                            end if;
4789
                        end if;
4790
 
4791
                    --
4792
                    -- OP 7415: ASR - Arithmetic Shift Right.
4793
                    -- The second word of the two-word instruction defines the
4794
                    -- number of shifts to be performed. In Mode A, the number
4795
                    -- of shifts performed is equal to one more than the number
4796
                    -- in the last five bits of the second word.  In Mode B,
4797
                    -- the number of shifts performed is equal to the number in
4798
                    -- the last five bits of the second word.  A shift count of
4799
                    -- zero is legal, and loads the link from AC(0) but leaves
4800
                    -- the AC and MQ registers unchaged.
4801
                    --
4802
 
4803
                    when opEAEASR =>
4804
                        if EMODE = '0' then
4805
 
4806
                            --
4807
                            -- Mode A:
4808
                            -- Handle case where ASR Shift count is maxed out.
4809
                            -- Sign extended AC into L and MQ
4810
                            --
4811
 
4812
                            if unsigned(MD(7 to 11)) > 23 then
4813
                                if AC(0) = '0' then
4814
                                    acOP <= acopCLACLL;
4815
                                    mqOP <= mqopCLR;
4816
                                else
4817
                                    acOP <= acopCLACLLCMACML;
4818
                                    mqOP <= mqopSET;
4819
                                end if;
4820
                                scOP      <= scopCLR;
4821
                                nextState <= stateDone;
4822
 
4823
                            --
4824
                            -- Mode A:
4825
                            -- Normal case where ASR shift count not maxed out.
4826
                            -- Sign extend AC into L
4827
                            --
4828
 
4829
                            else
4830
 
4831
                                scOP <= scopMDP1;
4832
                                if AC(0) = '0' then
4833
                                    acOP  <= acopCLL;
4834
                                else
4835
                                    acOP  <= acopCLLCML;
4836
                                end if;
4837
                                nextState <= stateEAEshift;
4838
 
4839
                            end if;
4840
 
4841
                        else
4842
 
4843
                            --
4844
                            -- Mode B:
4845
                            -- Handle case where ASR Shift count is maxed out.
4846
                            -- Shift sign extended AC
4847
                            --
4848
 
4849
                            if unsigned(MD(7 to 11)) > 25 then
4850
                                if AC(0) = '0' then
4851
                                    acOP  <= acopCLACLL;
4852
                                    mqOP  <= mqopCLR;
4853
                                    gtfOP <= gtfopCLR;
4854
                                else
4855
                                    acOP  <= acopCLACLLCMACML;
4856
                                    mqOP  <= mqopSET;
4857
                                    gtfOP <= gtfopSET;
4858
                                end if;
4859
                                scOP      <= scopSET;
4860
                                nextState <= stateDone;
4861
 
4862
                            --
4863
                            -- Mode B:
4864
                            -- Handle case where ASR Shift count is zero
4865
                            -- Sign extend AC into L
4866
                            --
4867
 
4868
                            elsif unsigned(MD(7 to 11)) = 0 then
4869
                                if AC(0) = '0' then
4870
                                    acOP  <= acopCLL;
4871
                                else
4872
                                    acOP  <= acopCLLCML;
4873
                                end if;
4874
                                nextState <= stateDone;
4875
 
4876
                            --
4877
                            -- Mode B:
4878
                            -- Normal case where ASR shift count not maxed out.
4879
                            --
4880
 
4881
                            else
4882
                                scOP      <= scopMD7to11;
4883
                                if AC(0) = '0' then
4884
                                    acOP  <= acopCLL;
4885
                                else
4886
                                    acOP  <= acopCLLCML;
4887
                                end if;
4888
                                nextState <= stateEAEshift;
4889
 
4890
                            end if;
4891
 
4892
                        end if;
4893
 
4894
                    --
4895
                    -- OP 7417: LSR - Logical Shift Right
4896
                    -- The second word of the two-word instruction defines the
4897
                    -- number of shifts to be performed. In Mode A, the number
4898
                    -- of shifts performed is equal to one more than the number
4899
                    -- in the last five bits of the second word.  In Mode B,
4900
                    -- the number of shifts performed is equal to the number in
4901
                    -- the last five bits of the second word.  A shift count of
4902
                    -- zero is legal, and clears the link without changing the
4903
                    -- AC or MQ registers.
4904
                    --
4905
 
4906
                    when opEAELSR =>
4907
                        if EMODE = '0' then
4908
 
4909
                            --
4910
                            -- Mode A:
4911
                            -- Handle case where LSR Shift count is maxed out.
4912
                            --
4913
 
4914
                            if unsigned(MD) > 23 then
4915
                                scOP      <= scopCLR;
4916
                                acOP      <= acopCLACLL;
4917
                                mqOP      <= mqopCLR;
4918
                                nextState <= stateDone;
4919
 
4920
                            --
4921
                            -- Mode A:
4922
                            -- Normal case where LSR shift count not maxed out.
4923
                            --
4924
 
4925
                            else
4926
                                scOP      <= scopMDP1;
4927
                                acOP      <= acopCLL;
4928
                                nextState <= stateEAEshift;
4929
 
4930
                            end if;
4931
 
4932
                        else
4933
 
4934
                            --
4935
                            -- Mode B:
4936
                            -- Handle case where LSR Shift count is maxed out.
4937
                            --
4938
 
4939
                            if unsigned(MD) > 24 then
4940
                                scOP      <= scopCLR;
4941
                                acOP      <= acopCLACLL;
4942
                                mqOP      <= mqopCLR;
4943
                                gtfOP     <= gtfopCLR;
4944
                                nextState <= stateEAEshift;
4945
 
4946
                            --
4947
                            -- Mode B:
4948
                            -- Handle case where LSR Shift count is zero
4949
                            --
4950
 
4951
                            elsif unsigned(MD(7 to 11)) = 0 then
4952
                                acOP      <= acopCLL;
4953
                                nextState <= stateDone;
4954
 
4955
                            --
4956
                            -- Mode B:
4957
                            -- Normal case where LSR shift count not maxed out.
4958
                            --
4959
 
4960
                            else
4961
                                scOP      <= scopMD7to11;
4962
                                acOP      <= acopCLL;
4963
                                nextState <= stateEAEshift;
4964
 
4965
                            end if;
4966
                        end if;
4967
 
4968
                    --
4969
                    -- OP 7441: SCA - Step Count OR with AC
4970
                    --
4971
                    -- The ones complement of the last five bits of this
4972
                    -- operand are loaded into the Step Counter and the
4973
                    -- program resumes at the instruction word following
4974
                    -- the operand.
4975
                    --
4976
 
4977
                    when opEAESCA =>
4978
                        assert false report "stateEAEfetchData: SCA should not re-dispatch here" severity warning;
4979
                        nextState <= stateLALA;
4980
 
4981
                    --
4982
                    -- OP 7407: DAD - Double Precision Add.  DAD is MODEB only.
4983
                    -- In MODEB, the operand is the address of the quotient,
4984
                    -- which is possibly pre-incremented before use.
4985
                    --
4986
 
4987
                    when opEAEDAD =>
4988
                        if EMODE = '0' then
4989
                            assert false report "stateEAEfetchData: SCA/SCL should not re-dispath here" severity warning;
4990
                            nextState <= stateLALA;
4991
                        else
4992
                            if MA(3 to 11) = maAutoIncr then
4993
 
4994
                                --
4995
                                -- Start the writeback of the incremented data
4996
                                --
4997
 
4998
                                wrOP      <= '1';
4999
                                mbOP      <= mbopMDP1;
5000
                                --XMAOPTBD
5001
                                --DATAFOP OR IFETCHOP
5002
                                memselOP  <= '1';
5003
                                nextState <= stateEAEindWrite;
5004
 
5005
                           else
5006
 
5007
                                --
5008
                                -- Start address phase of indirect data
5009
                                --
5010
 
5011
                                maOP      <= maopMD;
5012
                               --XMAOPTBD
5013
                                datafOP   <= '1';
5014
                                memselOP  <= '1';
5015
                                nextState <= stateEAEindReadAddr;
5016
 
5017
                            end if;
5018
                        end if;
5019
 
5020
                    --
5021
                    -- OP 7445: SCA/MUY -
5022
                    --          DST - Double Precision Store.
5023
                    --
5024
 
5025
                    when opEAEDST =>
5026
                        if EMODE = '0' then
5027
                            EAEop     <= eaeopMUY;
5028
                            nextState <= stateEAEmuy;
5029
                        else
5030
                            if MA(3 to 11) = maAutoIncr then
5031
 
5032
                                --
5033
                                -- Start the writeback of the incremented data
5034
                                --
5035
 
5036
                                wrOP      <= '1';
5037
                                mbOP      <= mbopMDP1;
5038
                                --XMAOPTBD
5039
                                --DATAFOP OR IFETCHOP
5040
                                memselOP  <= '1';
5041
                                nextState <= stateEAEindWrite;
5042
 
5043
                           else
5044
 
5045
                                --
5046
                                -- Start address phase of indirect data
5047
                                --
5048
 
5049
                                maOP      <= maopMD;
5050
                                xmaOP     <= xmaopDF;
5051
                                datafOP   <= '1';
5052
                                memselOP  <= '1';
5053
                                nextState <= stateEAEindReadAddr;
5054
 
5055
                            end if;
5056
                        end if;
5057
 
5058
                    --
5059
                    -- OP 7451:  DPSZ - Double Precision Skip if Zero
5060
                    --
5061
 
5062
                    when opEAEDPSZ =>
5063
                        assert false report "stateEAEfetchData: DPSZ should not re-dispatch here" severity warning;
5064
                        nextState <= stateLALA;
5065
 
5066
                    --
5067
                    -- OP 7453: DPIC - Double Precision Increment
5068
                    --
5069
 
5070
                    when opEAEDPIC =>
5071
                        assert false report "stateEAEfetchData: DPIC should not re-dispatch here" severity warning;
5072
                        nextState <= stateLALA;
5073
 
5074
                    --
5075
                    -- OP 7455: DCM - Double Precision Complement.
5076
                    --
5077
 
5078
                    when opEAEDCM =>
5079
                        assert false report "stateEAEfetchData: DCM should not re-dispatch here" severity warning;
5080
                        nextState <= stateLALA;
5081
 
5082
                    --
5083
                    -- OP 7457: SAM - Subtract AC from MQ.
5084
                    --
5085
 
5086
                    when opEAESAM =>
5087
                        assert false report "stateEAEfetchData: SAM should not re-dispatch here" severity warning;
5088
                        nextState <= stateLALA;
5089
 
5090
                    --
5091
                    -- Everything else.
5092
                    --
5093
 
5094
                    when others =>
5095
                        assert false report "stateEAEfetchData: Unimplemented EAE case" severity warning;
5096
                        nextState <= stateDone;
5097
                end case;
5098
 
5099
            --
5100
            -- statePOPaddr
5101
            -- This state increments the stack pointer SP1 or SP2, sets
5102
            -- the MA to the incremented value, and performs a Read Addr cycle.
5103
            --   MD <- MEM[000'MA]
5104
 
5105
            when statePOPaddr =>
5106
                rdOP      <= '1';
5107
                acOP      <= acopCLA;
5108
                xmaOP     <= xmaopCLR;
5109
                memselOP  <= '1';
5110
                busOP     <= busopRDZFdata;
5111
                nextState <= statePOPdata;
5112
 
5113
            --
5114
            -- statePOPdata
5115
            -- This state completed the read of the top-of-stack and
5116
            -- placed the data in the MD.  It also cleared AC so that
5117
            -- we can add MD to the AC.
5118
            --   AC <- MD
5119
            --
5120
 
5121
            when statePOPdata =>
5122
                acOP      <= acopADDMD;
5123
                nextState <= stateDone;
5124
 
5125
            --
5126
            -- RTN1 Read State
5127
            -- The previous state incremented SP1.
5128
            -- This state sets up a Read Addr Cycle to the memory location
5129
            -- pointed to by SP2.
5130
            --
5131
            -- If Instructions are being fetched from main memory, the stacks
5132
            -- are located in field 0 of main memory.  If Instructions are
5133
            -- being fetched from panel memory, the stacks are located in field
5134
            -- 0 of panel memory, except for the case of a RTN from control
5135
            -- panel  memory via a RTN1 or RTN2 Instruction. In this case, the
5136
            -- main memory stack is accessed by the instruction fetched from
5137
            -- panel memory.
5138
            --
5139
 
5140
            when stateRTN1 =>
5141
                maOP      <= maopSP1;
5142
                xmaOP     <= xmaopCLR;
5143
                memselOP  <= '1';
5144
                busOP     <= busopRDZFaddr;
5145
                nextState <= stateRTNaddr;
5146
 
5147
            --
5148
            -- RTN2 Read State
5149
            -- The previous state incremented SP2.
5150
            -- This state sets up a Read Addr Cycle to the memory location
5151
            -- pointed to by SP2.
5152
            --
5153
            -- If Instructions are being fetched from main memory, the stacks
5154
            -- are located in field 0 of main memory.  If Instructions are
5155
            -- being fetched from panel memory, the stacks are located in field
5156
            -- 0 of panel memory, except for the case of a RTN from control
5157
            -- panel  memory via a RTN1 or RTN2 Instruction. In this case, the
5158
            -- main memory stack is accessed by the instruction fetched from
5159
            -- panel memory.
5160
            --
5161
 
5162
            when stateRTN2 =>
5163
                maOP      <= maopSP2;
5164
                xmaOP     <= xmaopCLR;
5165
                memselOP  <= '1';
5166
                busOP     <= busopRDZFaddr;
5167
                nextState <= stateRTNaddr;
5168
 
5169
            --
5170
            -- stateRTNaddr
5171
            -- The previous state peformed a Read Addr cycle to the top-of-stack.
5172
            -- This state sets up a Read Data Cycle.
5173
            --
5174
            -- If Instructions are being fetched from main memory, the stacks
5175
            -- are located in field 0 of main memory.  If Instructions are
5176
            -- being fetched from panel memory, the stacks are located in field
5177
            -- 0 of panel memory, except for the case of a RTN from control
5178
            -- panel  memory via a RTN1 or RTN2 Instruction. In this case, the
5179
            -- main memory stack is accessed by the instruction fetched from
5180
            -- panel memory.
5181
            --
5182
 
5183
            when stateRTNaddr =>
5184
                rdOP      <= '1';
5185
                xmaOP     <= xmaopCLR;
5186
                memselOP  <= '1';
5187
                busOP     <= busopRDZFdata;
5188
                nextState <= stateRTNdata;
5189
 
5190
            --
5191
            -- stateRTNdata
5192
            -- The previous state performed a Read Data Cycle to the
5193
            -- top-of-stack.
5194
            --
5195
            -- The contents of the Instruction Buffer (IB) is loaded into the
5196
            -- Instruction Field (IF) register.
5197
            --
5198
            -- If the Interrupt Inhibit Flip Flop (II) is set, then the Force
5199
            -- Zero (FZ) flag is cleared.
5200
            --
5201
            -- When the PEX Flip-flop is set, the CPU shall exit from Panel
5202
            -- Mode to Main Memory (i.e., clear CTRLFF) during the next JMP,
5203
            -- JMS, RTN1 or RTN2 instruction.
5204
            --
5205
            -- PEX is cleared by the JMP, JMS, RTN1 or RTN2 instruction.
5206
            --
5207
 
5208
            when stateRTNdata =>
5209
                ifOP <= ifopIB;
5210
                pcOP <= pcopMD;
5211
 
5212
                if PEX = '1' then
5213
                    ctrlffOP <= ctrlffopCLR;
5214
                    pexOP    <= pexopCLR;
5215
                end if;
5216
 
5217
                if II = '1' then
5218
                    fzOP  <= fzopCLR;
5219
                end if;
5220
                nextState <= stateDone;
5221
 
5222
            --
5223
            -- stateEAEindWrite
5224
            -- This state performs an indirect write
5225
            --
5226
 
5227
            when stateEAEindWrite =>
5228
                maOP      <= maopMB;
5229
                --XMAOPTBD
5230
                datafOP   <= '1';
5231
                memselOP  <= '1';
5232
                nextState <= stateEAEindReadAddr;
5233
 
5234
            --
5235
            -- stateEAEindReadAddr -
5236
            -- The previous state set the MA register to the indirect address.
5237
            -- This state handles the address phase of the EAE indirect read cycle.
5238
            --
5239
 
5240
            when stateEAEindReadAddr =>
5241
                rdOP      <= '1';
5242
                --XMAOPTBD
5243
                datafOP   <= '1';
5244
                memselOP  <= '1';
5245
                nextState <= stateEAEindReadData;
5246
 
5247
            --
5248
            -- stateEAEindReadData -
5249
            -- This state handles the data phase of the EAE indirect read cycle.
5250
            -- At the end of this state, the indirect data should be in the MD
5251
            -- register.  This state then redispatches the MUY, DVI, DAD, and
5252
            -- DST instructions.  At this point the operand is in the MD register.
5253
            --
5254
 
5255
            when stateEAEindReadData =>
5256
                EAEIR := IR(6) & IR(8) & IR(9) & IR(10);
5257
                case EAEIR is
5258
 
5259
                    --
5260
                    -- MUY - Setup EAE and go to next state.
5261
                    --
5262
 
5263
                    when opEAEMUY =>
5264
                        eaeOP     <= eaeopMUY;
5265
                        nextState <= stateEAEmuy;
5266
 
5267
                    --
5268
                    -- DVI - Check for overflow right away.  If overflow, then
5269
                    -- set state and exit. Otherwise setup EAE, MQ, SC, and go to
5270
                    -- next state.  The Divisor is in MD.
5271
                    --
5272
 
5273
                    when opEAEDVI =>
5274
 
5275
                        --
5276
                        -- Handle divide overflow condition
5277
                        --
5278
 
5279
                        if AC >= MD then
5280
                            scOP      <= scopCLR;
5281
                            acOP      <= acopCLLCML;
5282
                            mqOP      <= mqopSHL1;
5283
                            nextState <= stateDone;
5284
 
5285
                        --
5286
                        -- Handle normal divide condition
5287
                        --
5288
 
5289
                        else
5290
                            mqaOP     <= mqaopMQ;
5291
                            scOP      <= scopCLR;
5292
                            acOP      <= acopCLL;
5293
                            nextState <= stateEAEsubDVI;
5294
 
5295
                        end if;
5296
 
5297
                    --
5298
                    -- DAD - Add the contents of MD to MQ.
5299
                    --
5300
                    --
5301
 
5302
                    when opEAEDAD =>
5303
                        maOP      <= maopINC;
5304
                        mqOP      <= mqopADDMD;
5305
                        --XMAOPTBD
5306
                        datafOP   <= '1';
5307
                        memselOP  <= '1';
5308
 
5309
                        --
5310
                        -- Handle cases where carry does/doesnot come from MQ
5311
                        --
5312
 
5313
                        if (unsigned('0'& MQ) + unsigned('0' & MD)) > 4095 then
5314
                            nextState <= stateEAEreadDADaddr1;
5315
                        else
5316
                            nextState <= stateEAEreadDADaddr0;
5317
                        end if;
5318
 
5319
                    --
5320
                    -- DST - Stores the MQ data to MEM[XMA & MA]
5321
                    --
5322
 
5323
                    when opEAEDST =>
5324
                        wrOP      <= '1';
5325
                        mbOP      <= mbopMQ;
5326
                        --XMAOPTBD
5327
                        --DATAFOP OR IFETCHOP
5328
                        memselOP  <= '1';
5329
                        nextState <= stateEAEdst;
5330
 
5331
                    --
5332
                    -- Everything else.
5333
                    --
5334
 
5335
                    when others =>
5336
                        nextState <= stateLALA;
5337
 
5338
                end case;
5339
 
5340
            --
5341
            -- StateEAEshift - This is where all the shift loop for the EAE ASR,
5342
            -- LSR, and SHR instructions occurs.  On right shifts, bits shifted
5343
            -- out of of EAE(24) are shifted into the GTF to facillitate
5344
            -- round-off operations.  In Mode A, the  shift operations complete
5345
            -- with SC set to zero.  In Mode B the shift operations complete
5346
            -- with the SC set to 31.
5347
            --
5348
 
5349
            when stateEAEshift =>
5350
                EAEIR := IR(6) & IR(8) & IR(9) & IR(10);
5351
                if unsigned(SC) = 0 then
5352
                    if EAEIR = opEAELSR then
5353
                        acOP <= acopCLL;
5354
                    end if;
5355
                    if EMODE = '0' then
5356
                        scOP <= scopCLR;
5357
                    else
5358
                        scOP <= scopSET;
5359
                    end if;
5360
                    nextState <= stateDone;
5361
                else
5362
                    case EAEIR is
5363
                        when opEAELSR =>
5364
                            if EMODE = '1' then
5365
                                if MQ(11) = '0' then
5366
                                    gtfOP <= gtfopCLR;
5367
                                else
5368
                                    gtfOP <= gtfopSET;
5369
                                end if;
5370
                            end if;
5371
                            acOP <= acopLSR;
5372
                            if AC(11) = '0' then
5373
                                mqOP <= mqopSHR0;
5374
                            else
5375
                                mqOP <= mqopSHR1;
5376
                            end if;
5377
                        when opEAEASR =>
5378
                            if EMODE = '1' then
5379
                                if MQ(11) = '0' then
5380
                                    gtfOP <= gtfopCLR;
5381
                                else
5382
                                    gtfOP <= gtfopSET;
5383
                                end if;
5384
                            end if;
5385
                            acOP <= acopASR;
5386
                            if AC(11) = '0' then
5387
                                mqOP <= mqopSHR0;
5388
                            else
5389
                                mqOP <= mqopSHR1;
5390
                            end if;
5391
                        when opEAESHL =>
5392
                            mqOP <= mqopSHL0;
5393
                            if MQ(0) = '0' then
5394
                                acOP <= acopSHL0;
5395
                            else
5396
                                acOP <= acopSHL1;
5397
                            end if;
5398
                        when others =>
5399
                            assert false report "stateEAEshift: Not a shift OP" severity warning;
5400
                    end case;
5401
                    scOP      <= scopDEC;
5402
                    nextState <= stateEAEwait;
5403
                end if;
5404
 
5405
            --
5406
            -- stateEAEwait
5407
            -- stateEAEshift has a hard time meeting timing.  This gives the
5408
            -- accumulators a little extra time to settle.
5409
            --
5410
 
5411
            when stateEAEwait =>
5412
                nextState <= stateEAEshift;
5413
 
5414
            --
5415
            -- stateEAEnmi
5416
            -- The Step Counter is initially cleared.  The contents of the
5417
            -- Link, AC, and MQ registers are are shifted left until AC(0) and
5418
            -- AC(1) are different or until AC(2) through MQ(11) are all zero.
5419
            -- The Step Count register is increment once for every shift.  If
5420
            -- MODE B, and the contents of AC & MQ is o"4000_0000", the AC is
5421
            -- cleared.
5422
            --
5423
 
5424
            when stateEAEnmi =>
5425
                if (AC(0) /= AC(1)) or (unsigned(AC(2 to 11)) = 0 and unsigned(MQ) = 0) then
5426
                    if EMODE = '1' and unsigned(AC) = 2048 and unsigned(MQ) = 0 then
5427
                        acOP  <= acopCLA;
5428
                    end if;
5429
                    nextState <= stateDone;
5430
                else
5431
                    scOP      <= scopINC;
5432
                    mqOP      <= mqopSHL0;
5433
                    if MQ(0) = '0' then
5434
                        acOP  <= acopSHL0;
5435
                    else
5436
                        acOP  <= acopSHL1;
5437
                    end if;
5438
                    nextState <= stateEAEnmi;
5439
                end if;
5440
 
5441
            --
5442
            -- The contents of the MQ are multiplied by the multiplier (in the
5443
            -- MD) and the MSBs of the 24 bit result are left in the AC and the
5444
            -- LSBs are left in the MQ. The multiplication is unsigned.  If AC
5445
            -- is non-zero, the product is added to AC.
5446
            --
5447
 
5448
            when stateEAEmuy =>
5449
                acOP      <= acopEAEZAC;
5450
                mqOP      <= mqopEAE;
5451
                scOP      <= scop12;
5452
                nextState <= stateDone;
5453
 
5454
            --
5455
            -- stateEAEsubDVI - Long division is a shift and subtract
5456
            -- operation.  This state handles the subtraction.
5457
            -- MQ = (AC & MQ) / MD
5458
            -- AC = (AC & MQ) % MD
5459
            --
5460
 
5461
            when stateEAEsubDVI =>
5462
                if unsigned(LAC) >= unsigned(MD) then
5463
                    mqOP  <= mqopSHL1;
5464
                    acOP  <= acopSUBMD;
5465
                else
5466
                    mqOP  <= mqopSHL0;
5467
                end if;
5468
                scOP      <= scopINC;
5469
                nextState <= stateEAEshiftDVI;
5470
 
5471
            --
5472
            -- stateEAEshiftDVI - Long division is a shift and subtract
5473
            -- operation.  This state handles the shift operation.
5474
            --
5475
 
5476
            when stateEAEshiftDVI =>
5477
 
5478
                --
5479
                -- Check for loop exit condtions
5480
                --
5481
 
5482
                if unsigned(SC) = 13 then
5483
                    acOP      <= acopCLL;
5484
                    nextState <= stateDone;
5485
 
5486
                --
5487
                -- Shift L, AC, and MQ left
5488
                --
5489
 
5490
                else
5491
                    mqaOP     <= mqaopSHL;
5492
                    if MQA(0) = '0' then
5493
                        acOP  <= acopSHL0;
5494
                    else
5495
                        acOP  <= acopSHL1;
5496
                    end if;
5497
                    nextState <= stateEAEsubDVI;
5498
 
5499
                end if;
5500
 
5501
            --
5502
            -- stateEAEreadDADaddr0
5503
            -- This is the address phase of the read cycle for the second
5504
            -- operand (third word).  This state is for cases where there is no
5505
            -- carry from the addition of MQ.
5506
            --
5507
 
5508
            when stateEAEreadDADaddr0 =>
5509
                rdOP      <= '1';
5510
                acOP      <= acopCLL;
5511
                --XMAOPTBD
5512
                datafOP   <= '1';
5513
                memselOP  <= '1';
5514
                nextState <= stateEAEreadDADdata0;
5515
 
5516
            --
5517
            -- stateEAEreadDADaddr1
5518
            -- This is the address phase of the read cycle for the second
5519
            -- operand (third word).   This state is for cases where there is a
5520
            -- carry from the addition of MQ.  Clear the link for the add
5521
            -- instruction in the next state.
5522
            --
5523
 
5524
            when stateEAEreadDADaddr1 =>
5525
                rdOP      <= '1';
5526
                acOP      <= acopCLL;
5527
                --XMAOPTBD
5528
                datafOP   <= '1';
5529
                memselOP  <= '1';
5530
                nextState <= stateEAEreadDADdata1;
5531
 
5532
            --
5533
            -- stateEAEreadDADdata0
5534
            -- This is the data phase of the read cycle for the second operand
5535
            -- (third word).  This state is for cases where there is no carry
5536
            -- from the addition of MQ. Clear the link for the add instruction
5537
            -- in the next state.
5538
            --
5539
 
5540
            when stateEAEreadDADdata0 =>
5541
                acOP      <= acopADDMD;
5542
                nextState <= stateDone;
5543
 
5544
            --
5545
            -- stateEAEreadDADdata1
5546
            -- This is the data phase of the read cycle for the second operand
5547
            -- (third word).  This state is for cases where there is a carry
5548
            -- from the addition of MQ.
5549
            --
5550
 
5551
            when stateEAEreadDADdata1 =>
5552
                acOP      <= acopADDMDP1;
5553
                nextState <= stateDone;
5554
 
5555
            --
5556
            -- stateEAEdst - This state stores the AC data to MEM[XMA & (MA + 1)]
5557
            --
5558
 
5559
            when stateEAEdst =>
5560
                wrOP      <= '1';
5561
                maOP      <= maopINC;
5562
                mbOP      <= mbopAC;
5563
                xmaOP     <= xmaopDF;
5564
                memselOP  <= '1';
5565
                datafOP   <= '1';
5566
                nextState <= stateDone;
5567
 
5568
            --
5569
            -- Done State
5570
            -- This is the last state of the instruction.  This wastes a state
5571
            -- but makes it easy to 'see' the end of the instruction cycle.
5572
            --
5573
 
5574
            when stateDone =>
5575
                nextstate <= stateCheckReq;
5576
 
5577
            --
5578
            -- You've landed in LA-LA land.  You shouldn't get here.  Somehow
5579
            -- some OPCODE was not decoded correctly or the next state for the
5580
            -- State Machine was not set.  Plug your ears, close your eyes and
5581
            -- scream LA-LA-LA-LA-LA-LA-LA-LA-LA-LA-LA.
5582
            --
5583
 
5584
            when stateLALA =>
5585
                nextState <= stateLALA;
5586
 
5587
        end case;
5588
 
5589
    end process NEXT_STATE;
5590
 
5591
    mem : block
5592
    begin
5593
 
5594
        --!
5595
        --! LXPAR is generated for panel memory accesses: It is asserted when:
5596
        --! #.  MEMSEL asserted and CPU is HD6120 and Panel Mode and Direct
5597
        --!     Memory Op with PDF in any state (two cases of CTRLFF).
5598
        --! #.  MEMSEL asserted and CPU is HD6120 and Panel Mode and Indirect
5599
        --!     Memory Op with PDF asserted (two cases of CTRLFF).
5600
        --!
5601
 
5602
        lxparOP <= '1' when ((memselOP = '1' and swCPU  = swHD6120 and CTRLFF = '0' and ctrlffOP  = ctrlffopSET and datafOP = '0') or
5603
                             (memselOP = '1' and swCPU  = swHD6120 and CTRLFF = '1' and ctrlffOP /= ctrlffopCLR and datafOP = '0') or
5604
                             (memselOP = '1' and swCPU  = swHD6120 and CTRLFF = '0' and ctrlffOP  = ctrlffopSET and datafOP = '1' and PDF = '1') or
5605
                             (memselOP = '1' and swCPU  = swHD6120 and CTRLFF = '1' and ctrlffOP /= ctrlffopCLR and datafOP = '1' and PDF = '1')) else
5606
                   '0';
5607
 
5608
 
5609
        --!
5610
        --! LXMAR is generated for normal memory accesses.  It is asserted when:
5611
        --! #.  MEMSEL asserted and CPU is HD6120 and Panel Mode and Indirect
5612
        --!     Memory Op with PDF negated (two cases of CRTLFF).
5613
        --! #.  MEMSEL asserted and CPU is HD6120 and Normal Mode (two cases of
5614
        --!     CTRLFF).
5615
        --! #.  MEMSEL asserted and not HD6120.
5616
        --!
5617
 
5618
        lxmarOP <= '1' when ((memselOP = '1' and swCPU  = swHD6120 and CTRLFF = '0' and ctrlffOP  = ctrlffopSET and datafOP = '1' and PDF = '0') or
5619
                             (memselOP = '1' and swCPU  = swHD6120 and CTRLFF = '1' and ctrlffOP /= ctrlffopCLR and datafOP = '1' and PDF = '0') or
5620
                             (memselOP = '1' and swCPU  = swHD6120 and CTRLFF = '0' and ctrlffOP /= ctrlffopSET) or
5621
                             (memselOP = '1' and swCPU  = swHD6120 and CTRLFF = '1' and ctrlffOP  = ctrlffopCLR) or
5622
                             (memselOP = '1' and swCPU /= swHD6120)) else
5623
                   '0';
5624
 
5625
        --!
5626
        --! Wait for Bus ACK on:
5627
        --! #.  DMA access
5628
        --! #.  Memory accesses
5629
        --! #.  Reads to devices
5630
        --! #.  Writes to devices
5631
        --!
5632
 
5633
        waitfOP <= '1' when ((memselOP = '1') or
5634
                             (lxdarOP = '1' and rdOP = '1') or
5635
                             (lxdarOP = '1' and wrOP = '1')) else
5636
                   '0';
5637
 
5638
    end block;
5639
 
5640
    --
5641
    --! DMA Request.
5642
    --! Only start DMA cycle when MEM cycle is unused.
5643
    --
5644
 
5645
    DMAREQ : process(sys)
5646
    begin
5647
        if sys.rst = '1' then
5648
            dmagnt <= '0';
5649
        elsif rising_edge(sys.clk) then
5650
            if dev.dma.req = '1' then
5651
                if memselOP = '0' then
5652
                    dmagnt <= '1';
5653
                end if;
5654
            else
5655
                dmagnt <= '0';
5656
            end if;
5657
        end if;
5658
    end process DMAREQ;
5659
 
5660
    --
5661
    --! State Machine
5662
    --! The state only changes when properly ack'd and when not doing DMA.
5663
    --
5664
 
5665
    CURR_STATE : process(sys)
5666
        variable lastdma : std_logic;
5667
        -- synthesis translate_off
5668
        variable LIN : line;
5669
        -- synthesis translate_on
5670
    begin
5671
        if sys.rst = '1' then
5672
            ioclrb  <= '1';
5673
            wrb     <= '0';
5674
            rdb     <= '0';
5675
            ifetchb <= '0';
5676
            datafb  <= '0';
5677
            lxdarb  <= '0';
5678
            lxmarb  <= '0';
5679
            lxparb  <= '0';
5680
            memselb <= '0';
5681
            intgntb <= '0';
5682
            waitfb  <= '0';
5683
            lastdma := '0';
5684
            state   <= stateReset;
5685
        elsif rising_edge(sys.clk) then
5686
            if dmagnt = '1' and memselOP = '1' then
5687
                null;
5688
            else
5689
                if waitfb = '0' or dev.ack = '1' then
5690
                    ioclrb  <= ioclrOP;
5691
                    wrb     <= wrOP;
5692
                    rdb     <= rdOP;
5693
                    ifetchb <= ifetchOP;
5694
                    datafb  <= datafOP;
5695
                    lxdarb  <= lxdarOP;
5696
                    lxmarb  <= lxmarOP;
5697
                    lxparb  <= lxparOP;
5698
                    memselb <= memselOP;
5699
                    intgntb <= intgntOP;
5700
                    waitfb  <= waitfOP;
5701
                    state   <= nextState;
5702
                end if;
5703
            end if;
5704
 
5705
-- synthesis translate_off
5706
 
5707
            if dmagnt = '1' and lastdma = '0' then
5708
                assert false report "-------------> DMA Asserted <------------" severity note;
5709
            elsif dmagnt = '0' and lastdma = '1' then
5710
                assert false report "-------------> DMA Negated <------------" severity note;
5711
            end if;
5712
            lastdma := dmagnt;
5713
 
5714
            case xmaOP is
5715
                when xmaopIF =>
5716
                    if datafOP = '1' then
5717
                        assert false report "Bus Monitor: XMA <- IF, but datafOP <- '1' " severity note;
5718
                    end if;
5719
                when xmaopDF =>
5720
                    if datafOP = '0' then
5721
                        assert false report "Bus Monitor: XMA <- DF, but datafOP <- '0' " severity note;
5722
                    end if;
5723
                when others =>
5724
                    if memselOP = '1' then
5725
                        assert false report "Bus Monitor: XMA <- NOP, but memselOP <- '1' " severity note;
5726
                    end if;
5727
             end case;
5728
 
5729
-- synthesis translate_on
5730
 
5731
        end if;
5732
    end process CURR_STATE;
5733
 
5734
--    oops <= '1' when ((xmaOP  = xmaopIF and datafOP  = '1') or
5735
--                      (xmaOP  = xmaopDF and datafOP  = '0') or
5736
--                      (xmaOP /= xmaopIF and memselOP = '1') or
5737
--                      (xmaOP /= xmaopDF and memselOP = '1')) else '0';
5738
 
5739
 
5740
    oops <= '1' when ((busOP = busopRESET       and ioclrOP   =      '0') or            -- IOCLR should be set
5741
 
5742
                      (busOP = busopIOCLR       and ioclrOP  =       '0') or            -- IOCLR should be set
5743
                      (busOP = busopIOCLR       and lxdarOP  =       '0') or            -- LXDAR should be set
5744
                      (busOP = busopIOCLR       and datafOP  =       '0') or            -- DATAF should be set
5745
 
5746
                      (busOP = busopFETCHaddr   and xmaOP    /=  xmaopIF) or
5747
                      (busOP = busopFETCHaddr   and ifetchOP  =      '0') or
5748
                      (busOP = busopFETCHaddr   and memselOP  =      '0') or
5749
 
5750
                      (busOP = busopFETCHdata   and xmaOP    /=  xmaopIF) or
5751
                      (busOP = busopFETCHdata   and ifetchOP  =      '0') or
5752
                      (busOP = busopFETCHdata   and memselOP  =      '0') or
5753
                      (busOP = busopFETCHdata   and rdOP      =      '0') or
5754
 
5755
                      (busOP = busopWRIB        and xmaOP    /=  xmaopIB) or
5756
                      (busOP = busopWRIB        and memselOP  =      '0') or
5757
                      (busOP = busopWRIB        and wrOP      =      '0') or
5758
 
5759
                      (busOP = busopRDIBaddr    and xmaOP    /=  xmaopIB) or
5760
                      (busOP = busopRDIBaddr    and memselOP  =      '0') or
5761
 
5762
                      (busOP = busopRDIBdata    and xmaOP    /=  xmaopIB) or
5763
                      (busOP = busopRDIBdata    and memselOP  =      '0') or
5764
                      (busOP = busopRDIBdata    and rdOP      =      '0') or
5765
 
5766
                      (busOP = busopWRIF        and xmaOP    /=  xmaopIF) or
5767
                      (busOP = busopWRIF        and memselOP  =      '0') or
5768
                      (busOP = busopWRIF        and wrOP      =      '0') or
5769
 
5770
                      (busOP = busopRDIFaddr    and xmaOP    /=  xmaopIF) or
5771
                      (busOP = busopRDIFaddr    and memselOP  =      '0') or
5772
 
5773
                      (busOP = busopRDIFdata    and xmaOP    /=  xmaopIF) or
5774
                      (busOP = busopRDIFdata    and memselOP  =      '0') or
5775
                      (busOP = busopRDIFdata    and rdOP      =      '0') or
5776
 
5777
                      (busOP = busopWRDF        and xmaOP    /=  xmaopDF) or
5778
                      (busOP = busopWRDF        and memselOP  =      '0') or
5779
                      (busOP = busopRDDFaddr    and datafOP   =      '0') or
5780
                      (busOP = busopWRDF        and wrOP      =      '0') or
5781
 
5782
                      (busOP = busopRDDFaddr    and xmaOP    /=  xmaopDF) or
5783
                      (busOP = busopRDDFaddr    and memselOP  =      '0') or
5784
                      (busOP = busopRDDFaddr    and datafOP   =      '0') or
5785
 
5786
                      (busOP = busopRDDFdata    and xmaOP    /=  xmaopDF) or
5787
                      (busOP = busopRDDFdata    and memselOP  =      '0') or
5788
                      (busOP = busopRDDFdata    and datafOP   =      '0') or
5789
                      (busOP = busopRDDFdata    and rdOP      =      '0') or
5790
 
5791
                      (busOP = busopWRZF        and xmaOP    /= xmaopCLR) or
5792
                      (busOP = busopWRZF        and memselOP   =     '0') or
5793
                      (busOP = busopWRZF        and wrOP       =     '0') or
5794
 
5795
                      (busOP = busopRDZFaddr    and xmaOP    /= xmaopCLR) or
5796
                      (busOP = busopRDZFaddr    and memselOP  =      '0') or
5797
 
5798
                      (busOP = busopRDZFdata    and xmaOP    /= xmaopCLR) or
5799
                      (busOP = busopRDZFdata    and memselOP  =      '0') or
5800
                      (busOP = busopRDZFdata    and rdOP      =      '0') or
5801
 
5802
                      (busOP = busopWRIOT       and datafOP  =       '0') or
5803
                      (busOP = busopWRIOT       and lxdarOP  =       '0') or
5804
                      (busOP = busopWRIOT       and wrOP     =       '0') or
5805
 
5806
                      (busOP = busopRDIOT       and datafOP  =       '0') or
5807
                      (busOP = busopRDIOT       and lxdarOP  =       '0') or
5808
                      (busOP = busopRDIOT       and rdOP     =       '0')) else '0';
5809
 
5810
 
5811
    --! PANEL:
5812
    --! Externally visable (front panel) register state is only updated at
5813
    --! certain times in the instruction cycle.
5814
    --
5815
 
5816
    PANEL : process(sys)
5817
        variable CPC : addr_t;
5818
    begin
5819
        if sys.rst = '1' then
5820
            cpu.regs.PC  <= (others => '0');
5821
            cpu.regs.AC  <= (others => '0');
5822
            cpu.regs.IR  <= (others => '0');
5823
            cpu.regs.MQ  <= (others => '0');
5824
            cpu.regs.ST  <= (others => '0');
5825
            cpu.regs.SC  <= (others => '0');
5826
            cpu.regs.MD  <= (others => '0');
5827
            cpu.regs.MA  <= (others => '0');
5828
            cpu.regs.XMA <= (others => '0');
5829
            CPC          := (others => '0');
5830
        elsif rising_edge(sys.clk) then
5831
 
5832
            --
5833
            -- Handle reads are writes
5834
            --
5835
 
5836
            if lxmarb = '1' then
5837
                if rdb = '1' then
5838
                    cpu.regs.MD <= MD;
5839
                elsif wrb = '1' then
5840
                    cpu.regs.MD <= MB;
5841
                end if;
5842
                cpu.regs.MA  <= MA;
5843
                cpu.regs.XMA <= XMA;
5844
            end if;
5845
 
5846
            --
5847
            -- State-based updates
5848
            --
5849
 
5850
            case state is
5851
 
5852
                --
5853
                -- Instruction Fetch
5854
                --
5855
 
5856
                when stateFetchAddr =>
5857
                    CPC := PC;
5858
 
5859
                --
5860
                -- State Halt Done
5861
                --
5862
 
5863
                when stateHaltDone =>
5864
                    cpu.regs.PC <= PC;
5865
                    cpu.regs.AC <= AC;
5866
                    cpu.regs.IR <= IR;
5867
                    cpu.regs.MA <= MA;
5868
                    cpu.regs.MQ <= MQ;
5869
                    cpu.regs.ST <= L & GTF & IRQ & II & ID & UF & INF & DF;
5870
                    cpu.regs.SC <= "0000000" & SC;
5871
 
5872
                --
5873
                -- Last state of instruction
5874
                --
5875
 
5876
                when stateDone =>
5877
                    cpu.regs.PC <= PC;
5878
                    cpu.regs.AC <= AC;
5879
                    cpu.regs.IR <= IR;
5880
                    cpu.regs.MQ <= MQ;
5881
                    cpu.regs.ST <= L & GTF & IRQ & II & ID & UF & INF & DF;
5882
                    cpu.regs.SC <= "0000000" & SC;
5883
                    dumpState(CPC);
5884
 
5885
                --
5886
                -- Anything else?
5887
                --
5888
 
5889
                when others =>
5890
                    null;
5891
            end case;
5892
        end if;
5893
    end process PANEL;
5894
 
5895
    --!
5896
    --! DMA Bus Switch
5897
    --!
5898
 
5899
    DMA : process(dmagnt, dev, dev.dma, rdb, wrb, ifetchb, lxmarb, lxparb,
5900
            lxdarb, memselb, datafb, MA, MB, XMA)
5901
    begin
5902
        if dmagnt = '1' then
5903
            cpu.buss.rd     <= dev.dma.rd;
5904
            cpu.buss.wr     <= dev.dma.wr;
5905
            cpu.buss.ifetch <= '0';
5906
            cpu.buss.dataf  <= '0';
5907
            cpu.buss.lxmar  <= dev.dma.lxmar;
5908
            cpu.buss.lxpar  <= dev.dma.lxpar;
5909
            cpu.buss.lxdar  <= '0';
5910
            cpu.buss.memsel <= dev.dma.memsel;
5911
            cpu.buss.addr   <= dev.dma.addr;
5912
            cpu.buss.eaddr  <= dev.dma.eaddr;
5913
            cpu.buss.data   <= dev.data;
5914
        else
5915
            cpu.buss.rd     <= rdb;
5916
            cpu.buss.wr     <= wrb;
5917
            cpu.buss.ifetch <= ifetchb;
5918
            cpu.buss.dataf  <= datafb;
5919
            cpu.buss.lxmar  <= lxmarb;
5920
            cpu.buss.lxpar  <= lxparb;
5921
            cpu.buss.lxdar  <= lxdarb;
5922
            cpu.buss.memsel <= memselb;
5923
            cpu.buss.addr   <= MA;
5924
            cpu.buss.eaddr  <= XMA;
5925
            cpu.buss.data   <= MB;
5926
        end if;
5927
    end process DMA;
5928
 
5929
    --
5930
    --! Data Latch
5931
    --! \note
5932
    --!      For now, this processes should infer a latch for the MD
5933
    --!     xs Register.  This is intentional.
5934
    --
5935
 
5936
    REG_MD : process(sys.rst, rdb, dev.data, MD)
5937
    begin
5938
        if sys.rst = '1' then
5939
            MD <= (others => '0');
5940
        elsif rdb = '1' then
5941
            MD <= dev.data;
5942
        else
5943
            MD <= MD;
5944
        end if;
5945
    end process REG_MD;
5946
 
5947
    --!
5948
    --! CPU combinational outputs
5949
    --!
5950
 
5951
    cpu.buss.ioclr  <= ioclrb;
5952
    cpu.buss.intgnt <= intgntb;
5953
    cpu.buss.dmagnt <= dmagnt;
5954
    cpu.run         <= '0' when ((state = stateReset            ) or
5955
                                 (state = stateInit             ) or
5956
                                 (state = stateHalt             ) or
5957
                                 (state = stateContinue         ) or
5958
                                 (state = stateLoadADDR         ) or
5959
                                 (state = stateLoadEXTD         ) or
5960
                                 (state = stateClear            ) or
5961
                                 (state = stateDepositWriteData ) or
5962
                                 (state = stateDeposit          ) or
5963
                                 (state = stateExamine          ) or
5964
                                 (state = stateExamineReadAddr  ) or
5965
                                 (state = stateExamineReadData  ) or
5966
                                 (state = stateHaltDone         ) or
5967
                                 (state = stateLALA             )) else
5968
                       '1';
5969
 
5970
end rtl;

powered by: WebSVN 2.1.0

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