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

Subversion Repositories tv80

[/] [tv80/] [branches/] [hpa1/] [rtl/] [core/] [tv80_core.v] - Blame information for rev 86

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 ghutchis
//
2
// TV80 8-Bit Microprocessor Core
3
// Based on the VHDL T80 core by Daniel Wallner (jesus@opencores.org)
4
//
5
// Copyright (c) 2004 Guy Hutchison (ghutchis@opencores.org)
6
//
7
// Permission is hereby granted, free of charge, to any person obtaining a 
8
// copy of this software and associated documentation files (the "Software"), 
9
// to deal in the Software without restriction, including without limitation 
10
// the rights to use, copy, modify, merge, publish, distribute, sublicense, 
11
// and/or sell copies of the Software, and to permit persons to whom the 
12
// Software is furnished to do so, subject to the following conditions:
13
//
14
// The above copyright notice and this permission notice shall be included 
15
// in all copies or substantial portions of the Software.
16
//
17
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
18
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
19
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
20
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 
21
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 
22
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 
23
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
 
25
module tv80_core (/*AUTOARG*/
26
  // Outputs
27
  m1_n, iorq, no_read, write, rfsh_n, halt_n, busak_n, A, do, mc, ts,
28
  intcycle_n, IntE, stop,
29
  // Inputs
30
  reset_n, clk, cen, wait_n, int_n, nmi_n, busrq_n, dinst, di
31
  );
32
  // Beginning of automatic inputs (from unused autoinst inputs)
33
  // End of automatics
34
 
35
  parameter Mode = 1;   // 0 => Z80, 1 => Fast Z80, 2 => 8080, 3 => GB
36
  parameter IOWait = 1; // 1 => Single cycle I/O, 1 => Std I/O cycle
37
  parameter Flag_C = 0;
38
  parameter Flag_N = 1;
39
  parameter Flag_P = 2;
40
  parameter Flag_X = 3;
41
  parameter Flag_H = 4;
42
  parameter Flag_Y = 5;
43
  parameter Flag_Z = 6;
44
  parameter Flag_S = 7;
45
 
46
  input     reset_n;
47
  input     clk;
48
  input     cen;
49
  input     wait_n;
50
  input     int_n;
51
  input     nmi_n;
52
  input     busrq_n;
53
  output    m1_n;
54
  output    iorq;
55
  output    no_read;
56
  output    write;
57
  output    rfsh_n;
58
  output    halt_n;
59
  output    busak_n;
60 20 ghutchis
  output    reti_n;
61 2 ghutchis
  output [15:0] A;
62
  input [7:0]   dinst;
63
  input [7:0]   di;
64
  output [7:0]  do;
65
  output [2:0]  mc;
66
  output [2:0]  ts;
67
  output        intcycle_n;
68
  output        IntE;
69
  output        stop;
70
 
71
  reg    m1_n;
72
  reg    iorq;
73
  reg    rfsh_n;
74
  reg    halt_n;
75
  reg    busak_n;
76
  reg [15:0] A;
77
  reg [7:0]  do;
78
  reg [2:0]  mc;
79
  reg [2:0]  ts;
80
  reg   intcycle_n;
81
  reg   IntE;
82
  reg   stop;
83 20 ghutchis
  reg   reti_n;
84 2 ghutchis
 
85
  parameter     aNone    = 3'b111;
86
  parameter     aBC      = 3'b000;
87
  parameter     aDE      = 3'b001;
88
  parameter     aXY      = 3'b010;
89
  parameter     aIOA     = 3'b100;
90
  parameter     aSP      = 3'b101;
91
  parameter     aZI      = 3'b110;
92
 
93
  // Registers
94
  reg [7:0]     ACC, F;
95
  reg [7:0]     Ap, Fp;
96
  reg [7:0]     I;
97
  reg [7:0]     R;
98
  reg [15:0]    SP, PC;
99
  reg [7:0]     RegDIH;
100
  reg [7:0]     RegDIL;
101
  wire [15:0]   RegBusA;
102
  wire [15:0]   RegBusB;
103
  wire [15:0]   RegBusC;
104
  reg [2:0]     RegAddrA_r;
105
  reg [2:0]     RegAddrA;
106
  reg [2:0]     RegAddrB_r;
107
  reg [2:0]     RegAddrB;
108
  reg [2:0]     RegAddrC;
109
  reg           RegWEH;
110
  reg           RegWEL;
111
  reg           Alternate;
112
 
113
  // Help Registers
114
  reg [15:0]    TmpAddr; // Temporary address register
115
  reg [7:0]     IR;              // Instruction register
116
  reg [1:0]     ISet;            // Instruction set selector
117
  reg [15:0]    RegBusA_r;
118
 
119
  reg [15:0]    ID16;
120
  reg [7:0]     Save_Mux;
121
 
122
  reg [2:0]     tstate;
123
  reg [2:0]     mcycle;
124
  reg           IntE_FF1;
125
  reg           IntE_FF2;
126
  reg           Halt_FF;
127
  reg           BusReq_s;
128
  reg           BusAck;
129
  reg           ClkEn;
130
  reg           NMI_s;
131
  reg           INT_s;
132
  reg [1:0]     IStatus;
133
 
134
  reg [7:0]     DI_Reg;
135
  reg           T_Res;
136
  reg [1:0]     XY_State;
137
  reg [2:0]     Pre_XY_F_M;
138
  reg           NextIs_XY_Fetch;
139
  reg           XY_Ind;
140
  reg           No_BTR;
141
  reg           BTR_r;
142
  reg           Auto_Wait;
143
  reg           Auto_Wait_t1;
144
  reg           Auto_Wait_t2;
145
  reg           IncDecZ;
146
 
147
  // ALU signals
148
  reg [7:0]     BusB;
149
  reg [7:0]     BusA;
150
  wire [7:0]    ALU_Q;
151
  wire [7:0]    F_Out;
152
 
153
  // Registered micro code outputs
154
  reg [4:0]     Read_To_Reg_r;
155
  reg           Arith16_r;
156
  reg           Z16_r;
157
  reg [3:0]     ALU_Op_r;
158
  reg           Save_ALU_r;
159
  reg           PreserveC_r;
160
  reg [2:0]     mcycles;
161
 
162
  // Micro code outputs
163
  wire [2:0]    mcycles_d;
164
  wire [2:0]    tstates;
165
  reg           IntCycle;
166
  reg           NMICycle;
