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

Subversion Repositories rtf65002

[/] [rtf65002/] [trunk/] [rtl/] [verilog/] [decode.v] - Blame information for rev 20

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

Line No. Rev Author Line
1 20 robfinch
// ============================================================================
2
//        __
3
//   \\__/ o\    (C) 2013  Robert Finch, Stratford
4
//    \  __ /    All rights reserved.
5
//     \/_//     robfinch<remove>@opencores.org
6
//       ||
7
//
8
// This source file is free software: you can redistribute it and/or modify 
9
// it under the terms of the GNU Lesser General Public License as published 
10
// by the Free Software Foundation, either version 3 of the License, or     
11
// (at your option) any later version.                                      
12
//                                                                          
13
// This source file is distributed in the hope that it will be useful,      
14
// but WITHOUT ANY WARRANTY; without even the implied warranty of           
15
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            
16
// GNU General Public License for more details.                             
17
//                                                                          
18
// You should have received a copy of the GNU General Public License        
19
// along with this program.  If not, see <http://www.gnu.org/licenses/>.    
20
//                                                                          
21
// ============================================================================
22
//
23
DECODE:
24
        begin
25
                first_ifetch <= `TRUE;
26
                Rt <= 4'h0;             // Default
27
                state <= IFETCH;
28
                case(ir[7:0])
29
                `STP:   begin clk_en <= 1'b0; pc <= pc + 32'd1; end
30
                `NOP:   begin pc <= pc + 32'd1; end
31
                `CLC:   begin cf <= 1'b0; pc <= pc + 32'd1; end
32
                `SEC:   begin cf <= 1'b1; pc <= pc + 32'd1; end
33
                `CLV:   begin vf <= 1'b0; pc <= pc + 32'd1; end
34
                `CLI:   begin im <= 1'b0; pc <= pc + 32'd1; end
35
                `CLD:   begin df <= 1'b0; pc <= pc + 32'd1; end
36
                `SED:   begin df <= 1'b1; pc <= pc + 32'd1; end
37
                `SEI:   begin im <= 1'b1; pc <= pc + 32'd1; end
38
                `WAI:   begin wai <= 1'b1; pc <= pc + 32'd1; end
39
                `EMM:   begin em <= 1'b1; pc <= pc + 32'd1; end
40
                `DEX:   begin res <= x - 32'd1; pc <= pc + 32'd1; end
41
                `INX:   begin res <= x + 32'd1; pc <= pc + 32'd1; end
42
                `DEY:   begin res <= y - 32'd1; pc <= pc + 32'd1; end
43
                `INY:   begin res <= y + 32'd1; pc <= pc + 32'd1; end
44
                `DEA:   begin res <= acc - 32'd1; pc <= pc + 32'd1; end
45
                `INA:   begin res <= acc + 32'd1; pc <= pc + 32'd1; end
46
                `TSX:   begin res <= isp; pc <= pc + 32'd1; end
47
                `TXS,`TXA,`TXY: begin res <= x; pc <= pc + 32'd1; end
48
                `TAX,`TAY,`TAS: begin res <= acc; pc <= pc + 32'd1; end
49
                `TYA,`TYX:      begin res <= y; pc <= pc + 32'd1; end
50
                `TRS:           begin
51
                                                res <= rfoa; pc <= pc + 32'd2; end
