-
Notifications
You must be signed in to change notification settings - Fork 9
/
68k.v
6299 lines (5505 loc) · 167 KB
/
68k.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (C) 2022-2023 nukeykt
*
* This file is part of Nuked-MD.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 68000 emulator.
* Thanks:
* John McMaster (siliconpr0n.org):
* 68000 decap and die shot.
* Olivier Galibert:
* 68000 schematics.
* org, andkorzh, HardWareMan (emu-russia):
* help & support.
*
*/
module m68kcpu
(
input MCLK,
input CLK,
input VPA,
input BR,
input BGACK,
input DTACK,
//input VPA_TEST,
input [2:0] IPL,
input BERR,
input RESET_i,
output RESET_pull,
input HALT_i,
output HALT_pull,
input [15:0] DATA_i,
output [15:0] DATA_o,
output DATA_z,
output E_CLK,
output BG,
output [2:0] FC,
output FC_z,
output RW,
output RW_z,
output [22:0] ADDRESS,
output ADDRESS_z,
output AS,
output LDS,
output UDS,
output strobe_z
);
wire w1;
reg l1;
reg l2;
wire w2;
reg l3;
reg l4;
wire w3;
wire w4;
wire w5;
wire w6;
wire w7;
wire w8;
wire w9;
wire w10;
wire w11;
wire w12;
wire w13;
wire w14;
wire w15;
wire w16;
wire w17;
wire w18;
wire w19;
wire w20;
wire w21;
wire w22;
wire w23;
wire w24;
wire w25;
wire w26;
wire w27;
wire w28;
wire w29;
wire w30;
wire w31;
wire w32;
wire w33;
wire w34;
wire w35;
wire w36;
wire w37;
wire w38;
wire w39;
wire w40;
wire w41;
wire w42;
wire w55;
wire w56;
wire w57;
wire w58;
wire w59;
wire w60;
wire w61;
reg w62;
reg w63;
reg w64;
reg w65;
reg w66;
reg w67;
reg w68;
reg w69;
reg w70;
reg w71;
reg w72;
reg w73;
wire w74;
reg w75;
wire w76;
reg w77;
wire w78;
wire w79;
wire w80;
wire w81;
wire w82;
wire w83;
wire w84;
wire w85;
wire w86;
wire w87;
wire w88;
wire w89;
wire w90;
wire w91;
wire w92;
wire w93;
wire w94;
wire w95;
reg l5;
wire w98;
wire w99;
wire w100;
//reg l6;
reg l7;
reg l8;
reg l9;
//reg l10;
wire w101;
wire w102;
reg w103;
wire w104;
reg w105;
wire w106;
reg [15:0] w107;
wire [7:0] w108;
reg [15:0] w109;
wire [15:0] w110;
wire [15:0] w114;
wire addr_carry;
wire w123;
wire w124;
wire w125;
wire w126;
reg w127;
reg w128;
wire [15:0] w132;
wire [15:0] w145;
reg [15:0] w147;
reg l11;
wire w148;
wire w149;
wire w150;
wire w151;
wire w152;
wire w153;
wire w154;
wire w155;
wire w156;
wire w157;
reg [15:0] w158;
wire [15:0] w159;
wire w160;
wire w161;
wire w162;
wire w163;
wire w164;
wire w165;
wire w166;
wire w167;
wire w168;
reg [15:0] w169;
wire w170;
reg [15:0] w171;
wire [15:0] w172;
wire [15:0] w173;
wire w174;
wire w175;
wire w176;
wire w177;
wire w178;
wire w179;
wire w180;
wire w181;
wire w183;
wire w184;
wire w185;
wire w186;
wire w187;
wire w188;
wire w189;
wire w190;
wire w191;
wire w192;
wire w193;
wire w194;
wire w195;
wire w196;
wire w197;
wire w198;
wire w199;
wire w200;
wire w201;
wire w202;
wire w203;
wire w204;
wire w205;
wire w206;
wire w207;
wire w208;
wire w209;
wire w210;
wire w211;
wire w212;
wire w213;
wire w214;
wire w215;
wire w216;
wire w217;
wire w218;
wire w219;
wire w220;
wire w221;
wire w222;
wire w223;
wire w224;
wire w225;
wire w226;
wire w227;
wire w228;
reg w229;
wire w230;
reg w231;
reg w232;
wire w235;
reg w238;
wire w239;
wire w240;
wire w241;
wire w242;
wire w243;
wire w244;
wire w245;
wire w246;
wire w247;
wire w248;
wire w249;
wire w250;
wire w251;
wire w252;
wire w253;
wire w254;
wire w255;
wire w256;
wire w257;
reg w258;
reg [3:0] w259[0:1];
reg w260;
reg w261[0:1];
reg w262;
reg w263;
reg w264;
wire w265;
wire w266;
reg w267;
reg w268[0:2];
reg w269[0:2];
reg [2:0] w270[0:1];
reg w273;
reg w274;
reg w275[0:2];
reg w276[0:2];
reg w277[0:5];
reg w278;
reg _w279_0, _w279_2;
wire _w279_1, _w279_3;
reg w280_mem;
wire w280;
reg _w281_0, _w281_2;
wire _w281_1, _w281_3;
reg w282_mem, w282_n_mem;
wire w282, w282_n;
reg _w284_0, _w284_2;
wire _w284_1, _w284_3;
wire w285;
reg w285_mem;
wire w286;
reg w287;
wire w288;
reg w289;
reg w290;
wire w291;
reg w292;
wire w293;
reg w294[0:1];
wire w295;
reg w296[0:3];
reg w297[0:3];
reg w298[0:3];
reg w299;
wire w300;
reg w301;
wire w302;
reg w303;
wire w304;
wire w305;
wire w306;
wire w307;
reg w308;
//wire w309;
reg w310;
wire w311;
reg w312;
wire w313;
reg w314;
wire w316;
reg w315[0:1];
reg w317;
wire w318;
reg w319;
reg w320;
reg w321;
reg w322;
reg w323;
reg w324;
wire w325;
reg w326;
wire w327;
wire w328;
reg c1_l;
reg c2_l;
reg c3_l;
reg c4_l;
reg c5_l;
wire w330;
wire w331;
wire w332;
wire w333;
wire w334;
reg w335;
wire w336;
wire w337;
reg w338;
wire w339;
wire w340;
wire w341;
reg w342;
reg w343[0:2];
reg w344;
reg w345;
wire w346;
wire w347;
reg w348;
reg w349;
reg w350;
reg w351;
wire w352;
wire w353;
wire w354;
wire w355;
reg w356_0;
wire w356_1;
reg w357_0;
wire w357_1;
reg w358_0;
wire w358_1;
reg w359[0:2];
wire w359_3;
wire w360;
wire w361;
reg w361_mem;
reg w362;
reg w363;
reg w364[0:1];
wire w365;
reg w366;
reg w367;
reg w368;
reg w369;
reg w370;
reg w371;
wire w372;
reg w373;
reg w374;
wire w375;
wire w376;
wire w377;
reg w378;
reg w379;
reg w380;
wire w381;
wire w382;
reg w383;
reg w384;
wire w385;
reg w386;
reg w387;
reg w388;
wire w389[0:8];
wire w390;
wire w391;
wire w392;
wire w393;
wire w394;
wire w395;
wire w396;
wire w397;
reg w398;
wire w399;
reg w400;
reg w401;
wire w402;
wire w403;
reg w404;
wire w405;
reg w406;
wire w407;
reg w408;
wire w409;
reg w410;
wire w411;
wire w412;
wire w413;
reg w414[0:2];
reg w415;
wire w416;
reg w417;
reg w418_mem;
wire w418_1;
wire w419;
reg w420;
reg w421_mem;
wire w421_1;
wire w422;
wire w423;
reg w423_mem;
wire w424;
wire w425;
wire w426;
wire w427;
wire w428;
reg w429;
wire w430;
wire w431;
wire w432;
wire w433;
wire w434;
reg w435[0:2];
reg w436[0:1];
wire w437;
reg w438;
reg w439[0:1];
wire w440;
wire w441;
reg w442[0:1];
reg w443[0:1];
wire w444;
reg w444_mem;
reg [9:0] w445;
reg w446;
reg w447;
reg w448;
wire w449;
wire w450;
reg w451;
reg w452;
reg w453;
reg w454;
reg w455;
reg w456;
reg w457;
reg w458;
reg w459;
reg w460;
reg w461;
wire w462[0:10];
wire w463;
wire [9:0] w464;
wire w465[0:4];
wire [9:0] codebus;
reg [9:0] codebus_mem;
wire w466;
wire w467;
wire w468;
wire w469;
wire w470;
wire w471;
wire [9:0] codebus2;
reg [9:0] codebus2_mem;
reg w472;
reg w473;
wire w474;
wire w475;
wire w476;
wire w477;
wire w478;
reg w479;
reg w480;
reg w481;
wire w482[0:4];
wire w483;
wire w484;
wire w485;
wire w486;
wire w487;
wire w488;
reg w489;
reg w490;
//wire w491;
//wire w492;
//wire w493;
//wire w494;
reg w495;
//wire w496;
//wire w497;
//wire w498;
//wire w499;
reg w500;
reg w501;
reg w502;
reg w503;
reg w504;
reg w505;
reg w506;
wire w507;
wire w508;
wire w509;
wire w510;
wire w511;
wire w512;
//wire w513;
//wire w514;
wire w515;
wire w516;
wire w517;
wire w518;
//reg [0:117] w519;
//reg [0:117] w520;
//reg [0:67] w521;
reg [16:0] w522;
//reg [16:0] w523;
wire w524;
wire w525;
wire w526;
wire w527;
//reg [67:0] w528;
reg [67:0] w529;
//reg [271:0] ucode[0:33];
//reg [271:0] ncode[0:83];
(* ramstyle = "M10K" *) reg [271:0] ucode[0:63];
(* ramstyle = "M10K" *) reg [271:0] ncode[0:255];
reg [15:0] w530;
wire [170:0] a0_pla;
reg [164:20] a0_pla_mem;
wire [9:0] w531;
wire w532;
wire w533;
wire [149:0] a2_pla;
wire a2_pla_g1, a2_pla_g2, a2_pla_g3;
wire [9:0] w534;
wire [9:0] w535;
wire w536;
wire w537;
reg [15:0] w538;
wire [31:0] irdbus;
wire [31:0] irdbus_dbg;
wire [31:0] irdbus_normal;
wire w539;
wire w540;
wire w541;
wire w542;
wire w543;
wire w544;
reg w545;
wire w546;
wire w547;
wire w548;
reg w549;
reg w550;
reg w551;
reg w552;
wire w553;
wire w554;
wire w555, w555_1;
wire w556, w556_1;
wire w557;
wire w558;
wire [3:0] w559;
wire [3:0] w560;
wire [17:0] cond_pla1;
wire [22:0] cond_pla2;
wire w561;
wire w562;
wire w563;
wire w564;
wire w565;
wire w566;
wire w567;
wire w568;
wire [49:0] ird_pla1;
wire [31:0] ird_pla2;
wire [29:0] ird_pla3;
wire [21:0] ird_pla4;
wire [14:0] w569;
wire w570;
wire w571;
wire w572;
wire w573;
wire w574;
wire w575;
wire w576;
reg w577;
wire w578;
wire w579;
wire w580;
wire w581;
wire w582;
wire w583;
wire w584;
wire w585;
wire w586;
wire w587;
wire w588;
wire w589;
wire w590;
wire [15:0] w591;
wire w592;
wire w593;
wire w594;
wire w595;
reg [3:0] w596;
wire [17:0] w597;
reg w598;
wire w599;
wire w600;
wire w601;
wire w602;
wire w603;
wire w604;
reg [15:0] alu_io;
reg w605;
reg w606;
reg w607;
reg w609;
reg w610;
reg w611;
wire w612;
reg w613;
wire w614;
reg w615;
reg [4:0] w616;
reg w617;
reg w618;
wire w619;
reg [3:0] w620;
wire [3:0] w621;
wire w625;
wire [3:0] w626;
wire w627;
wire w628;
wire w629;
wire w630;
wire w631;
wire w632;
wire w633;
reg w634;
wire w635;
wire w636;
wire w637;
reg w638;
reg w639;
wire w640;
reg w641;
wire w642;
wire w643;
reg w644;
wire w645;
wire w646;
wire w647;
reg w648;
reg w649;
reg w650;
wire w651;
wire w652;
wire w653;
wire w654;
wire w655;
reg w656;
reg w657;
reg w658;
reg w659;
reg w660;
reg w661;
reg w662;
reg w663;
reg w664;
reg w665;
reg w666;
wire w667;
wire w668;
wire w669;
wire w670;
wire w671;
wire w672;
wire w673;
wire w674;
wire w675;
wire w676;
wire w677;
wire w678;
wire w679;
wire w680;
wire w681;
wire w682;
wire w683;
wire w684;
wire w685;
wire w686;
wire w687;
wire w688;
wire w689;
wire w690;
reg w691;
reg w692;
reg w693;
reg w694;
reg w695;
reg w696;
reg w697;
reg w698;
reg w699;
reg w700;
reg w701;
reg w702;
reg w703;
reg w704;
reg w705;
reg w706;
reg w707;
reg w708;
reg w709;
reg w710;
reg w711;
wire w712;
wire w713;
reg w714;
reg w715;
reg w716;
reg w717;
reg w718;
reg w719;
reg w720;
reg w721;
reg w722;
reg w723;
reg w724;
reg w725;
reg w726;
reg w727;
reg w728;
reg w729;
reg w730;
reg w731;
reg w732;
wire w733;
reg w733_mem;
wire w734;
wire w735;
wire w736;
wire w737;
reg w737_mem;
wire w738;
reg w738_mem;
wire w739;
reg w739_mem;
reg w740;
reg w741;
wire w742;
reg w742_mem;
wire w743;
wire w744;
reg w744_mem;
wire w745;
wire w746;
reg w746_mem;
wire w747;
reg w748;
wire w749;
reg w750;
reg w751;
reg w752;
reg w753;
reg w754;
reg w755;
reg w756;
wire w757;
reg w758;
reg w759;
reg w760;
reg w761;
reg w762;
reg w763;
wire w764;
reg w765;
reg w766;
reg w767;
reg w768;
reg w769;
reg w770;
wire w771;
reg w773;
wire w774;
reg w775;
reg w776;
reg w777;
wire w778;
reg w779;
wire w780;
reg w781;
reg w782;
wire w783;
wire w784;
reg w784_mem;
wire w785;
wire w786;
wire w787;
wire w789;
wire w790;
wire w791;
wire w792;
reg w793;
wire w794;
wire w795;
wire w796;
wire w797;
wire w798;
wire w799;
wire w800;
wire w801;
wire w802;
wire w803;
wire w804;
wire w805;
wire w806;
reg w807;
reg w808;
wire w809;
wire w810;
wire w811;
reg w812;
wire w813;
wire w814;
wire w815;
wire w816;
wire w817;
reg w818;
reg w819;
wire w820;
wire w821;
wire w822;
wire w823;
wire w824;
wire w825;
wire w826;
wire w827;
wire w828;
wire w829;
wire w830;
wire w831;
wire w832;
reg w833;
reg w834;
reg w835;
wire w836;
wire w837;
reg w838;
reg w839;
wire w840;
reg w841;
wire w842;
wire w843;
reg w844;
reg w845;
reg w846;
wire w847;
reg w848;
wire w849;
reg w850;
reg w851;
reg w852;
wire w853;
wire w854;
wire w855;
wire w856;
wire w857;
wire w858;
wire w859;
wire w860;
wire w861;
wire w862;
wire w863;
wire w864;
wire w865;
wire w866;
wire w867;
wire w868;
wire w869;
wire w870;
wire w871;
wire w872;
wire w873;
wire w874;
wire w875;
wire w876;
wire w877;
wire w878;
wire w879;
wire w880;
wire w881;
reg w882;
wire w883;
reg w884;
reg w885;
wire w886;
wire w887;
wire w888;
reg w889;
wire w890;
reg w891;
wire w892;
reg w893;
reg w894;
wire w895;
wire w896;
wire w897;
reg w898;
wire w899;
wire w900;
wire w901;
wire w902;
wire w903;
reg w904;
wire w905;
wire w906;
//wire w907;
//wire w908;
wire w909;
wire w910;
wire w911;
wire w912;
reg w913;
wire w914;
reg w915;
wire w916;
reg w917;
wire w918;
wire w919;
wire w920;
wire w921;
wire w922;
wire w923;
reg w924;
//wire w925;
wire w926;
reg w927;
wire w928;
reg w929;
wire w930;
wire w931;
wire w932;
wire w933;
wire w934;
reg w935;
wire w936;
reg w937;