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

Subversion Repositories m32632

[/] [m32632/] [trunk/] [rtl/] [STEUER_MISC.v] - Blame information for rev 11

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

Line No. Rev Author Line
1 9 ns32kum
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2
//
3
// This file is part of the M32632 project
4
// http://opencores.org/project,m32632
5
//
6
// Filename: STEUER_MISC.v
7
// Version:  1.0
8
// Date:     30 May 2015
9
//
10
// Copyright (C) 2015 Udo Moeller
11
// 
12
// This source file may be used and distributed without 
13
// restriction provided that this copyright statement is not 
14
// removed from the file and that any derivative work contains 
15
// the original copyright notice and the associated disclaimer.
16
// 
17
// This source file is free software; you can redistribute it 
18
// and/or modify it under the terms of the GNU Lesser General 
19
// Public License as published by the Free Software Foundation;
20
// either version 2.1 of the License, or (at your option) any 
21
// later version. 
22
// 
23
// This source is distributed in the hope that it will be 
24
// useful, but WITHOUT ANY WARRANTY; without even the implied 
25
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
26
// PURPOSE. See the GNU Lesser General Public License for more 
27
// details. 
28
// 
29
// You should have received a copy of the GNU Lesser General 
30
// Public License along with this source; if not, download it 
31
// from http://www.opencores.org/lgpl.shtml 
32
// 
33
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
34
//
35
//      Modules contained in this file:
36
//      1. OPDEC_REG    Central Instruction Register
37
//      2. PROG_COUNTER Program Counters
38
//      3. REG_LIST             Register List Evaluation
39
//      4. ILL_UNDEF    Illegal and Undefined Opcodes Detection
40
//      5. GRUPPE_2             Decoder and State Machine for GRUPPE_2 Opcodes
41
//
42 11 ns32kum
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
43 9 ns32kum
 
44 11 ns32kum
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
45 9 ns32kum
//
46
//      1. OPDEC_REG    Central Instruction Register
47
//
48 11 ns32kum
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
49
module OPDEC_REG ( BCLK, BRESET, NEW, ACC_STAT, PROT_ERROR, ALSB, USED, IC_DIN, IC_INIT, DC_INIT, Y_INIT, RESTART, STOP_IC,
50 9 ns32kum
                                   OPREG, ANZ_VAL, IC_READ, NEW_PC, NEXT_ADR, DATA_HOLD, ABORT, IC_TEX, INIT_DONE);
51
 
52
        input                   BCLK,BRESET;
53
        input                   NEW;            // a program jump took place
54
        input    [3:0]   ACC_STAT;       // ICACHE signals data is available or Abort
55
        input                   PROT_ERROR;     // comes direct from ICACHE
56
        input    [1:0]   ALSB;           // lower addressbits of access address to ICACHE
57
        input    [2:0]   USED;           // Message from DECODER how many bytes were used
58
        input   [31:0]   IC_DIN;         // ICACHE Data
59
        input                   IC_INIT,DC_INIT,Y_INIT; // Initialising or new setting is running
60
        input                   RESTART;        // "Break" of Instruction Pipeline - set up new i.e. after load of PSR
61
        input                   STOP_IC;        // For LMR and CINV
62
 
63
        output  [55:0]   OPREG;          // this is the Central Opcode Decode Register, length = 7 bytes
64
        output   [2:0]   ANZ_VAL;
65
        output                  IC_READ;
66
        output                  NEW_PC;
67
        output                  NEXT_ADR;
68
        output                  DATA_HOLD;
69
        output                  ABORT;
70
        output   [2:0]   IC_TEX;
71
        output                  INIT_DONE;
72
 
73
        reg             [55:0]   OPREG;
74
        reg              [2:0]   ANZ_VAL;
75
        reg                             IC_READ;
76
        reg                             ABORT;
77
        reg                             abort_flag;
78
        reg              [2:0]   IC_TEX;
79
        reg             [55:0]   data_to_ri;
80
        reg                             old_init;
81
        reg                             pre_new;
82
        reg                             new_reg;
83
        reg                             nseq_flag;
84
        reg                             stop_init;
85
 
86
        wire     [2:0]   new_anz;
87
        wire                    new_restart;
88
        wire                    acc_err,acc_ok,acc_ende;
89
 
90
        // ++++++++++++++++++++  Evaluation of ACC_STAT from Instructioncache  ++++++++++++++++++++++++++++
91
 
92
        // ACC_STAT[3:0] : PROT_ERROR , ABO_LEVEL1 , ABORT , ACC_OK
93
 
94
        assign acc_err = ACC_STAT[3] | ACC_STAT[1] | PROT_ERROR;
95
        assign acc_ok  = ACC_STAT[0];
96
 
97
        always @(posedge BCLK or negedge BRESET)        // is kept until DECODER really needs the data !
98
                if (!BRESET) ABORT <= 1'b0;
99
                  else ABORT <=  (acc_err & ~(new_restart | pre_new)) | (ABORT & ~NEW_PC);
100
 
101 11 ns32kum
        always @(posedge BCLK) if (acc_err) IC_TEX <= (ACC_STAT[3] | PROT_ERROR) ? {nseq_flag,2'b11} : {nseq_flag,~ACC_STAT[2],ACC_STAT[2]};
102 9 ns32kum
 
103
        always @(posedge BCLK) nseq_flag <= NEW_PC | (nseq_flag & ~acc_ok);     // for MMU Status Register
104
 
105
        always @(posedge BCLK) abort_flag <= acc_err;
106 11 ns32kum
        assign acc_ende = ~IC_READ | acc_ok | abort_flag;       // abort_flag one cycle later is ok ! If no ICache access always end
107 9 ns32kum
 
108
        assign new_restart = NEW | RESTART;     // They are pulses
109
 
110
        // Branch work out : NEW/RESTART notice if access still not ended
111
        always @(posedge BCLK) pre_new <= (new_restart & ~acc_ende) | (pre_new & ~acc_ende & BRESET);
112
 
113
        assign NEW_PC = (new_restart | pre_new) & acc_ende;     // At the end of access geenerate new address !
114
 
115 11 ns32kum
        // There are 2 "NEW/RESTART" : "new_restart" combinatorical out of DECODER, "pre_new" out of Register
116 9 ns32kum
        always @(posedge BCLK) new_reg <= new_restart | pre_new | (new_reg & ~acc_ende & BRESET);
117
 
118
        always @(USED or OPREG) // Data first shift to the right
119
                case (USED)
120
                  3'b000 : data_to_ri = OPREG;
121
                  3'b001 : data_to_ri =               { 8'hxx, OPREG[55:8]};
122
                  3'b010 : data_to_ri =             {16'hxxxx,OPREG[55:16]};
123
                  3'b011 : data_to_ri =          {24'hxx_xxxx,OPREG[55:24]};
124
                  3'b100 : data_to_ri =        {32'hxxxx_xxxx,OPREG[55:32]};
125
                  3'b101 : data_to_ri =     {40'hxx_xxxx_xxxx,OPREG[55:40]};
126
                  3'b110 : data_to_ri =   {48'hxxxx_xxxx_xxxx,OPREG[55:48]};
127
                  3'b111 : data_to_ri = 56'hxx_xxxx_xxxx_xxxx;
128
                endcase
129
 
130
        assign new_anz = ANZ_VAL - USED;
131
 
132
        always @(posedge BCLK)
133
                casex ({new_reg,acc_ok,ALSB,new_anz})
134
                  7'b1_100_xxx : OPREG <=        {24'hxx_xxxx,IC_DIN};
135
                  7'b1_101_xxx : OPREG <=      {32'hxxxx_xxxx,IC_DIN[31:8]};
136
                  7'b1_110_xxx : OPREG <=   {40'hxx_xxxx_xxxx,IC_DIN[31:16]};
137
                  7'b1_111_xxx : OPREG <= {48'hxxxx_xxxx_xxxx,IC_DIN[31:24]};
138
                  7'b0_0xx_xxx : OPREG <= data_to_ri;
139
                  7'b0_1xx_000 : OPREG <= {24'hxx_xxxx,IC_DIN};
140
                  7'b0_1xx_001 : OPREG <= {   16'hxxxx,IC_DIN, data_to_ri[7:0]};
141
                  7'b0_1xx_010 : OPREG <= {      8'hxx,IC_DIN,data_to_ri[15:0]};
142
                  7'b0_1xx_011 : OPREG <= {            IC_DIN,data_to_ri[23:0]};
143
                  7'b0_1xx_1xx : OPREG <= data_to_ri;
144
                endcase
145
 
146
        always @(posedge BCLK or negedge BRESET)
147
                if (!BRESET) ANZ_VAL <= 3'b000;
148
                  else
149
                        casex ({new_restart,new_reg,acc_ok,new_anz[2]})
150
                          4'b1x_x_x : ANZ_VAL <= 3'b000;        // hard setting to 0
151
                          4'b01_0_x : ANZ_VAL <= 3'b000;
152
                          4'b01_1_x : ANZ_VAL <= pre_new ? 3'b000 : 3'b100 - {1'b0,ALSB};
153
                          4'b00_0_x : ANZ_VAL <= new_anz;
154
                          4'b00_1_0 : ANZ_VAL <= new_anz + 3'b100;
155
                          4'b00_1_1 : ANZ_VAL <= new_anz;
156
                        endcase
157
 
158 11 ns32kum
        assign NEXT_ADR = new_reg ? (acc_ok & ~pre_new) : (acc_ok & ~new_anz[2]);       // switches MUX at PC resp. ICACHE