52
                `TSR:           begin
53
                                                Rt <= ir[15:12];
54
                                                case(ir[11:8])
55
                                                4'h0:   res <= {write_allocate,dcacheOn,icacheOn};
56
                                                4'h1:   res <= dp;
57
                                                4'h2:   res <= prod[31:0];
58
                                                4'h3:   res <= prod[63:32];
59
                                                4'h4:   res <= tick;
60
                                                4'h5:   begin res <= lfsr; lfsr <= {lfsr[30:0],lfsr_fb}; end
61
                                                4'h6:   res <= dp8;
62
                                                4'h7:   res <= abs8;
63
                                                4'h8:   res <= {vbr[31:1],nmoi};
64
                                                4'hE:   res <= {spage[31:8],sp};
65
                                                4'hF:   res <= isp;
66
                                                endcase
67
                                                pc <= pc + 32'd2;
68
                                        end
69
                `ASL_ACC:       begin res <= {acc,1'b0}; pc <= pc + 32'd1; end
70
                `ROL_ACC:       begin res <= {acc,cf}; pc <= pc + 32'd1; end
71
                `LSR_ACC:       begin res <= {acc[0],1'b0,acc[31:1]}; pc <= pc + 32'd1; end
72
                `ROR_ACC:       begin res <= {acc[0],cf,acc[31:1]}; pc <= pc + 32'd1; end
73
 
74
                `RR:
75
                        begin
76
                                state <= IFETCH;
77
                                case(ir[23:20])
78
                                `ADD_RR:        begin res <= rfoa + rfob; a <= rfoa; b <= rfob; end
79
                                `SUB_RR:        begin res <= rfoa - rfob; a <= rfoa; b <= rfob; end
80
                                `AND_RR:        begin res <= rfoa & rfob; a <= rfoa; b <= rfob; end     // for bit flags
81
                                `OR_RR:         begin res <= rfoa | rfob; a <= rfoa; b <= rfob; end
82
                                `EOR_RR:        begin res <= rfoa ^ rfob; a <= rfoa; b <= rfob; end
83
                                `MUL_RR:        begin state <= MULDIV1; end
84
                                `MULS_RR:       begin state <= MULDIV1; end
85
                                `DIV_RR:        begin state <= MULDIV1; end
86
                                `DIVS_RR:       begin state <= MULDIV1; end
87
                                `MOD_RR:        begin state <= MULDIV1; end
88
                                `MODS_RR:       begin state <= MULDIV1; end
89
                                `ASL_RRR:       begin a <= rfoa; b <= rfob; state <= CALC; end
90
                                `LSR_RRR:       begin a <= rfoa; b <= rfob; state <= CALC; end
91
                                endcase
92
                                Rt <= ir[19:16];
93
                                pc <= pc + 32'd3;
94
                        end
95
                `LD_RR:         begin res <= rfoa; Rt <= ir[15:12]; pc <= pc + 32'd2; end
96
                `ASL_RR:        begin res <= {rfoa,1'b0}; pc <= pc + 32'd2; Rt <= ir[15:12]; end
97
                `ROL_RR:        begin res <= {rfoa,cf}; pc <= pc + 32'd2; Rt <= ir[15:12]; end
98
                `LSR_RR:        begin res <= {rfoa[0],1'b0,rfoa[31:1]}; pc <= pc + 32'd2; Rt <= ir[15:12]; end
99
                `ROR_RR:        begin res <= {rfoa[0],cf,rfoa[31:1]}; pc <= pc + 32'd2; Rt <= ir[15:12]; end
100
                `DEC_RR:        begin res <= rfoa - 32'd1; pc <= pc + 32'd2; Rt <= ir[15:12]; end
101
                `INC_RR:        begin res <= rfoa + 32'd1; pc <= pc + 32'd2; Rt <= ir[15:12]; end
102
 
103
                `ADD_IMM8:      begin res <= rfoa + {{24{ir[23]}},ir[23:16]}; Rt <= ir[15:12]; pc <= pc + 32'd3; a <= rfoa; b <= {{24{ir[23]}},ir[23:16]}; end
104
                `SUB_IMM8:      begin res <= rfoa - {{24{ir[23]}},ir[23:16]}; Rt <= ir[15:12]; pc <= pc + 32'd3; a <= rfoa; b <= {{24{ir[23]}},ir[23:16]}; end
105
                `OR_IMM8:       begin res <= rfoa | {{24{ir[23]}},ir[23:16]}; Rt <= ir[15:12]; pc <= pc + 32'd3; b <= {{24{ir[23]}},ir[23:16]}; end
106
                `AND_IMM8:      begin res <= rfoa & {{24{ir[23]}},ir[23:16]}; Rt <= ir[15:12]; pc <= pc + 32'd3; b <= {{24{ir[23]}},ir[23:16]}; end
107
                `EOR_IMM8:      begin res <= rfoa ^ {{24{ir[23]}},ir[23:16]}; Rt <= ir[15:12]; pc <= pc + 32'd3; b <= {{24{ir[23]}},ir[23:16]}; end
108
                `CMP_IMM8:      begin res <= acc - {{24{ir[15]}},ir[15:8]}; Rt <= 4'h0; pc <= pc + 32'd2; b <= {{24{ir[15]}},ir[15:8]}; end
109
                `ASL_IMM8:      begin a <= rfoa; b <= ir[20:16]; Rt <= ir[15:12]; pc <= pc + 32'd3; state <= CALC; end
110
                `LSR_IMM8:      begin a <= rfoa; b <= ir[20:16]; Rt <= ir[15:12]; pc <= pc + 32'd3; state <= CALC; end
111
 
112
                `ADD_IMM16:     begin res <= rfoa + {{16{ir[31]}},ir[31:16]}; Rt <= ir[15:12]; pc <= pc + 32'd4; a <= rfoa; b <= {{16{ir[31]}},ir[31:16]}; end
113
                `SUB_IMM16:     begin res <= rfoa - {{16{ir[31]}},ir[31:16]}; Rt <= ir[15:12]; pc <= pc + 32'd4; a <= rfoa; b <= {{16{ir[31]}},ir[31:16]}; end
114
                `OR_IMM16:      begin res <= rfoa | {{16{ir[31]}},ir[31:16]}; Rt <= ir[15:12]; pc <= pc + 32'd4; b <= {{16{ir[31]}},ir[31:16]}; end
115
                `AND_IMM16:     begin res <= rfoa & {{16{ir[31]}},ir[31:16]}; Rt <= ir[15:12]; pc <= pc + 32'd4; b <= {{16{ir[31]}},ir[31:16]}; end
116
                `EOR_IMM16:     begin res <= rfoa ^ {{16{ir[31]}},ir[31:16]}; Rt <= ir[15:12]; pc <= pc + 32'd4; b <= {{16{ir[31]}},ir[31:16]}; end
117
 
118
                `ADD_IMM32:     begin res <= rfoa + ir[47:16]; Rt <= ir[15:12]; pc <= pc + 32'd6; a <= rfoa; b <= ir[47:16]; end
119
                `SUB_IMM32:     begin res <= rfoa - ir[47:16]; Rt <= ir[15:12]; pc <= pc + 32'd6; a <= rfoa; b <= ir[47:16]; end
120
                `OR_IMM32:      begin res <= rfoa | ir[47:16]; Rt <= ir[15:12]; pc <= pc + 32'd6; b <= ir[47:16]; end
121
                `AND_IMM32:     begin res <= rfoa & ir[47:16]; Rt <= ir[15:12]; pc <= pc + 32'd6; b <= ir[47:16]; end
122
                `EOR_IMM32:     begin res <= rfoa ^ ir[47:16]; Rt <= ir[15:12]; pc <= pc + 32'd6; b <= ir[47:16]; end
123
 
124
                `LDX_IMM32,`LDY_IMM32,`LDA_IMM32:       begin res <= ir[39:8]; pc <= pc + 32'd5; end
125
                `LDX_IMM16,`LDA_IMM16:  begin res <= {{16{ir[23]}},ir[23:8]}; pc <= pc + 32'd3; end
126
                `LDX_IMM8,`LDA_IMM8: begin res <= {{24{ir[15]}},ir[15:8]}; pc <= pc + 32'd2; end
127
 
128
                `LDX_ZPX,`LDY_ZPX:
129
                        begin
130
                                radr <= zpx32xy_address;
131
                                pc <= pc + 32'd3;
132
                                state <= LOAD1;
133
                        end
134
                `ORB_ZPX:
135
                        begin
136
                                a <= rfoa;
137
                                Rt <= ir[19:16];
138
                                radr <= zpx32_address[31:2];
139
                                radr2LSB <= zpx32_address[1:0];
140
                                pc <= pc + 32'd4;
141
                                state <= LOAD1;
142
                        end
143
                `LDX_ABS,`LDY_ABS:
144
                        begin
145
                                radr <= ir[39:8];
146
                                pc <= pc + 32'd5;
147
                                state <= LOAD1;
148
                        end
149
                `ORB_ABS:
150
                        begin
151
                                a <= rfoa;
152
                                Rt <= ir[15:12];
153
                                radr <= ir[47:18];
154
                                radr2LSB <= ir[17:16];
155
                                pc <= pc + 32'd6;
156
                                state <= LOAD1;
157
                        end
158
                `LDX_ABSY,`LDY_ABSX:
159
                        begin
160
                                radr <= absx32xy_address;
161
                                pc <= pc + 32'd6;
162
                                state <= LOAD1;
163
                        end
164
                `ORB_ABSX:
165
                        begin
166
                                a <= rfoa;
167
                                Rt <= ir[19:16];
168
                                radr <= absx32_address[31:2];
169
                                radr2LSB <= absx32_address[1:0];
170
                                pc <= pc + 32'd7;
171
                                state <= LOAD1;
172
                        end
173
                `ST_ZPX:
174
                        begin
175
                                wadr <= zpx32_address;
176
                                wdat <= rfoa;
177
                                pc <= pc + 32'd4;
178
                                state <= STORE1;
179
                        end
180
                `STB_ZPX:
181
                        begin
182
                                wadr <= zpx32_address[31:2];
183
                                wadr2LSB <= zpx32_address[1:0];
184
                                pc <= pc + 32'd4;
185
                                state <= STORE1;
186
                        end
187
                `ST_ABS:
188
                        begin
189
                                wadr <= ir[47:16];
190
                                wdat <= rfoa;
191
                                pc <= pc + 32'd6;
192
                                state <= STORE1;
193
                        end
194
                `STB_ABS:
195
                        begin
196
                                wadr <= ir[47:18];
197
                                wadr2LSB <= ir[17:16];
198
                                wdat <= {4{rfoa[7:0]}};
199
                                pc <= pc + 32'd6;
200
                                state <= STORE1;
201
                        end
202
                `ST_ABSX:
203
                        begin
204
                                wadr <= absx32_address;
205
                                wdat <= rfoa;
206
                                pc <= pc + 32'd7;
207
                                state <= STORE1;
208
                        end
209
                `STB_ABSX:
210
                        begin
211
                                wadr <= absx32_address[31:2];
212
                                wadr2LSB <= absx32_address[1:0];
213
                                wdat <= {4{rfoa[7:0]}};
214
                                pc <= pc + 32'd7;
215
                                state <= STORE1;
216
                        end
217
                `STX_ZPX:
218
                        begin
219
                                wadr <= dp + ir[23:12] + rfoa;
220
                                wdat <= x;
221
                                pc <= pc + 32'd3;
222
                                state <= STORE1;
223
                        end
224
                `STX_ABS:
225
                        begin
226
                                wadr <= ir[39:8];
227
                                wdat <= x;
228
                                pc <= pc + 32'd5;
229
                                state <= STORE1;
230
                        end
231
                `STY_ZPX:
232
                        begin
233
                                wadr <= dp + ir[23:12] + rfoa;
234
                                wdat <= y;
235
                                pc <= pc + 32'd3;
236
                                state <= STORE1;
237
                        end
238
                `STY_ABS:
239
                        begin
240
                                wadr <= ir[39:8];
241
                                wdat <= y;
242
                                pc <= pc + 32'd5;
243
                                state <= STORE1;
244
                        end
245
                `ADD_ZPX,`SUB_ZPX,`OR_ZPX,`AND_ZPX,`EOR_ZPX:
246
                        begin
247
                                a <= rfoa;
248
                                Rt <= ir[19:16];
249
                                radr <= zpx32_address;
250
                                pc <= pc + 32'd4;
251
                                state <= LOAD1;
252
                        end
253
                `ASL_ZPX,`ROL_ZPX,`LSR_ZPX,`ROR_ZPX,`INC_ZPX,`DEC_ZPX:
254
                        begin
255
                                radr <= dp + rfoa + ir[23:12];
256
                                pc <= pc + 32'd3;
257
                                state <= LOAD1;
258
                        end
259
                `ADD_IX,`SUB_IX,`OR_IX,`AND_IX,`EOR_IX,`ST_IX:
260
                        begin
261
                                a <= rfoa;
262
                                if (ir[7:0]==`ST_IX)
263
                                        res <= rfoa;            // for ST_IX, Rt=0
264
                                else
265
                                        Rt <= ir[19:16];
266
                                pc <= pc + 32'd4;
267
                                radr <= dp + ir[31:20] + rfob;
268
                                state <= IX1;
269
                        end
270
                `ADD_RIND,`SUB_RIND,`OR_RIND,`AND_RIND,`EOR_RIND,`ST_RIND:
271
                        begin
272
                                radr <= rfob;
273
                                wadr <= rfob;           // for store
274
                                wdat <= rfoa;
275
                                a <= rfoa;
276
                                if (ir[7:0]==`ST_RIND) begin
277
                                        res <= rfoa;            // for ST_IX, Rt=0
278
                                        pc <= pc + 32'd2;
279
                                        state <= STORE1;
280
                                end
281
                                else begin
282
                                        Rt <= ir[19:16];
283
                                        pc <= pc + 32'd3;
284
                                        state <= LOAD1;
285
                                end
286
                        end
287
                `ADD_IY,`SUB_IY,`OR_IY,`AND_IY,`EOR_IY,`ST_IY:
288
                        begin
289
                                a <= rfoa;
290
                                if (ir[7:0]==`ST_IY)
291
                                        res <= rfoa;            // for ST_IY, Rt=0
292
                                else
293
                                        Rt <= ir[19:16];
294
                                pc <= pc + 32'd4;
295
                                radr <= dp + ir[31:20];
296
                                state <= IY1;
297
                        end
298
                `ADD_ABS,`SUB_ABS,`OR_ABS,`AND_ABS,`EOR_ABS:
299
                        begin
300
                                a <= rfoa;
301
                                radr <= ir[47:16];
302
                                Rt <= ir[15:12];
303
                                pc <= pc + 32'd6;
304
                                state <= LOAD1;
305
                        end
306
                `ASL_ABS,`ROL_ABS,`LSR_ABS,`ROR_ABS,`INC_ABS,`DEC_ABS:
307
                        begin
308
                                radr <= ir[39:8];
309
                                pc <= pc + 32'd5;
310
                                state <= LOAD1;
311
                        end
312
                `ADD_ABSX,`SUB_ABSX,`OR_ABSX,`AND_ABSX,`EOR_ABSX:
313
                        begin
314
                                a <= rfoa;
315
                                radr <= ir[55:24] + rfob;
316
                                Rt <= ir[19:16];
317
                                pc <= pc + 32'd7;
318
                                state <= LOAD1;
319
                        end
320
                `ASL_ABSX,`ROL_ABSX,`LSR_ABSX,`ROR_ABSX,`INC_ABSX,`DEC_ABSX:
321
                        begin
322
                                radr <= ir[47:16] + rfob;
323
                                pc <= pc + 32'd6;
324
                                state <= LOAD1;
325
                        end
326
                `CPX_IMM32:
327
                        begin
328
                                res <= x - ir[39:8];
329
                                pc <= pc + 32'd5;
330
                                state <= IFETCH;
331
                        end
332
                `CPY_IMM32:
333
                        begin
334
                                res <= y - ir[39:8];
335
                                pc <= pc + 32'd5;
336
                                state <= IFETCH;
337
                        end
338
                `CPX_ZPX:
339
                        begin
340
                                radr <= dp + ir[23:12] + rfoa;
341
                                pc <= pc + 32'd3;
342
                                state <= LOAD1;
343
                        end
344
                `CPY_ZPX:
345
                        begin
346
                                radr <= dp + ir[23:12] + rfoa;
347
                                pc <= pc + 32'd3;
348
                                state <= LOAD1;
349
                        end
350
                `CPX_ABS:
351
                        begin
352
                                radr <= ir[39:8];
353
                                pc <= pc + 32'd5;
354
                                state <= LOAD1;
355
                        end
356
                `CPY_ABS:
357
                        begin
358
                                radr <= ir[39:8];
359
                                pc <= pc + 32'd5;
360
                                state <= LOAD1;
361
                        end
362
                `BRK:
363
                        begin
364
                                bf <= 1'b1;
365
                                radr <= isp_dec;
366
                                wadr <= isp_dec;
367
                                wdat <= pc + 32'd1;
368
                                cyc_o <= 1'b1;
369
                                stb_o <= 1'b1;
370
                                we_o <= 1'b1;
371
                                sel_o <= 4'hF;
372
                                adr_o <= {isp_dec,2'b00};
373
                                dat_o <= pc + 32'd1;
374
                                vect <= {vbr[31:9],`BRK_VECTNO,2'b00};
375
                                state <= IRQ1;
376
                        end
377
                `JMP:
378
                        begin
379
                                pc[15:0] <= ir[23:8];
380
                                state <= IFETCH;
381
                        end
382
                `JML:
383
                        begin
384
                                pc <= ir[39:8];
385
                                state <= IFETCH;
386
                        end
387
                `JMP_IND:
388
                        begin
389
                                radr <= ir[39:8];
390
                                state <= JMP_IND1;
391
                        end
392
                `JMP_INDX:
393
                        begin
394
                                radr <= ir[39:8] + x;
395
                                state <= JMP_IND1;
396
                        end
397
                `JMP_RIND:
398
                        begin
399
                                pc <= rfoa;
400
                                res <= pc + 32'd2;
401
                                Rt <= ir[15:12];
402
                                state <= IFETCH;
403
                        end
404
                `JSR:
405
                        begin
406
                                radr <= isp_dec;
407
                                wadr <= isp_dec;
408
                                wdat <= pc + 32'd3;
409
                                cyc_o <= 1'b1;
410
                                stb_o <= 1'b1;
411
                                we_o <= 1'b1;
412
                                sel_o <= 4'hF;
413
                                adr_o <= {isp_dec,2'b00};
414
                                dat_o <= pc + 32'd3;
415
                                vect <= {pc[31:16],ir[23:8]};
416
                                state <= JSR1;
417
                        end
418
                `JSR_RIND:
419
                        begin
420
                                radr <= isp_dec;
421
                                wadr <= isp_dec;
422
                                wdat <= pc + 32'd2;
423
                                cyc_o <= 1'b1;
424
                                stb_o <= 1'b1;
425
                                we_o <= 1'b1;
426
                                sel_o <= 4'hF;
427
                                adr_o <= {isp_dec,2'b00};
428
                                dat_o <= pc + 32'd2;
429
                                vect <= rfoa;
430
                                state <= JSR1;
431
                                $stop;
432
                        end
433
                `JSL:
434
                        begin
435
                                radr <= isp_dec;
436
                                wadr <= isp_dec;
437
                                wdat <= pc + 32'd5;
438
                                cyc_o <= 1'b1;
439
                                stb_o <= 1'b1;
440
                                we_o <= 1'b1;
441
                                sel_o <= 4'hF;
442
                                adr_o <= {isp_dec,2'b00};
443
                                dat_o <= pc + 32'd5;
444
                                vect <= ir[39:8];
445
                                state <= JSR1;
446
                        end
447
                `BSR:
448
                        begin
449
                                radr <= isp_dec;
450
                                wadr <= isp_dec;
451
                                wdat <= pc + 32'd3;
452
                                cyc_o <= 1'b1;
453
                                stb_o <= 1'b1;
454
                                we_o <= 1'b1;
455
                                sel_o <= 4'hF;
456
                                adr_o <= {isp_dec,2'b00};
457
                                dat_o <= pc + 32'd3;
458
                                vect <= pc + {{16{ir[23]}},ir[23:8]};
459
                                state <= JSR1;
460
                        end
461
                `JSR_INDX:
462
                        begin
463
                                radr <= isp - 32'd1;
464
                                wadr <= isp - 32'd1;
465
                                wdat <= pc + 32'd5;
466
                                cyc_o <= 1'b1;
467
                                stb_o <= 1'b1;
468
                                we_o <= 1'b1;
469
                                sel_o <= 4'hF;
470
                                adr_o <= {isp-32'd1,2'b00};
471
                                dat_o <= pc + 32'd5;
472
                                state <= JSR_INDX1;
473
                        end
474
//              `JSR16:
475
//                      begin
476
//                              radr <= isp - 32'd1;
477
//                              wadr <= isp - 32'd1;
478
//                              wdat <= pc + 32'd3;
479
//                              cyc_o <= 1'b1;
480
//                              stb_o <= 1'b1;
481
//                              we_o <= 1'b1;
482
//                              sel_o <= 4'hF;
483
//                              adr_o <= {isp-32'd1,2'b00};
484
//                              dat_o <= pc + 32'd3;
485
//                              state <= JSR161;
486
//                      end
487
                `RTS,`RTL:
488
                                begin
489
                                radr <= isp;
490
                                state <= RTS1;
491
                                end
492
                `RTI:   begin
493
                                radr <= isp;
494
                                state <= RTI1;
495
                                end
496
                `BEQ,`BNE,`BPL,`BMI,`BCC,`BCS,`BVC,`BVS,`BRA:
497
                        begin
498
                                state <= IFETCH;
499
                                if (ir[15:8]==8'h00) begin
500
                                        radr <= isp_dec;
501
                                        wadr <= isp_dec;
502
                                        wdat <= pc + 32'd2;
503
                                        cyc_o <= 1'b1;
504
                                        stb_o <= 1'b1;
505
                                        we_o <= 1'b1;
506
                                        sel_o <= 4'hF;
507
                                        adr_o <= {isp_dec,2'b00};
508
                                        dat_o <= pc + 32'd2;
509
                                        vect <= {vbr[31:9],`SLP_VECTNO,2'b00};
510
                                        state <= IRQ1;
511
                                end
512
                                else if (ir[15:8]==8'h1) begin
513
                                        if (takb)
514
                                                pc <= pc + {{16{ir[31]}},ir[31:16]};
515
                                        else
516
                                                pc <= pc + 32'd4;
517
                                end
518
                                else begin
519
                                        if (takb)
520
                                                pc <= pc + {{24{ir[15]}},ir[15:8]};
521
                                        else
522
                                                pc <= pc + 32'd2;
523
                                end
524
                        end
525
/*              `BEQ_RR:
526
                        begin
527
                                state <= IFETCH;
528
                                if (ir[23:16]==8'h00) begin
529
                                        radr <= isp_dec;
530
                                        wadr <= isp_dec;
531
                                        wdat <= pc + 32'd2;
532
                                        cyc_o <= 1'b1;
533
                                        stb_o <= 1'b1;
534
                                        we_o <= 1'b1;
535
                                        sel_o <= 4'hF;
536
                                        adr_o <= {isp_dec,2'b00};
537
                                        dat_o <= pc + 32'd2;
538
                                        vect <= `SLP_VECT;
539
                                        state <= IRQ1;
540
                                end
541
                                else if (ir[23:16]==8'h1) begin
542
                                        if (rfoa==rfob)
543
                                                pc <= pc + {{16{ir[39]}},ir[39:24]};
544
                                        else
545
                                                pc <= pc + 32'd5;
546
                                end
547
                                else begin
548
                                        if (takb)
549
                                                pc <= pc + {{24{ir[23]}},ir[23:16]};
550
                                        else
551
                                                pc <= pc + 32'd3;
552
                                end
553
                        end*/
554
                `BRL:
555
                        begin
556
                                if (ir[23:8]==16'h0000) begin
557
                                        radr <= isp_dec;
558
                                        wadr <= isp_dec;
559
                                        wdat <= pc + 32'd3;
560
                                        cyc_o <= 1'b1;
561
                                        stb_o <= 1'b1;
562
                                        we_o <= 1'b1;
563
                                        sel_o <= 4'hF;
564
                                        adr_o <= {isp_dec,2'b00};
565
                                        dat_o <= pc + 32'd3;
566
                                        vect <= {vbr[31:9],`SLP_VECTNO,2'b00};
567
                                        state <= IRQ1;
568
                                end
569
                                else begin
570
                                        pc <= pc + {{16{ir[23]}},ir[23:8]};
571
                                        state <= IFETCH;
572
                                end
573
                        end
574
                `PHP:
575
                        begin
576
                                cyc_o <= 1'b1;
577
                                stb_o <= 1'b1;
578
                                sel_o <= 4'hF;
579
                                we_o <= 1'b1;
580
                                radr <= isp_dec;
581
                                wadr <= isp_dec;
582
                                wdat <= sr;
583
                                adr_o <= {isp_dec,2'b00};
584
                                dat_o <= sr;
585
                                isp <= isp_dec;
586
                                state <= PHP1;
587
                        end
588
                `PHA:
589
                        begin
590
                                cyc_o <= 1'b1;
591
                                stb_o <= 1'b1;
592
                                sel_o <= 4'hF;
593
                                we_o <= 1'b1;
594
                                radr <= isp_dec;
595
                                wadr <= isp_dec;
596
                                wdat <= acc;
597
                                adr_o <= {isp_dec,2'b00};
598
                                dat_o <= acc;
599
                                isp <= isp_dec;
600
                                state <= PHP1;
601
                        end
602
                `PHX:
603
                        begin
604
                                cyc_o <= 1'b1;
605
                                stb_o <= 1'b1;
606
                                sel_o <= 4'hF;
607
                                we_o <= 1'b1;
608
                                radr <= isp_dec;
609
                                wadr <= isp_dec;
610
                                wdat <= x;
611
                                adr_o <= {isp_dec,2'b00};
612
                                dat_o <= x;
613
                                isp <= isp_dec;
614
                                state <= PHP1;
615
                        end
616
                `PHY:
617
                        begin
618
                                cyc_o <= 1'b1;
619
                                stb_o <= 1'b1;
620
                                sel_o <= 4'hF;
621
                                we_o <= 1'b1;
622
                                radr <= isp_dec;
623
                                wadr <= isp_dec;
624
                                wdat <= y;
625
                                adr_o <= {isp_dec,2'b00};
626
                                dat_o <= y;
627
                                isp <= isp_dec;
628
                                state <= PHP1;
629
                        end
630
                `PUSH:
631
                        begin
632
                                cyc_o <= 1'b1;
633
                                stb_o <= 1'b1;
634
                                sel_o <= 4'hF;
635
                                we_o <= 1'b1;
636
                                radr <= isp_dec;
637
                                wadr <= isp_dec;
638
                                wdat <= rfoa;
639
                                adr_o <= {isp_dec,2'b00};
640
                                dat_o <= rfoa;
641
                                state <= PHP1;
642
                                isp <= isp_dec;
643
                                pc <= pc + 32'd1;
644
                        end
645
                `PLP:
646
                        begin
647
                                radr <= isp;
648
                                state <= PLP1;
649
                                pc <= pc + 32'd1;
650
                        end
651
                `PLA,`PLX,`PLY:
652
                        begin
653
                                radr <= isp;
654
                                isp <= isp_inc;
655
                                state <= PLA1;
656
                                pc <= pc + 32'd1;
657
                        end
658
                `POP:
659
                        begin
660
                                Rt <= ir[15:12];
661
                                radr <= isp;
662
                                isp <= isp_inc;
663
                                state <= PLA1;
664
                                pc <= pc + 32'd2;
665
                        end
666
                default:        // unimplemented opcode
667
                        pc <= pc + 32'd1;
668
                endcase
669
        end

powered by: WebSVN 2.1.0

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