167
  wire          Inc_PC;
168
  wire          Inc_WZ;
169
  wire [3:0]    IncDec_16;
170
  wire [1:0]    Prefix;
171
  wire          Read_To_Acc;
172
  wire          Read_To_Reg;
173
  wire [3:0]     Set_BusB_To;
174
  wire [3:0]     Set_BusA_To;
175
  wire [3:0]     ALU_Op;
176
  wire           Save_ALU;
177
  wire           PreserveC;
178
  wire           Arith16;
179
  wire [2:0]     Set_Addr_To;
180
  wire           Jump;
181
  wire           JumpE;
182
  wire           JumpXY;
183
  wire           Call;
184
  wire           RstP;
185
  wire           LDZ;
186
  wire           LDW;
187
  wire           LDSPHL;
188
  wire           iorq_i;
189
  wire [2:0]     Special_LD;
190
  wire           ExchangeDH;
191
  wire           ExchangeRp;
192
  wire           ExchangeAF;
193
  wire           ExchangeRS;
194
  wire           I_DJNZ;
195
  wire           I_CPL;
196
  wire           I_CCF;
197
  wire           I_SCF;
198
  wire           I_RETN;
199 20 ghutchis
  wire           I_RETI;
200 2 ghutchis
  wire           I_BT;
201
  wire           I_BC;
202
  wire           I_BTR;
203
  wire           I_RLD;
204
  wire           I_RRD;
205
  wire           I_INRC;
206
  wire           SetDI;
207
  wire           SetEI;
208
  wire [1:0]     IMode;
209
  wire           Halt;
210
 
211
  reg [15:0]     PC16;
212
  reg [15:0]     PC16_B;
213
  reg [15:0]     SP16, SP16_A, SP16_B;
214
  reg [15:0]     ID16_B;
215
  reg            Oldnmi_n;
216
 
217
  tv80_mcode #(Mode, Flag_C, Flag_N, Flag_P, Flag_X, Flag_H, Flag_Y, Flag_Z, Flag_S) i_mcode
218
    (
219
     .IR                   (IR),
220
     .ISet                 (ISet),
221
     .MCycle               (mcycle),
222
     .F                    (F),
223
     .NMICycle             (NMICycle),
224
     .IntCycle             (IntCycle),
225
     .MCycles              (mcycles_d),
226
     .TStates              (tstates),
227
     .Prefix               (Prefix),
228
     .Inc_PC               (Inc_PC),
229
     .Inc_WZ               (Inc_WZ),
230
     .IncDec_16            (IncDec_16),
231
     .Read_To_Acc          (Read_To_Acc),
232
     .Read_To_Reg          (Read_To_Reg),
233
     .Set_BusB_To          (Set_BusB_To),
234
     .Set_BusA_To          (Set_BusA_To),
235
     .ALU_Op               (ALU_Op),
236
     .Save_ALU             (Save_ALU),
237
     .PreserveC            (PreserveC),
238
     .Arith16              (Arith16),
239
     .Set_Addr_To          (Set_Addr_To),
240
     .IORQ                 (iorq_i),
241
     .Jump                 (Jump),
242
     .JumpE                (JumpE),
243
     .JumpXY               (JumpXY),
244
     .Call                 (Call),
245
     .RstP                 (RstP),
246
     .LDZ                  (LDZ),
247
     .LDW                  (LDW),
248
     .LDSPHL               (LDSPHL),
249
     .Special_LD           (Special_LD),
250
     .ExchangeDH           (ExchangeDH),
251
     .ExchangeRp           (ExchangeRp),
252
     .ExchangeAF           (ExchangeAF),
253
     .ExchangeRS           (ExchangeRS),
254
     .I_DJNZ               (I_DJNZ),
255
     .I_CPL                (I_CPL),
256
     .I_CCF                (I_CCF),
257
     .I_SCF                (I_SCF),
258
     .I_RETN               (I_RETN),
259 20 ghutchis
     .I_RETI               (I_RETI),
260 2 ghutchis
     .I_BT                 (I_BT),
261
     .I_BC                 (I_BC),
262
     .I_BTR                (I_BTR),
263
     .I_RLD                (I_RLD),
264
     .I_RRD                (I_RRD),
265
     .I_INRC               (I_INRC),
266
     .SetDI                (SetDI),
267
     .SetEI                (SetEI),
268
     .IMode                (IMode),
269
     .Halt                 (Halt),
270
     .NoRead               (no_read),
271
     .Write                (write)
272
     );
273
 
274
  tv80_alu #(Mode, Flag_C, Flag_N, Flag_P, Flag_X, Flag_H, Flag_Y, Flag_Z, Flag_S) i_alu
275
    (
276
     .Arith16              (Arith16_r),
277
     .Z16                  (Z16_r),
278
     .ALU_Op               (ALU_Op_r),
279
     .IR                   (IR[5:0]),
280
     .ISet                 (ISet),
281
     .BusA                 (BusA),
282
     .BusB                 (BusB),
283
     .F_In                 (F),
284
     .Q                    (ALU_Q),
285
     .F_Out                (F_Out)
286
     );
287
 
288
  always @(/*AUTOSENSE*/ALU_Q or BusAck or BusB or DI_Reg
289
           or ExchangeRp or IR or Save_ALU_r or Set_Addr_To or XY_Ind
290
           or XY_State or cen or mcycle or tstate or tstates)
291
    begin
292
      ClkEn = cen && ~ BusAck;
293
 
294
      if (tstate == tstates)
295
        T_Res = 1'b1;
296
      else T_Res = 1'b0;
297
 
298
      if (XY_State != 2'b00 && XY_Ind == 1'b0 &&
299
          ((Set_Addr_To == aXY) ||
300
           (mcycle == 3'b001 && IR == 8'b11001011) ||
301
           (mcycle == 3'b001 && IR == 8'b00110110)))
302
        NextIs_XY_Fetch = 1'b1;
303
      else
304
        NextIs_XY_Fetch = 1'b0;
305
 
306
      if (ExchangeRp)
307
        Save_Mux = BusB;
308
      else if (!Save_ALU_r)
309
        Save_Mux = DI_Reg;
310
      else
311
        Save_Mux = ALU_Q;
312
    end // always @ *
313
 
314
  always @ (posedge clk)
315
    begin