159 9 ns32kum
 
160
        // Instruction CACHE Control : READ is coming after all INITs are done
161
 
162
        always @(posedge BCLK) old_init <= IC_INIT | DC_INIT | Y_INIT;
163
 
164
        assign INIT_DONE = old_init & ~IC_INIT & ~DC_INIT;
165
 
166
        always @(posedge BCLK or negedge BRESET)
167
                if (!BRESET) stop_init <= 1'b0;
168
                        else stop_init <= stop_init | IC_READ;
169
 
170 11 ns32kum
        // The INIT_DONE should come after Reset. But it comes too at LMR PTB therefore extra enable after Reset !
171 9 ns32kum
        always @(posedge BCLK or negedge BRESET)
172
                if (!BRESET) IC_READ <= 1'b0;
173
                        else IC_READ <= (IC_READ & ~acc_err & ~(STOP_IC & acc_ok)) | NEW_PC | (INIT_DONE & ~stop_init);
174
 
175
        // The Opcode-Register can not store the data : keep them in ICACHE at IO-access
176
        assign DATA_HOLD = ~new_restart & ~new_reg & acc_ok & new_anz[2];
177
 
178
endmodule
179
 
180 11 ns32kum
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
181 9 ns32kum
//
182
//      2. PROG_COUNTER Program Counters
183
//
184 11 ns32kum
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
185
module PROG_COUNTER ( BCLK, BRESET, NEW, LOAD_PC, NEW_PC, NEXT_ADR, NEXT_PCA, DISP, PC_NEW, USED, USER, SAVE_PC, FPU_TRAP,
186 9 ns32kum
                                          ADIVAR, PC_ARCHI, PC_ICACHE, PC_SAVE, ALSB, IC_USER);
187
 
188
        input                   BCLK,BRESET;
189
        input                   NEW;
190
        input                   LOAD_PC;
191
        input                   NEW_PC;
192
        input                   NEXT_ADR;
193
        input                   NEXT_PCA;
194
        input   [31:0]   DISP;
195
        input   [31:0]   PC_NEW;
196
        input    [2:0]   USED;
197
        input                   USER;
198
        input                   SAVE_PC;
199
        input                   FPU_TRAP;
200
        input                   ADIVAR;
201
 
202
        output  [31:0]   PC_ARCHI;       // goes to Datapath
203
        output  [31:0]   PC_ICACHE;
204
        output  [31:0]   PC_SAVE;        // is the return address
205
        output   [1:0]   ALSB;
206
        output                  IC_USER;
207
 
208
        reg             [31:0]   PC_ARCHI;
209
        reg             [31:0]   pc_adduse;
210
        reg             [31:0]   pc_ic_reg;
211
        reg             [31:0]   fpu_trap_pc;
212
        reg                             IC_USER;
213
 
214
        wire    [31:0]   branch,pc_jump,next_pc,pc_icache_i;
215
 
216
        assign PC_SAVE = pc_adduse + {29'h0,USED};
217
        assign branch  = PC_ARCHI + DISP;
218
 
219
        assign pc_jump = LOAD_PC ? PC_NEW : branch;
220
 
221
        assign next_pc = NEW ? pc_jump : PC_SAVE;       // Only at NEW is the DISP correct !
222
 
223
        always @(posedge BCLK or negedge BRESET)
224
                if (!BRESET) pc_adduse <= 32'h0;
225
                  else
226
                        pc_adduse <= next_pc;
227
 
228
        // The Architectur - PC : Address mode "Programm Memory"-relativ
229
        // no BRESET because NEXT_PCA is immediately valid
230
        always @(posedge BCLK)
231
                if (FPU_TRAP) PC_ARCHI <= fpu_trap_pc;  // go back !
232
                  else
233
                        if (NEXT_PCA) PC_ARCHI <= pc_adduse;
234
 
235
        always @(posedge BCLK) if (SAVE_PC) fpu_trap_pc <= PC_ARCHI;    // Special storage for PC for FPU Trap
236
 
237
        always @(posedge BCLK or negedge BRESET)
238
                if (!BRESET) pc_ic_reg <= 32'h0;
239
                  else
240
                        pc_ic_reg <= pc_icache_i;
241
 
242 11 ns32kum
        // NEW is only one cycle long - but in pc_adduse is the PC stored when ACC_OK is not there and therefore NEW_PC
243 9 ns32kum
        // is used to initiate a new access in ICACHE
244 11 ns32kum
        assign pc_icache_i = NEW_PC ? (NEW ? pc_jump : pc_adduse) : (NEXT_ADR ? ({pc_ic_reg[31:2],2'b00} + 32'h0000_0004) : pc_ic_reg);
245 9 ns32kum
 
246
        // This MUX is extra for LMR IVAR,... and CINV build in
247
        assign PC_ICACHE = {(ADIVAR ? PC_NEW[31:4] : pc_icache_i[31:4]),pc_icache_i[3:0]};
248
 
249
        assign ALSB = pc_ic_reg[1:0];    // for OPDEC_REG
250
 
251
        // The IC_USER flag is allowed to switch synchronously with one cycle delay to PC_ICACHE
252
        always @(posedge BCLK or negedge BRESET)
253
                if (!BRESET) IC_USER <= 1'b0;
254
                  else
255
                        if (NEW_PC) IC_USER <= USER;
256
 
257
endmodule
258
 
259 11 ns32kum
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
260 9 ns32kum
//
261
//      3. REG_LIST             Register List Evaluation
262
//
263 11 ns32kum
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
264 9 ns32kum
module REG_LIST ( DIN, IPOS, INIT, OPOS, VALID);
265
 
266
        // Detects set bits in register list for SAVE/RESTORE & ENTER/EXIT
267
 
268
        input    [7:0]   DIN;
269
        input    [2:0]   IPOS;
270
        input                   INIT;
271
        output   [2:0]   OPOS;
272
        output                  VALID;
273
 
274
        reg              [7:1]  filter;
275
        wire     [7:0]   mdat_0;
276
        wire     [3:0]   mdat_1;
277
        wire     [1:0]   mdat_2;
278
 
279
        always @(IPOS or DIN)
280
                case (IPOS)
281
                  3'd0 : filter =  DIN[7:1];
282
                  3'd1 : filter = {DIN[7:2],1'b0};
283
                  3'd2 : filter = {DIN[7:3],2'b0};
284
                  3'd3 : filter = {DIN[7:4],3'b0};
285
                  3'd4 : filter = {DIN[7:5],4'b0};
286
                  3'd5 : filter = {DIN[7:6],5'b0};
287
                  3'd6 : filter = {DIN[7]  ,6'b0};
288
                  3'd7 : filter =           7'b0;
289
                endcase
290
 