316
      if (reset_n == 1'b0 )
317
        begin
318
          PC <= #1 0;  // Program Counter
319
          A <= #1 0;
320
          TmpAddr <= #1 0;
321
          IR <= #1 8'b00000000;
322
          ISet <= #1 2'b00;
323
          XY_State <= #1 2'b00;
324
          IStatus <= #1 2'b00;
325
          mcycles <= #1 3'b000;
326
          do <= #1 8'b00000000;
327
 
328
          ACC <= #1 8'hFF;
329
          F <= #1 8'hFF;
330
          Ap <= #1 8'hFF;
331
          Fp <= #1 8'hFF;
332
          I <= #1 0;
333
          R <= #1 0;
334
          SP <= #1 16'hFFFF;
335
          Alternate <= #1 1'b0;
336
 
337
          Read_To_Reg_r <= #1 5'b00000;
338
          Arith16_r <= #1 1'b0;
339
          BTR_r <= #1 1'b0;
340
          Z16_r <= #1 1'b0;
341
          ALU_Op_r <= #1 4'b0000;
342
          Save_ALU_r <= #1 1'b0;
343
          PreserveC_r <= #1 1'b0;
344
          XY_Ind <= #1 1'b0;
345
        end
346
      else
347
        begin
348
 
349
          if (ClkEn == 1'b1 )
350
            begin
351
 
352
              ALU_Op_r <= #1 4'b0000;
353
              Save_ALU_r <= #1 1'b0;
354
              Read_To_Reg_r <= #1 5'b00000;
355
 
356
              mcycles <= #1 mcycles_d;
357
 
358
              if (IMode != 2'b11 )
359
                begin
360
                  IStatus <= #1 IMode;
361
                end
362
 
363
              Arith16_r <= #1 Arith16;
364
              PreserveC_r <= #1 PreserveC;
365
              if (ISet == 2'b10 && ALU_Op[2] == 1'b0 && ALU_Op[0] == 1'b1 && mcycle == 3'b011 )
366
                begin
367
                  Z16_r <= #1 1'b1;
368
                end
369
              else
370
                begin
371
                  Z16_r <= #1 1'b0;
372
                end
373
 
374
              if (mcycle  == 3'b001 && tstate[2] == 1'b0 )
375
                begin
376
                  // mcycle == 1 && tstate == 1, 2, || 3
377
 
378
                  if (tstate == 2 && wait_n == 1'b1 )
379
                    begin
380
                      if (Mode < 2 )
381
                        begin
382
                          A[7:0] <= #1 R;
383
                          A[15:8] <= #1 I;
384
                          R[6:0] <= #1 R[6:0] + 1;
385
                        end
386
 
387
                      if (Jump == 1'b0 && Call == 1'b0 && NMICycle == 1'b0 && IntCycle == 1'b0 && ~ (Halt_FF == 1'b1 || Halt == 1'b1) )
388
                        begin
389
                          PC <= #1 PC16;
390
                        end
391
 
392
                      if (IntCycle == 1'b1 && IStatus == 2'b01 )
393
                        begin
394
                          IR <= #1 8'b11111111;
395
                        end
396
                      else if (Halt_FF == 1'b1 || (IntCycle == 1'b1 && IStatus == 2'b10) || NMICycle == 1'b1 )
397
                        begin
398
                          IR <= #1 8'b00000000;
399
                        end
400
                      else
401
                        begin
402
                          IR <= #1 dinst;
403
                        end
404
 
405
                      ISet <= #1 2'b00;
406
                      if (Prefix != 2'b00 )
407
                        begin
408
                          if (Prefix == 2'b11 )
409
                            begin
410
                              if (IR[5] == 1'b1 )
411
                                begin
412
                                  XY_State <= #1 2'b10;
413
                                end
414
                              else
415
                                begin
416
                                  XY_State <= #1 2'b01;
417
                                end
418
                            end
419
                          else
420
                            begin
421
                              if (Prefix == 2'b10 )
422
                                begin
423
                                  XY_State <= #1 2'b00;
424
                                  XY_Ind <= #1 1'b0;
425
                                end
426
                              ISet <= #1 Prefix;
427
                            end
428
                        end
429
                      else
430
                        begin
431
                          XY_State <= #1 2'b00;
432
                          XY_Ind <= #1 1'b0;
433
                        end
434
                    end // if (tstate == 2 && wait_n == 1'b1 )
435
 
436
 
437
                end
438
              else
439
                begin
440
                  // either (mcycle > 1) OR (mcycle == 1 AND tstate > 3)
441
 
442
                  if (mcycle == 3'b110 )
443
                    begin
444
                      XY_Ind <= #1 1'b1;
445
                      if (Prefix == 2'b01 )
446
                        begin
447
                          ISet <= #1 2'b01;
448
                        end
449
                    end
450
 
451
                  if (T_Res == 1'b1 )
452
                    begin
453
                      BTR_r <= #1 (I_BT || I_BC || I_BTR) && ~ No_BTR;
454
                      if (Jump == 1'b1 )
455
                        begin
456
                          A[15:8] <= #1 DI_Reg;
457
                          A[7:0] <= #1 TmpAddr[7:0];
458
                          PC[15:8] <= #1 DI_Reg;
459
                          PC[7:0] <= #1 TmpAddr[7:0];
460
                        end
461
                      else if (JumpXY == 1'b1 )
462
                        begin
463
                          A <= #1 RegBusC;
464
                          PC <= #1 RegBusC;
465
                        end else if (Call == 1'b1 || RstP == 1'b1 )
466
                          begin
467
                            A <= #1 TmpAddr;
468
                            PC <= #1 TmpAddr;
469
                          end
470
                        else if (mcycle == mcycles && NMICycle == 1'b1 )
471
                          begin
472
                            A <= #1 16'b0000000001100110;
473
                            PC <= #1 16'b0000000001100110;
474
                          end
475
                        else if (mcycle == 3'b011 && IntCycle == 1'b1 && IStatus == 2'b10 )
476
                          begin
477
                            A[15:8] <= #1 I;
478
                            A[7:0] <= #1 TmpAddr[7:0];
479
                            PC[15:8] <= #1 I;
480
                            PC[7:0] <= #1 TmpAddr[7:0];
481
                          end
482
                        else
483
                          begin
484
                            case (Set_Addr_To)
485
                              aXY :
486
                                begin
487
                                  if (XY_State == 2'b00 )
488
                                    begin
489
                                      A <= #1 RegBusC;
490
                                    end
491
                                  else
492
                                    begin
493
                                      if (NextIs_XY_Fetch == 1'b1 )
494
                                        begin
495
                                          A <= #1 PC;
496
                                        end
497
                                      else
498
                                        begin
499
                                          A <= #1 TmpAddr;
500
                                        end
501
                                    end // else: !if(XY_State == 2'b00 )
502
                                end // case: aXY
503
 
504
                              aIOA :
505
                                begin
506
                                  if (Mode == 3 )
507
                                    begin
508
                                      // Memory map I/O on GBZ80
509
                                      A[15:8] <= #1 8'hFF;
510
                                    end
511
                                  else if (Mode == 2 )
512
                                    begin
513
                                      // Duplicate I/O address on 8080
514
                                      A[15:8] <= #1 DI_Reg;
515
                                    end
516
                                  else
517
                                    begin
518
                                      A[15:8] <= #1 ACC;
519
                                    end
520
                                  A[7:0] <= #1 DI_Reg;
521
                                end // case: aIOA
522
 
523
 
524
                              aSP :
525
                                begin
526
                                  A <= #1 SP;
527
                                end
528
 
529
                              aBC :
530
                                begin
531
                                  if (Mode == 3 && iorq_i == 1'b1 )
532
                                    begin
533
                                      // Memory map I/O on GBZ80
534
                                      A[15:8] <= #1 8'hFF;
535
                                      A[7:0] <= #1 RegBusC[7:0];
536
                                    end
537
                                  else
538
                                    begin
539
                                      A <= #1 RegBusC;
540
                                    end
541
                                end // case: aBC
542
 
543
                              aDE :
544
                                begin
545
                                  A <= #1 RegBusC;
546
                                end
547
 
548
                              aZI :
549
                                begin
550
                                  if (Inc_WZ == 1'b1 )
551
                                    begin
552
                                      A <= #1 TmpAddr + 1;
553
                                    end
554
                                  else
555
                                    begin
556
                                      A[15:8] <= #1 DI_Reg;
557
                                      A[7:0] <= #1 TmpAddr[7:0];
558
                                    end
559
                                end // case: aZI
560
 
561
                              default   :
562
                                begin
563
                                  A <= #1 PC;
564
                                end
565
                            endcase // case(Set_Addr_To)
566
 
567
                          end // else: !if(mcycle == 3'b011 && IntCycle == 1'b1 && IStatus == 2'b10 )
568
 
569
 
570
                      Save_ALU_r <= #1 Save_ALU;
571
                      ALU_Op_r <= #1 ALU_Op;
572
 
573
                      if (I_CPL == 1'b1 )
574
                        begin
575
                          // CPL
576
                          ACC <= #1 ~ ACC;
577
                          F[Flag_Y] <= #1 ~ ACC[5];
578
                          F[Flag_H] <= #1 1'b1;
579
                          F[Flag_X] <= #1 ~ ACC[3];
580
                          F[Flag_N] <= #1 1'b1;
581
                        end
582
                      if (I_CCF == 1'b1 )
583
                        begin
584
                          // CCF
585
                          F[Flag_C] <= #1 ~ F[Flag_C];
586
                          F[Flag_Y] <= #1 ACC[5];
587
                          F[Flag_H] <= #1 F[Flag_C];
588
                          F[Flag_X] <= #1 ACC[3];
589
                          F[Flag_N] <= #1 1'b0;
590
                        end
591
                      if (I_SCF == 1'b1 )
592
                        begin
593
                          // SCF
594
                          F[Flag_C] <= #1 1'b1;
595
                          F[Flag_Y] <= #1 ACC[5];
596
                          F[Flag_H] <= #1 1'b0;
597
                          F[Flag_X] <= #1 ACC[3];
598
                          F[Flag_N] <= #1 1'b0;
599
                        end
600
                    end // if (T_Res == 1'b1 )
601
 
602
 
603
                  if (tstate == 2 && wait_n == 1'b1 )
604
                    begin
605
                      if (ISet == 2'b01 && mcycle == 3'b111 )
606
                        begin
607
                          IR <= #1 dinst;
608
                        end
609
                      if (JumpE == 1'b1 )
610
                        begin
611
                          PC <= #1 PC16;
612
                        end
613
                      else if (Inc_PC == 1'b1 )
614
                        begin
615
                          //PC <= #1 PC + 1;
616
                          PC <= #1 PC16;
617
                        end
618
                      if (BTR_r == 1'b1 )
619
                        begin
620
                          //PC <= #1 PC - 2;
621
                          PC <= #1 PC16;
622
                        end
623
                      if (RstP == 1'b1 )
624
                        begin
625
                          TmpAddr <= #1 { 10'h0, IR[5:3], 3'h0 };
626
                          //TmpAddr <= #1 (others =>1'b0);
627
                          //TmpAddr[5:3] <= #1 IR[5:3];
628
                        end
629
                    end
630
                  if (tstate == 3 && mcycle == 3'b110 )
631
                    begin
632
                      TmpAddr <= #1 SP16;
633
                    end
634
 
635
                  if ((tstate == 2 && wait_n == 1'b1) || (tstate == 4 && mcycle == 3'b001) )
636
                    begin
637
                      if (IncDec_16[2:0] == 3'b111 )
638
                        begin
639
                          SP <= #1 SP16;
640
                        end
641
                    end
642
 
643
                  if (LDSPHL == 1'b1 )
644
                    begin
645
                      SP <= #1 RegBusC;
646
                    end
647
                  if (ExchangeAF == 1'b1 )
648
                    begin
649
                      Ap <= #1 ACC;
650
                      ACC <= #1 Ap;
651
                      Fp <= #1 F;
652
                      F <= #1 Fp;
653
                    end
654
                  if (ExchangeRS == 1'b1 )
655
                    begin
656
                      Alternate <= #1 ~ Alternate;
657
                    end
658
                end // else: !if(mcycle  == 3'b001 && tstate(2) == 1'b0 )
659
 
660
 
661
              if (tstate == 3 )
662
                begin
663
                  if (LDZ == 1'b1 )
664
                    begin
665
                      TmpAddr[7:0] <= #1 DI_Reg;
666
                    end
667
                  if (LDW == 1'b1 )
668
                    begin
669
                      TmpAddr[15:8] <= #1 DI_Reg;
670
                    end
671
 
672
                  if (Special_LD[2] == 1'b1 )
673
                    begin
674
                      case (Special_LD[1:0])
675
                        2'b00 :
676
                          begin
677
                            ACC <= #1 I;
678
                            F[Flag_P] <= #1 IntE_FF2;
679
                          end
680
 
681
                        2'b01 :
682
                          begin
683
                            ACC <= #1 R;
684
                            F[Flag_P] <= #1 IntE_FF2;
685
                          end
686
 
687
                        2'b10 :
688
                          I <= #1 ACC;
689
 
690
                        default :
691
                          R <= #1 ACC;
692
                      endcase
693
                    end
694
                end // if (tstate == 3 )
695
 
696
 
697
              if ((I_DJNZ == 1'b0 && Save_ALU_r == 1'b1) || ALU_Op_r == 4'b1001 )
698
                begin
699
                  if (Mode == 3 )
700
                    begin
701
                      F[6] <= #1 F_Out[6];
702
                      F[5] <= #1 F_Out[5];
703
                      F[7] <= #1 F_Out[7];
704
                      if (PreserveC_r == 1'b0 )
705
                        begin
706
                          F[4] <= #1 F_Out[4];
707
                        end
708
                    end
709
                  else
710
                    begin
711
                      F[7:1] <= #1 F_Out[7:1];
712
                      if (PreserveC_r == 1'b0 )
713
                        begin
714
                          F[Flag_C] <= #1 F_Out[0];
715
                        end
716
                    end
717
                end // if ((I_DJNZ == 1'b0 && Save_ALU_r == 1'b1) || ALU_Op_r == 4'b1001 )
718
 
719
              if (T_Res == 1'b1 && I_INRC == 1'b1 )
720
                begin
721
                  F[Flag_H] <= #1 1'b0;
722
                  F[Flag_N] <= #1 1'b0;
723
                  if (DI_Reg[7:0] == 8'b00000000 )
724
                    begin
725
                      F[Flag_Z] <= #1 1'b1;
726
                    end
727
                  else
728
                    begin
729
                      F[Flag_Z] <= #1 1'b0;
730
                    end
731
                  F[Flag_S] <= #1 DI_Reg[7];
732
                  F[Flag_P] <= #1 ~ (^DI_Reg[7:0]);
733
                end // if (T_Res == 1'b1 && I_INRC == 1'b1 )
734
 
735
 
736
              if (tstate == 1 && Auto_Wait_t1 == 1'b0 )
737
                begin
738
                  do <= #1 BusB;
739
                  if (I_RLD == 1'b1 )
740
                    begin
741
                      do[3:0] <= #1 BusA[3:0];
742
                      do[7:4] <= #1 BusB[3:0];
743
                    end
744
                  if (I_RRD == 1'b1 )
745
                    begin
746
                      do[3:0] <= #1 BusB[7:4];
747
                      do[7:4] <= #1 BusA[3:0];
748
                    end
749
                end
750
 
751
              if (T_Res == 1'b1 )
752
                begin
753
                  Read_To_Reg_r[3:0] <= #1 Set_BusA_To;
754
                  Read_To_Reg_r[4] <= #1 Read_To_Reg;
755
                  if (Read_To_Acc == 1'b1 )
756
                    begin
757
                      Read_To_Reg_r[3:0] <= #1 4'b0111;
758
                      Read_To_Reg_r[4] <= #1 1'b1;
759
                    end
760
                end
761
 
762
              if (tstate == 1 && I_BT == 1'b1 )
763
                begin
764
                  F[Flag_X] <= #1 ALU_Q[3];
765
                  F[Flag_Y] <= #1 ALU_Q[1];
766
                  F[Flag_H] <= #1 1'b0;
767
                  F[Flag_N] <= #1 1'b0;
768
                end
769
              if (I_BC == 1'b1 || I_BT == 1'b1 )
770
                begin
771
                  F[Flag_P] <= #1 IncDecZ;
772
                end
773
 
774
              if ((tstate == 1 && Save_ALU_r == 1'b0 && Auto_Wait_t1 == 1'b0) ||
775
                  (Save_ALU_r == 1'b1 && ALU_Op_r != 4'b0111) )
776
                begin
777
                  case (Read_To_Reg_r)
778
                    5'b10111 :
779
                      ACC <= #1 Save_Mux;
780
                    5'b10110 :
781
                      do <= #1 Save_Mux;
782
                    5'b11000 :
783
                      SP[7:0] <= #1 Save_Mux;
784
                    5'b11001 :
785
                      SP[15:8] <= #1 Save_Mux;
786
                    5'b11011 :
787
                      F <= #1 Save_Mux;
788
                  endcase
789
                end // if ((tstate == 1 && Save_ALU_r == 1'b0 && Auto_Wait_t1 == 1'b0) ||...              
790
            end // if (ClkEn == 1'b1 )         
791
        end // else: !if(reset_n == 1'b0 )
792
    end
793
 
794
 
795
  //-------------------------------------------------------------------------
796
  //
797
  // BC('), DE('), HL('), IX && IY
798
  //
799
  //-------------------------------------------------------------------------
800
  always @ (posedge clk)
801
    begin
802
      if (ClkEn == 1'b1 )
803
        begin
804
          // Bus A / Write
805
          RegAddrA_r <= #1  { Alternate, Set_BusA_To[2:1] };
806
          if (XY_Ind == 1'b0 && XY_State != 2'b00 && Set_BusA_To[2:1] == 2'b10 )
807
            begin
808
              RegAddrA_r <= #1 { XY_State[1],  2'b11 };
809
            end
810
 
811
          // Bus B
812
          RegAddrB_r <= #1 { Alternate, Set_BusB_To[2:1] };
813
          if (XY_Ind == 1'b0 && XY_State != 2'b00 && Set_BusB_To[2:1] == 2'b10 )
814
            begin
815
              RegAddrB_r <= #1 { XY_State[1],  2'b11 };
816
            end
817
 
818
          // Address from register
819
          RegAddrC <= #1 { Alternate,  Set_Addr_To[1:0] };
820
          // Jump (HL), LD SP,HL
821
          if ((JumpXY == 1'b1 || LDSPHL == 1'b1) )
822
            begin
823
              RegAddrC <= #1 { Alternate, 2'b10 };
824
            end
825
          if (((JumpXY == 1'b1 || LDSPHL == 1'b1) && XY_State != 2'b00) || (mcycle == 3'b110) )
826
            begin
827
              RegAddrC <= #1 { XY_State[1],  2'b11 };
828
            end
829
 
830
          if (I_DJNZ == 1'b1 && Save_ALU_r == 1'b1 && Mode < 2 )
831
            begin
832
              IncDecZ <= #1 F_Out[Flag_Z];
833
            end
834
          if ((tstate == 2 || (tstate == 3 && mcycle == 3'b001)) && IncDec_16[2:0] == 3'b100 )
835
            begin
836
              if (ID16 == 0 )
837
                begin
838
                  IncDecZ <= #1 1'b0;
839
                end
840
              else
841
                begin
842
                  IncDecZ <= #1 1'b1;
843
                end
844
            end
845
 
846
          RegBusA_r <= #1 RegBusA;
847
        end
848
 
849
    end // always @ (posedge clk)
850
 
851
 
852
  always @(/*AUTOSENSE*/Alternate or ExchangeDH or IncDec_16
853
           or RegAddrA_r or RegAddrB_r or XY_State or mcycle or tstate)
854
    begin
855
      if ((tstate == 2 || (tstate == 3 && mcycle == 3'b001 && IncDec_16[2] == 1'b1)) && XY_State == 2'b00)
856
        RegAddrA = { Alternate, IncDec_16[1:0] };
857
      else if ((tstate == 2 || (tstate == 3 && mcycle == 3'b001 && IncDec_16[2] == 1'b1)) && IncDec_16[1:0] == 2'b10)
858
        RegAddrA = { XY_State[1], 2'b11 };
859
      else if (ExchangeDH == 1'b1 && tstate == 3)
860
        RegAddrA = { Alternate, 2'b10 };
861
      else if (ExchangeDH == 1'b1 && tstate == 4)
862
        RegAddrA = { Alternate, 2'b01 };
863
      else
864
        RegAddrA = RegAddrA_r;
865
 
866
      if (ExchangeDH == 1'b1 && tstate == 3)
867
        RegAddrB = { Alternate, 2'b01 };
868
      else
869
        RegAddrB = RegAddrB_r;
870
    end // always @ *
871
 
872
 
873
  always @(/*AUTOSENSE*/ALU_Op_r or Auto_Wait_t1 or ExchangeDH
874
           or IncDec_16 or Read_To_Reg_r or Save_ALU_r or mcycle
875
           or tstate or wait_n)
876
    begin
877
      RegWEH = 1'b0;
878
      RegWEL = 1'b0;
879
      if ((tstate == 1 && Save_ALU_r == 1'b0 && Auto_Wait_t1 == 1'b0) ||
880
          (Save_ALU_r == 1'b1 && ALU_Op_r != 4'b0111) )
881
        begin
882
          case (Read_To_Reg_r)
883
            5'b10000 , 5'b10001 , 5'b10010 , 5'b10011 , 5'b10100 , 5'b10101 :
884
              begin
885
                RegWEH = ~ Read_To_Reg_r[0];
886
                RegWEL = Read_To_Reg_r[0];
887
              end
888
          endcase // case(Read_To_Reg_r)
889
 
890
        end // if ((tstate == 1 && Save_ALU_r == 1'b0 && Auto_Wait_t1 == 1'b0) ||...
891
 
892
 
893
      if (ExchangeDH == 1'b1 && (tstate == 3 || tstate == 4) )
894
        begin
895
          RegWEH = 1'b1;
896
          RegWEL = 1'b1;
897
        end
898
 
899
      if (IncDec_16[2] == 1'b1 && ((tstate == 2 && wait_n == 1'b1 && mcycle != 3'b001) || (tstate == 3 && mcycle == 3'b001)) )
900
        begin
901
          case (IncDec_16[1:0])
902
            2'b00 , 2'b01 , 2'b10 :
903
              begin
904
                RegWEH = 1'b1;
905
                RegWEL = 1'b1;
906
              end
907
          endcase
908
        end
909
    end // always @ *
910
 
911
 
912
  always @(/*AUTOSENSE*/ExchangeDH or ID16 or IncDec_16 or RegBusA_r
913
           or RegBusB or Save_Mux or mcycle or tstate)
914
    begin
915
      RegDIH = Save_Mux;
916
      RegDIL = Save_Mux;
917
 
918
      if (ExchangeDH == 1'b1 && tstate == 3 )
919
        begin
920
          RegDIH = RegBusB[15:8];
921
          RegDIL = RegBusB[7:0];
922
        end
923
      else if (ExchangeDH == 1'b1 && tstate == 4 )
924
        begin
925
          RegDIH = RegBusA_r[15:8];
926
          RegDIL = RegBusA_r[7:0];
927
        end
928
      else if (IncDec_16[2] == 1'b1 && ((tstate == 2 && mcycle != 3'b001) || (tstate == 3 && mcycle == 3'b001)) )
929
        begin
930
          RegDIH = ID16[15:8];
931
          RegDIL = ID16[7:0];
932
        end
933
    end
934
 
935
  tv80_reg i_reg
936
    (
937
     .clk                  (clk),
938
     .CEN                  (ClkEn),
939
     .WEH                  (RegWEH),
940
     .WEL                  (RegWEL),
941
     .AddrA                (RegAddrA),
942
     .AddrB                (RegAddrB),
943
     .AddrC                (RegAddrC),
944
     .DIH                  (RegDIH),
945
     .DIL                  (RegDIL),
946
     .DOAH                 (RegBusA[15:8]),
947
     .DOAL                 (RegBusA[7:0]),
948
     .DOBH                 (RegBusB[15:8]),
949
     .DOBL                 (RegBusB[7:0]),
950
     .DOCH                 (RegBusC[15:8]),
951
     .DOCL                 (RegBusC[7:0])
952
     );
953
 
954
  //-------------------------------------------------------------------------
955
  //
956
  // Buses
957
  //
958
  //-------------------------------------------------------------------------
959
 
960
  always @ (posedge clk)
961
    begin
962
      if (ClkEn == 1'b1 )
963
        begin
964
          case (Set_BusB_To)
965
            4'b0111 :
966
              BusB <= #1 ACC;
967
            4'b0000 , 4'b0001 , 4'b0010 , 4'b0011 , 4'b0100 , 4'b0101 :
968
              begin
969
                if (Set_BusB_To[0] == 1'b1 )
970
                  begin
971
                    BusB <= #1 RegBusB[7:0];
972
                  end
973
                else
974
                  begin
975
                    BusB <= #1 RegBusB[15:8];
976
                  end
977
              end
978
            4'b0110 :
979
              BusB <= #1 DI_Reg;
980
            4'b1000 :
981
              BusB <= #1 SP[7:0];
982
            4'b1001 :
983
              BusB <= #1 SP[15:8];
984
            4'b1010 :
985
              BusB <= #1 8'b00000001;
986
            4'b1011 :
987
              BusB <= #1 F;
988
            4'b1100 :
989
              BusB <= #1 PC[7:0];
990
            4'b1101 :
991
              BusB <= #1 PC[15:8];
992
            4'b1110 :
993
              BusB <= #1 8'b00000000;
994
            default :
995
              BusB <= #1 8'hxx;
996
          endcase
997
 
998
          case (Set_BusA_To)
999
            4'b0111 :
1000
              BusA <= #1 ACC;
1001
            4'b0000 , 4'b0001 , 4'b0010 , 4'b0011 , 4'b0100 , 4'b0101 :
1002
              begin
1003
                if (Set_BusA_To[0] == 1'b1 )
1004
                  begin
1005
                    BusA <= #1 RegBusA[7:0];
1006
                  end
1007
                else
1008
                  begin
1009
                    BusA <= #1 RegBusA[15:8];
1010
                  end
1011
              end
1012
            4'b0110 :
1013
              BusA <= #1 DI_Reg;
1014
            4'b1000 :
1015
              BusA <= #1 SP[7:0];
1016
            4'b1001 :
1017
              BusA <= #1 SP[15:8];
1018
            4'b1010 :
1019
              BusA <= #1 8'b00000000;
1020
            default :
1021
              BusB <= #1  8'hxx;
1022
          endcase
1023
        end
1024
    end
1025
 
1026
  //-------------------------------------------------------------------------
1027
  //
1028
  // Generate external control signals
1029
  //
1030
  //-------------------------------------------------------------------------
1031
  always @ (posedge clk)
1032
    begin
1033
      if (reset_n == 1'b0 )
1034
        begin
1035
          rfsh_n <= #1 1'b1;
1036
        end
1037
      else
1038
        begin
1039
          if (cen == 1'b1 )
1040
            begin
1041
              if (mcycle == 3'b001 && ((tstate == 2  && wait_n == 1'b1) || tstate == 3) )
1042
                begin
1043
                  rfsh_n <= #1 1'b0;
1044
                end
1045
              else
1046
                begin
1047
                  rfsh_n <= #1 1'b1;
1048
                end
1049
            end
1050
        end
1051
    end
1052
 
1053
 
1054
  always @(/*AUTOSENSE*/BusAck or Halt_FF or I_DJNZ or IntCycle
1055
           or IntE_FF1 or di or iorq_i or mcycle or tstate)
1056
    begin
1057
      mc = mcycle;
1058
      ts = tstate;
1059
      DI_Reg = di;
1060
      halt_n = ~ Halt_FF;
1061
      busak_n = ~ BusAck;
1062
      intcycle_n = ~ IntCycle;
1063
      IntE = IntE_FF1;
1064
      iorq = iorq_i;
1065
      stop = I_DJNZ;
1066
    end
1067
 
1068
  //-----------------------------------------------------------------------
1069
  //
1070
  // Syncronise inputs
1071
  //
1072
  //-----------------------------------------------------------------------
1073
 
1074
  always @ (posedge clk)
1075
    begin : sync_inputs
1076
 
1077
      if (reset_n == 1'b0 )
1078
        begin
1079
          BusReq_s <= #1 1'b0;
1080
          INT_s <= #1 1'b0;
1081
          NMI_s <= #1 1'b0;
1082
          Oldnmi_n <= #1 1'b0;
1083
        end
1084
      else
1085
        begin
1086
          if (cen == 1'b1 )
1087
            begin
1088
              BusReq_s <= #1 ~ busrq_n;
1089
              INT_s <= #1 ~ int_n;
1090
              if (NMICycle == 1'b1 )
1091
                begin
1092
                  NMI_s <= #1 1'b0;
1093
                end
1094
              else if (nmi_n == 1'b0 && Oldnmi_n == 1'b1 )
1095
                begin
1096
                  NMI_s <= #1 1'b1;
1097
                end
1098
              Oldnmi_n <= #1 nmi_n;
1099
            end
1100
        end
1101
    end
1102
 
1103
  //-----------------------------------------------------------------------
1104
  //
1105
  // Main state machine
1106
  //
1107
  //-----------------------------------------------------------------------
1108
 
1109
  always @ (posedge clk)
1110
    begin
1111
      if (reset_n == 1'b0 )
1112
        begin
1113
          mcycle <= #1 3'b001;
1114
          tstate <= #1 3'b000;
1115
          Pre_XY_F_M <= #1 3'b000;
1116
          Halt_FF <= #1 1'b0;
1117
          BusAck <= #1 1'b0;
1118
          NMICycle <= #1 1'b0;
1119
          IntCycle <= #1 1'b0;
1120
          IntE_FF1 <= #1 1'b0;
1121
          IntE_FF2 <= #1 1'b0;
1122
          No_BTR <= #1 1'b0;
1123
          Auto_Wait_t1 <= #1 1'b0;
1124
          Auto_Wait_t2 <= #1 1'b0;
1125
          m1_n <= #1 1'b1;
1126 20 ghutchis
          reti_n <= #1 1'b1;
1127 2 ghutchis
        end
1128
      else
1129
        begin
1130
          if (cen == 1'b1 )
1131
            begin
1132
              if (T_Res == 1'b1 )
1133
                begin
1134
                  Auto_Wait_t1 <= #1 1'b0;
1135
                end
1136
              else
1137
                begin
1138
                  Auto_Wait_t1 <= #1 Auto_Wait || iorq_i;
1139
                end
1140 20 ghutchis
              Auto_Wait_t2 <= #1 Auto_Wait_t1 && !T_Res;
1141 2 ghutchis
              No_BTR <= #1 (I_BT && (~ IR[4] || ~ F[Flag_P])) ||
1142
                        (I_BC && (~ IR[4] || F[Flag_Z] || ~ F[Flag_P])) ||
1143
                        (I_BTR && (~ IR[4] || F[Flag_Z]));
1144 20 ghutchis
              reti_n <= #1 ~I_RETI;
1145 2 ghutchis
              if (tstate == 2 )
1146
                begin
1147
                  if (SetEI == 1'b1 )
1148
                    begin
1149
                      IntE_FF1 <= #1 1'b1;
1150
                      IntE_FF2 <= #1 1'b1;
1151
                    end
1152
                  if (I_RETN == 1'b1 )
1153
                    begin
1154
                      IntE_FF1 <= #1 IntE_FF2;
1155
                    end
1156
                end
1157
              if (tstate == 3 )
1158
                begin
1159
                  if (SetDI == 1'b1 )
1160
                    begin
1161
                      IntE_FF1 <= #1 1'b0;
1162
                      IntE_FF2 <= #1 1'b0;
1163
                    end
1164
                end
1165
              if (IntCycle == 1'b1 || NMICycle == 1'b1 )
1166
                begin
1167
                  Halt_FF <= #1 1'b0;
1168
                end
1169
              if (mcycle == 3'b001 && tstate == 2 && wait_n == 1'b1 )
1170
                begin
1171
                  m1_n <= #1 1'b1;
1172
                end
1173
              if (BusReq_s == 1'b1 && BusAck == 1'b1 )
1174
                begin
1175
                end
1176
              else
1177
                begin
1178
                  BusAck <= #1 1'b0;
1179
                  if (tstate == 2 && wait_n == 1'b0 )
1180
                    begin
1181
                    end
1182
                  else if (T_Res == 1'b1 )
1183
                    begin
1184
                      if (Halt == 1'b1 )
1185
                        begin
1186
                          Halt_FF <= #1 1'b1;
1187
                        end
1188
                      if (BusReq_s == 1'b1 )
1189
                        begin
1190
                          BusAck <= #1 1'b1;
1191
                        end
1192
                      else
1193
                        begin
1194
                          tstate <= #1 3'b001;
1195
                          if (NextIs_XY_Fetch == 1'b1 )
1196
                            begin
1197
                              mcycle <= #1 3'b110;
1198
                              Pre_XY_F_M <= #1 mcycle;
1199
                              if (IR == 8'b00110110 && Mode == 0 )
1200
                                begin
1201
                                  Pre_XY_F_M <= #1 3'b010;
1202
                                end
1203
                            end
1204
                          else if ((mcycle == 3'b111) || (mcycle == 3'b110 && Mode == 1 && ISet != 2'b01) )
1205
                            begin
1206
                              mcycle <= #1 Pre_XY_F_M + 1;
1207
                            end
1208
                          else if ((mcycle == mcycles) ||
1209
                                   No_BTR == 1'b1 ||
1210
                                   (mcycle == 3'b010 && I_DJNZ == 1'b1 && IncDecZ == 1'b1) )
1211
                            begin
1212
                              m1_n <= #1 1'b0;
1213
                              mcycle <= #1 3'b001;
1214
                              IntCycle <= #1 1'b0;
1215
                              NMICycle <= #1 1'b0;
1216
                              if (NMI_s == 1'b1 && Prefix == 2'b00 )
1217
                                begin
1218
                                  NMICycle <= #1 1'b1;
1219
                                  IntE_FF1 <= #1 1'b0;
1220
                                end
1221
                              else if ((IntE_FF1 == 1'b1 && INT_s == 1'b1) && Prefix == 2'b00 && SetEI == 1'b0 )
1222
                                begin
1223
                                  IntCycle <= #1 1'b1;
1224
                                  IntE_FF1 <= #1 1'b0;
1225
                                  IntE_FF2 <= #1 1'b0;
1226
                                end
1227
                            end
1228
                          else
1229
                            begin
1230
                              mcycle <= #1 mcycle + 1;
1231
                            end
1232
                        end
1233
                    end
1234
                  else
1235
                    begin   // verilog has no "nor" operator
1236
                      if ( ~(Auto_Wait == 1'b1 && Auto_Wait_t2 == 1'b0) &&
1237
                           ~(IOWait == 1 && iorq_i == 1'b1 && Auto_Wait_t1 == 1'b0) )
1238
                        begin
1239
                          tstate <= #1 tstate + 1;
1240
                        end
1241
                    end
1242
                end
1243
              if (tstate == 0 )
1244
                begin
1245
                  m1_n <= #1 1'b0;
1246
                end
1247
            end
1248
        end
1249
    end
1250
 
1251
  always @(/*AUTOSENSE*/BTR_r or DI_Reg or IncDec_16 or JumpE or PC
1252
           or RegBusA or RegBusC or SP or tstate)
1253
    begin
1254
      if (JumpE == 1'b1 )
1255
        begin
1256
          PC16_B = { {8{DI_Reg[7]}}, DI_Reg };
1257
        end
1258
      else if (BTR_r == 1'b1 )
1259
        begin
1260
          PC16_B = -2;
1261
        end
1262
      else
1263
        begin
1264
          PC16_B = 1;
1265
        end
1266
 
1267
      if (tstate == 3)
1268
        begin
1269
          SP16_A = RegBusC;
1270
          SP16_B = { {8{DI_Reg[7]}}, DI_Reg };
1271
        end
1272
      else
1273
        begin
1274
          // suspect that ID16 and SP16 could be shared
1275
          SP16_A = SP;
1276
 
1277
          if (IncDec_16[3] == 1'b1)
1278
            SP16_B = -1;
1279
          else
1280
            SP16_B = 1;
1281
        end
1282
 
1283
      if (IncDec_16[3])
1284
        ID16_B = -1;
1285
      else
1286
        ID16_B = 1;
1287
 
1288
      ID16 = RegBusA + ID16_B;
1289
      PC16 = PC + PC16_B;
1290
      SP16 = SP16_A + SP16_B;
1291
    end // always @ *
1292
 
1293
 
1294
  always @(/*AUTOSENSE*/IntCycle or NMICycle or mcycle)
1295
    begin
1296
      Auto_Wait = 1'b0;
1297
      if (IntCycle == 1'b1 || NMICycle == 1'b1 )
1298
        begin
1299
          if (mcycle == 3'b001 )
1300
            begin
1301
              Auto_Wait = 1'b1;
1302
            end
1303
        end
1304
    end // always @ *
1305
 
1306
// synopsys dc_script_begin
1307 20 ghutchis
// set_attribute current_design "revision" "$Id: tv80_core.v,v 1.1.4.1 2004-08-31 05:48:57 ghutchis Exp $" -type string -quiet
1308 2 ghutchis
// synopsys dc_script_end
1309
endmodule // T80
1310
 

powered by: WebSVN 2.1.0

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