291
        assign mdat_0  = INIT ? DIN : {filter,1'b0};
292
        assign OPOS[2] = (mdat_0[3:0] == 4'h0);
293
        assign mdat_1  = OPOS[2] ? mdat_0[7:4] : mdat_0[3:0];
294
        assign OPOS[1] = (mdat_1[1:0] == 2'b00);
295
        assign mdat_2  = OPOS[1] ? mdat_1[3:2] : mdat_1[1:0];
296
        assign OPOS[0] = ~mdat_2[0];
297
        assign VALID   = (mdat_2 != 2'b00);
298
 
299
endmodule
300
 
301 11 ns32kum
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
302 9 ns32kum
//
303
//      4. ILL_UNDEF    Illegal and Undefined Opcodes Detection
304
//
305 11 ns32kum
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
306 9 ns32kum
module ILL_UNDEF (OPREG, ANZ_VAL, USER, CFG, ILL, UNDEF );
307
 
308
        input   [23:0]   OPREG;
309
        input    [2:0]   ANZ_VAL;
310
        input    [3:1]  CFG;            // 3=CUSTOM,2=MMU,1=FPU
311
        input                   USER;
312
 
313
        output  reg             ILL;
314
        output                  UNDEF;
315
 
316
        reg                             undef_opc;
317
        reg                             undef_am;
318
        reg                             undef_im;
319
 
320
        wire     [2:0]   valid;
321
        wire                    gen12,gen22,gen13,gen23;
322
        wire                    igen12,igen22,igen13,igen23;
323
        wire                    lsbes;
324
 
325
        parameter udef_amode = 5'b10011;        // Undefined Addressing Mode
326
        parameter imode          = 5'b10100;    // Immediate Addressing Mode 
327
 
328
        // [2]= minimum 3, [1]= minimum 2, [0]=minimum 1
329 11 ns32kum
        assign valid = {(ANZ_VAL[2] | (ANZ_VAL[1:0] == 2'b11)),(ANZ_VAL[2:1] != 2'b00),(ANZ_VAL != 3'b000)};
330 9 ns32kum
        assign lsbes = (OPREG[1:0] == 2'b10);    // Tag of all 3 Byte opcodes
331
 
332
        // +++++++++++++++++++++++++  Detect illegale opcodes  +++++++++++++++++++
333
 
334
        always @(OPREG or lsbes or valid or USER)
335
                casex ({valid[2:1],OPREG[13:2],lsbes})
336
                  15'bx1_xx_x000_1x10_11_0 : ILL = USER;        // SPRi/LPRi DCR
337
                  15'bx1_xx_x001_xx10_11_0 : ILL = USER;        // SPRi/LPRi BPC/DSR
338
                  15'bx1_xx_xx10_xx10_11_0 : ILL = USER;        // SPRi/LPRi CAR/CFG/PSR
339
                  15'bx1_xx_x101_1x10_11_0 : ILL = USER;        // SPRi/LPRi USP
340
                  15'bx1_xx_x111_0x10_11_0 : ILL = USER;        // SPRi/LPRi INTBASE
341
                  15'bx1_xx_x0x1_0111_11_x : ILL = USER & OPREG[0];      // BICPSRW,BISPSRW
342
                  15'bx1_00_10xx_0000_11_1 : ILL = USER;        // SETCFG - Achtung : is coded as 2 Byte Opcode 
343
                  15'b1x_00_xxxx_0001_11_1 : ILL = USER;        // LMR/SMR/RDVAL/WRVAL
344
                  15'b1x_10_01xx_0001_11_1 : ILL = USER;        // CINV
345
                  default                                  : ILL = 1'b0;
346
                endcase
347
 
348
        // ++++++++++++++++++++++++ Detect Undefined opcodes  +++++++++++++++
349
 
350
        always @(OPREG or lsbes or valid or CFG)
351
                casex ({valid,OPREG[13:2],lsbes})
352
                  16'bx1x_xx_xxxx_1111_110 : undef_opc = 1'b1;          // Format 3 : xxx1
353
                  16'bx1x_xx_x100_0111_110 : undef_opc = 1'b1;          // Format 3 : 1000
354
                  16'b1xx_1x_xxxx_0000_111 : undef_opc = 1'b1;          // Format 5 : 1xxx
355
                  16'b1xx_01_xxxx_0000_111 : undef_opc = 1'b1;          // Format 5 : 01xx
356
                  16'b1xx_01_00xx_0100_111 : undef_opc = 1'b1;          // Format 6 : 0100
357
                  16'b1xx_10_10xx_x100_111 : undef_opc = 1'b1;          // Format 6/7 : 1010
358 11 ns32kum
                  16'b1xx_xx_xxxx_x011_111 : undef_opc = ~CFG[1];       // Format 9/11 : FPU Befehle wie MOVif etc. und ADDf etc.
359 9 ns32kum
                  16'b1xx_xx_xxxx_1111_111 : undef_opc = ~CFG[1];       // Format 12 : FPU Befehle wie POLYf etc.
360
                  16'b1xx_x1_xxxx_0001_111 : undef_opc = 1'b1;          // Format 14 : x1xx 
361
                  16'b1xx_10_00xx_0001_111 : undef_opc = 1'b1;          // Format 14 : 1000
362
                  16'b1xx_10_1xxx_0001_111 : undef_opc = 1'b1;          // Format 14 : 101x
363
                  16'b1xx_00_1xxx_0001_111 : undef_opc = ~CFG[2] | ~OPREG[18];  // Format 14 : LMR/SMR
364
                  16'b1xx_xx_xxxx_x011_011 : undef_opc = ~CFG[3];       // Format 15.1/15.5 : CUSTOM CCV0, CCAL0 etc.
365
                  16'b1xx_xx_xxxx_0001_011 : undef_opc = 1'b1;          // Format 15.0 - not yet in, requires HW change
366
                  16'b1xx_xx_xxxx_x1x1_011 : undef_opc = 1'b1;          // Format 15 : rest
367
                  16'b1xx_xx_xxxx_1001_011 : undef_opc = 1'b1;          // Format 15.4
368
                // completely undefined :
369
                  16'bxx1_xx_xxxx_0111_111 : undef_opc = 1'b1;          // Format 10
370
                  16'bxx1_xx_xxxx_100x_111 : undef_opc = 1'b1;          // Format 13/18
371
                  16'bxx1_xx_xxxx_x101_111 : undef_opc = 1'b1;          // Format 16/17
372
                  16'bxx1_xx_xxxx_xxx0_011 : undef_opc = 1'b1;          // Format 19
373
                  default                                  : undef_opc = 1'b0;
374
                endcase
375
 
376
        // 2. Undefined Addressing mode 5'b10011
377
 
378
        assign gen12 = (OPREG[15:11] == udef_amode);
379
        assign gen22 = (OPREG[10:6]  == udef_amode);
380
        assign gen13 = (OPREG[23:19] == udef_amode);
381
        assign gen23 = (OPREG[18:14] == udef_amode);
382
 
383
        always @(OPREG or valid or gen12 or gen22 or gen13 or gen23)
384 11 ns32kum
                if (valid[2] && (OPREG[7:5] != 3'b000) && (OPREG[3:0] == 4'b1110)) undef_am = gen13 | gen23;     // nearly all 3 Byte opcodes
385 9 ns32kum
                  else
386 11 ns32kum
                    undef_am = valid[1] & gen12 & (OPREG[1:0] != 2'b10) & ((OPREG[3:2] != 2'b11) & gen22);       // all 2 Byte opcodes
387 9 ns32kum
 
388
        // 3. When is Immediate not allowed ?
389
 
390
        assign igen12 = (OPREG[15:11] == imode);
391
        assign igen22 = (OPREG[10:6]  == imode);
392
        assign igen13 = (OPREG[23:19] == imode);
393
        assign igen23 = (OPREG[18:14] == imode);
394
 
395
        always @(*)
396
                casex ({valid[2:1],OPREG[13:2],lsbes})
397 11 ns32kum
                  15'bx1_xxxxxx_x0xx11_0 : undef_im =  igen12 & (OPREG[5:4] != 2'b01);  // Format 2 : ADDQD,SPR,Scond
398 9 ns32kum
                  15'bx1_xxxxxx_x10111_0 : undef_im =  igen12;          // Format 2 : ACB,MOVQ
399
                  15'bx1_xxxxx0_011111_0 : undef_im =  igen12;          // Format 3 : CXPD,JUMP,JSR
400
                  15'bx1_xxxxxx_xxxxx0_0 : undef_im =  igen22;          // Format 4
401 11 ns32kum
                  15'bx1_xxxxxx_xxxx01_0 : undef_im = (igen12 & (OPREG[5:4] == 2'b10))  // Format 4 : SRC1 - not ADDR
402 9 ns32kum
                                                                                         |(igen22 & (OPREG[5:4] != 2'b00)); // Format 4 : SRC2 - CMP
403
                  15'b1x_xxxxxx_x10011_1 : undef_im =  igen23;          // Format 6+7
404
                  15'b1x_xxx0xx_0x1011_1 : undef_im =  igen13 | igen23; // Format 8 EXT,CVTP
405
                  15'b1x_xxx0xx_101011_1 : undef_im =  igen23;          // Format 8 : INS
406
                  15'b1x_xxx0xx_111011_1 : undef_im =  igen13;          // Format 8 : CHECK
407
                  15'b1x_xxx1xx_101011_1 : undef_im =  igen13 | igen23; // Format 8 MOVUS,MOVSU
408
                  15'b1x_xxx1xx_011011_1 : undef_im =  igen23;          // Format 8 : FFS
409
                  15'b1x_xxxxxx_001111_1 : undef_im =  igen23;          // Format 9
410
                  15'b1x_xxxxxx_101111_1 : undef_im =  igen23 & (OPREG[13:10] != 4'h2); // Format 10 without CMPf
411
                  15'b1x_010xxx_111111_1 : undef_im =  igen23;          // Format 12 SCALB+LOGB
412
                  15'b1x_000xxx_000111_1 : undef_im =  igen13;          // Format 14 RDVAL+WRVAL
413
                  15'b1x_0011xx_000111_1 : undef_im =  igen13;          // Format 14 SMR
414
                  default                                : undef_im = 1'b0;
415
                endcase
416
 
417
        // Final Message :
418
 
419
        assign UNDEF = undef_opc | undef_am | undef_im;
420
 
421
endmodule
422
 
423 11 ns32kum
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
424 9 ns32kum
//
425
//      5. GRUPPE_2             Decoder and State Machine for GRUPPE_2 Opcodes
426
//
427 11 ns32kum
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
428
module GRUPPE_2 ( BCLK, PHASE_0, OPREG, PHASE, SRC_1, SRC_2, REGA1, REGA2, IRRW1, IRRW2, ADRD1, ADRD2, EXR12, EXR22,
429 9 ns32kum
                                  PHRD1, PHRD2, NXRD1, NXRW2, ACCA, OPERA,
430
                                  STATE_0, STATE_GROUP_50, STATE_GROUP_60 );
431
 
432
 
433
        input                   BCLK,PHASE_0;
434
        input   [13:0]   OPREG;
435
        input    [3:0]   PHASE;  // nur die 4 LSBs
436
        // Source 1 & 2 Inputs
437
        input    [6:0]   SRC_1,SRC_2,REGA1,REGA2,IRRW1,IRRW2;
438
        input   [18:0]   ADRD1,ADRD2,EXR12,EXR22;
439
        input    [3:0]   PHRD1,PHRD2;
440
        input    [3:0]   NXRD1,NXRW2;
441
        input    [3:0]   ACCA;   // ACCA = Access type : 0x Register
442
                                                        //      [3:2] or [1:0]          10 Memory
443
                                                        //                                              11 Memory + Index
444
        input   [10:0]   OPERA;
445
 
446
        output  [66:0]   STATE_0;
447
        output  [66:0]   STATE_GROUP_50,STATE_GROUP_60;
448
 
449
        reg             [66:0]   STATE_GROUP_50,STATE_GROUP_60;
450
        reg             [66:0]   STATE_0,state_50,state_53,state_54,state_55,state_58,state_59,state_5A;
451
        reg              [4:0]   op_code,op_reg_reg;
452
        reg              [7:0]   phsrc1,phsrc2;
453
        reg              [5:0]   chkreg;
454
        reg              [1:0]   bwdreg;
455
        reg                             tbit_flag,size_dw;
456
        reg                             inss_flag;
457
 
458
        wire    [18:0]   exoffset,re_wr;
459
        wire    [10:0]   op_kust,op_bwd;
460
        wire     [7:0]   phchk;
461
        wire     [4:0]   op_reg;
462
        wire     [6:0]   src_1l,src_2l;
463
        wire     [5:0]   dest_2;
464
        wire     [3:0]   get8b_s,get8b_d;
465
        wire     [6:0]   rd_reg;
466
        wire    [10:0]   op_zext;
467
        wire     [3:0]   imdi;
468
 
469
        parameter dont_care     = 67'hx_xxxx_xxxx_xxxx_xxxx;
470
        // Address-Field : Size:2 RD WR LDEA FULLACC INDEX:4 SPUPD disp_val:4 POST CLRMSW SRC2SEL:2
471
        parameter addr_nop      = 19'h0;        // alle Parameter auf 0
472
        parameter disp2ea       = 19'bxx_0010_0000_0_0000_0010; // pass DISP
473
        parameter case_op       = 19'bxx_0010_1000_0_0000_0001; // SRC1 add to PC_ARCHI
474
        parameter read_byb      = 19'b00_1011_11xx_0_0000_0011; // read of SRC2 for Bit opcodes
475 11 ns32kum
        parameter exr11         = {2'b10  ,4'b1011,4'h0 ,9'h080};       // 2. access External with Mem.-Pointer + 4* Disp
476 9 ns32kum
        parameter adrcvtp       = 19'bxx_0010_0111_0_0000_0000; // for CVTP
477 11 ns32kum
        parameter addone        = 19'bxx_0010_0100_0_0000_0000; // for INDEX : SRC1 + SRC2 , simple Add without Flags
478 9 ns32kum
        parameter addind        = 19'bxx_0010_0100_0_0000_0011; // for INDEX : SRC1 + EA
479
        parameter src_x         = 7'hxx;
480
        parameter dest_x        = 6'hxx;
481
        parameter imme          = {1'b1,6'hxx};
482
        parameter F0            = 7'h20;
483
        parameter F0_h          = 7'h21;
484
        parameter w_F0          = 6'h20;
485
        parameter w_F0_h        = 6'h21;
486
        parameter temp_l        = 6'h3C;
487
        parameter temp_h        = 6'h3D;        // Second last place for 8B TEMP Register
488
        parameter temp_1        = 6'h3E;
489
        parameter rtmpl         = 7'h3C;
490
        parameter rtmph         = 7'h3D;
491
        parameter rtmp1         = 7'h3E;
492
        parameter op_mov        = {3'bxxx,8'h45};
493
        parameter op_adr        = {3'bxxx,8'h49};
494
        parameter op_addl       = {3'b0xx,8'hB0};
495
        parameter op_addf       = {3'b1xx,8'hB0};
496
        parameter op_mull       = {3'b0xx,8'hBC};
497
        parameter op_mulf       = {3'b1xx,8'hBC};
498
        parameter op_truf       = {3'b101,8'h9A};       // TRUNCFW for SCALBF
499
        parameter op_trul       = {3'b001,8'h9A};       // TRUNCLW for SCALBL
500
        parameter op_stpr       = {3'b1xx,8'h54};       // Special-Op for String opcodes
501
        parameter op_lsh        = {3'b011,8'h65};       // EXT : shift to right : DOUBLE !
502
        parameter op_msk        = {3'b011,8'h80};       // reuse of EXT Opcode at INS !
503
        parameter op_mul        = {3'b011,8'h78};       // INDEX
504
        parameter op_rwv        = {3'bxxx,8'hE0};       // RDVAL+WRVAL
505
 
506
        always @(OPREG) // whether the Opcode is valid is decided in DECODER !
507
          casex (OPREG) // [13:0]
508
                14'bxx_xxxx_1111_1110 : op_code = {2'b01,OPREG[11:10],OPREG[8]};        // DOT/POLY/SCALB
509
                14'b00_0xxx_0000_1110 : op_code = 5'b1_0000;    // MOVS/CMPS
510
                14'b00_11xx_0000_1110 : op_code = 5'b1_0000;    // SKPS
511
                14'b00_0xxx_1100_1110 : op_code = 5'b1_0001;    // MOVM/CMPM
512
                14'bxx_xx10_0111_11xx : op_code = 5'b1_0010;    // JUMP/JSR
513
                14'bxx_x111_0111_11xx : op_code = 5'b1_0011;    // CASE
514
                14'bxx_xxxx_xx11_010x : op_code = 5'b1_0100;    // TBIT
515
                14'bxx_xxxx_xx11_0111 : op_code = 5'b1_0100;    // TBIT
516
                14'b0x_1xxx_0100_1110 : op_code = 5'b1_0100;    // CBIT/SBIT
517
                14'b11_10xx_0100_1110 : op_code = 5'b1_0100;    // IBIT
518
                14'b00_11xx_1100_1110 : op_code = 5'b1_0101;    // EXTS
519
                14'b10_x1xx_1100_1110 : op_code = 5'b1_0111;    // DEI/MEI
520
                14'bxx_x0xx_1110_1110 : op_code = 5'b1_1000;    // CHECK
521
                14'bxx_x0xx_0010_1110 : op_code = 5'b1_1010;    // EXT
522
                14'bxx_x0xx_1010_1110 : op_code = 5'b1_1011;    // INS
523
                14'b00_10xx_1100_1110 : op_code = 5'b1_1011;    // INSS, the same like INS !
524
                14'bxx_x0xx_0110_1110 : op_code = 5'b1_1100;    // CVTP
525
                14'bxx_x1xx_0010_1110 : op_code = 5'b1_1101;    // INDEX
526
                14'bxx_x000_0111_11xx : op_code = 5'b1_1110;    // CXPD
527
                14'b00_0xxx_0001_1110 : op_code = 5'b1_1111;    // RDVAL+WRVAL
528
                default                           : op_code = 5'b00_xxx;
529
          endcase
530
 
531
        always @(posedge BCLK) if (PHASE_0) op_reg_reg <= op_code;
532
        assign op_reg = PHASE_0 ? op_code : op_reg_reg;
533
 
534
        always @(PHRD1) // recode of States
535
          casex (PHRD1)
536
                 4'h5 : phsrc1 = 8'h51;
537
                 4'h6 : phsrc1 = 8'h52;
538
                 4'hB : phsrc1 = 8'h53; // ok, is in default ...
539
          default : phsrc1 = 8'h53;
540
          endcase
541
 
542
        assign get8b_s = (PHRD1 == 4'hB) ? 4'hC : 4'h0; // Special case 8B Immeadiate, is used in State 53
543
 
544
        always @(PHRD2) // recode of States
545
          casex (PHRD2)
546
                 4'h5 : phsrc2 = 8'h56;
547
                 4'h6 : phsrc2 = 8'h57;
548
                 4'hB : phsrc2 = 8'h58; // ok, is in default ...
549
          default : phsrc2 = 8'h58;
550
          endcase
551
 
552
        assign get8b_d = (PHRD2 == 4'hB) ? 4'hC : 4'h0; // Special case 8B Immeadiate, is used in State 58
553
 
554
        assign src_1l = {SRC_1[6:1],1'b0};
555
        assign src_2l = {SRC_2[6:1],1'b0};
556
        assign dest_2 =  SRC_2[5:0];
557
 
558
        assign phchk = {7'b0101_010,size_dw};   // Phase 54 or 55
559
 
560
        assign op_kust = {1'bx,OPERA[9:8],8'h7A};       // Special-Opcode for MOVM/CMPM
561
        assign op_bwd  = {1'bx,OPERA[9:8],8'h45};       // for CASE and Bit opcodes
562
 
563 11 ns32kum
        assign re_wr   = {EXR22[18:17],4'b0101,4'h0, 9'h003};   // REUSE Address : Write of rmw , top 2 Bits contain size
564 9 ns32kum
 
565
        always @(posedge BCLK) tbit_flag <= ~OPERA[1];  // due to Timing ...
566
        always @(posedge BCLK) size_dw   <=  OPERA[9];
567
 
568
        always @(posedge BCLK) if (PHASE_0) chkreg <= {3'b000,OPREG[13:11]};    // for CHECK
569
        assign rd_reg = (PHASE_0) ? {4'b0,OPREG[13:11]} : {1'b0,chkreg};        // for read operation at EXT/INS
570
 
571
        always @(posedge BCLK) if (PHASE_0) bwdreg <= OPREG[9:8];               // only for INS/INSS !
572
        assign op_zext = {1'bx,(PHASE_0 ? OPREG[9:8] : bwdreg),8'h76};
573
 
574
        always @(posedge BCLK) if (PHASE_0) inss_flag <= OPREG[6];      // Difference INSS to INS
575
        assign imdi = inss_flag ? 4'h8 : 4'hE;  // read Immediate or Displacement
576
        assign exoffset = inss_flag ? 19'b10_1011_0000_0_0000_0011      // Read of SRC2 at INSS
577
                                                                : 19'b10_1011_1100_0_0000_0011; // Read of SRC1+Offset at EXT, SRC2+Offset at INS 
578
 
579
        always @(*)
580
          casex (op_reg)
581 11 ns32kum
                5'b1_0000 :     // MOVS Phase 0 : Entry 1. Pointer "in Page"-test prepare, 2. test for R0=0 , then jump to x'C0
582 9 ns32kum
                        begin
583 11 ns32kum
                          STATE_0  = {   addr_nop,8'h67, 7'h01, 7'h02, 1'b0,dest_x,op_stpr,     2'b00,2'b00,4'h0  };    // String-Pointer prepare
584 9 ns32kum
                          state_50 = dont_care;
585
                          state_53 = dont_care;
586
                          state_54 = dont_care;
587
                          state_55 = dont_care;
588
                          state_58 = dont_care;
589
                          state_59 = dont_care;
590
                          state_5A = dont_care;
591
                        end
592
                5'b1_0001 :     // MOVM Phase 0 : Entry with test for R0=0 , then jump to x'C0
593
                        begin
594
                          STATE_0  = {   ADRD1,   phsrc1,src_x, REGA1, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRD1 };
595
                          state_50 = {   ADRD1,   phsrc1,IRRW1, REGA1, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRD1 };
596
                          state_53 = {   ADRD2,   phsrc2,IRRW2, REGA2, 1'b1,temp_h,op_adr,  2'b00,2'b00,NXRW2 };
597
                          state_54 = dont_care;
598
                          state_55 = dont_care;
599 11 ns32kum
                          state_58 = {   disp2ea, 8'h65, src_x, src_x, 1'b1,temp_1,op_adr,  2'b00,2'b00,4'b1110 };      // Read of DISP for count
600
                          state_59 = {   addr_nop,8'h67, rtmph, rtmp1, 1'b0,dest_x,op_stpr,     2'b00,2'b00,4'h0  };    // String-Pointer prepare
601 9 ns32kum
                          state_5A = dont_care;
602
                        end
603
                5'b1_0010 :     // JUMP/JSR
604
                        begin
605
                          STATE_0  = {   ADRD1,   phsrc1,src_x, REGA1, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRD1 };
606
                          state_50 = {   ADRD1,   phsrc1,IRRW1, REGA1, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRD1 };
607
                          state_53 = {   addr_nop,8'h66, src_x, src_x, 1'b1,temp_h,op_adr,  2'b00,2'b00,4'h0  };
608
                          state_54 = dont_care;
609
                          state_55 = dont_care;
610
                          state_58 = dont_care;
611
                          state_59 = dont_care;
612
                          state_5A = dont_care;
613
                        end
614
                5'b1_1110 :     // CXPD
615
                        begin
616
                          STATE_0  = {   ADRD1,   phsrc1,src_x, REGA1, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRD1 };
617
                          state_50 = {   ADRD1,   phsrc1,IRRW1, REGA1, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRD1 };
618
                          state_53 = {   addr_nop,8'h6B, imme,  src_x, 1'b1,temp_h,op_mov,  2'b00,2'b00,4'h0  };
619
                          state_54 = dont_care;
620
                          state_55 = dont_care;
621
                          state_58 = dont_care;
622
                          state_59 = dont_care;
623
                          state_5A = dont_care;
624
                        end
625
                5'b1_1111 :     // RDVAL+WRVAL
626
                        begin
627
                          STATE_0  = {   ADRD1,   phsrc1,src_x, REGA1, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRD1 };
628
                          state_50 = {   ADRD1,   phsrc1,IRRW1, REGA1, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRD1 };
629 11 ns32kum
                          state_53 = {   addr_nop,8'h00, src_x, src_x, 1'b0,dest_x,op_rwv,  2'b00,2'b10,4'h0  };        // LD_OUT set because of "F"
630 9 ns32kum
                          state_54 = dont_care;
631
                          state_55 = dont_care;
632
                          state_58 = dont_care;
633
                          state_59 = dont_care;
634
                          state_5A = dont_care;
635
                        end
636
                5'b1_0011 :     // CASE
637
                        begin
638
                          STATE_0  = ACCA[3] ?          // _M...
639
                                                 {   ADRD1,   phsrc1,src_x, REGA1, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRD1 }
640
                                           : {   case_op, 8'h54, SRC_1, src_x, 1'b0,dest_x,op_bwd,      2'b00,2'b00,4'h0  };
641 11 ns32kum
                          state_50 = {   ADRD1,   phsrc1,IRRW1, REGA1, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRD1 };        // only one operand in mem.
642 9 ns32kum
                          state_53 = {   case_op, 8'h54, imme,  src_x, 1'b0,dest_x,op_bwd,      2'b00,2'b00,4'h0  };
643
                          state_54 = {   addr_nop,8'h66, src_x, src_x, 1'b1,temp_h,op_adr,  2'b00,2'b00,4'h0  };
644
                          state_55 = dont_care;
645
                          state_58 = dont_care;
646
                          state_59 = dont_care;
647
                          state_5A = dont_care;
648
                        end
649 11 ns32kum
                5'b1_0100 : // all Bit opcodes with Bit in memory. RMW Test in Phase x'59 = Special case, otherwise x'58
650 9 ns32kum
                        begin
651
                          STATE_0  = ACCA[3] ?          // _M...
652
                                                 {   ADRD1,   phsrc1,src_x, REGA1, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRD1 }
653
                                           : {   addr_nop,8'h54, SRC_1, src_x, 1'b1,temp_h,op_mov,      2'b00,2'b00,4'h0  };
654
                          state_50 = ACCA[3] ?          // _M...
655
                                                 {   ADRD1,   phsrc1,IRRW1, REGA1, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRD1 }
656
                                           : {   addr_nop,8'h54, SRC_1, src_x, 1'b1,temp_h,op_mov,      2'b00,2'b00,4'h0  };
657
                          state_53 = {   addr_nop,8'h54, imme,  src_x, 1'b1,temp_h,op_mov,      2'b00,2'b00,4'h0  };
658 11 ns32kum
                          state_54 = {   ADRD2,   phsrc2,IRRW2, REGA2, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRW2 };        // here SRC1 => TEMP_H
659 9 ns32kum
                          state_55 = dont_care;
660 11 ns32kum
                          state_58 = {   read_byb,8'h59, rtmph, src_x, 1'b0,dest_x,op_bwd,      2'b00,2'b00,4'h1  };    // next read of Byte
661 9 ns32kum
                          state_59 = tbit_flag ?
662
                                                 {       addr_nop,8'h00, src_x, imme,  1'b0,dest_x,OPERA,       2'b00,2'b10,4'h0  }             // TBIT end
663 11 ns32kum
                                           : {   re_wr,   8'h27, src_x, imme,  1'b0,dest_x,OPERA,       2'b00,2'b10,4'h1  };    // CBIT/SBIT/IBIT end
664 9 ns32kum
                          state_5A = dont_care;
665
                        end
666
                5'b1_0101 : // EXTS : BASE Operand => TEMP, calculate address of Destination
667
                        begin
668
                          STATE_0  = ACCA[3] ?          // _M...
669
                                                 {   ADRD1,   phsrc1,src_x, REGA1, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRD1 }
670
                                           : {   addr_nop,8'h54, SRC_1, src_x, 1'b1,temp_h,op_mov,      2'b00,2'b00,4'h0  };
671
                          state_50 = ACCA[3] ?          // _M...
672
                                                 {   ADRD1,   phsrc1,IRRW1, REGA1, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRD1 }
673
                                           : {   addr_nop,8'h54, SRC_1, src_x, 1'b1,temp_h,op_mov,      2'b00,2'b00,4'h0  };
674
                          state_53 = {   addr_nop,8'h54, imme,  src_x, 1'b1,temp_h,op_mov,      2'b00,2'b00,4'h0  };
675
                          state_54 = ACCA[1] ?
676 11 ns32kum
                                                 {       ADRD2,   phsrc2,IRRW2, REGA2, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRW2 }         // here Adr(DEST) => EA
677
                                           : {   addr_nop,8'h59, src_x, src_x, 1'b0,dest_x,op_mov,      2'b00,2'b00,4'h8  };    // 1 Byte Immediate read
678 9 ns32kum
                          state_55 = dont_care;
679 11 ns32kum
                          state_58 = {   addr_nop,8'h59, src_x, src_x, 1'b0,dest_x,op_mov,      2'b00,2'b00,4'h8  };    // 1 Byte Immediate read
680 9 ns32kum
                          state_59 = ACCA[1] ?          // _..M.
681
                                                 {       re_wr,   8'h27, imme,  rtmph, 1'b0,dest_x,OPERA,       2'b00,2'b10,4'h1  }             // result in memory
682 11 ns32kum
                                           : {   addr_nop,8'h00, imme,  rtmph, 1'b1,dest_2,OPERA,       2'b00,2'b00,4'h0  };    // result in Register
683 9 ns32kum
                          state_5A = dont_care;
684
                        end
685
                5'b1_1010 : // EXT : BASE Operand => TEMP, calculate address of Destination
686
                        begin
687
                          STATE_0  = ACCA[3] ?          // _M...
688
                                                 {   ADRD1,   phsrc1,src_x, REGA1, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRD1 }
689
                                           : {   addr_nop,8'h54, SRC_1, src_x, 1'b1,temp_h,op_mov,      2'b00,2'b00,4'h0  };
690
                          state_50 = ACCA[3] ?          // _M...
691
                                                 {   ADRD1,   phsrc1,IRRW1, REGA1, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRD1 }
692
                                           : {   addr_nop,8'h54, SRC_1, src_x, 1'b1,temp_h,op_mov,      2'b00,2'b00,4'h0  };
693 11 ns32kum
                          state_53 = {   addr_nop,8'h55, src_x, src_x, 1'b0,dest_x,op_mov,      2'b00,2'b00,4'h0  };    // Addr => EA Reg
694 9 ns32kum
                          state_54 = ACCA[1] ?
695
                                                  ( ACCA[3] ?
696
                                                    {addr_nop,8'h5A, imme,  src_x, 1'b1,temp_h,op_mov,  2'b00,2'b00,4'h0  }
697 11 ns32kum
                                                   :{ADRD2,   phsrc2,IRRW2, REGA2, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRW2 }     )       // here Adr(DEST) => EA
698 9 ns32kum
                                           : {   addr_nop,8'h59, rd_reg,(ACCA[3] ? imme : rtmph),
699
                                                                                                                   1'b1,temp_h,op_lsh,  2'b00,2'b00,4'hE  };    // Displacement read
700 11 ns32kum
                          state_55 = {   exoffset,8'h54, rd_reg,src_x, 1'b0,dest_x,op_mov,      2'b00,2'b00,4'h1  };    // Read Source, EA reuse
701
                          state_58 = {   addr_nop,8'h59, rd_reg,rtmph, 1'b1,temp_h,op_lsh,      2'b00,2'b00,4'hE  };    // Displacement read
702 9 ns32kum
                          state_59 = ACCA[1] ?          // _..M.
703
                                                 {       re_wr,   8'h27, src_x, rtmph, 1'b0,dest_x,OPERA,       2'b00,2'b10,4'h1  }             // result in memory
704 11 ns32kum
                                           : {   addr_nop,8'h00, src_x, rtmph, 1'b1,dest_2,OPERA,       2'b00,2'b00,4'h0  };    // result in Register
705
                          state_5A = {   ADRD2,   phsrc2,IRRW2, REGA2, 1'b0,dest_x,op_mov,      2'b00,2'b00,NXRW2 };    // special case Mem-Mem
706 9 ns32kum
                        end
707 11 ns32kum
                5'b1_1011 : // INS/INSS : BASE Operand => TEMP, SRC2 read as Double ! RMW not tested (Phase x'6A) but uncritical
708 9 ns32kum
                        begin
709
                          STATE_0  = ACCA[3] ?          // _M...
710
                                                 {   ADRD1,   phsrc1,src_x, REGA1, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRD1 }
711
                                           : {   addr_nop,8'h54, SRC_1, src_x, 1'b1,temp_h,op_zext, 2'b00,2'b00,4'h0  };
712
                          state_50 = ACCA[3] ?          // _M...
713
                                                 {   ADRD1,   phsrc1,IRRW1, REGA1, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRD1 }
714
                                           : {   addr_nop,8'h54, SRC_1, src_x, 1'b1,temp_h,op_zext, 2'b00,2'b00,4'h0  };
715 11 ns32kum
                          state_53 = {   addr_nop,8'h54, imme,  src_x, 1'b1,temp_h,op_zext, 2'b00,2'b00,4'h0  };        // zext(SRC1) => TEMP
716 9 ns32kum
                          state_54 = ACCA[1] ?
717 11 ns32kum
                                                 {       ADRD2,   phsrc2,IRRW2, REGA2, 1'b0,dest_x,op_mov,      2'b00,2'b00,NXRW2 }             // here Adr(DEST) => EA
718
                                           : {   addr_nop,8'h5A, SRC_2, src_x, 1'b1,temp_l,op_mov,      2'b00,2'b00,imdi  };    // Imme./Disp. read
719
                          state_55 = {   exoffset,8'h6A, rd_reg,src_x, 1'b0,dest_x,op_mov,      2'b00,2'b00,4'h1  };    // Read Source, EA reuse
720 9 ns32kum
                          state_58 = {   addr_nop,8'h55, src_x, src_x, 1'b0,dest_x,op_mov,      2'b00,2'b00,4'h0  };    // 
721
                          state_59 = ACCA[1] ?          // _..M.
722
                                                 {       re_wr,   8'h27, rtmph, rtmpl, 1'b0,dest_x,OPERA,       2'b00,2'b10,4'h1  }             // result in memory
723 11 ns32kum
                                           : {   addr_nop,8'h00, rtmph, rtmpl, 1'b1,dest_2,OPERA,       2'b00,2'b00,4'h0  };    // result in Register
724
                          state_5A = {   addr_nop,8'h68, imme,  src_x, 1'b1,temp_1,op_msk,      2'b00,2'b00,4'h0  };    // Mask generate
725 9 ns32kum
                        end
726
                5'b1_1101 : // INDEX : 
727
                        begin
728
                          STATE_0  = ACCA[3] ?          // _M...
729
                                                 {   ADRD1,   phsrc1,src_x, REGA1, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRD1 }
730
                                           : {   addr_nop,8'h54, SRC_1, src_x, 1'b1,temp_h,op_zext, 2'b00,2'b00,4'h0  };
731
                          state_50 = ACCA[3] ?          // _M...
732
                                                 {   ADRD1,   phsrc1,IRRW1, REGA1, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRD1 }
733
                                           : {   addr_nop,8'h54, SRC_1, src_x, 1'b1,temp_h,op_zext, 2'b00,2'b00,4'h0  };
734 11 ns32kum
                          state_53 = {   addr_nop,8'h54, imme,  src_x, 1'b1,temp_h,op_zext, 2'b00,2'b00,4'h0  };        // zext(SRC1) => TEMP_H
735 9 ns32kum
                          state_54 = ACCA[1] ?
736 11 ns32kum
                                                 {       ADRD2,   phsrc2,IRRW2, REGA2, 1'b0,dest_x,op_mov,      2'b00,2'b00,NXRW2 }             // zext(SRC2) => TEMP_L
737 9 ns32kum
                                           : {   addr_nop,8'h55, SRC_2, src_x, 1'b1,temp_l,op_zext, 2'b00,2'b00,4'h0  };
738 11 ns32kum
                          state_55 = {   addr_nop,8'h5A, rd_reg,rtmph, 1'b1,temp_h,op_mul,      2'b00,2'b00,4'h0  };    // Multiplication
739 9 ns32kum
                          state_58 = {   addr_nop,8'h55, imme,  src_x, 1'b1,temp_l,op_zext, 2'b00,2'b00,4'h0  };        // 
740 11 ns32kum
                          state_59 = {   addind,  8'h60, rtmpl, src_x, 1'b0,dest_x,op_mov,      2'b00,2'b00,4'h0  };    // Add of Index in EA
741
                          state_5A = {   addone,  8'h59, rd_reg,rtmph, 1'b0,dest_x,op_mov,      2'b00,2'b00,4'h0  };    // Add of EA (=+1)
742 9 ns32kum
                        end
743
                5'b1_0111 :     // DEI + MEI , both read 8B from DEST ! RMW critical !
744
                        begin
745
                          STATE_0  = ACCA[3] ?          // _M...
746
                                                 {   ADRD1,   phsrc1,src_x, REGA1, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRD1 }
747
                                           : {   addr_nop,8'h54, SRC_1, src_x, 1'b1,temp_h,op_mov,      2'b00,2'b00,4'h0  };
748
                          state_50 = ACCA[3] ?          // _M...
749
                                                 {   ADRD1,   phsrc1,IRRW1, REGA1, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRD1 }
750
                                           : {   addr_nop,8'h54, SRC_1, src_x, 1'b1,temp_h,op_mov,      2'b00,2'b00,4'h0  };
751
                          state_53 = {   addr_nop,8'h54, imme,  src_x, 1'b1,temp_h,op_mov,      2'b00,2'b00,4'h0  };
752
                          state_54 = ACCA[1] ?
753 11 ns32kum
                                                 {       ADRD2,   phsrc2,IRRW2, REGA2, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRW2 }         // here SRC1 => TEMP_H
754
                                           : {   addr_nop,8'h59, rtmph, SRC_2, 1'b0,dest_x,OPERA,       2'b01,2'b00,4'h0  };    // 1. part of Register
755 9 ns32kum
                          state_55 = dont_care;
756
                          state_58 = size_dw ?
757 11 ns32kum
                                                 {       addr_nop,8'h59, rtmph, imme,  1'b0,dest_x,OPERA,       2'b01,2'b00,4'h0  }             // D needs 2 accesses
758
                                           : {   addr_nop,8'h1F, rtmph, imme,  1'b0,dest_x,OPERA,       2'b11,2'b00,4'h0  };    // B+W start at once
759 9 ns32kum
                          state_59 = {   addr_nop,8'h1F, src_x, (ACCA[1] ? imme : src_2l),                                                      // SRC2 = memory or Reg
760
                                                                                                           ~ACCA[1],dest_2,OPERA,       2'b10,2'b00,4'h0  };
761
                          state_5A = dont_care;
762
                        end
763
                5'b1_1000 :     // CHECK
764
                        begin
765 11 ns32kum
                          STATE_0  = {   ADRD1,   phsrc1,src_x, REGA1, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRD1 };        // No Register !
766 9 ns32kum
                          state_50 = {   ADRD1,   phsrc1,IRRW1, REGA1, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRD1 };
767 11 ns32kum
                          state_53 = {   addr_nop,phchk, imme,  src_x, 1'b1,temp_h,op_mov,      2'b00,2'b00,4'h0  };    // No Immediate !
768 9 ns32kum
                          state_54 = ACCA[1] ?
769
                                                 {       ADRD2,   phsrc2,IRRW2, REGA2, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRW2 }
770
                                           : (  size_dw ?
771 11 ns32kum
                                                        {addr_nop,8'h5A, SRC_2, rtmpl, 1'b0,dest_x,OPERA,       2'b00,2'b10,4'h0  }             // Upper Bound - pointer
772 9 ns32kum
                                                  : {addr_nop,8'h00, rtmph, SRC_2, 1'b1,chkreg,OPERA,   2'b00,2'b10,4'h0  } );
773
                          state_55 = {   addr_nop,8'h54, imme,  src_x, 1'b1,temp_l,op_mov,      2'b00,2'b00,4'h0  };
774
                          state_58 = size_dw ?
775 11 ns32kum
                                                 {       addr_nop,8'h59, imme,  src_x, 1'b1,temp_1,op_mov,      2'b00,2'b00,4'h0  }             // here SRC2 => TEMP_1
776 9 ns32kum
                                           : {   addr_nop,8'h00, rtmph, imme,  1'b1,chkreg,OPERA,       2'b00,2'b10,4'h0  };
777 11 ns32kum
                          state_59 = {   addr_nop,8'h5A, rtmp1, rtmpl, 1'b0,dest_x,OPERA,       2'b00,2'b10,4'h0  };    // Upper Bound - pointer
778 9 ns32kum
                          state_5A = {   addr_nop,8'h00, rtmph, (ACCA[1] ? rtmp1 : SRC_2),
779
                                                                                                                   1'b1,chkreg,OPERA,   2'b00,2'b10,4'h0  };    // pointer - Lower Bound
780
                        end
781
                5'b1_1100 :     // CVTP
782
                        begin
783 11 ns32kum
                          STATE_0  = {   ADRD1,   phsrc1,src_x, REGA1, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRD1 };        // Address
784 9 ns32kum
                          state_50 = {   ADRD1,   phsrc1,IRRW1, REGA1, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRD1 };
785
                          state_53 = {   addr_nop,8'h54, src_x, src_x, 1'b1,temp_h,op_adr,      2'b00,2'b00,4'h0  };
786 11 ns32kum
                          state_54 = {   adrcvtp, 8'h73, rtmph, rd_reg,1'b0,dest_x,op_mov,  2'b00,2'b00,4'h0  };        // 8*TEMP+Offset
787 9 ns32kum
                          state_55 = dont_care;
788
                          state_58 = dont_care;
789
                          state_59 = dont_care;
790
                          state_5A = dont_care;
791
                        end
792
                5'b01_000 :     // SCALBL : RMW critical !
793
                        begin
794
                          STATE_0  = ACCA[3] ?          // _M...
795
                                                 {   ADRD1,   phsrc1,src_x, REGA1, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRD1 }
796
                                           : {   addr_nop,8'h54, SRC_1, src_1l,1'b1,temp_h,op_trul, 2'b11,2'b00,4'h0  };
797
                          state_50 = ACCA[3] ?          // _M...
798
                                                 {   ADRD1,   phsrc1,IRRW1, REGA1, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRD1 }
799
                                           : {   addr_nop,8'h54, SRC_1, src_1l,1'b1,temp_h,op_trul, 2'b11,2'b00,4'h0  };
800
                          state_53 = {   addr_nop,8'h55, imme,  src_x, 1'b1,temp_h,op_mov,      2'b00,2'b00,get8b_s };
801
                          state_54 = ACCA[1] ?
802
                                                 {       ADRD2,   phsrc2,IRRW2, REGA2, 1'b0,dest_x,op_trul, 2'b00,2'b00,NXRW2 }
803
                                           : {   addr_nop,8'h5A, src_x, src_x, 1'b0,temp_h,op_trul,     2'b00,2'b00,4'h0  };
804 11 ns32kum
                          state_55 = {   addr_nop,8'h54, rtmph, imme,  1'b1,temp_h,op_trul, 2'b11,2'b00,4'h0  };        // 2. half of external SRC1
805 9 ns32kum
                          state_58 = {   addr_nop,8'h59, rtmph, imme,  1'b0,dest_2,OPERA,       2'b01,2'b00,4'h0  };
806
                          state_59 = {   addr_nop,8'h1F, src_x, (ACCA[1] ? imme : src_2l),
807
                                                                                                           ~ACCA[1],dest_2,OPERA,       2'b10,2'b00,4'h0  };
808 11 ns32kum
                          state_5A = {   addr_nop,8'h59, rtmph, SRC_2, 1'b0,dest_2,OPERA,       2'b01,2'b00,4'h0  };    // empty cycle for TRUNC => TEMP !
809 9 ns32kum
                        end
810
                5'b01_001 :     // SCALBF : RMW critical !
811
                        begin
812
                          STATE_0  = ACCA[3] ?          // _M...
813
                                                 {   ADRD1,   phsrc1,src_x, REGA1, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRD1 }
814
                                           : {   addr_nop,8'h54, SRC_1, src_x, 1'b1,temp_h,op_truf, 2'b00,2'b00,4'h0  };
815
                          state_50 = ACCA[3] ?          // _M...
816
                                                 {   ADRD1,   phsrc1,IRRW1, REGA1, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRD1 }
817
                                           : {   addr_nop,8'h54, SRC_1, src_x, 1'b1,temp_h,op_truf, 2'b00,2'b00,4'h0  };
818
                          state_53 = {   addr_nop,8'h54, imme,  src_x, 1'b1,temp_h,op_truf, 2'b00,2'b00,4'h0  };
819
                          state_54 = ACCA[1] ?
820
                                                 {       ADRD2,   phsrc2,IRRW2, REGA2, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRW2 }
821
                                           : {   addr_nop,8'h1F, rtmph, SRC_2, 1'b1,dest_2,OPERA,       2'b11,2'b00,4'h0  };
822
                          state_55 = dont_care;
823
                          state_58 = {   addr_nop,8'h1F, rtmph, imme,  1'b0,dest_x,OPERA,       2'b11,2'b00,4'h0  };
824
                          state_59 = dont_care;
825
                          state_5A = dont_care;
826
                        end
827
                5'b01_100 :     // POLYL
828
                        begin
829
                          STATE_0  = ACCA[3] ?          // _M...
830
                                                 {   ADRD1,   phsrc1,src_x, REGA1, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRD1 }
831
                                           : {   addr_nop,8'h54, SRC_1, F0_h,  1'b0,temp_h,op_mull, 2'b01,2'b00,4'h0  };
832
                          state_50 = ACCA[3] ?          // _M...
833
                                                 {   ADRD1,   phsrc1,IRRW1, REGA1, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRD1 }
834
                                           : {   addr_nop,8'h54, SRC_1, F0_h,  1'b0,temp_h,op_mull, 2'b01,2'b00,4'h0  };
835
                          state_53 = {   addr_nop,8'h54, imme,  F0_h,  1'b0,temp_h,op_mull, 2'b01,2'b00,get8b_s };
836
                          state_54 = {   addr_nop,8'h64, (ACCA[3] ? imme : src_1l),
837
                                                                                                        F0,    1'b1,temp_h,op_mull, 2'b10,2'b00,4'h0  };
838
                          state_55 = dont_care;
839
                          state_58 = {   addr_nop,8'h59, imme,  rtmph, 1'b0,dest_x,op_addl, 2'b01,2'b00,get8b_d };
840
                          state_59 = {   addr_nop,8'h62, (ACCA[1] ? imme : src_2l),
841
                                                                                                        rtmpl, 1'b1,w_F0_h,op_addl, 2'b10,2'b00,4'h0  };
842
                          state_5A = dont_care;
843
                        end
844
                5'b01_101 :     // POLYF
845
                        begin
846
                          STATE_0  = ACCA[3] ?          // _M...
847
                                                 {   ADRD1,   phsrc1,src_x, REGA1, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRD1 }
848
                                           : {   addr_nop,8'h54, SRC_1, F0,    1'b1,temp_h,op_mulf, 2'b00,2'b00,4'h0  };
849
                          state_50 = ACCA[3] ?          // _M...
850
                                                 {   ADRD1,   phsrc1,IRRW1, REGA1, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRD1 }
851
                                           : {   addr_nop,8'h54, SRC_1, F0,    1'b1,temp_h,op_mulf, 2'b00,2'b00,4'h0  };
852
                          state_53 = {   addr_nop,8'h54, imme,  F0,    1'b1,temp_h,op_mulf, 2'b00,2'b00,4'h0  };
853
                          state_54 = ACCA[1] ?
854
                                                 {       ADRD2,   phsrc2,IRRW2, REGA2, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRW2 }
855
                                           : {   addr_nop,8'h00, rtmph, SRC_2, 1'b1,w_F0  ,op_addf, 2'b00,2'b00,4'h0  };
856
                          state_55 = dont_care;
857
                          state_58 = {   addr_nop,8'h00, rtmph, imme,  1'b1,w_F0  ,op_addf, 2'b00,2'b00,4'h0  };
858
                          state_59 = dont_care;
859
                          state_5A = dont_care;
860
                        end
861
                5'b01_110 :     // DOTL
862
                        begin
863
                          STATE_0  = (~ACCA[3] & ~ACCA[1]) ?            // _R.R.
864
                                                 {       addr_nop,8'h59, SRC_1, SRC_2, 1'b0,dest_x,op_mull, 2'b01,2'b00,4'h0  }
865
                                           : (  ACCA[3] ?               // _M...
866
                                                    {ADRD1,   phsrc1,src_x, REGA1, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRD1 }
867
                                                  : {ADRD2,   phsrc2,src_x, REGA2, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRW2 } );
868
                          state_50 = ACCA[3] ?          // _M...
869
                                                 {   ADRD1,   phsrc1,IRRW1, REGA1, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRD1 }
870
                                           : {   ADRD2,   phsrc2,IRRW2, REGA2, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRW2 };
871
                          state_53 = ACCA[1] ?          // _..M.
872
                                                 {   addr_nop,8'h54, imme,  src_x, 1'b1,temp_h,op_mov,  2'b00,2'b00,get8b_s }
873
                                           : {   addr_nop,8'h59, imme,  SRC_2, 1'b0,dest_x,op_mull, 2'b01,2'b00,get8b_s };
874
                          state_54 = {   addr_nop,8'h55, imme,  src_x, 1'b1,temp_l,op_mov,  2'b00,2'b00,4'h0  };
875
                          state_55 = {   ADRD2,   phsrc2,IRRW2, REGA2, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRW2 };
876
                          state_58 = {   addr_nop,8'h59, (ACCA[3] ? rtmph : SRC_1),             //_M...
877
                                                                                                        imme,  1'b0,dest_x,op_mull, 2'b01,2'b00,get8b_d };
878 11 ns32kum
                          state_59 = {   addr_nop,8'h5A, (ACCA[3] ? (ACCA[1] ? rtmpl : imme) : src_1l), (ACCA[1] ? imme : src_2l),
879 9 ns32kum
                                                                                                                   1'b1,temp_h,op_mull, 2'b10,2'b00,4'h0  };
880
                          state_5A = {   addr_nop,8'h61, rtmph, F0_h,  1'b0,temp_h,op_mull, 2'b01,2'b00,4'h0  };
881
                        end
882
                5'b01_111 :     // DOTF
883
                        begin
884
                          STATE_0  = (~ACCA[3] & ~ACCA[1]) ?            // _R.R.
885
                                                 {       addr_nop,8'h63, SRC_1 ,SRC_2 ,1'b1,temp_h,op_mulf, 2'b00,2'b00,4'h0  }         // opera = MULF
886
                                           : (  ACCA[3] ?               // _M...
887
                                                    {ADRD1,   phsrc1,src_x, REGA1, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRD1 }
888
                                                  : {ADRD2,   phsrc2,src_x, REGA2, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRW2 } );
889
                          state_50 = ACCA[3] ?          // _M...
890
                                                 {   ADRD1,   phsrc1,IRRW1, REGA1, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRD1 }
891
                                           : {   ADRD2,   phsrc2,IRRW2, REGA2, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRW2 };
892
                          state_53 = ACCA[1] ?          // _..M.
893
                                                 {   addr_nop,8'h55, imme,  src_x, 1'b1,temp_h,op_mov,  2'b00,2'b00,4'h0  }
894
                                           : {   addr_nop,8'h63, imme,  SRC_2 ,1'b1,temp_h,op_mulf, 2'b00,2'b00,4'h0  };
895
                          state_54 = dont_care;
896
                          state_55 = {   ADRD2,   phsrc2,IRRW2, REGA2, 1'b0,dest_x,op_mov,  2'b00,2'b00,NXRW2 };
897
                          state_58 = {   addr_nop,8'h63, (ACCA[3] ? rtmph : SRC_1),             //_M...
898
                                                                                                        imme,  1'b1,temp_h,op_mulf, 2'b00,2'b00,4'h0  };
899
                          state_59 = dont_care;
900
                          state_5A = dont_care;
901
                        end
902
                default
903
                        begin
904
                          STATE_0  = dont_care;
905
                          state_50 = dont_care;
906
                          state_53 = dont_care;
907
                          state_54 = dont_care;
908
                          state_55 = dont_care;
909
                          state_58 = dont_care;
910
                          state_59 = dont_care;
911
                          state_5A = dont_care;
912
                        end
913
                endcase
914
 
915
        always @(*)
916
          casex (PHASE)
917
                 4'h0 : STATE_GROUP_50 = state_50;
918
                // Phase 51 : wait for data and Disp2 for External Address mode : part 2 EA = (MOD+4)+4*DISP1
919 11 ns32kum
                 4'h1 : STATE_GROUP_50 = {exr11,   8'h52, src_x,imme , 1'b0,dest_x,             op_mov, 2'b00,2'b00,    4'b1111};
920 9 ns32kum
                // Phase 52 : Memory-Pointer for Memory Relative and last access External
921 11 ns32kum
                 4'h2 : STATE_GROUP_50 = {EXR12,   8'h53, IRRW1,imme , 1'b0,dest_x,             op_mov, 2'b00,2'b00,    4'b1111};  // atys[0] !
922 9 ns32kum
                 4'h3 : STATE_GROUP_50 = state_53;
923
                 4'h4 : STATE_GROUP_50 = state_54;
924
                 4'h5 : STATE_GROUP_50 = state_55;
925
                // Phase 56 : wait for data and Disp2 for External Address mode : part 2 EA = (MOD+4)+4*DISP1
926 11 ns32kum
                 4'h6 : STATE_GROUP_50 = {exr11,   8'h57, src_x,imme , 1'b0,dest_x,             op_mov, 2'b00,2'b00,    4'b1111};
927 9 ns32kum
                // Phase 57 : Memory-Pointer for Memory Relative and last access External
928 11 ns32kum
                 4'h7 : STATE_GROUP_50 = {EXR22,   8'h58, IRRW2,imme , 1'b0,dest_x,             op_mov, 2'b00,2'b00,    4'b1111};  // atyd[0] !
929 9 ns32kum
                 4'h8 : STATE_GROUP_50 = state_58;
930
                 4'h9 : STATE_GROUP_50 = state_59;
931
                 4'hA : STATE_GROUP_50 = state_5A;
932
          default : STATE_GROUP_50 = dont_care;
933
          endcase
934
 
935
        always @(*)
936
          casex (PHASE)
937 11 ns32kum
                 4'h0 : STATE_GROUP_60 = {       addr_nop,8'h00, src_x, src_x, 1'b1,chkreg,op_adr,  2'b00,2'b00,4'h0  };        // for INDEX
938
                 4'h1 : STATE_GROUP_60 = {       addr_nop,8'h62, rtmpl, F0,    1'b1,w_F0_h,op_addl, 2'b10,2'b00,4'h0  };        // for DOTL
939
                 4'h2 : STATE_GROUP_60 = {       addr_nop,8'h00, src_x, src_x, 1'b0,w_F0_h,op_addl, 2'b00,2'b00,4'h0  };        // for DOTL & POLYL !
940
                 4'h3 : STATE_GROUP_60 = {       addr_nop,8'h00, rtmph, F0,    1'b1,w_F0,  op_addf, 2'b00,2'b00,4'h0  };        // for DOTF
941 9 ns32kum
                 4'h4 : STATE_GROUP_60 = ACCA[1] ?      // ..M.
942
                                                                 {       ADRD2,   phsrc2,IRRW2, REGA2, 1'b0,temp_h,op_mull, 2'b00,2'b00,NXRW2 }
943
                                                           : {   addr_nop,8'h59, SRC_2, rtmph, 1'b0,temp_h,op_addl, 2'b01,2'b00,4'h0  };        // for POLYL
944 11 ns32kum
                 4'h5 : STATE_GROUP_60 = {       addr_nop,8'h59, src_x, src_x, 1'b1,temp_l,op_kust, 2'b00,2'b00,4'h0  };        // for MOVM/CMPM
945
                 4'h6 : STATE_GROUP_60 = {       addr_nop,8'h01, rtmph, src_x, 1'b0,dest_x,op_mov,      2'b00,2'b00,4'h0  };    // for JUMP/JSR/CASE
946
                 4'h7 : STATE_GROUP_60 = {       addr_nop,8'hC0, (op_reg_reg[0] ? rtmpl : 7'h00),                                                        // Jump to String execution
947 9 ns32kum
                                                                                                                        src_x, 1'b0,dest_x,OPERA,       2'b00,2'b10,4'h0  };    // LD_OUT set, CMPS F-Flag
948
                // for INS                                                                                                              
949 11 ns32kum
                 4'h8 : STATE_GROUP_60 = {       addr_nop,8'h69, rd_reg,rtmph, 1'b1,temp_h,op_lsh,      2'b00,2'b00,4'h0  };    // SRC1 shift
950
                 4'h9 : STATE_GROUP_60 = {       addr_nop,8'h59, rd_reg,rtmp1, 1'b0,dest_x,op_lsh,      2'b00,2'b00,4'h0  };    // Mask shift
951
                 4'hA : STATE_GROUP_60 = {       addr_nop,8'h5A, imme,  src_x, 1'b1,temp_l,op_mov,      2'b00,2'b00,imdi  };    // Imme./Disp. read
952 9 ns32kum
                // for CXPD, this State is decoded explicitly in DECODER
953 11 ns32kum
                 4'hB : STATE_GROUP_60 = {       addr_nop,8'h39, imme,  src_x, 1'b1,temp_l,op_mov,      2'b00,2'b00,4'h0  };    // pass PC
954 9 ns32kum
          default : STATE_GROUP_60 = dont_care;
955
          endcase
956
 
957
endmodule

powered by: WebSVN 2.1.0

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