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

Subversion Repositories turbo8051

[/] [turbo8051/] [trunk/] [rtl/] [8051/] [oc8051_decoder.v] - Blame information for rev 76

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dinesha
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  8051 core decoder                                           ////
4
////                                                              ////
5
////  This file is part of the 8051 cores project                 ////
6 76 dinesha
//// http://www.opencores.org/cores/turb08051/                    ////
7 2 dinesha
////                                                              ////
8
////  Description                                                 ////
9
////   Main 8051 core module. decodes instruction and creates     ////
10
////   control sigals.                                            ////
11
////                                                              ////
12
////  To Do:                                                      ////
13
////   optimize state machine, especially IDS ASS and AS3         ////
14
////                                                              ////
15
////  Author(s):                                                  ////
16
////      - Simon Teran, simont@opencores.org                     ////
17 76 dinesha
////      - Dinesh Annayya, dinesha@opencores.org                 ////
18 2 dinesha
////                                                              ////
19
//////////////////////////////////////////////////////////////////////
20
////                                                              ////
21
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
22
////                                                              ////
23
//// This source file may be used and distributed without         ////
24
//// restriction provided that this copyright statement is not    ////
25
//// removed from the file and that any derivative work contains  ////
26
//// the original copyright notice and the associated disclaimer. ////
27
////                                                              ////
28
//// This source file is free software; you can redistribute it   ////
29
//// and/or modify it under the terms of the GNU Lesser General   ////
30
//// Public License as published by the Free Software Foundation; ////
31
//// either version 2.1 of the License, or (at your option) any   ////
32
//// later version.                                               ////
33
////                                                              ////
34
//// This source is distributed in the hope that it will be       ////
35
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
36
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
37
//// PURPOSE.  See the GNU Lesser General Public License for more ////
38
//// details.                                                     ////
39
////                                                              ////
40
//// You should have received a copy of the GNU Lesser General    ////
41
//// Public License along with this source; if not, download it   ////
42
//// from http://www.opencores.org/lgpl.shtml                     ////
43
////                                                              ////
44
//////////////////////////////////////////////////////////////////////
45
//
46
// CVS Revision History
47
//
48
// $Log: not supported by cvs2svn $
49
// Revision 1.21  2003/06/03 17:09:57  simont
50
// pipelined acces to axternal instruction interface added.
51
//
52
// Revision 1.20  2003/05/06 11:10:38  simont
53
// optimize state machine.
54
//
55
// Revision 1.19  2003/05/06 09:41:35  simont
56
// remove define OC8051_AS2_PCL, chane signal src_sel2 to 2 bit wide.
57
//
58
// Revision 1.18  2003/05/05 15:46:36  simont
59
// add aditional alu destination to solve critical path.
60
//
61
// Revision 1.17  2003/04/25 17:15:51  simont
62
// change branch instruction execution (reduse needed clock periods).
63
//
64
// Revision 1.16  2003/04/09 16:24:03  simont
65
// change wr_sft to 2 bit wire.
66
//
67
// Revision 1.15  2003/04/09 15:49:42  simont
68
// Register oc8051_sfr dato output, add signal wait_data.
69
//
70
// Revision 1.14  2003/01/13 14:14:40  simont
71
// replace some modules
72
//
73
// Revision 1.13  2002/10/23 16:53:39  simont
74
// fix bugs in instruction interface
75
//
76
// Revision 1.12  2002/10/17 18:50:00  simont
77
// cahnge interface to instruction rom
78
//
79
// Revision 1.11  2002/09/30 17:33:59  simont
80
// prepared header
81
//
82
//
83
 
84 76 dinesha
`include "top_defines.v"
85 2 dinesha
 
86
 
87
module oc8051_decoder (clk, rst, op_in, op1_c,
88
  ram_rd_sel_o, ram_wr_sel_o,
89
  bit_addr, wr_o, wr_sfr_o,
90
  src_sel1, src_sel2, src_sel3,
91
  alu_op_o, psw_set, eq, cy_sel, comp_sel,
92
  pc_wr, pc_sel, rd, rmw, istb, mem_act, mem_wait,
93
  wait_data);
94
 
95
//
96
// clk          (in)  clock
97
// rst          (in)  reset
98
// op_in        (in)  operation code [oc8051_op_select.op1]
99
// eq           (in)  compare result [oc8051_comp.eq]
100
// ram_rd_sel   (out) select, whitch address will be send to ram for read [oc8051_ram_rd_sel.sel, oc8051_sp.ram_rd_sel]
101
// ram_wr_sel   (out) select, whitch address will be send to ram for write [oc8051_ram_wr_sel.sel -r, oc8051_sp.ram_wr_sel -r]
102
// wr           (out) write - if 1 then we will write to ram [oc8051_ram_top.wr -r, oc8051_acc.wr -r, oc8051_b_register.wr -r, oc8051_sp.wr-r, oc8051_dptr.wr -r, oc8051_psw.wr -r, oc8051_indi_addr.wr -r, oc8051_ports.wr -r]
103
// src_sel1     (out) select alu source 1 [oc8051_alu_src1_sel.sel -r]
104
// src_sel2     (out) select alu source 2 [oc8051_alu_src2_sel.sel -r]
105
// src_sel3     (out) select alu source 3 [oc8051_alu_src3_sel.sel -r]
106
// alu_op       (out) alu operation [oc8051_alu.op_code -r]
107
// psw_set      (out) will we remember cy, ac, ov from alu [oc8051_psw.set -r]
108
// cy_sel       (out) carry in alu select [oc8051_cy_select.cy_sel -r]
109
// comp_sel     (out) compare source select [oc8051_comp.sel]
110
// bit_addr     (out) if instruction is bit addresable [oc8051_ram_top.bit_addr -r, oc8051_acc.wr_bit -r, oc8051_b_register.wr_bit-r, oc8051_sp.wr_bit -r, oc8051_dptr.wr_bit -r, oc8051_psw.wr_bit -r, oc8051_indi_addr.wr_bit -r, oc8051_ports.wr_bit -r]
111
// pc_wr        (out) pc write [oc8051_pc.wr]
112
// pc_sel       (out) pc select [oc8051_pc.pc_wr_sel]
113
// rd           (out) read from rom [oc8051_pc.rd, oc8051_op_select.rd]
114
// reti         (out) return from interrupt [pin]
115
// rmw          (out) read modify write feature [oc8051_ports.rmw]
116
// pc_wait      (out)
117
//
118
 
119
input clk, rst, eq, mem_wait, wait_data;
120
input [7:0] op_in;
121
 
122
output wr_o, bit_addr, pc_wr, rmw, istb, src_sel3;
123
output [1:0] psw_set, cy_sel, wr_sfr_o, src_sel2, comp_sel;
124
output [2:0] mem_act, src_sel1, ram_rd_sel_o, ram_wr_sel_o, pc_sel, op1_c;
125
output [3:0] alu_op_o;
126
output rd;
127
 
128
reg rmw;
129
reg src_sel3, wr,  bit_addr, pc_wr;
130
reg [3:0] alu_op;
131
reg [1:0] src_sel2, comp_sel, psw_set, cy_sel, wr_sfr;
132
reg [2:0] mem_act, src_sel1, ram_wr_sel, ram_rd_sel, pc_sel;
133
 
134
//
135
// state        if 2'b00 then normal execution, sle instructin that need more than one clock
136
// op           instruction buffer
137
reg  [1:0] state;
138
wire [1:0] state_dec;
139
reg  [7:0] op;
140
wire [7:0] op_cur;
141
reg  [2:0] ram_rd_sel_r;
142
 
143
reg stb_i;
144
 
145
assign rd = !state[0] && !state[1] && !wait_data;// && !stb_o;
146
 
147
assign istb = (!state[1]) && stb_i;
148
 
149
assign state_dec = wait_data ? 2'b00 : state;
150
 
151
assign op_cur = mem_wait ? 8'h00
152
                : (state[0] || state[1] || mem_wait || wait_data) ? op : op_in;
153
//assign op_cur = (state[0] || state[1] || mem_wait || wait_data) ? op : op_in;
154
 
155
assign op1_c = op_cur[2:0];
156
 
157
assign alu_op_o     = wait_data ? `OC8051_ALU_NOP : alu_op;
158
assign wr_sfr_o     = wait_data ? `OC8051_WRS_N   : wr_sfr;
159
assign ram_rd_sel_o = wait_data ? ram_rd_sel_r    : ram_rd_sel;
160
assign ram_wr_sel_o = wait_data ? `OC8051_RWS_DC  : ram_wr_sel;
161
assign wr_o         = wait_data ? 1'b0            : wr;
162
 
163
//
164
// main block
165
// unregisterd outputs
166
always @(op_cur or eq or state_dec or mem_wait)
167
begin
168
    case (state_dec) /* synopsys full_case parallel_case */
169
      2'b01: begin
170
        casex (op_cur) /* synopsys parallel_case */
171
          `OC8051_DIV : begin
172
             `ifdef OC8051_SIMULATION
173
                 $display("Executing : Div Instruction");
174
             `endif
175
              ram_rd_sel = `OC8051_RRS_B;
176
            end
177
          `OC8051_MUL : begin
178
             `ifdef OC8051_SIMULATION
179
                 $display("Executing : Mul Instruction");
180
             `endif
181
 
182
              ram_rd_sel = `OC8051_RRS_B;
183
            end
184
          default begin
185
              ram_rd_sel = `OC8051_RRS_DC;
186
          end
187
        endcase
188
        stb_i = 1'b1;
189
        bit_addr = 1'b0;
190
        pc_wr = `OC8051_PCW_N;
191
        pc_sel = `OC8051_PIS_DC;
192
        comp_sel =  `OC8051_CSS_DC;
193
        rmw = `OC8051_RMW_N;
194
      end
195
      2'b10: begin
196
        casex (op_cur) /* synopsys parallel_case */
197
          `OC8051_SJMP : begin
198
             `ifdef OC8051_SIMULATION
199
                 $display("Executing : SJUMP Instruction");
200
             `endif
201
 
202
              ram_rd_sel = `OC8051_RRS_DC;
203
              pc_wr = `OC8051_PCW_Y;
204
              pc_sel = `OC8051_PIS_SO1;
205
              comp_sel =  `OC8051_CSS_DC;
206
              bit_addr = 1'b0;
207
            end
208
          `OC8051_JC : begin
209
             `ifdef OC8051_SIMULATION
210
                 $display("Executing : JC Instruction");
211
             `endif
212
 
213
              ram_rd_sel = `OC8051_RRS_PSW;
214
              pc_wr = eq;
215
              pc_sel = `OC8051_PIS_SO1;
216
              comp_sel =  `OC8051_CSS_CY;
217
              bit_addr = 1'b0;
218
            end
219
          `OC8051_JNC : begin
220
             `ifdef OC8051_SIMULATION
221
                 $display("Executing : JNC Instruction");
222
             `endif
223
 
224
              ram_rd_sel = `OC8051_RRS_PSW;
225
              pc_wr = !eq;
226
              pc_sel = `OC8051_PIS_SO1;
227
              comp_sel =  `OC8051_CSS_CY;
228
              bit_addr = 1'b0;
229
            end
230
          `OC8051_JNZ : begin
231
             `ifdef OC8051_SIMULATION
232
                 $display("Executing : JNZ Instruction");
233
             `endif
234
 
235
              ram_rd_sel = `OC8051_RRS_ACC;
236
              pc_wr = !eq;
237
              pc_sel = `OC8051_PIS_SO1;
238
              comp_sel =  `OC8051_CSS_AZ;
239
              bit_addr = 1'b0;
240
            end
241
          `OC8051_JZ : begin
242
             `ifdef OC8051_SIMULATION
243
                 $display("Executing : JZ Instruction");
244
             `endif
245
 
246
              ram_rd_sel = `OC8051_RRS_ACC;
247
              pc_wr = eq;
248
              pc_sel = `OC8051_PIS_SO1;
249
              comp_sel =  `OC8051_CSS_AZ;
250
              bit_addr = 1'b0;
251
            end
252
 
253
          `OC8051_RET : begin
254
             `ifdef OC8051_SIMULATION
255
                 $display("Executing : RET Instruction");
256
             `endif
257
 
258
              ram_rd_sel = `OC8051_RRS_DC;
259
              pc_wr = `OC8051_PCW_Y;
260
              pc_sel = `OC8051_PIS_AL;
261
              comp_sel =  `OC8051_CSS_DC;
262
              bit_addr = 1'b0;
263
            end
264
          `OC8051_RETI : begin
265
             `ifdef OC8051_SIMULATION
266
                 $display("Executing : RETI Instruction");
267
             `endif
268
 
269
              ram_rd_sel = `OC8051_RRS_DC;
270
              pc_wr = `OC8051_PCW_Y;
271
              pc_sel = `OC8051_PIS_AL;
272
              comp_sel =  `OC8051_CSS_DC;
273
              bit_addr = 1'b0;
274
            end
275
          `OC8051_CJNE_R : begin
276
             `ifdef OC8051_SIMULATION
277
                 $display("Executing : CJNE_R Instruction");
278
             `endif
279
 
280
              ram_rd_sel = `OC8051_RRS_DC;
281
              pc_wr = !eq;
282
              pc_sel = `OC8051_PIS_SO2;
283
              comp_sel =  `OC8051_CSS_DES;
284
              bit_addr = 1'b0;
285
            end
286
          `OC8051_CJNE_I : begin
287
             `ifdef OC8051_SIMULATION
288
                 $display("Executing : CJNE_I Instruction");
289
             `endif
290
 
291
              ram_rd_sel = `OC8051_RRS_DC;
292
              pc_wr = !eq;
293
              pc_sel = `OC8051_PIS_SO2;
294
              comp_sel =  `OC8051_CSS_DES;
295
              bit_addr = 1'b0;
296
            end
297
          `OC8051_CJNE_D : begin
298
             `ifdef OC8051_SIMULATION
299
                 $display("Executing : CJNE_D Instruction");
300
             `endif
301
 
302
              ram_rd_sel = `OC8051_RRS_DC;
303
              pc_wr = !eq;
304
              pc_sel = `OC8051_PIS_SO2;
305
              comp_sel =  `OC8051_CSS_DES;
306
              bit_addr = 1'b0;
307
            end
308
          `OC8051_CJNE_C : begin
309
             `ifdef OC8051_SIMULATION
310
                 $display("Executing : CJNE_C Instruction");
311
             `endif
312
 
313
              ram_rd_sel = `OC8051_RRS_DC;
314
              pc_wr = !eq;
315
              pc_sel = `OC8051_PIS_SO2;
316
              comp_sel =  `OC8051_CSS_DES;
317
              bit_addr = 1'b0;
318
            end
319
          `OC8051_DJNZ_R : begin
320
             `ifdef OC8051_SIMULATION
321
                 $display("Executing : DJNZ_R Instruction");
322
             `endif
323
 
324
              ram_rd_sel = `OC8051_RRS_DC;
325
              pc_wr = !eq;
326
              pc_sel = `OC8051_PIS_SO1;
327
              comp_sel =  `OC8051_CSS_DES;
328
              bit_addr = 1'b0;
329
            end
330
          `OC8051_DJNZ_D : begin
331
             `ifdef OC8051_SIMULATION
332
                 $display("Executing : DJNZ_D Instruction");
333
             `endif
334
              ram_rd_sel = `OC8051_RRS_DC;
335
              pc_wr = !eq;
336
              pc_sel = `OC8051_PIS_SO2;
337
              comp_sel =  `OC8051_CSS_DES;
338
              bit_addr = 1'b0;
339
            end
340
          `OC8051_JB : begin
341
             `ifdef OC8051_SIMULATION
342
                 $display("Executing : JB Instruction");
343
             `endif
344
 
345
              ram_rd_sel = `OC8051_RRS_DC;
346
              pc_wr = eq;
347
              pc_sel = `OC8051_PIS_SO2;
348
              comp_sel =  `OC8051_CSS_BIT;
349
              bit_addr = 1'b0;
350
            end
351
          `OC8051_JBC : begin
352
             `ifdef OC8051_SIMULATION
353
                 $display("Executing : JBC Instruction");
354
             `endif
355
 
356
              ram_rd_sel = `OC8051_RRS_DC;
357
              pc_wr = eq;
358
              pc_sel = `OC8051_PIS_SO2;
359
              comp_sel =  `OC8051_CSS_BIT;
360
              bit_addr = 1'b1;
361
            end
362
          `OC8051_JMP_D : begin
363
             `ifdef OC8051_SIMULATION
364
                 $display("Executing : JMP_D Instruction");
365
             `endif
366
 
367
              ram_rd_sel = `OC8051_RRS_DC;
368
              pc_wr = `OC8051_PCW_Y;
369
              pc_sel = `OC8051_PIS_ALU;
370
              comp_sel =  `OC8051_CSS_DC;
371
              bit_addr = 1'b0;
372
            end
373
          `OC8051_JNB : begin
374
             `ifdef OC8051_SIMULATION
375
                 $display("Executing : JNB Instruction");
376
             `endif
377
 
378
              ram_rd_sel = `OC8051_RRS_DC;
379
              pc_wr = !eq;
380
              pc_sel = `OC8051_PIS_SO2;
381
              comp_sel =  `OC8051_CSS_BIT;
382
              bit_addr = 1'b1;
383
            end
384
          `OC8051_DIV : begin
385
             `ifdef OC8051_SIMULATION
386
                 $display("Executing : DIV Instruction");
387
             `endif
388
 
389
              ram_rd_sel = `OC8051_RRS_B;
390
              pc_wr = `OC8051_PCW_N;
391
              pc_sel = `OC8051_PIS_DC;
392
              comp_sel =  `OC8051_CSS_DC;
393
              bit_addr = 1'b0;
394
            end
395
          `OC8051_MUL : begin
396
             `ifdef OC8051_SIMULATION
397
                 $display("Executing : MUL Instruction");
398
             `endif
399
 
400
              ram_rd_sel = `OC8051_RRS_B;
401
              pc_wr = `OC8051_PCW_N;
402
              pc_sel = `OC8051_PIS_DC;
403
              comp_sel =  `OC8051_CSS_DC;
404
              bit_addr = 1'b0;
405
            end
406
          default begin
407
              ram_rd_sel = `OC8051_RRS_DC;
408
              pc_wr = `OC8051_PCW_N;
409
              pc_sel = `OC8051_PIS_DC;
410
              comp_sel =  `OC8051_CSS_DC;
411
              bit_addr = 1'b0;
412
          end
413
        endcase
414
        rmw = `OC8051_RMW_N;
415
        stb_i = 1'b1;
416
      end
417
      2'b11: begin
418
        casex (op_cur) /* synopsys parallel_case */
419
          `OC8051_CJNE_R : begin
420
             `ifdef OC8051_SIMULATION
421
                 $display("Executing : CJNE_R Instruction");
422
             `endif
423
 
424
              ram_rd_sel = `OC8051_RRS_DC;
425
              pc_wr = `OC8051_PCW_N;
426
              pc_sel = `OC8051_PIS_DC;
427
            end
428
          `OC8051_CJNE_I : begin
429
             `ifdef OC8051_SIMULATION
430
                 $display("Executing : CJNE_I Instruction");
431
             `endif
432
 
433
              ram_rd_sel = `OC8051_RRS_DC;
434
              pc_wr = `OC8051_PCW_N;
435
              pc_sel = `OC8051_PIS_DC;
436
            end
437
          `OC8051_CJNE_D : begin
438
             `ifdef OC8051_SIMULATION
439
                 $display("Executing : CJNE_D Instruction");
440
             `endif
441
 
442
              ram_rd_sel = `OC8051_RRS_DC;
443
              pc_wr = `OC8051_PCW_N;
444
              pc_sel = `OC8051_PIS_DC;
445
            end
446
          `OC8051_CJNE_C : begin
447
             `ifdef OC8051_SIMULATION
448
                 $display("Executing : CJNE_C Instruction");
449
             `endif
450
 
451
              ram_rd_sel = `OC8051_RRS_DC;
452
              pc_wr = `OC8051_PCW_N;
453
              pc_sel = `OC8051_PIS_DC;
454
            end
455
          `OC8051_DJNZ_R : begin
456
             `ifdef OC8051_SIMULATION
457
                 $display("Executing : DJNZ_R Instruction");
458
             `endif
459
 
460
              ram_rd_sel = `OC8051_RRS_DC;
461
              pc_wr = `OC8051_PCW_N;
462
              pc_sel = `OC8051_PIS_DC;
463
            end
464
          `OC8051_DJNZ_D : begin
465
             `ifdef OC8051_SIMULATION
466
                 $display("Executing : DJNZ_D Instruction");
467
             `endif
468
 
469
              ram_rd_sel = `OC8051_RRS_DC;
470
              pc_wr = `OC8051_PCW_N;
471
              pc_sel = `OC8051_PIS_DC;
472
            end
473
          `OC8051_RET : begin
474
             `ifdef OC8051_SIMULATION
475
                 $display("Executing : RET Instruction");
476
             `endif
477
 
478
              ram_rd_sel = `OC8051_RRS_SP;
479
              pc_wr = `OC8051_PCW_Y;
480
              pc_sel = `OC8051_PIS_AH;
481
            end
482
          `OC8051_RETI : begin
483
             `ifdef OC8051_SIMULATION
484
                 $display("Executing : RETI Instruction");
485
             `endif
486
 
487
              ram_rd_sel = `OC8051_RRS_SP;
488
              pc_wr = `OC8051_PCW_Y;
489
              pc_sel = `OC8051_PIS_AH;
490
            end
491
          `OC8051_DIV : begin
492
             `ifdef OC8051_SIMULATION
493
                 $display("Executing : DIV Instruction");
494
             `endif
495
 
496
              ram_rd_sel = `OC8051_RRS_B;
497
              pc_wr = `OC8051_PCW_N;
498
              pc_sel = `OC8051_PIS_DC;
499
            end
500
          `OC8051_MUL : begin
501
             `ifdef OC8051_SIMULATION
502
                 $display("Executing : MUL Instruction");
503
             `endif
504
 
505
              ram_rd_sel = `OC8051_RRS_B;
506
              pc_wr = `OC8051_PCW_N;
507
              pc_sel = `OC8051_PIS_DC;
508
            end
509
         default begin
510
             `ifdef OC8051_SIMULATION
511
                 $display("Executing : RRS_DC Instruction");
512
             `endif
513
 
514
              ram_rd_sel = `OC8051_RRS_DC;
515
              pc_wr = `OC8051_PCW_N;
516
              pc_sel = `OC8051_PIS_DC;
517
          end
518
        endcase
519
        comp_sel =  `OC8051_CSS_DC;
520
        rmw = `OC8051_RMW_N;
521
        stb_i = 1'b1;
522
        bit_addr = 1'b0;
523
      end
524
      2'b00: begin
525
        casex (op_cur) /* synopsys parallel_case */
526
          `OC8051_ACALL :begin
527
              ram_rd_sel = `OC8051_RRS_DC;
528
              pc_wr = `OC8051_PCW_Y;
529
              pc_sel = `OC8051_PIS_I11;
530
              comp_sel =  `OC8051_CSS_DC;
531
              rmw = `OC8051_RMW_N;
532
              stb_i = 1'b0;
533
              bit_addr = 1'b0;
534
            end
535
          `OC8051_AJMP : begin
536
              ram_rd_sel = `OC8051_RRS_DC;
537
              pc_wr = `OC8051_PCW_Y;
538
              pc_sel = `OC8051_PIS_I11;
539
              comp_sel =  `OC8051_CSS_DC;
540
              rmw = `OC8051_RMW_N;
541
              stb_i = 1'b0;
542
              bit_addr = 1'b0;
543
            end
544
          `OC8051_ADD_R : begin
545
              ram_rd_sel = `OC8051_RRS_RN;
546
              pc_wr = `OC8051_PCW_N;
547
              pc_sel = `OC8051_PIS_DC;
548
              comp_sel =  `OC8051_CSS_DC;
549
              rmw = `OC8051_RMW_N;
550
              stb_i = 1'b1;
551
              bit_addr = 1'b0;
552
            end
553
          `OC8051_ADDC_R : begin
554
             ram_rd_sel = `OC8051_RRS_RN;
555
              pc_wr = `OC8051_PCW_N;
556
              pc_sel = `OC8051_PIS_DC;
557
              comp_sel =  `OC8051_CSS_DC;
558
              rmw = `OC8051_RMW_N;
559
              stb_i = 1'b1;
560
              bit_addr = 1'b0;
561
            end
562
          `OC8051_ANL_R : begin
563
              ram_rd_sel = `OC8051_RRS_RN;
564
              pc_wr = `OC8051_PCW_N;
565
              pc_sel = `OC8051_PIS_DC;
566
              comp_sel =  `OC8051_CSS_DC;
567
              rmw = `OC8051_RMW_Y;
568
              stb_i = 1'b1;
569
              bit_addr = 1'b0;
570
            end
571
          `OC8051_CJNE_R : begin
572
              ram_rd_sel = `OC8051_RRS_RN;
573
              pc_wr = `OC8051_PCW_N;
574
              pc_sel = `OC8051_PIS_DC;
575
              comp_sel =  `OC8051_CSS_DC;
576
              rmw = `OC8051_RMW_N;
577
              stb_i = 1'b0;
578
              bit_addr = 1'b0;
579
            end
580
          `OC8051_DEC_R : begin
581
              ram_rd_sel = `OC8051_RRS_RN;
582
              pc_wr = `OC8051_PCW_N;
583
              pc_sel = `OC8051_PIS_DC;
584
              comp_sel =  `OC8051_CSS_DC;
585
              rmw = `OC8051_RMW_Y;
586
              stb_i = 1'b1;
587
              bit_addr = 1'b0;
588
            end
589
          `OC8051_DJNZ_R : begin
590
              ram_rd_sel = `OC8051_RRS_RN;
591
              pc_wr = `OC8051_PCW_N;
592
              pc_sel = `OC8051_PIS_DC;
593
              comp_sel =  `OC8051_CSS_DC;
594
              rmw = `OC8051_RMW_Y;
595
              stb_i = 1'b0;
596
              bit_addr = 1'b0;
597
            end
598
          `OC8051_INC_R : begin
599
              ram_rd_sel = `OC8051_RRS_RN;
600
              pc_wr = `OC8051_PCW_N;
601
              pc_sel = `OC8051_PIS_DC;
602
              comp_sel =  `OC8051_CSS_DC;
603
              rmw = `OC8051_RMW_Y;
604
              stb_i = 1'b1;
605
              bit_addr = 1'b0;
606
            end
607
          `OC8051_MOV_R : begin
608
              ram_rd_sel = `OC8051_RRS_RN;
609
              pc_wr = `OC8051_PCW_N;
610
              pc_sel = `OC8051_PIS_DC;
611
              comp_sel =  `OC8051_CSS_DC;
612
              rmw = `OC8051_RMW_N;
613
              stb_i = 1'b1;
614
              bit_addr = 1'b0;
615
            end
616
          `OC8051_MOV_DR : begin
617
              ram_rd_sel = `OC8051_RRS_D;
618
              pc_wr = `OC8051_PCW_N;
619
              pc_sel = `OC8051_PIS_DC;
620
              comp_sel =  `OC8051_CSS_DC;
621
              rmw = `OC8051_RMW_N;
622
              stb_i = 1'b1;
623
              bit_addr = 1'b0;
624
            end
625
          `OC8051_MOV_RD : begin
626
              ram_rd_sel = `OC8051_RRS_RN;
627
              pc_wr = `OC8051_PCW_N;
628
              pc_sel = `OC8051_PIS_DC;
629
              comp_sel =  `OC8051_CSS_DC;
630
              rmw = `OC8051_RMW_N;
631
              stb_i = 1'b1;
632
              bit_addr = 1'b0;
633
            end
634
          `OC8051_ORL_R : begin
635
              ram_rd_sel = `OC8051_RRS_RN;
636
              pc_wr = `OC8051_PCW_N;
637
              pc_sel = `OC8051_PIS_DC;
638
              comp_sel =  `OC8051_CSS_DC;
639
              rmw = `OC8051_RMW_Y;
640
              stb_i = 1'b1;
641
              bit_addr = 1'b0;
642
            end
643
          `OC8051_SUBB_R : begin
644
              ram_rd_sel = `OC8051_RRS_RN;
645
              pc_wr = `OC8051_PCW_N;
646
              pc_sel = `OC8051_PIS_DC;
647
              comp_sel =  `OC8051_CSS_DC;
648
              rmw = `OC8051_RMW_N;
649
              stb_i = 1'b1;
650
              bit_addr = 1'b0;
651
            end
652
          `OC8051_XCH_R : begin
653
              ram_rd_sel = `OC8051_RRS_RN;
654
              pc_wr = `OC8051_PCW_N;
655
              pc_sel = `OC8051_PIS_DC;
656
              comp_sel =  `OC8051_CSS_DC;
657
              rmw = `OC8051_RMW_N;
658
              stb_i = 1'b1;
659
              bit_addr = 1'b0;
660
            end
661
          `OC8051_XRL_R : begin
662
              ram_rd_sel = `OC8051_RRS_RN;
663
              pc_wr = `OC8051_PCW_N;
664
              pc_sel = `OC8051_PIS_DC;
665
              comp_sel =  `OC8051_CSS_DC;
666
              rmw = `OC8051_RMW_Y;
667
              stb_i = 1'b1;
668
              bit_addr = 1'b0;
669
            end
670
 
671
    //op_code [7:1]
672
          `OC8051_ADD_I : begin
673
              ram_rd_sel = `OC8051_RRS_I;
674
              pc_wr = `OC8051_PCW_N;
675
              pc_sel = `OC8051_PIS_DC;
676
              comp_sel =  `OC8051_CSS_DC;
677
              rmw = `OC8051_RMW_N;
678
              stb_i = 1'b1;
679
              bit_addr = 1'b0;
680
            end
681
          `OC8051_ADDC_I : begin
682
              ram_rd_sel = `OC8051_RRS_I;
683
              pc_wr = `OC8051_PCW_N;
684
              pc_sel = `OC8051_PIS_DC;
685
              comp_sel =  `OC8051_CSS_DC;
686
              rmw = `OC8051_RMW_N;
687
              stb_i = 1'b1;
688
              bit_addr = 1'b0;
689
            end
690
          `OC8051_ANL_I : begin
691
              ram_rd_sel = `OC8051_RRS_I;
692
              pc_wr = `OC8051_PCW_N;
693
              pc_sel = `OC8051_PIS_DC;
694
              comp_sel =  `OC8051_CSS_DC;
695
              rmw = `OC8051_RMW_Y;
696
              stb_i = 1'b1;
697
              bit_addr = 1'b0;
698
            end
699
          `OC8051_CJNE_I : begin
700
              ram_rd_sel = `OC8051_RRS_I;
701
              pc_wr = `OC8051_PCW_N;
702
              pc_sel = `OC8051_PIS_DC;
703
              comp_sel =  `OC8051_CSS_DC;
704
              rmw = `OC8051_RMW_N;
705
              stb_i = 1'b0;
706
              bit_addr = 1'b0;
707
            end
708
          `OC8051_DEC_I : begin
709
              ram_rd_sel = `OC8051_RRS_I;
710
              pc_wr = `OC8051_PCW_N;
711
              pc_sel = `OC8051_PIS_DC;
712
              comp_sel =  `OC8051_CSS_DC;
713
              rmw = `OC8051_RMW_Y;
714
              stb_i = 1'b1;
715
              bit_addr = 1'b0;
716
            end
717
          `OC8051_INC_I : begin
718
              ram_rd_sel = `OC8051_RRS_I;
719
              pc_wr = `OC8051_PCW_N;
720
              pc_sel = `OC8051_PIS_DC;
721
              comp_sel =  `OC8051_CSS_DC;
722
              rmw = `OC8051_RMW_Y;
723
              stb_i = 1'b1;
724
              bit_addr = 1'b0;
725
            end
726
          `OC8051_MOV_I : begin
727
              ram_rd_sel = `OC8051_RRS_I;
728
              pc_wr = `OC8051_PCW_N;
729
              pc_sel = `OC8051_PIS_DC;
730
              comp_sel =  `OC8051_CSS_DC;
731
              rmw = `OC8051_RMW_N;
732
              stb_i = 1'b1;
733
              bit_addr = 1'b0;
734
            end
735
          `OC8051_MOV_ID : begin
736
              ram_rd_sel = `OC8051_RRS_I;
737
              pc_wr = `OC8051_PCW_N;
738
              pc_sel = `OC8051_PIS_DC;
739
              comp_sel =  `OC8051_CSS_DC;
740
              rmw = `OC8051_RMW_N;
741
              stb_i = 1'b1;
742
              bit_addr = 1'b0;
743
            end
744
          `OC8051_MOV_DI : begin
745
              ram_rd_sel = `OC8051_RRS_D;
746
              pc_wr = `OC8051_PCW_N;
747
              pc_sel = `OC8051_PIS_DC;
748
              comp_sel =  `OC8051_CSS_DC;
749
              rmw = `OC8051_RMW_N;
750
              stb_i = 1'b1;
751
              bit_addr = 1'b0;
752
            end
753
          `OC8051_MOVX_IA : begin
754
              ram_rd_sel = `OC8051_RRS_DC;
755
              pc_wr = `OC8051_PCW_N;
756
              pc_sel = `OC8051_PIS_DC;
757
              comp_sel =  `OC8051_CSS_DC;
758
              rmw = `OC8051_RMW_N;
759
              stb_i = 1'b0;
760
              bit_addr = 1'b0;
761
            end
762
          `OC8051_MOVX_AI :begin
763
              ram_rd_sel = `OC8051_RRS_DC;
764
              pc_wr = `OC8051_PCW_N;
765
              pc_sel = `OC8051_PIS_DC;
766
              comp_sel =  `OC8051_CSS_DC;
767
              rmw = `OC8051_RMW_N;
768
              stb_i = 1'b0;
769
              bit_addr = 1'b0;
770
            end
771
          `OC8051_ORL_I : begin
772
              ram_rd_sel = `OC8051_RRS_I;
773
              pc_wr = `OC8051_PCW_N;
774
              pc_sel = `OC8051_PIS_DC;
775
              comp_sel =  `OC8051_CSS_DC;
776
              rmw = `OC8051_RMW_Y;
777
              stb_i = 1'b1;
778
              bit_addr = 1'b0;
779
            end
780
          `OC8051_SUBB_I : begin
781
              ram_rd_sel = `OC8051_RRS_I;
782
              pc_wr = `OC8051_PCW_N;
783
              pc_sel = `OC8051_PIS_DC;
784
              comp_sel =  `OC8051_CSS_DC;
785
              rmw = `OC8051_RMW_N;
786
              stb_i = 1'b1;
787
              bit_addr = 1'b0;
788
            end
789
          `OC8051_XCH_I : begin
790
              ram_rd_sel = `OC8051_RRS_I;
791
              pc_wr = `OC8051_PCW_N;
792
              pc_sel = `OC8051_PIS_DC;
793
              comp_sel =  `OC8051_CSS_DC;
794
              rmw = `OC8051_RMW_N;
795
              stb_i = 1'b1;
796
              bit_addr = 1'b0;
797
            end
798
          `OC8051_XCHD :begin
799
              ram_rd_sel = `OC8051_RRS_I;
800
              pc_wr = `OC8051_PCW_N;
801
              pc_sel = `OC8051_PIS_DC;
802
              comp_sel =  `OC8051_CSS_DC;
803
              rmw = `OC8051_RMW_N;
804
              stb_i = 1'b1;
805
              bit_addr = 1'b0;
806
            end
807
          `OC8051_XRL_I : begin
808
              ram_rd_sel = `OC8051_RRS_I;
809
              pc_wr = `OC8051_PCW_N;
810
              pc_sel = `OC8051_PIS_DC;
811
              comp_sel =  `OC8051_CSS_DC;
812
              rmw = `OC8051_RMW_Y;
813
              stb_i = 1'b1;
814
              bit_addr = 1'b0;
815
            end
816
 
817
    //op_code [7:0]
818
          `OC8051_ADD_D : begin
819
              ram_rd_sel = `OC8051_RRS_D;
820
              pc_wr = `OC8051_PCW_N;
821
              pc_sel = `OC8051_PIS_DC;
822
              comp_sel =  `OC8051_CSS_DC;
823
              rmw = `OC8051_RMW_N;
824
              stb_i = 1'b1;
825
              bit_addr = 1'b0;
826
            end
827
          `OC8051_ADDC_D : begin
828
              ram_rd_sel = `OC8051_RRS_D;
829
              pc_wr = `OC8051_PCW_N;
830
              pc_sel = `OC8051_PIS_DC;
831
              comp_sel =  `OC8051_CSS_DC;
832
              rmw = `OC8051_RMW_N;
833
              stb_i = 1'b1;
834
              bit_addr = 1'b0;
835
            end
836
          `OC8051_ANL_D : begin
837
              ram_rd_sel = `OC8051_RRS_D;
838
              pc_wr = `OC8051_PCW_N;
839
              pc_sel = `OC8051_PIS_DC;
840
              comp_sel =  `OC8051_CSS_DC;
841
              rmw = `OC8051_RMW_Y;
842
              stb_i = 1'b1;
843
              bit_addr = 1'b0;
844
            end
845
          `OC8051_ANL_C : begin
846
              ram_rd_sel = `OC8051_RRS_DC;
847
              pc_wr = `OC8051_PCW_N;
848
              pc_sel = `OC8051_PIS_DC;
849
              comp_sel =  `OC8051_CSS_DC;
850
              rmw = `OC8051_RMW_Y;
851
              stb_i = 1'b1;
852
              bit_addr = 1'b0;
853
            end
854
          `OC8051_ANL_DD : begin
855
              ram_rd_sel = `OC8051_RRS_D;
856
              pc_wr = `OC8051_PCW_N;
857
              pc_sel = `OC8051_PIS_DC;
858
              comp_sel =  `OC8051_CSS_DC;
859
              rmw = `OC8051_RMW_Y;
860
              stb_i = 1'b1;
861
              bit_addr = 1'b0;
862
            end
863
          `OC8051_ANL_DC : begin
864
              ram_rd_sel = `OC8051_RRS_D;
865
              pc_wr = `OC8051_PCW_N;
866
              pc_sel = `OC8051_PIS_DC;
867
              comp_sel =  `OC8051_CSS_DC;
868
              rmw = `OC8051_RMW_Y;
869
              stb_i = 1'b1;
870
              bit_addr = 1'b0;
871
            end
872
          `OC8051_ANL_B : begin
873
              ram_rd_sel = `OC8051_RRS_D;
874
              pc_wr = `OC8051_PCW_N;
875
              pc_sel = `OC8051_PIS_DC;
876
              comp_sel =  `OC8051_CSS_DC;
877
              rmw = `OC8051_RMW_Y;
878
              stb_i = 1'b1;
879
              bit_addr = 1'b1;
880
            end
881
          `OC8051_ANL_NB : begin
882
              ram_rd_sel = `OC8051_RRS_D;
883
              pc_wr = `OC8051_PCW_N;
884
              pc_sel = `OC8051_PIS_DC;
885
              comp_sel =  `OC8051_CSS_DC;
886
              rmw = `OC8051_RMW_Y;
887
              stb_i = 1'b1;
888
              bit_addr = 1'b1;
889
            end
890
          `OC8051_CJNE_D : begin
891
              ram_rd_sel = `OC8051_RRS_D;
892
              pc_wr = `OC8051_PCW_N;
893
              pc_sel = `OC8051_PIS_DC;
894
              comp_sel =  `OC8051_CSS_DC;
895
              rmw = `OC8051_RMW_N;
896
              stb_i = 1'b0;
897
              bit_addr = 1'b0;
898
            end
899
          `OC8051_CJNE_C : begin
900
              ram_rd_sel = `OC8051_RRS_DC;
901
              pc_wr = `OC8051_PCW_N;
902
              pc_sel = `OC8051_PIS_DC;
903
              comp_sel =  `OC8051_CSS_DC;
904
              rmw = `OC8051_RMW_N;
905
              stb_i = 1'b0;
906
              bit_addr = 1'b0;
907
            end
908
          `OC8051_CLR_B : begin
909
              ram_rd_sel = `OC8051_RRS_D;
910
              pc_wr = `OC8051_PCW_N;
911
              pc_sel = `OC8051_PIS_DC;
912
              comp_sel =  `OC8051_CSS_DC;
913
              rmw = `OC8051_RMW_Y;
914
              stb_i = 1'b1;
915
              bit_addr = 1'b1;
916
            end
917
          `OC8051_CPL_B : begin
918
              ram_rd_sel = `OC8051_RRS_D;
919
              pc_wr = `OC8051_PCW_N;
920
              pc_sel = `OC8051_PIS_DC;
921
              comp_sel =  `OC8051_CSS_DC;
922
              rmw = `OC8051_RMW_Y;
923
              stb_i = 1'b1;
924
              bit_addr = 1'b1;
925
            end
926
          `OC8051_DEC_D : begin
927
              ram_rd_sel = `OC8051_RRS_D;
928
              pc_wr = `OC8051_PCW_N;
929
              pc_sel = `OC8051_PIS_DC;
930
              comp_sel =  `OC8051_CSS_DC;
931
              rmw = `OC8051_RMW_Y;
932
              stb_i = 1'b1;
933
              bit_addr = 1'b0;
934
            end
935
          `OC8051_DIV : begin
936
              ram_rd_sel = `OC8051_RRS_B;
937
              pc_wr = `OC8051_PCW_N;
938
              pc_sel = `OC8051_PIS_DC;
939
              comp_sel =  `OC8051_CSS_DC;
940
              rmw = `OC8051_RMW_N;
941
              stb_i = 1'b0;
942
              bit_addr = 1'b0;
943
            end
944
          `OC8051_DJNZ_D : begin
945
              ram_rd_sel = `OC8051_RRS_D;
946
              pc_wr = `OC8051_PCW_N;
947
              pc_sel = `OC8051_PIS_DC;
948
              comp_sel =  `OC8051_CSS_DC;
949
              rmw = `OC8051_RMW_Y;
950
              stb_i = 1'b0;
951
              bit_addr = 1'b0;
952
            end
953
          `OC8051_INC_D : begin
954
              ram_rd_sel = `OC8051_RRS_D;
955
              pc_wr = `OC8051_PCW_N;
956
              pc_sel = `OC8051_PIS_DC;
957
              comp_sel =  `OC8051_CSS_DC;
958
              rmw = `OC8051_RMW_Y;
959
              stb_i = 1'b1;
960
              bit_addr = 1'b0;
961
            end
962
          `OC8051_INC_DP : begin
963
              ram_rd_sel = `OC8051_RRS_DPTR;
964
              pc_wr = `OC8051_PCW_N;
965
              pc_sel = `OC8051_PIS_DC;
966
              comp_sel =  `OC8051_CSS_DC;
967
              rmw = `OC8051_RMW_N;
968
              stb_i = 1'b1;
969
              bit_addr = 1'b0;
970
            end
971
          `OC8051_JB : begin
972
              ram_rd_sel = `OC8051_RRS_D;
973
              pc_wr = `OC8051_PCW_N;
974
              pc_sel = `OC8051_PIS_SO2;
975
              comp_sel =  `OC8051_CSS_BIT;
976
              rmw = `OC8051_RMW_N;
977
              stb_i = 1'b0;
978
              bit_addr = 1'b1;
979
            end
980
          `OC8051_JBC : begin
981
              ram_rd_sel = `OC8051_RRS_D;
982
              pc_wr = `OC8051_PCW_N;
983
              pc_sel = `OC8051_PIS_DC;
984
              comp_sel =  `OC8051_CSS_BIT;
985
              rmw = `OC8051_RMW_N;
986
              stb_i = 1'b0;
987
              bit_addr = 1'b1;
988
            end
989
/*          `OC8051_JC : begin
990
              ram_rd_sel = `OC8051_RRS_PSW;
991
              pc_wr = eq;
992
              pc_sel = `OC8051_PIS_SO1;
993
              comp_sel =  `OC8051_CSS_CY;
994
              rmw = `OC8051_RMW_N;
995
              stb_i = 1'b0;
996
              bit_addr = 1'b0;
997
            end*/
998
          `OC8051_JMP_D : begin
999
              ram_rd_sel = `OC8051_RRS_DPTR;
1000
              pc_wr = `OC8051_PCW_N;
1001
              pc_sel = `OC8051_PIS_DC;
1002
              comp_sel =  `OC8051_CSS_DC;
1003
              rmw = `OC8051_RMW_N;
1004
              stb_i = 1'b0;
1005
              bit_addr = 1'b0;
1006
            end
1007
 
1008
          `OC8051_JNB : begin
1009
              ram_rd_sel = `OC8051_RRS_D;
1010
              pc_wr = `OC8051_PCW_N;
1011
              pc_sel = `OC8051_PIS_SO2;
1012
              comp_sel =  `OC8051_CSS_BIT;
1013
              rmw = `OC8051_RMW_N;
1014
              stb_i = 1'b0;
1015
              bit_addr = 1'b1;
1016
            end
1017
/*          `OC8051_JNC : begin
1018
              ram_rd_sel = `OC8051_RRS_PSW;
1019
              pc_wr = !eq;
1020
              pc_sel = `OC8051_PIS_SO1;
1021
              comp_sel =  `OC8051_CSS_CY;
1022
              rmw = `OC8051_RMW_N;
1023
              stb_i = 1'b0;
1024
              bit_addr = 1'b0;
1025
            end
1026
          `OC8051_JNZ : begin
1027
              ram_rd_sel = `OC8051_RRS_ACC;
1028
              pc_wr = !eq;
1029
              pc_sel = `OC8051_PIS_SO1;
1030
              comp_sel =  `OC8051_CSS_AZ;
1031
              rmw = `OC8051_RMW_N;
1032
              stb_i = 1'b0;
1033
              bit_addr = 1'b0;
1034
            end
1035
          `OC8051_JZ : begin
1036
              ram_rd_sel = `OC8051_RRS_ACC;
1037
              pc_wr = eq;
1038
              pc_sel = `OC8051_PIS_SO1;
1039
              comp_sel =  `OC8051_CSS_AZ;
1040
              rmw = `OC8051_RMW_N;
1041
              stb_i = 1'b0;
1042
              bit_addr = 1'b0;
1043
            end*/
1044
          `OC8051_LCALL :begin
1045
              ram_rd_sel = `OC8051_RRS_DC;
1046
              pc_wr = `OC8051_PCW_Y;
1047
              pc_sel = `OC8051_PIS_I16;
1048
              comp_sel =  `OC8051_CSS_DC;
1049
              rmw = `OC8051_RMW_N;
1050
              stb_i = 1'b0;
1051
              bit_addr = 1'b0;
1052
            end
1053
          `OC8051_LJMP : begin
1054
              ram_rd_sel = `OC8051_RRS_DC;
1055
              pc_wr = `OC8051_PCW_Y;
1056
              pc_sel = `OC8051_PIS_I16;
1057
              comp_sel =  `OC8051_CSS_DC;
1058
              rmw = `OC8051_RMW_N;
1059
              stb_i = 1'b0;
1060
              bit_addr = 1'b0;
1061
            end
1062
          `OC8051_MOV_D : begin
1063
              ram_rd_sel = `OC8051_RRS_D;
1064
              pc_wr = `OC8051_PCW_N;
1065
              pc_sel = `OC8051_PIS_DC;
1066
              comp_sel =  `OC8051_CSS_DC;
1067
              rmw = `OC8051_RMW_N;
1068
              stb_i = 1'b1;
1069
              bit_addr = 1'b0;
1070
            end
1071
          `OC8051_MOV_DD : begin
1072
              ram_rd_sel = `OC8051_RRS_D;
1073
              pc_wr = `OC8051_PCW_N;
1074
              pc_sel = `OC8051_PIS_DC;
1075
              comp_sel =  `OC8051_CSS_DC;
1076
              rmw = `OC8051_RMW_N;
1077
              stb_i = 1'b1;
1078
              bit_addr = 1'b0;
1079
            end
1080
          `OC8051_MOV_BC : begin
1081
              ram_rd_sel = `OC8051_RRS_D;
1082
              pc_wr = `OC8051_PCW_N;
1083
              pc_sel = `OC8051_PIS_DC;
1084
              comp_sel =  `OC8051_CSS_DC;
1085
              rmw = `OC8051_RMW_N;
1086
              stb_i = 1'b1;
1087
              bit_addr = 1'b1;
1088
            end
1089
          `OC8051_MOV_CB : begin
1090
              ram_rd_sel = `OC8051_RRS_D;
1091
              pc_wr = `OC8051_PCW_N;
1092
              pc_sel = `OC8051_PIS_DC;
1093
              comp_sel =  `OC8051_CSS_DC;
1094
              rmw = `OC8051_RMW_N;
1095
              stb_i = 1'b1;
1096
              bit_addr = 1'b1;
1097
            end
1098
          `OC8051_MOVC_DP :begin
1099
              ram_rd_sel = `OC8051_RRS_DPTR;
1100
              pc_wr = `OC8051_PCW_N;
1101
              pc_sel = `OC8051_PIS_DC;
1102
              comp_sel =  `OC8051_CSS_DC;
1103
              rmw = `OC8051_RMW_N;
1104
              stb_i = 1'b0;
1105
              bit_addr = 1'b0;
1106
            end
1107
          `OC8051_MOVC_PC : begin
1108
              ram_rd_sel = `OC8051_RRS_DC;
1109
              pc_wr = `OC8051_PCW_N;
1110
              pc_sel = `OC8051_PIS_DC;
1111
              comp_sel =  `OC8051_CSS_DC;
1112
              rmw = `OC8051_RMW_N;
1113
              stb_i = 1'b0;
1114
              bit_addr = 1'b0;
1115
            end
1116
          `OC8051_MOVX_PA : begin
1117
              ram_rd_sel = `OC8051_RRS_DC;
1118
              pc_wr = `OC8051_PCW_N;
1119
              pc_sel = `OC8051_PIS_DC;
1120
              comp_sel =  `OC8051_CSS_DC;
1121
              rmw = `OC8051_RMW_N;
1122
              stb_i = 1'b0;
1123
              bit_addr = 1'b0;
1124
            end
1125
          `OC8051_MOVX_AP : begin
1126
              ram_rd_sel = `OC8051_RRS_DC;
1127
              pc_wr = `OC8051_PCW_N;
1128
              pc_sel = `OC8051_PIS_DC;
1129
              comp_sel =  `OC8051_CSS_DC;
1130
              rmw = `OC8051_RMW_N;
1131
              stb_i = 1'b0;
1132
              bit_addr = 1'b0;
1133
            end
1134
          `OC8051_MUL : begin
1135
              ram_rd_sel = `OC8051_RRS_B;
1136
              pc_wr = `OC8051_PCW_N;
1137
              pc_sel = `OC8051_PIS_DC;
1138
              comp_sel =  `OC8051_CSS_DC;
1139
              rmw = `OC8051_RMW_N;
1140
              stb_i = 1'b0;
1141
              bit_addr = 1'b0;
1142
            end
1143
          `OC8051_ORL_D : begin
1144
              ram_rd_sel = `OC8051_RRS_D;
1145
              pc_wr = `OC8051_PCW_N;
1146
              pc_sel = `OC8051_PIS_DC;
1147
              comp_sel =  `OC8051_CSS_DC;
1148
              rmw = `OC8051_RMW_Y;
1149
              stb_i = 1'b1;
1150
              bit_addr = 1'b0;
1151
            end
1152
          `OC8051_ORL_AD : begin
1153
              ram_rd_sel = `OC8051_RRS_D;
1154
              pc_wr = `OC8051_PCW_N;
1155
              pc_sel = `OC8051_PIS_DC;
1156
              comp_sel =  `OC8051_CSS_DC;
1157
              rmw = `OC8051_RMW_Y;
1158
              stb_i = 1'b1;
1159
              bit_addr = 1'b0;
1160
            end
1161
          `OC8051_ORL_CD : begin
1162
              ram_rd_sel = `OC8051_RRS_D;
1163
              pc_wr = `OC8051_PCW_N;
1164
              pc_sel = `OC8051_PIS_DC;
1165
              comp_sel =  `OC8051_CSS_DC;
1166
              rmw = `OC8051_RMW_Y;
1167
              stb_i = 1'b1;
1168
              bit_addr = 1'b0;
1169
            end
1170
          `OC8051_ORL_B : begin
1171
              ram_rd_sel = `OC8051_RRS_D;
1172
              pc_wr = `OC8051_PCW_N;
1173
              pc_sel = `OC8051_PIS_DC;
1174
              comp_sel =  `OC8051_CSS_DC;
1175
              rmw = `OC8051_RMW_Y;
1176
              stb_i = 1'b1;
1177
              bit_addr = 1'b1;
1178
            end
1179
          `OC8051_ORL_NB : begin
1180
              ram_rd_sel = `OC8051_RRS_D;
1181
              pc_wr = `OC8051_PCW_N;
1182
              pc_sel = `OC8051_PIS_DC;
1183
              comp_sel =  `OC8051_CSS_DC;
1184
              rmw = `OC8051_RMW_Y;
1185
              stb_i = 1'b1;
1186
              bit_addr = 1'b1;
1187
            end
1188
          `OC8051_POP : begin
1189
              ram_rd_sel = `OC8051_RRS_SP;
1190
              pc_wr = `OC8051_PCW_N;
1191
              pc_sel = `OC8051_PIS_DC;
1192
              comp_sel =  `OC8051_CSS_DC;
1193
              rmw = `OC8051_RMW_N;
1194
              stb_i = 1'b1;
1195
              bit_addr = 1'b0;
1196
            end
1197
          `OC8051_PUSH : begin
1198
              ram_rd_sel = `OC8051_RRS_D;
1199
              pc_wr = `OC8051_PCW_N;
1200
              pc_sel = `OC8051_PIS_DC;
1201
              comp_sel =  `OC8051_CSS_DC;
1202
              rmw = `OC8051_RMW_N;
1203
              stb_i = 1'b1;
1204
              bit_addr = 1'b0;
1205
            end
1206
          `OC8051_RET : begin
1207
              ram_rd_sel = `OC8051_RRS_SP;
1208
              pc_wr = `OC8051_PCW_N;
1209
              pc_sel = `OC8051_PIS_DC;
1210
              comp_sel =  `OC8051_CSS_DC;
1211
              rmw = `OC8051_RMW_N;
1212
              stb_i = 1'b0;
1213
              bit_addr = 1'b0;
1214
            end
1215
          `OC8051_RETI : begin
1216
              ram_rd_sel = `OC8051_RRS_SP;
1217
              pc_wr = `OC8051_PCW_N;
1218
              pc_sel = `OC8051_PIS_DC;
1219
              comp_sel =  `OC8051_CSS_DC;
1220
              rmw = `OC8051_RMW_N;
1221
              stb_i = 1'b0;
1222
              bit_addr = 1'b0;
1223
            end
1224
          `OC8051_SETB_B : begin
1225
              ram_rd_sel = `OC8051_RRS_D;
1226
              pc_wr = `OC8051_PCW_N;
1227
              pc_sel = `OC8051_PIS_DC;
1228
              comp_sel =  `OC8051_CSS_DC;
1229
              rmw = `OC8051_RMW_Y;
1230
              stb_i = 1'b1;
1231
              bit_addr = 1'b1;
1232
            end
1233
/*          `OC8051_SJMP : begin
1234
              ram_rd_sel = `OC8051_RRS_DC;
1235
              pc_wr = `OC8051_PCW_Y;
1236
              pc_sel = `OC8051_PIS_SO1;
1237
              comp_sel =  `OC8051_CSS_DC;
1238
              rmw = `OC8051_RMW_N;
1239
              stb_i = 1'b0;
1240
              bit_addr = 1'b0;
1241
            end*/
1242
          `OC8051_SUBB_D : begin
1243
              ram_rd_sel = `OC8051_RRS_D;
1244
              pc_wr = `OC8051_PCW_N;
1245
              pc_sel = `OC8051_PIS_DC;
1246
              comp_sel =  `OC8051_CSS_DC;
1247
              rmw = `OC8051_RMW_N;
1248
              stb_i = 1'b1;
1249
              bit_addr = 1'b0;
1250
            end
1251
          `OC8051_XCH_D : begin
1252
              ram_rd_sel = `OC8051_RRS_D;
1253
              pc_wr = `OC8051_PCW_N;
1254
              pc_sel = `OC8051_PIS_DC;
1255
              comp_sel =  `OC8051_CSS_DC;
1256
              rmw = `OC8051_RMW_N;
1257
              stb_i = 1'b1;
1258
              bit_addr = 1'b0;
1259
            end
1260
          `OC8051_XRL_D : begin
1261
              ram_rd_sel = `OC8051_RRS_D;
1262
              pc_wr = `OC8051_PCW_N;
1263
              pc_sel = `OC8051_PIS_DC;
1264
              comp_sel =  `OC8051_CSS_DC;
1265
              rmw = `OC8051_RMW_Y;
1266
              stb_i = 1'b1;
1267
              bit_addr = 1'b0;
1268
            end
1269
          `OC8051_XRL_AD : begin
1270
              ram_rd_sel = `OC8051_RRS_D;
1271
              pc_wr = `OC8051_PCW_N;
1272
              pc_sel = `OC8051_PIS_DC;
1273
              comp_sel =  `OC8051_CSS_DC;
1274
              rmw = `OC8051_RMW_Y;
1275
              stb_i = 1'b1;
1276
              bit_addr = 1'b0;
1277
            end
1278
          `OC8051_XRL_CD : begin
1279
              ram_rd_sel = `OC8051_RRS_D;
1280
              pc_wr = `OC8051_PCW_N;
1281
              pc_sel = `OC8051_PIS_DC;
1282
              comp_sel =  `OC8051_CSS_DC;
1283
              rmw = `OC8051_RMW_Y;
1284
              stb_i = 1'b1;
1285
              bit_addr = 1'b0;
1286
            end
1287
          default: begin
1288
              ram_rd_sel = `OC8051_RRS_DC;
1289
              pc_wr = `OC8051_PCW_N;
1290
              pc_sel = `OC8051_PIS_DC;
1291
              comp_sel =  `OC8051_CSS_DC;
1292
              rmw = `OC8051_RMW_N;
1293
              stb_i = 1'b1;
1294
              bit_addr = 1'b0;
1295
           end
1296
        endcase
1297
      end
1298
    endcase
1299
end
1300
 
1301
 
1302
 
1303
 
1304
 
1305
 
1306
 
1307
 
1308
 
1309
 
1310
//
1311
//
1312
// registerd outputs
1313
 
1314
always @(posedge clk or posedge rst)
1315
begin
1316
  if (rst) begin
1317
    ram_wr_sel <= #1 `OC8051_RWS_DC;
1318
    src_sel1 <= #1 `OC8051_AS1_DC;
1319
    src_sel2 <= #1 `OC8051_AS2_DC;
1320
    alu_op <= #1 `OC8051_ALU_NOP;
1321
    wr <= #1 1'b0;
1322
    psw_set <= #1 `OC8051_PS_NOT;
1323
    cy_sel <= #1 `OC8051_CY_0;
1324
    src_sel3 <= #1 `OC8051_AS3_DC;
1325
    wr_sfr <= #1 `OC8051_WRS_N;
1326
  end else if (!wait_data) begin
1327
    case (state_dec) /* synopsys parallel_case */
1328
      2'b01: begin
1329
        casex (op_cur) /* synopsys parallel_case */
1330
          `OC8051_MOVC_DP :begin
1331
              ram_wr_sel <= #1 `OC8051_RWS_DC;
1332
              src_sel1 <= #1 `OC8051_AS1_OP1;
1333
              src_sel2 <= #1 `OC8051_AS2_DC;
1334
              alu_op <= #1 `OC8051_ALU_NOP;
1335
              wr <= #1 1'b0;
1336
              psw_set <= #1 `OC8051_PS_NOT;
1337
              wr_sfr <= #1 `OC8051_WRS_ACC1;
1338
            end
1339
          `OC8051_MOVC_PC :begin
1340
              ram_wr_sel <= #1 `OC8051_RWS_DC;
1341
              src_sel1 <= #1 `OC8051_AS1_OP1;
1342
              src_sel2 <= #1 `OC8051_AS2_DC;
1343
              alu_op <= #1 `OC8051_ALU_NOP;
1344
              wr <= #1 1'b0;
1345
              psw_set <= #1 `OC8051_PS_NOT;
1346
              wr_sfr <= #1 `OC8051_WRS_ACC1;
1347
            end
1348
          `OC8051_MOVX_PA : begin
1349
              ram_wr_sel <= #1 `OC8051_RWS_DC;
1350
              src_sel1 <= #1 `OC8051_AS1_OP1;
1351
              src_sel2 <= #1 `OC8051_AS2_DC;
1352
              alu_op <= #1 `OC8051_ALU_NOP;
1353
              wr <= #1 1'b0;
1354
              psw_set <= #1 `OC8051_PS_NOT;
1355
              wr_sfr <= #1 `OC8051_WRS_ACC1;
1356
            end
1357
          `OC8051_MOVX_IA : begin
1358
              ram_wr_sel <= #1 `OC8051_RWS_DC;
1359
              src_sel1 <= #1 `OC8051_AS1_OP1;
1360
              src_sel2 <= #1 `OC8051_AS2_DC;
1361
              alu_op <= #1 `OC8051_ALU_NOP;
1362
              wr <= #1 1'b0;
1363
              psw_set <= #1 `OC8051_PS_NOT;
1364
              wr_sfr <= #1 `OC8051_WRS_ACC1;
1365
            end
1366
/*          `OC8051_ACALL :begin
1367
              ram_wr_sel <= #1 `OC8051_RWS_SP;
1368
              src_sel1 <= #1 `OC8051_AS1_PCH;
1369
              src_sel2 <= #1 `OC8051_AS2_DC;
1370
              alu_op <= #1 `OC8051_ALU_NOP;
1371
              wr <= #1 1'b1;
1372
              psw_set <= #1 `OC8051_PS_NOT;
1373
              wr_sfr <= #1 `OC8051_WRS_N;
1374
            end
1375
          `OC8051_AJMP : begin
1376
              ram_wr_sel <= #1 `OC8051_RWS_DC;
1377
              src_sel1 <= #1 `OC8051_AS1_DC;
1378
              src_sel2 <= #1 `OC8051_AS2_DC;
1379
              alu_op <= #1 `OC8051_ALU_NOP;
1380
              wr <= #1 1'b0;
1381
              psw_set <= #1 `OC8051_PS_NOT;
1382
              wr_sfr <= #1 `OC8051_WRS_N;
1383
            end
1384
          `OC8051_LCALL :begin
1385
              ram_wr_sel <= #1 `OC8051_RWS_SP;
1386
              src_sel1 <= #1 `OC8051_AS1_PCH;
1387
              src_sel2 <= #1 `OC8051_AS2_DC;
1388
              alu_op <= #1 `OC8051_ALU_NOP;
1389
              wr <= #1 1'b1;
1390
              psw_set <= #1 `OC8051_PS_NOT;
1391
              wr_sfr <= #1 `OC8051_WRS_N;
1392
            end*/
1393
          `OC8051_DIV : begin
1394
              ram_wr_sel <= #1 `OC8051_RWS_B;
1395
              src_sel1 <= #1 `OC8051_AS1_ACC;
1396
              src_sel2 <= #1 `OC8051_AS2_RAM;
1397
              alu_op <= #1 `OC8051_ALU_DIV;
1398
              wr <= #1 1'b1;
1399
              psw_set <= #1 `OC8051_PS_OV;
1400
              wr_sfr <= #1 `OC8051_WRS_ACC2;
1401
            end
1402
          `OC8051_MUL : begin
1403
              ram_wr_sel <= #1 `OC8051_RWS_B;
1404
              src_sel1 <= #1 `OC8051_AS1_ACC;
1405
              src_sel2 <= #1 `OC8051_AS2_RAM;
1406
              alu_op <= #1 `OC8051_ALU_MUL;
1407
              wr <= #1 1'b1;
1408
              psw_set <= #1 `OC8051_PS_OV;
1409
              wr_sfr <= #1 `OC8051_WRS_ACC2;
1410
            end
1411
          default begin
1412
              ram_wr_sel <= #1 `OC8051_RWS_DC;
1413
              src_sel1 <= #1 `OC8051_AS1_DC;
1414
              src_sel2 <= #1 `OC8051_AS2_DC;
1415
              alu_op <= #1 `OC8051_ALU_NOP;
1416
              wr <= #1 1'b0;
1417
              psw_set <= #1 `OC8051_PS_NOT;
1418
              wr_sfr <= #1 `OC8051_WRS_N;
1419
          end
1420
        endcase
1421
        cy_sel <= #1 `OC8051_CY_0;
1422
        src_sel3 <= #1 `OC8051_AS3_DC;
1423
      end
1424
      2'b10: begin
1425
        casex (op_cur) /* synopsys parallel_case */
1426
          `OC8051_ACALL :begin
1427
              ram_wr_sel <= #1 `OC8051_RWS_SP;
1428
              src_sel1 <= #1 `OC8051_AS1_PCH;
1429
              src_sel2 <= #1 `OC8051_AS2_DC;
1430
              alu_op <= #1 `OC8051_ALU_NOP;
1431
              wr <= #1 1'b1;
1432
              psw_set <= #1 `OC8051_PS_NOT;
1433
            end
1434
          `OC8051_LCALL :begin
1435
              ram_wr_sel <= #1 `OC8051_RWS_SP;
1436
              src_sel1 <= #1 `OC8051_AS1_PCH;
1437
              src_sel2 <= #1 `OC8051_AS2_DC;
1438
              alu_op <= #1 `OC8051_ALU_NOP;
1439
              wr <= #1 1'b1;
1440
              psw_set <= #1 `OC8051_PS_NOT;
1441
            end
1442
          `OC8051_JBC : begin
1443
              ram_wr_sel <= #1 `OC8051_RWS_D;
1444
              src_sel1 <= #1 `OC8051_AS1_DC;
1445
              src_sel2 <= #1 `OC8051_AS2_DC;
1446
              alu_op <= #1 `OC8051_ALU_NOP;
1447
              wr <= #1 1'b1;
1448
              psw_set <= #1 `OC8051_PS_NOT;
1449
            end
1450
          `OC8051_DIV : begin
1451
              ram_wr_sel <= #1 `OC8051_RWS_DC;
1452
              src_sel1 <= #1 `OC8051_AS1_ACC;
1453
              src_sel2 <= #1 `OC8051_AS2_RAM;
1454
              alu_op <= #1 `OC8051_ALU_DIV;
1455
              wr <= #1 1'b0;
1456
              psw_set <= #1 `OC8051_PS_OV;
1457
            end
1458
          `OC8051_MUL : begin
1459
              ram_wr_sel <= #1 `OC8051_RWS_DC;
1460
              src_sel1 <= #1 `OC8051_AS1_ACC;
1461
              src_sel2 <= #1 `OC8051_AS2_RAM;
1462
              alu_op <= #1 `OC8051_ALU_MUL;
1463
              wr <= #1 1'b0;
1464
              psw_set <= #1 `OC8051_PS_OV;
1465
            end
1466
          default begin
1467
              ram_wr_sel <= #1 `OC8051_RWS_DC;
1468
              src_sel1 <= #1 `OC8051_AS1_DC;
1469
              src_sel2 <= #1 `OC8051_AS2_DC;
1470
              alu_op <= #1 `OC8051_ALU_NOP;
1471
              wr <= #1 1'b0;
1472
              psw_set <= #1 `OC8051_PS_NOT;
1473
          end
1474
        endcase
1475
        cy_sel <= #1 `OC8051_CY_0;
1476
        src_sel3 <= #1 `OC8051_AS3_DC;
1477
        wr_sfr <= #1 `OC8051_WRS_N;
1478
      end
1479
 
1480
      2'b11: begin
1481
        casex (op_cur) /* synopsys parallel_case */
1482
          `OC8051_RET : begin
1483
              src_sel1 <= #1 `OC8051_AS1_RAM;
1484
              src_sel2 <= #1 `OC8051_AS2_DC;
1485
              alu_op <= #1 `OC8051_ALU_NOP;
1486
              psw_set <= #1 `OC8051_PS_NOT;
1487
            end
1488
          `OC8051_RETI : begin
1489
              src_sel1 <= #1 `OC8051_AS1_RAM;
1490
              src_sel2 <= #1 `OC8051_AS2_DC;
1491
              alu_op <= #1 `OC8051_ALU_NOP;
1492
              psw_set <= #1 `OC8051_PS_NOT;
1493
            end
1494
          `OC8051_DIV : begin
1495
              src_sel1 <= #1 `OC8051_AS1_ACC;
1496
              src_sel2 <= #1 `OC8051_AS2_RAM;
1497
              alu_op <= #1 `OC8051_ALU_DIV;
1498
              psw_set <= #1 `OC8051_PS_OV;
1499
            end
1500
          `OC8051_MUL : begin
1501
              src_sel1 <= #1 `OC8051_AS1_ACC;
1502
              src_sel2 <= #1 `OC8051_AS2_RAM;
1503
              alu_op <= #1 `OC8051_ALU_MUL;
1504
              psw_set <= #1 `OC8051_PS_OV;
1505
            end
1506
         default begin
1507
              src_sel1 <= #1 `OC8051_AS1_DC;
1508
              src_sel2 <= #1 `OC8051_AS2_DC;
1509
              alu_op <= #1 `OC8051_ALU_NOP;
1510
              psw_set <= #1 `OC8051_PS_NOT;
1511
          end
1512
        endcase
1513
        ram_wr_sel <= #1 `OC8051_RWS_DC;
1514
        wr <= #1 1'b0;
1515
        cy_sel <= #1 `OC8051_CY_0;
1516
        src_sel3 <= #1 `OC8051_AS3_DC;
1517
        wr_sfr <= #1 `OC8051_WRS_N;
1518
      end
1519
      default: begin
1520
        casex (op_cur) /* synopsys parallel_case */
1521
          `OC8051_ACALL :begin
1522
              ram_wr_sel <= #1 `OC8051_RWS_SP;
1523
              src_sel1 <= #1 `OC8051_AS1_PCL;
1524
              src_sel2 <= #1 `OC8051_AS2_DC;
1525
              alu_op <= #1 `OC8051_ALU_NOP;
1526
              wr <= #1 1'b1;
1527
              psw_set <= #1 `OC8051_PS_NOT;
1528
              cy_sel <= #1 `OC8051_CY_0;
1529
              src_sel3 <= #1 `OC8051_AS3_DC;
1530
              wr_sfr <= #1 `OC8051_WRS_N;
1531
            end
1532
          `OC8051_AJMP : begin
1533
              ram_wr_sel <= #1 `OC8051_RWS_DC;
1534
              src_sel1 <= #1 `OC8051_AS1_DC;
1535
              src_sel2 <= #1 `OC8051_AS2_DC;
1536
              alu_op <= #1 `OC8051_ALU_NOP;
1537
              wr <= #1 1'b0;
1538
              psw_set <= #1 `OC8051_PS_NOT;
1539
              cy_sel <= #1 `OC8051_CY_0;
1540
              src_sel3 <= #1 `OC8051_AS3_DC;
1541
              wr_sfr <= #1 `OC8051_WRS_N;
1542
            end
1543
          `OC8051_ADD_R : begin
1544
              ram_wr_sel <= #1 `OC8051_RWS_DC;
1545
              src_sel1 <= #1 `OC8051_AS1_ACC;
1546
              src_sel2 <= #1 `OC8051_AS2_RAM;
1547
              alu_op <= #1 `OC8051_ALU_ADD;
1548
              wr <= #1 1'b0;
1549
              psw_set <= #1 `OC8051_PS_AC;
1550
              cy_sel <= #1 `OC8051_CY_0;
1551
              src_sel3 <= #1 `OC8051_AS3_DC;
1552
              wr_sfr <= #1 `OC8051_WRS_ACC1;
1553
            end
1554
          `OC8051_ADDC_R : begin
1555
              ram_wr_sel <= #1 `OC8051_RWS_DC;
1556
              src_sel1 <= #1 `OC8051_AS1_ACC;
1557
              src_sel2 <= #1 `OC8051_AS2_RAM;
1558
              alu_op <= #1 `OC8051_ALU_ADD;
1559
              wr <= #1 1'b0;
1560
              psw_set <= #1 `OC8051_PS_AC;
1561
              cy_sel <= #1 `OC8051_CY_PSW;
1562
              src_sel3 <= #1 `OC8051_AS3_DC;
1563
              wr_sfr <= #1 `OC8051_WRS_ACC1;
1564
            end
1565
          `OC8051_ANL_R : begin
1566
              ram_wr_sel <= #1 `OC8051_RWS_DC;
1567
              src_sel1 <= #1 `OC8051_AS1_ACC;
1568
              src_sel2 <= #1 `OC8051_AS2_RAM;
1569
              alu_op <= #1 `OC8051_ALU_AND;
1570
              wr <= #1 1'b0;
1571
              psw_set <= #1 `OC8051_PS_NOT;
1572
              cy_sel <= #1 `OC8051_CY_0;
1573
              src_sel3 <= #1 `OC8051_AS3_DC;
1574
              wr_sfr <= #1 `OC8051_WRS_ACC1;
1575
            end
1576
          `OC8051_CJNE_R : begin
1577
              ram_wr_sel <= #1 `OC8051_RWS_DC;
1578
              src_sel1 <= #1 `OC8051_AS1_RAM;
1579
              src_sel2 <= #1 `OC8051_AS2_OP2;
1580
              alu_op <= #1 `OC8051_ALU_SUB;
1581
              wr <= #1 1'b0;
1582
              psw_set <= #1 `OC8051_PS_CY;
1583
              cy_sel <= #1 `OC8051_CY_0;
1584
              src_sel3 <= #1 `OC8051_AS3_DC;
1585
              wr_sfr <= #1 `OC8051_WRS_N;
1586
            end
1587
          `OC8051_DEC_R : begin
1588
              ram_wr_sel <= #1 `OC8051_RWS_RN;
1589
              src_sel1 <= #1 `OC8051_AS1_RAM;
1590
              src_sel2 <= #1 `OC8051_AS2_ZERO;
1591
              alu_op <= #1 `OC8051_ALU_INC;
1592
              wr <= #1 1'b1;
1593
              psw_set <= #1 `OC8051_PS_NOT;
1594
              cy_sel <= #1 `OC8051_CY_1;
1595
              src_sel3 <= #1 `OC8051_AS3_DC;
1596
              wr_sfr <= #1 `OC8051_WRS_N;
1597
            end
1598
          `OC8051_DJNZ_R : begin
1599
              ram_wr_sel <= #1 `OC8051_RWS_RN;
1600
              src_sel1 <= #1 `OC8051_AS1_RAM;
1601
              src_sel2 <= #1 `OC8051_AS2_ZERO;
1602
              alu_op <= #1 `OC8051_ALU_INC;
1603
              wr <= #1 1'b1;
1604
              psw_set <= #1 `OC8051_PS_NOT;
1605
              cy_sel <= #1 `OC8051_CY_1;
1606
              src_sel3 <= #1 `OC8051_AS3_DC;
1607
              wr_sfr <= #1 `OC8051_WRS_N;
1608
            end
1609
          `OC8051_INC_R : begin
1610
              ram_wr_sel <= #1 `OC8051_RWS_RN;
1611
              src_sel1 <= #1 `OC8051_AS1_RAM;
1612
              src_sel2 <= #1 `OC8051_AS2_ZERO;
1613
              alu_op <= #1 `OC8051_ALU_INC;
1614
              wr <= #1 1'b1;
1615
              psw_set <= #1 `OC8051_PS_NOT;
1616
              cy_sel <= #1 `OC8051_CY_0;
1617
              src_sel3 <= #1 `OC8051_AS3_DC;
1618
              wr_sfr <= #1 `OC8051_WRS_N;
1619
            end
1620
          `OC8051_MOV_R : begin
1621
              ram_wr_sel <= #1 `OC8051_RWS_DC;
1622
              src_sel1 <= #1 `OC8051_AS1_RAM;
1623
              src_sel2 <= #1 `OC8051_AS2_DC;
1624
              alu_op <= #1 `OC8051_ALU_NOP;
1625
              wr <= #1 1'b0;
1626
              psw_set <= #1 `OC8051_PS_NOT;
1627
              cy_sel <= #1 `OC8051_CY_0;
1628
              src_sel3 <= #1 `OC8051_AS3_DC;
1629
              wr_sfr <= #1 `OC8051_WRS_ACC1;
1630
            end
1631
          `OC8051_MOV_AR : begin
1632
              ram_wr_sel <= #1 `OC8051_RWS_RN;
1633
              src_sel1 <= #1 `OC8051_AS1_ACC;
1634
              src_sel2 <= #1 `OC8051_AS2_DC;
1635
              alu_op <= #1 `OC8051_ALU_NOP;
1636
              wr <= #1 1'b1;
1637
              psw_set <= #1 `OC8051_PS_NOT;
1638
              cy_sel <= #1 `OC8051_CY_0;
1639
              src_sel3 <= #1 `OC8051_AS3_DC;
1640
              wr_sfr <= #1 `OC8051_WRS_N;
1641
            end
1642
          `OC8051_MOV_DR : begin
1643
              ram_wr_sel <= #1 `OC8051_RWS_RN;
1644
              src_sel1 <= #1 `OC8051_AS1_RAM;
1645
              src_sel2 <= #1 `OC8051_AS2_DC;
1646
              alu_op <= #1 `OC8051_ALU_NOP;
1647
              wr <= #1 1'b1;
1648
              psw_set <= #1 `OC8051_PS_NOT;
1649
              cy_sel <= #1 `OC8051_CY_0;
1650
              src_sel3 <= #1 `OC8051_AS3_DC;
1651
              wr_sfr <= #1 `OC8051_WRS_N;
1652
            end
1653
          `OC8051_MOV_CR : begin
1654
              ram_wr_sel <= #1 `OC8051_RWS_RN;
1655
              src_sel1 <= #1 `OC8051_AS1_OP2;
1656
              src_sel2 <= #1 `OC8051_AS2_DC;
1657
              alu_op <= #1 `OC8051_ALU_NOP;
1658
              wr <= #1 1'b1;
1659
              psw_set <= #1 `OC8051_PS_NOT;
1660
              cy_sel <= #1 `OC8051_CY_0;
1661
              src_sel3 <= #1 `OC8051_AS3_DC;
1662
              wr_sfr <= #1 `OC8051_WRS_N;
1663
            end
1664
          `OC8051_MOV_RD : begin
1665
              ram_wr_sel <= #1 `OC8051_RWS_D;
1666
              src_sel1 <= #1 `OC8051_AS1_RAM;
1667
              src_sel2 <= #1 `OC8051_AS2_DC;
1668
              alu_op <= #1 `OC8051_ALU_NOP;
1669
              wr <= #1 1'b1;
1670
              psw_set <= #1 `OC8051_PS_NOT;
1671
              cy_sel <= #1 `OC8051_CY_0;
1672
              src_sel3 <= #1 `OC8051_AS3_DC;
1673
              wr_sfr <= #1 `OC8051_WRS_N;
1674
            end
1675
          `OC8051_ORL_R : begin
1676
              ram_wr_sel <= #1 `OC8051_RWS_DC;
1677
              src_sel1 <= #1 `OC8051_AS1_RAM;
1678
              src_sel2 <= #1 `OC8051_AS2_ACC;
1679
              alu_op <= #1 `OC8051_ALU_OR;
1680
              wr <= #1 1'b0;
1681
              psw_set <= #1 `OC8051_PS_NOT;
1682
              cy_sel <= #1 `OC8051_CY_0;
1683
              src_sel3 <= #1 `OC8051_AS3_DC;
1684
              wr_sfr <= #1 `OC8051_WRS_ACC1;
1685
            end
1686
          `OC8051_SUBB_R : begin
1687
              ram_wr_sel <= #1 `OC8051_RWS_DC;
1688
              src_sel1 <= #1 `OC8051_AS1_ACC;
1689
              src_sel2 <= #1 `OC8051_AS2_RAM;
1690
              alu_op <= #1 `OC8051_ALU_SUB;
1691
              wr <= #1 1'b0;
1692
              psw_set <= #1 `OC8051_PS_AC;
1693
              cy_sel <= #1 `OC8051_CY_PSW;
1694
              src_sel3 <= #1 `OC8051_AS3_DC;
1695
              wr_sfr <= #1 `OC8051_WRS_ACC1;
1696
            end
1697
          `OC8051_XCH_R : begin
1698
              ram_wr_sel <= #1 `OC8051_RWS_RN;
1699
              src_sel1 <= #1 `OC8051_AS1_RAM;
1700
              src_sel2 <= #1 `OC8051_AS2_ACC;
1701
              alu_op <= #1 `OC8051_ALU_XCH;
1702
              wr <= #1 1'b1;
1703
              psw_set <= #1 `OC8051_PS_NOT;
1704
              cy_sel <= #1 `OC8051_CY_1;
1705
              src_sel3 <= #1 `OC8051_AS3_DC;
1706
              wr_sfr <= #1 `OC8051_WRS_ACC2;
1707
            end
1708
          `OC8051_XRL_R : begin
1709
              ram_wr_sel <= #1 `OC8051_RWS_DC;
1710
              src_sel1 <= #1 `OC8051_AS1_RAM;
1711
              src_sel2 <= #1 `OC8051_AS2_ACC;
1712
              alu_op <= #1 `OC8051_ALU_XOR;
1713
              wr <= #1 1'b0;
1714
              psw_set <= #1 `OC8051_PS_NOT;
1715
              cy_sel <= #1 `OC8051_CY_0;
1716
              src_sel3 <= #1 `OC8051_AS3_DC;
1717
              wr_sfr <= #1 `OC8051_WRS_ACC1;
1718
            end
1719
 
1720
    //op_code [7:1]
1721
          `OC8051_ADD_I : begin
1722
              ram_wr_sel <= #1 `OC8051_RWS_DC;
1723
              src_sel1 <= #1 `OC8051_AS1_ACC;
1724
              src_sel2 <= #1 `OC8051_AS2_RAM;
1725
              alu_op <= #1 `OC8051_ALU_ADD;
1726
              wr <= #1 1'b0;
1727
              psw_set <= #1 `OC8051_PS_AC;
1728
              cy_sel <= #1 `OC8051_CY_0;
1729
              src_sel3 <= #1 `OC8051_AS3_DC;
1730
              wr_sfr <= #1 `OC8051_WRS_ACC1;
1731
            end
1732
          `OC8051_ADDC_I : begin
1733
              ram_wr_sel <= #1 `OC8051_RWS_DC;
1734
              src_sel1 <= #1 `OC8051_AS1_ACC;
1735
              src_sel2 <= #1 `OC8051_AS2_RAM;
1736
              alu_op <= #1 `OC8051_ALU_ADD;
1737
              wr <= #1 1'b0;
1738
              psw_set <= #1 `OC8051_PS_AC;
1739
              cy_sel <= #1 `OC8051_CY_PSW;
1740
              src_sel3 <= #1 `OC8051_AS3_DC;
1741
              wr_sfr <= #1 `OC8051_WRS_ACC1;
1742
            end
1743
          `OC8051_ANL_I : begin
1744
              ram_wr_sel <= #1 `OC8051_RWS_DC;
1745
              src_sel1 <= #1 `OC8051_AS1_ACC;
1746
              src_sel2 <= #1 `OC8051_AS2_RAM;
1747
              alu_op <= #1 `OC8051_ALU_AND;
1748
              wr <= #1 1'b0;
1749
              psw_set <= #1 `OC8051_PS_NOT;
1750
              cy_sel <= #1 `OC8051_CY_0;
1751
              src_sel3 <= #1 `OC8051_AS3_DC;
1752
              wr_sfr <= #1 `OC8051_WRS_ACC1;
1753
            end
1754
          `OC8051_CJNE_I : begin
1755
              ram_wr_sel <= #1 `OC8051_RWS_DC;
1756
              src_sel1 <= #1 `OC8051_AS1_RAM;
1757
              src_sel2 <= #1 `OC8051_AS2_OP2;
1758
              alu_op <= #1 `OC8051_ALU_SUB;
1759
              wr <= #1 1'b0;
1760
              psw_set <= #1 `OC8051_PS_CY;
1761
              cy_sel <= #1 `OC8051_CY_0;
1762
              src_sel3 <= #1 `OC8051_AS3_DC;
1763
              wr_sfr <= #1 `OC8051_WRS_N;
1764
            end
1765
          `OC8051_DEC_I : begin
1766
              ram_wr_sel <= #1 `OC8051_RWS_I;
1767
              src_sel1 <= #1 `OC8051_AS1_RAM;
1768
              src_sel2 <= #1 `OC8051_AS2_ZERO;
1769
              alu_op <= #1 `OC8051_ALU_INC;
1770
              wr <= #1 1'b1;
1771
              psw_set <= #1 `OC8051_PS_NOT;
1772
              cy_sel <= #1 `OC8051_CY_1;
1773
              src_sel3 <= #1 `OC8051_AS3_DC;
1774
              wr_sfr <= #1 `OC8051_WRS_N;
1775
            end
1776
          `OC8051_INC_I : begin
1777
              ram_wr_sel <= #1 `OC8051_RWS_I;
1778
              src_sel1 <= #1 `OC8051_AS1_RAM;
1779
              src_sel2 <= #1 `OC8051_AS2_ZERO;
1780
              alu_op <= #1 `OC8051_ALU_INC;
1781
              wr <= #1 1'b1;
1782
              psw_set <= #1 `OC8051_PS_NOT;
1783
              cy_sel <= #1 `OC8051_CY_0;
1784
              src_sel3 <= #1 `OC8051_AS3_DC;
1785
              wr_sfr <= #1 `OC8051_WRS_N;
1786
            end
1787
          `OC8051_MOV_I : begin
1788
              ram_wr_sel <= #1 `OC8051_RWS_DC;
1789
              src_sel1 <= #1 `OC8051_AS1_RAM;
1790
              src_sel2 <= #1 `OC8051_AS2_DC;
1791
              alu_op <= #1 `OC8051_ALU_NOP;
1792
              wr <= #1 1'b0;
1793
              psw_set <= #1 `OC8051_PS_NOT;
1794
              cy_sel <= #1 `OC8051_CY_0;
1795
              src_sel3 <= #1 `OC8051_AS3_DC;
1796
              wr_sfr <= #1 `OC8051_WRS_ACC1;
1797
            end
1798
          `OC8051_MOV_ID : begin
1799
              ram_wr_sel <= #1 `OC8051_RWS_D;
1800
              src_sel1 <= #1 `OC8051_AS1_RAM;
1801
              src_sel2 <= #1 `OC8051_AS2_DC;
1802
              alu_op <= #1 `OC8051_ALU_NOP;
1803
              wr <= #1 1'b1;
1804
              psw_set <= #1 `OC8051_PS_NOT;
1805
              cy_sel <= #1 `OC8051_CY_0;
1806
              src_sel3 <= #1 `OC8051_AS3_DC;
1807
              wr_sfr <= #1 `OC8051_WRS_N;
1808
            end
1809
          `OC8051_MOV_AI : begin
1810
              ram_wr_sel <= #1 `OC8051_RWS_I;
1811
              src_sel1 <= #1 `OC8051_AS1_ACC;
1812
              src_sel2 <= #1 `OC8051_AS2_DC;
1813
              alu_op <= #1 `OC8051_ALU_NOP;
1814
              wr <= #1 1'b1;
1815
              psw_set <= #1 `OC8051_PS_NOT;
1816
              cy_sel <= #1 `OC8051_CY_0;
1817
              src_sel3 <= #1 `OC8051_AS3_DC;
1818
              wr_sfr <= #1 `OC8051_WRS_N;
1819
            end
1820
          `OC8051_MOV_DI : begin
1821
              ram_wr_sel <= #1 `OC8051_RWS_I;
1822
              src_sel1 <= #1 `OC8051_AS1_RAM;
1823
              src_sel2 <= #1 `OC8051_AS2_DC;
1824
              alu_op <= #1 `OC8051_ALU_NOP;
1825
              wr <= #1 1'b1;
1826
              psw_set <= #1 `OC8051_PS_NOT;
1827
              cy_sel <= #1 `OC8051_CY_0;
1828
              src_sel3 <= #1 `OC8051_AS3_DC;
1829
              wr_sfr <= #1 `OC8051_WRS_N;
1830
            end
1831
          `OC8051_MOV_CI : begin
1832
              ram_wr_sel <= #1 `OC8051_RWS_I;
1833
              src_sel1 <= #1 `OC8051_AS1_OP2;
1834
              src_sel2 <= #1 `OC8051_AS2_DC;
1835
              alu_op <= #1 `OC8051_ALU_NOP;
1836
              wr <= #1 1'b1;
1837
              psw_set <= #1 `OC8051_PS_NOT;
1838
              cy_sel <= #1 `OC8051_CY_0;
1839
              src_sel3 <= #1 `OC8051_AS3_DC;
1840
              wr_sfr <= #1 `OC8051_WRS_N;
1841
            end
1842
          `OC8051_MOVX_IA : begin
1843
              ram_wr_sel <= #1 `OC8051_RWS_DC;
1844
              src_sel1 <= #1 `OC8051_AS1_DC;
1845
              src_sel2 <= #1 `OC8051_AS2_DC;
1846
              alu_op <= #1 `OC8051_ALU_NOP;
1847
              wr <= #1 1'b0;
1848
              psw_set <= #1 `OC8051_PS_NOT;
1849
              cy_sel <= #1 `OC8051_CY_0;
1850
              src_sel3 <= #1 `OC8051_AS3_DC;
1851
              wr_sfr <= #1 `OC8051_WRS_N;
1852
            end
1853
          `OC8051_MOVX_AI :begin
1854
              ram_wr_sel <= #1 `OC8051_RWS_DC;
1855
              src_sel1 <= #1 `OC8051_AS1_DC;
1856
              src_sel2 <= #1 `OC8051_AS2_DC;
1857
              alu_op <= #1 `OC8051_ALU_NOP;
1858
              wr <= #1 1'b0;
1859
              psw_set <= #1 `OC8051_PS_NOT;
1860
              cy_sel <= #1 `OC8051_CY_0;
1861
              src_sel3 <= #1 `OC8051_AS3_DC;
1862
              wr_sfr <= #1 `OC8051_WRS_N;
1863
            end
1864
          `OC8051_ORL_I : begin
1865
              ram_wr_sel <= #1 `OC8051_RWS_DC;
1866
              src_sel1 <= #1 `OC8051_AS1_RAM;
1867
              src_sel2 <= #1 `OC8051_AS2_ACC;
1868
              alu_op <= #1 `OC8051_ALU_OR;
1869
              wr <= #1 1'b0;
1870
              psw_set <= #1 `OC8051_PS_NOT;
1871
              cy_sel <= #1 `OC8051_CY_0;
1872
              src_sel3 <= #1 `OC8051_AS3_DC;
1873
              wr_sfr <= #1 `OC8051_WRS_ACC1;
1874
            end
1875
          `OC8051_SUBB_I : begin
1876
              ram_wr_sel <= #1 `OC8051_RWS_DC;
1877
              src_sel1 <= #1 `OC8051_AS1_ACC;
1878
              src_sel2 <= #1 `OC8051_AS2_RAM;
1879
              alu_op <= #1 `OC8051_ALU_SUB;
1880
              wr <= #1 1'b0;
1881
              psw_set <= #1 `OC8051_PS_AC;
1882
              cy_sel <= #1 `OC8051_CY_PSW;
1883
              src_sel3 <= #1 `OC8051_AS3_DC;
1884
              wr_sfr <= #1 `OC8051_WRS_ACC1;
1885
            end
1886
          `OC8051_XCH_I : begin
1887
              ram_wr_sel <= #1 `OC8051_RWS_I;
1888
              src_sel1 <= #1 `OC8051_AS1_RAM;
1889
              src_sel2 <= #1 `OC8051_AS2_ACC;
1890
              alu_op <= #1 `OC8051_ALU_XCH;
1891
              wr <= #1 1'b1;
1892
              psw_set <= #1 `OC8051_PS_NOT;
1893
              cy_sel <= #1 `OC8051_CY_1;
1894
              src_sel3 <= #1 `OC8051_AS3_DC;
1895
              wr_sfr <= #1 `OC8051_WRS_ACC2;
1896
            end
1897
          `OC8051_XCHD :begin
1898
              ram_wr_sel <= #1 `OC8051_RWS_I;
1899
              src_sel1 <= #1 `OC8051_AS1_RAM;
1900
              src_sel2 <= #1 `OC8051_AS2_ACC;
1901
              alu_op <= #1 `OC8051_ALU_XCH;
1902
              wr <= #1 1'b1;
1903
              psw_set <= #1 `OC8051_PS_NOT;
1904
              cy_sel <= #1 `OC8051_CY_0;
1905
              src_sel3 <= #1 `OC8051_AS3_DC;
1906
              wr_sfr <= #1 `OC8051_WRS_ACC2;
1907
            end
1908
          `OC8051_XRL_I : begin
1909
              ram_wr_sel <= #1 `OC8051_RWS_DC;
1910
              src_sel1 <= #1 `OC8051_AS1_RAM;
1911
              src_sel2 <= #1 `OC8051_AS2_ACC;
1912
              alu_op <= #1 `OC8051_ALU_XOR;
1913
              wr <= #1 1'b0;
1914
              psw_set <= #1 `OC8051_PS_NOT;
1915
              cy_sel <= #1 `OC8051_CY_0;
1916
              src_sel3 <= #1 `OC8051_AS3_DC;
1917
              wr_sfr <= #1 `OC8051_WRS_ACC1;
1918
            end
1919
 
1920
    //op_code [7:0]
1921
          `OC8051_ADD_D : begin
1922
              ram_wr_sel <= #1 `OC8051_RWS_DC;
1923
              src_sel1 <= #1 `OC8051_AS1_ACC;
1924
              src_sel2 <= #1 `OC8051_AS2_RAM;
1925
              alu_op <= #1 `OC8051_ALU_ADD;
1926
              wr <= #1 1'b0;
1927
              psw_set <= #1 `OC8051_PS_AC;
1928
              cy_sel <= #1 `OC8051_CY_0;
1929
              src_sel3 <= #1 `OC8051_AS3_DC;
1930
              wr_sfr <= #1 `OC8051_WRS_ACC1;
1931
            end
1932
          `OC8051_ADD_C : begin
1933
              ram_wr_sel <= #1 `OC8051_RWS_DC;
1934
              src_sel1 <= #1 `OC8051_AS1_OP2;
1935
              src_sel2 <= #1 `OC8051_AS2_ACC;
1936
              alu_op <= #1 `OC8051_ALU_ADD;
1937
              wr <= #1 1'b0;
1938
              psw_set <= #1 `OC8051_PS_AC;
1939
              cy_sel <= #1 `OC8051_CY_0;
1940
              src_sel3 <= #1 `OC8051_AS3_DC;
1941
              wr_sfr <= #1 `OC8051_WRS_ACC1;
1942
            end
1943
          `OC8051_ADDC_D : begin
1944
              ram_wr_sel <= #1 `OC8051_RWS_DC;
1945
              src_sel1 <= #1 `OC8051_AS1_ACC;
1946
              src_sel2 <= #1 `OC8051_AS2_RAM;
1947
              alu_op <= #1 `OC8051_ALU_ADD;
1948
              wr <= #1 1'b0;
1949
              psw_set <= #1 `OC8051_PS_AC;
1950
              cy_sel <= #1 `OC8051_CY_PSW;
1951
              src_sel3 <= #1 `OC8051_AS3_DC;
1952
              wr_sfr <= #1 `OC8051_WRS_ACC1;
1953
            end
1954
          `OC8051_ADDC_C : begin
1955
              ram_wr_sel <= #1 `OC8051_RWS_DC;
1956
              src_sel1 <= #1 `OC8051_AS1_OP2;
1957
              src_sel2 <= #1 `OC8051_AS2_ACC;
1958
              alu_op <= #1 `OC8051_ALU_ADD;
1959
              wr <= #1 1'b0;
1960
              psw_set <= #1 `OC8051_PS_AC;
1961
              cy_sel <= #1 `OC8051_CY_PSW;
1962
              src_sel3 <= #1 `OC8051_AS3_DC;
1963
              wr_sfr <= #1 `OC8051_WRS_ACC1;
1964
            end
1965
          `OC8051_ANL_D : begin
1966
              ram_wr_sel <= #1 `OC8051_RWS_DC;
1967
              src_sel1 <= #1 `OC8051_AS1_ACC;
1968
              src_sel2 <= #1 `OC8051_AS2_RAM;
1969
              alu_op <= #1 `OC8051_ALU_AND;
1970
              wr <= #1 1'b0;
1971
              psw_set <= #1 `OC8051_PS_NOT;
1972
              cy_sel <= #1 `OC8051_CY_0;
1973
              src_sel3 <= #1 `OC8051_AS3_DC;
1974
              wr_sfr <= #1 `OC8051_WRS_ACC1;
1975
            end
1976
          `OC8051_ANL_C : begin
1977
              ram_wr_sel <= #1 `OC8051_RWS_DC;
1978
              src_sel1 <= #1 `OC8051_AS1_OP2;
1979
              src_sel2 <= #1 `OC8051_AS2_ACC;
1980
              alu_op <= #1 `OC8051_ALU_AND;
1981
              wr <= #1 1'b0;
1982
              psw_set <= #1 `OC8051_PS_NOT;
1983
              cy_sel <= #1 `OC8051_CY_0;
1984
              src_sel3 <= #1 `OC8051_AS3_DC;
1985
              wr_sfr <= #1 `OC8051_WRS_ACC1;
1986
            end
1987
          `OC8051_ANL_DD : begin
1988
              ram_wr_sel <= #1 `OC8051_RWS_D;
1989
              src_sel1 <= #1 `OC8051_AS1_ACC;
1990
              src_sel2 <= #1 `OC8051_AS2_RAM;
1991
              alu_op <= #1 `OC8051_ALU_AND;
1992
              wr <= #1 1'b1;
1993
              psw_set <= #1 `OC8051_PS_NOT;
1994
              cy_sel <= #1 `OC8051_CY_0;
1995
              src_sel3 <= #1 `OC8051_AS3_DC;
1996
              wr_sfr <= #1 `OC8051_WRS_N;
1997
            end
1998
          `OC8051_ANL_DC : begin
1999
              ram_wr_sel <= #1 `OC8051_RWS_D;
2000
              src_sel1 <= #1 `OC8051_AS1_OP3;
2001
              src_sel2 <= #1 `OC8051_AS2_RAM;
2002
              alu_op <= #1 `OC8051_ALU_AND;
2003
              wr <= #1 1'b1;
2004
              psw_set <= #1 `OC8051_PS_NOT;
2005
              cy_sel <= #1 `OC8051_CY_0;
2006
              src_sel3 <= #1 `OC8051_AS3_DC;
2007
              wr_sfr <= #1 `OC8051_WRS_N;
2008
            end
2009
          `OC8051_ANL_B : begin
2010
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2011
              src_sel1 <= #1 `OC8051_AS1_DC;
2012
              src_sel2 <= #1 `OC8051_AS2_DC;
2013
              alu_op <= #1 `OC8051_ALU_AND;
2014
              wr <= #1 1'b0;
2015
              psw_set <= #1 `OC8051_PS_CY;
2016
              cy_sel <= #1 `OC8051_CY_PSW;
2017
              src_sel3 <= #1 `OC8051_AS3_DC;
2018
              wr_sfr <= #1 `OC8051_WRS_N;
2019
            end
2020
          `OC8051_ANL_NB : begin
2021
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2022
              src_sel1 <= #1 `OC8051_AS1_DC;
2023
              src_sel2 <= #1 `OC8051_AS2_DC;
2024
              alu_op <= #1 `OC8051_ALU_RR;
2025
              wr <= #1 1'b0;
2026
              psw_set <= #1 `OC8051_PS_CY;
2027
              cy_sel <= #1 `OC8051_CY_PSW;
2028
              src_sel3 <= #1 `OC8051_AS3_DC;
2029
              wr_sfr <= #1 `OC8051_WRS_N;
2030
            end
2031
          `OC8051_CJNE_D : begin
2032
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2033
              src_sel1 <= #1 `OC8051_AS1_ACC;
2034
              src_sel2 <= #1 `OC8051_AS2_RAM;
2035
              alu_op <= #1 `OC8051_ALU_SUB;
2036
              wr <= #1 1'b0;
2037
              psw_set <= #1 `OC8051_PS_CY;
2038
              cy_sel <= #1 `OC8051_CY_0;
2039
              src_sel3 <= #1 `OC8051_AS3_DC;
2040
              wr_sfr <= #1 `OC8051_WRS_N;
2041
            end
2042
          `OC8051_CJNE_C : begin
2043
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2044
              src_sel1 <= #1 `OC8051_AS1_ACC;
2045
              src_sel2 <= #1 `OC8051_AS2_OP2;
2046
              alu_op <= #1 `OC8051_ALU_SUB;
2047
              wr <= #1 1'b0;
2048
              psw_set <= #1 `OC8051_PS_CY;
2049
              cy_sel <= #1 `OC8051_CY_0;
2050
              src_sel3 <= #1 `OC8051_AS3_DC;
2051
              wr_sfr <= #1 `OC8051_WRS_N;
2052
            end
2053
          `OC8051_CLR_A : begin
2054
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2055
              src_sel1 <= #1 `OC8051_AS1_ACC;
2056
              src_sel2 <= #1 `OC8051_AS2_ACC;
2057
              alu_op <= #1 `OC8051_ALU_SUB;
2058
              wr <= #1 1'b0;
2059
              psw_set <= #1 `OC8051_PS_NOT;
2060
              cy_sel <= #1 `OC8051_CY_0;
2061
              src_sel3 <= #1 `OC8051_AS3_PC;
2062
              wr_sfr <= #1 `OC8051_WRS_ACC1;
2063
            end
2064
          `OC8051_CLR_C : begin
2065
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2066
              src_sel1 <= #1 `OC8051_AS1_DC;
2067
              src_sel2 <= #1 `OC8051_AS2_DC;
2068
              alu_op <= #1 `OC8051_ALU_NOP;
2069
              wr <= #1 1'b0;
2070
              psw_set <= #1 `OC8051_PS_CY;
2071
              cy_sel <= #1 `OC8051_CY_0;
2072
              src_sel3 <= #1 `OC8051_AS3_PC;
2073
              wr_sfr <= #1 `OC8051_WRS_N;
2074
            end
2075
          `OC8051_CLR_B : begin
2076
              ram_wr_sel <= #1 `OC8051_RWS_D;
2077
              src_sel1 <= #1 `OC8051_AS1_DC;
2078
              src_sel2 <= #1 `OC8051_AS2_DC;
2079
              alu_op <= #1 `OC8051_ALU_NOP;
2080
              wr <= #1 1'b1;
2081
              psw_set <= #1 `OC8051_PS_NOT;
2082
              cy_sel <= #1 `OC8051_CY_0;
2083
              src_sel3 <= #1 `OC8051_AS3_PC;
2084
              wr_sfr <= #1 `OC8051_WRS_N;
2085
            end
2086
          `OC8051_CPL_A : begin
2087
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2088
              src_sel1 <= #1 `OC8051_AS1_ACC;
2089
              src_sel2 <= #1 `OC8051_AS2_DC;
2090
              alu_op <= #1 `OC8051_ALU_NOT;
2091
              wr <= #1 1'b0;
2092
              psw_set <= #1 `OC8051_PS_NOT;
2093
              cy_sel <= #1 `OC8051_CY_0;
2094
              src_sel3 <= #1 `OC8051_AS3_DC;
2095
              wr_sfr <= #1 `OC8051_WRS_ACC1;
2096
            end
2097
          `OC8051_CPL_C : begin
2098
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2099
              src_sel1 <= #1 `OC8051_AS1_DC;
2100
              src_sel2 <= #1 `OC8051_AS2_DC;
2101
              alu_op <= #1 `OC8051_ALU_NOT;
2102
              wr <= #1 1'b0;
2103
              psw_set <= #1 `OC8051_PS_CY;
2104
              cy_sel <= #1 `OC8051_CY_PSW;
2105
              src_sel3 <= #1 `OC8051_AS3_DC;
2106
              wr_sfr <= #1 `OC8051_WRS_N;
2107
            end
2108
          `OC8051_CPL_B : begin
2109
              ram_wr_sel <= #1 `OC8051_RWS_D;
2110
              src_sel1 <= #1 `OC8051_AS1_DC;
2111
              src_sel2 <= #1 `OC8051_AS2_DC;
2112
              alu_op <= #1 `OC8051_ALU_NOT;
2113
              wr <= #1 1'b1;
2114
              psw_set <= #1 `OC8051_PS_NOT;
2115
              cy_sel <= #1 `OC8051_CY_RAM;
2116
              src_sel3 <= #1 `OC8051_AS3_DC;
2117
              wr_sfr <= #1 `OC8051_WRS_N;
2118
            end
2119
          `OC8051_DA : begin
2120
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2121
              src_sel1 <= #1 `OC8051_AS1_ACC;
2122
              src_sel2 <= #1 `OC8051_AS2_DC;
2123
              alu_op <= #1 `OC8051_ALU_DA;
2124
              wr <= #1 1'b0;
2125
              psw_set <= #1 `OC8051_PS_CY;
2126
              cy_sel <= #1 `OC8051_CY_PSW;
2127
              src_sel3 <= #1 `OC8051_AS3_DC;
2128
              wr_sfr <= #1 `OC8051_WRS_ACC1;
2129
            end
2130
          `OC8051_DEC_A : begin
2131
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2132
              src_sel1 <= #1 `OC8051_AS1_ACC;
2133
              src_sel2 <= #1 `OC8051_AS2_ZERO;
2134
              alu_op <= #1 `OC8051_ALU_INC;
2135
              wr <= #1 1'b0;
2136
              psw_set <= #1 `OC8051_PS_NOT;
2137
              cy_sel <= #1 `OC8051_CY_1;
2138
              src_sel3 <= #1 `OC8051_AS3_DC;
2139
              wr_sfr <= #1 `OC8051_WRS_ACC1;
2140
            end
2141
          `OC8051_DEC_D : begin
2142
              ram_wr_sel <= #1 `OC8051_RWS_D;
2143
              src_sel1 <= #1 `OC8051_AS1_RAM;
2144
              src_sel2 <= #1 `OC8051_AS2_ZERO;
2145
              alu_op <= #1 `OC8051_ALU_INC;
2146
              wr <= #1 1'b1;
2147
              psw_set <= #1 `OC8051_PS_NOT;
2148
              cy_sel <= #1 `OC8051_CY_1;
2149
              src_sel3 <= #1 `OC8051_AS3_DC;
2150
              wr_sfr <= #1 `OC8051_WRS_N;
2151
            end
2152
          `OC8051_DIV : begin
2153
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2154
              src_sel1 <= #1 `OC8051_AS1_ACC;
2155
              src_sel2 <= #1 `OC8051_AS2_RAM;
2156
              alu_op <= #1 `OC8051_ALU_DIV;
2157
              wr <= #1 1'b0;
2158
              psw_set <= #1 `OC8051_PS_OV;
2159
              cy_sel <= #1 `OC8051_CY_0;
2160
              src_sel3 <= #1 `OC8051_AS3_DC;
2161
              wr_sfr <= #1 `OC8051_WRS_N;
2162
            end
2163
          `OC8051_DJNZ_D : begin
2164
              ram_wr_sel <= #1 `OC8051_RWS_D;
2165
              src_sel1 <= #1 `OC8051_AS1_RAM;
2166
              src_sel2 <= #1 `OC8051_AS2_ZERO;
2167
              alu_op <= #1 `OC8051_ALU_INC;
2168
              wr <= #1 1'b1;
2169
              psw_set <= #1 `OC8051_PS_NOT;
2170
              cy_sel <= #1 `OC8051_CY_1;
2171
              src_sel3 <= #1 `OC8051_AS3_DC;
2172
              wr_sfr <= #1 `OC8051_WRS_N;
2173
            end
2174
          `OC8051_INC_A : begin
2175
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2176
              src_sel1 <= #1 `OC8051_AS1_ACC;
2177
              src_sel2 <= #1 `OC8051_AS2_ZERO;
2178
              alu_op <= #1 `OC8051_ALU_INC;
2179
              wr <= #1 1'b0;
2180
              psw_set <= #1 `OC8051_PS_NOT;
2181
              cy_sel <= #1 `OC8051_CY_0;
2182
              src_sel3 <= #1 `OC8051_AS3_DC;
2183
              wr_sfr <= #1 `OC8051_WRS_ACC1;
2184
            end
2185
          `OC8051_INC_D : begin
2186
              ram_wr_sel <= #1 `OC8051_RWS_D;
2187
              src_sel1 <= #1 `OC8051_AS1_RAM;
2188
              src_sel2 <= #1 `OC8051_AS2_ZERO;
2189
              alu_op <= #1 `OC8051_ALU_INC;
2190
              wr <= #1 1'b1;
2191
              psw_set <= #1 `OC8051_PS_NOT;
2192
              cy_sel <= #1 `OC8051_CY_0;
2193
              src_sel3 <= #1 `OC8051_AS3_DC;
2194
              wr_sfr <= #1 `OC8051_WRS_N;
2195
            end
2196
          `OC8051_INC_DP : begin
2197
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2198
              src_sel1 <= #1 `OC8051_AS1_RAM;
2199
              src_sel2 <= #1 `OC8051_AS2_ZERO;
2200
              alu_op <= #1 `OC8051_ALU_ADD;
2201
              wr <= #1 1'b0;
2202
              psw_set <= #1 `OC8051_PS_NOT;
2203
              cy_sel <= #1 `OC8051_CY_1;
2204
              src_sel3 <= #1 `OC8051_AS3_DP;
2205
              wr_sfr <= #1 `OC8051_WRS_DPTR;
2206
            end
2207
          `OC8051_JB : begin
2208
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2209
              src_sel1 <= #1 `OC8051_AS1_DC;
2210
              src_sel2 <= #1 `OC8051_AS2_DC;
2211
              alu_op <= #1 `OC8051_ALU_NOP;
2212
              wr <= #1 1'b0;
2213
              psw_set <= #1 `OC8051_PS_NOT;
2214
              cy_sel <= #1 `OC8051_CY_0;
2215
              src_sel3 <= #1 `OC8051_AS3_PC;
2216
              wr_sfr <= #1 `OC8051_WRS_N;
2217
            end
2218
          `OC8051_JBC :begin
2219
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2220
              src_sel1 <= #1 `OC8051_AS1_DC;
2221
              src_sel2 <= #1 `OC8051_AS2_DC;
2222
              alu_op <= #1 `OC8051_ALU_NOP;
2223
              wr <= #1 1'b0;
2224
              psw_set <= #1 `OC8051_PS_NOT;
2225
              cy_sel <= #1 `OC8051_CY_0;
2226
              src_sel3 <= #1 `OC8051_AS3_PC;
2227
              wr_sfr <= #1 `OC8051_WRS_N;
2228
            end
2229
          `OC8051_JC : begin
2230
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2231
              src_sel1 <= #1 `OC8051_AS1_DC;
2232
              src_sel2 <= #1 `OC8051_AS2_DC;
2233
              alu_op <= #1 `OC8051_ALU_NOP;
2234
              wr <= #1 1'b0;
2235
              psw_set <= #1 `OC8051_PS_NOT;
2236
              cy_sel <= #1 `OC8051_CY_0;
2237
              src_sel3 <= #1 `OC8051_AS3_PC;
2238
              wr_sfr <= #1 `OC8051_WRS_N;
2239
            end
2240
          `OC8051_JMP_D : begin
2241
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2242
              src_sel1 <= #1 `OC8051_AS1_ACC;
2243
              src_sel2 <= #1 `OC8051_AS2_RAM;
2244
              alu_op <= #1 `OC8051_ALU_ADD;
2245
              wr <= #1 1'b0;
2246
              psw_set <= #1 `OC8051_PS_NOT;
2247
              cy_sel <= #1 `OC8051_CY_0;
2248
              src_sel3 <= #1 `OC8051_AS3_DP;
2249
              wr_sfr <= #1 `OC8051_WRS_N;
2250
            end
2251
          `OC8051_JNB : begin
2252
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2253
              src_sel1 <= #1 `OC8051_AS1_DC;
2254
              src_sel2 <= #1 `OC8051_AS2_DC;
2255
              alu_op <= #1 `OC8051_ALU_NOP;
2256
              wr <= #1 1'b0;
2257
              psw_set <= #1 `OC8051_PS_NOT;
2258
              cy_sel <= #1 `OC8051_CY_0;
2259
              src_sel3 <= #1 `OC8051_AS3_PC;
2260
              wr_sfr <= #1 `OC8051_WRS_N;
2261
            end
2262
          `OC8051_JNC : begin
2263
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2264
              src_sel1 <= #1 `OC8051_AS1_DC;
2265
              src_sel2 <= #1 `OC8051_AS2_DC;
2266
              alu_op <= #1 `OC8051_ALU_NOP;
2267
              wr <= #1 1'b0;
2268
              psw_set <= #1 `OC8051_PS_NOT;
2269
              cy_sel <= #1 `OC8051_CY_0;
2270
              src_sel3 <= #1 `OC8051_AS3_PC;
2271
              wr_sfr <= #1 `OC8051_WRS_N;
2272
            end
2273
          `OC8051_JNZ :begin
2274
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2275
              src_sel1 <= #1 `OC8051_AS1_DC;
2276
              src_sel2 <= #1 `OC8051_AS2_DC;
2277
              alu_op <= #1 `OC8051_ALU_NOP;
2278
              wr <= #1 1'b0;
2279
              psw_set <= #1 `OC8051_PS_NOT;
2280
              cy_sel <= #1 `OC8051_CY_0;
2281
              src_sel3 <= #1 `OC8051_AS3_PC;
2282
              wr_sfr <= #1 `OC8051_WRS_N;
2283
            end
2284
          `OC8051_JZ : begin
2285
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2286
              src_sel1 <= #1 `OC8051_AS1_DC;
2287
              src_sel2 <= #1 `OC8051_AS2_DC;
2288
              alu_op <= #1 `OC8051_ALU_NOP;
2289
              wr <= #1 1'b0;
2290
              psw_set <= #1 `OC8051_PS_NOT;
2291
              cy_sel <= #1 `OC8051_CY_0;
2292
              src_sel3 <= #1 `OC8051_AS3_PC;
2293
              wr_sfr <= #1 `OC8051_WRS_N;
2294
            end
2295
          `OC8051_LCALL :begin
2296
              ram_wr_sel <= #1 `OC8051_RWS_SP;
2297
              src_sel1 <= #1 `OC8051_AS1_PCL;
2298
              src_sel2 <= #1 `OC8051_AS2_DC;
2299
              alu_op <= #1 `OC8051_ALU_NOP;
2300
              wr <= #1 1'b1;
2301
              psw_set <= #1 `OC8051_PS_NOT;
2302
              cy_sel <= #1 `OC8051_CY_0;
2303
              src_sel3 <= #1 `OC8051_AS3_DC;
2304
              wr_sfr <= #1 `OC8051_WRS_N;
2305
            end
2306
          `OC8051_LJMP : begin
2307
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2308
              src_sel1 <= #1 `OC8051_AS1_DC;
2309
              src_sel2 <= #1 `OC8051_AS2_DC;
2310
              alu_op <= #1 `OC8051_ALU_NOP;
2311
              wr <= #1 1'b0;
2312
              psw_set <= #1 `OC8051_PS_NOT;
2313
              cy_sel <= #1 `OC8051_CY_0;
2314
              src_sel3 <= #1 `OC8051_AS3_DC;
2315
              wr_sfr <= #1 `OC8051_WRS_N;
2316
            end
2317
          `OC8051_MOV_D : begin
2318
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2319
              src_sel1 <= #1 `OC8051_AS1_RAM;
2320
              src_sel2 <= #1 `OC8051_AS2_DC;
2321
              alu_op <= #1 `OC8051_ALU_NOP;
2322
              wr <= #1 1'b0;
2323
              psw_set <= #1 `OC8051_PS_NOT;
2324
              cy_sel <= #1 `OC8051_CY_0;
2325
              src_sel3 <= #1 `OC8051_AS3_DC;
2326
              wr_sfr <= #1 `OC8051_WRS_ACC1;
2327
            end
2328
          `OC8051_MOV_C : begin
2329
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2330
              src_sel1 <= #1 `OC8051_AS1_OP2;
2331
              src_sel2 <= #1 `OC8051_AS2_DC;
2332
              alu_op <= #1 `OC8051_ALU_NOP;
2333
              wr <= #1 1'b0;
2334
              psw_set <= #1 `OC8051_PS_NOT;
2335
              cy_sel <= #1 `OC8051_CY_0;
2336
              src_sel3 <= #1 `OC8051_AS3_DC;
2337
              wr_sfr <= #1 `OC8051_WRS_ACC1;
2338
            end
2339
          `OC8051_MOV_DA : begin
2340
              ram_wr_sel <= #1 `OC8051_RWS_D;
2341
              src_sel1 <= #1 `OC8051_AS1_ACC;
2342
              src_sel2 <= #1 `OC8051_AS2_DC;
2343
              alu_op <= #1 `OC8051_ALU_NOP;
2344
              wr <= #1 1'b1;
2345
              psw_set <= #1 `OC8051_PS_NOT;
2346
              cy_sel <= #1 `OC8051_CY_0;
2347
              src_sel3 <= #1 `OC8051_AS3_DC;
2348
              wr_sfr <= #1 `OC8051_WRS_N;
2349
            end
2350
          `OC8051_MOV_DD : begin
2351
              ram_wr_sel <= #1 `OC8051_RWS_D3;
2352
              src_sel1 <= #1 `OC8051_AS1_RAM;
2353
              src_sel2 <= #1 `OC8051_AS2_DC;
2354
              alu_op <= #1 `OC8051_ALU_NOP;
2355
              wr <= #1 1'b1;
2356
              psw_set <= #1 `OC8051_PS_NOT;
2357
              cy_sel <= #1 `OC8051_CY_0;
2358
              src_sel3 <= #1 `OC8051_AS3_DC;
2359
              wr_sfr <= #1 `OC8051_WRS_N;
2360
            end
2361
          `OC8051_MOV_CD : begin
2362
              ram_wr_sel <= #1 `OC8051_RWS_D;
2363
              src_sel1 <= #1 `OC8051_AS1_OP3;
2364
              src_sel2 <= #1 `OC8051_AS2_DC;
2365
              alu_op <= #1 `OC8051_ALU_NOP;
2366
              wr <= #1 1'b1;
2367
              psw_set <= #1 `OC8051_PS_NOT;
2368
              cy_sel <= #1 `OC8051_CY_0;
2369
              src_sel3 <= #1 `OC8051_AS3_DC;
2370
              wr_sfr <= #1 `OC8051_WRS_N;
2371
            end
2372
          `OC8051_MOV_BC : begin
2373
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2374
              src_sel1 <= #1 `OC8051_AS1_DC;
2375
              src_sel2 <= #1 `OC8051_AS2_DC;
2376
              alu_op <= #1 `OC8051_ALU_NOP;
2377
              wr <= #1 1'b0;
2378
              psw_set <= #1 `OC8051_PS_CY;
2379
              cy_sel <= #1 `OC8051_CY_RAM;
2380
              src_sel3 <= #1 `OC8051_AS3_DC;
2381
              wr_sfr <= #1 `OC8051_WRS_N;
2382
            end
2383
          `OC8051_MOV_CB : begin
2384
              ram_wr_sel <= #1 `OC8051_RWS_D;
2385
              src_sel1 <= #1 `OC8051_AS1_DC;
2386
              src_sel2 <= #1 `OC8051_AS2_DC;
2387
              alu_op <= #1 `OC8051_ALU_NOP;
2388
              wr <= #1 1'b1;
2389
              psw_set <= #1 `OC8051_PS_NOT;
2390
              cy_sel <= #1 `OC8051_CY_PSW;
2391
              src_sel3 <= #1 `OC8051_AS3_DC;
2392
              wr_sfr <= #1 `OC8051_WRS_N;
2393
            end
2394
          `OC8051_MOV_DP : begin
2395
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2396
              src_sel1 <= #1 `OC8051_AS1_OP3;
2397
              src_sel2 <= #1 `OC8051_AS2_OP2;
2398
              alu_op <= #1 `OC8051_ALU_NOP;
2399
              wr <= #1 1'b0;
2400
              psw_set <= #1 `OC8051_PS_NOT;
2401
              cy_sel <= #1 `OC8051_CY_0;
2402
              src_sel3 <= #1 `OC8051_AS3_DC;
2403
              wr_sfr <= #1 `OC8051_WRS_DPTR;
2404
            end
2405
          `OC8051_MOVC_DP :begin
2406
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2407
              src_sel1 <= #1 `OC8051_AS1_ACC;
2408
              src_sel2 <= #1 `OC8051_AS2_RAM;
2409
              alu_op <= #1 `OC8051_ALU_ADD;
2410
              wr <= #1 1'b0;
2411
              psw_set <= #1 `OC8051_PS_NOT;
2412
              cy_sel <= #1 `OC8051_CY_0;
2413
              src_sel3 <= #1 `OC8051_AS3_DP;
2414
              wr_sfr <= #1 `OC8051_WRS_N;
2415
            end
2416
          `OC8051_MOVC_PC : begin
2417
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2418
              src_sel1 <= #1 `OC8051_AS1_PCL;
2419
              src_sel2 <= #1 `OC8051_AS2_ACC;
2420
              alu_op <= #1 `OC8051_ALU_ADD;
2421
              wr <= #1 1'b0;
2422
              psw_set <= #1 `OC8051_PS_NOT;
2423
              cy_sel <= #1 `OC8051_CY_0;
2424
              src_sel3 <= #1 `OC8051_AS3_PC;
2425
              wr_sfr <= #1 `OC8051_WRS_N;
2426
            end
2427
          `OC8051_MOVX_PA : begin
2428
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2429
              src_sel1 <= #1 `OC8051_AS1_DC;
2430
              src_sel2 <= #1 `OC8051_AS2_DC;
2431
              alu_op <= #1 `OC8051_ALU_NOP;
2432
              wr <= #1 1'b0;
2433
              psw_set <= #1 `OC8051_PS_NOT;
2434
              cy_sel <= #1 `OC8051_CY_0;
2435
              src_sel3 <= #1 `OC8051_AS3_DC;
2436
              wr_sfr <= #1 `OC8051_WRS_N;
2437
            end
2438
          `OC8051_MOVX_AP : begin
2439
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2440
              src_sel1 <= #1 `OC8051_AS1_DC;
2441
              src_sel2 <= #1 `OC8051_AS2_DC;
2442
              alu_op <= #1 `OC8051_ALU_NOP;
2443
              wr <= #1 1'b0;
2444
              psw_set <= #1 `OC8051_PS_NOT;
2445
              cy_sel <= #1 `OC8051_CY_0;
2446
              src_sel3 <= #1 `OC8051_AS3_DC;
2447
              wr_sfr <= #1 `OC8051_WRS_N;
2448
            end
2449
          `OC8051_MUL : begin
2450
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2451
              src_sel1 <= #1 `OC8051_AS1_ACC;
2452
              src_sel2 <= #1 `OC8051_AS2_RAM;
2453
              alu_op <= #1 `OC8051_ALU_MUL;
2454
              wr <= #1 1'b0;
2455
              psw_set <= #1 `OC8051_PS_OV;
2456
              cy_sel <= #1 `OC8051_CY_0;
2457
              src_sel3 <= #1 `OC8051_AS3_DC;
2458
              wr_sfr <= #1 `OC8051_WRS_N;
2459
            end
2460
          `OC8051_ORL_D : begin
2461
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2462
              src_sel1 <= #1 `OC8051_AS1_RAM;
2463
              src_sel2 <= #1 `OC8051_AS2_ACC;
2464
              alu_op <= #1 `OC8051_ALU_OR;
2465
              wr <= #1 1'b0;
2466
              psw_set <= #1 `OC8051_PS_NOT;
2467
              cy_sel <= #1 `OC8051_CY_0;
2468
              src_sel3 <= #1 `OC8051_AS3_DC;
2469
              wr_sfr <= #1 `OC8051_WRS_ACC1;
2470
            end
2471
          `OC8051_ORL_C : begin
2472
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2473
              src_sel1 <= #1 `OC8051_AS1_OP2;
2474
              src_sel2 <= #1 `OC8051_AS2_ACC;
2475
              alu_op <= #1 `OC8051_ALU_OR;
2476
              wr <= #1 1'b0;
2477
              psw_set <= #1 `OC8051_PS_NOT;
2478
              cy_sel <= #1 `OC8051_CY_0;
2479
              src_sel3 <= #1 `OC8051_AS3_DC;
2480
              wr_sfr <= #1 `OC8051_WRS_ACC1;
2481
            end
2482
          `OC8051_ORL_AD : begin
2483
              ram_wr_sel <= #1 `OC8051_RWS_D;
2484
              src_sel1 <= #1 `OC8051_AS1_RAM;
2485
              src_sel2 <= #1 `OC8051_AS2_ACC;
2486
              alu_op <= #1 `OC8051_ALU_OR;
2487
              wr <= #1 1'b1;
2488
              psw_set <= #1 `OC8051_PS_NOT;
2489
              cy_sel <= #1 `OC8051_CY_0;
2490
              src_sel3 <= #1 `OC8051_AS3_DC;
2491
              wr_sfr <= #1 `OC8051_WRS_N;
2492
            end
2493
          `OC8051_ORL_CD : begin
2494
              ram_wr_sel <= #1 `OC8051_RWS_D;
2495
              src_sel1 <= #1 `OC8051_AS1_OP3;
2496
              src_sel2 <= #1 `OC8051_AS2_RAM;
2497
              alu_op <= #1 `OC8051_ALU_OR;
2498
              wr <= #1 1'b1;
2499
              psw_set <= #1 `OC8051_PS_NOT;
2500
              cy_sel <= #1 `OC8051_CY_0;
2501
              src_sel3 <= #1 `OC8051_AS3_DC;
2502
              wr_sfr <= #1 `OC8051_WRS_N;
2503
            end
2504
          `OC8051_ORL_B : begin
2505
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2506
              src_sel1 <= #1 `OC8051_AS1_DC;
2507
              src_sel2 <= #1 `OC8051_AS2_DC;
2508
              alu_op <= #1 `OC8051_ALU_OR;
2509
              wr <= #1 1'b0;
2510
              psw_set <= #1 `OC8051_PS_CY;
2511
              cy_sel <= #1 `OC8051_CY_PSW;
2512
              src_sel3 <= #1 `OC8051_AS3_DC;
2513
              wr_sfr <= #1 `OC8051_WRS_N;
2514
            end
2515
          `OC8051_ORL_NB : begin
2516
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2517
              src_sel1 <= #1 `OC8051_AS1_DC;
2518
              src_sel2 <= #1 `OC8051_AS2_DC;
2519
              alu_op <= #1 `OC8051_ALU_RL;
2520
              wr <= #1 1'b0;
2521
              psw_set <= #1 `OC8051_PS_CY;
2522
              cy_sel <= #1 `OC8051_CY_PSW;
2523
              src_sel3 <= #1 `OC8051_AS3_DC;
2524
              wr_sfr <= #1 `OC8051_WRS_N;
2525
            end
2526
          `OC8051_POP : begin
2527
              ram_wr_sel <= #1 `OC8051_RWS_D;
2528
              src_sel1 <= #1 `OC8051_AS1_RAM;
2529
              src_sel2 <= #1 `OC8051_AS2_DC;
2530
              alu_op <= #1 `OC8051_ALU_NOP;
2531
              wr <= #1 1'b1;
2532
              psw_set <= #1 `OC8051_PS_NOT;
2533
              cy_sel <= #1 `OC8051_CY_0;
2534
              src_sel3 <= #1 `OC8051_AS3_DC;
2535
              wr_sfr <= #1 `OC8051_WRS_N;
2536
            end
2537
          `OC8051_PUSH : begin
2538
              ram_wr_sel <= #1 `OC8051_RWS_SP;
2539
              src_sel1 <= #1 `OC8051_AS1_RAM;
2540
              src_sel2 <= #1 `OC8051_AS2_DC;
2541
              alu_op <= #1 `OC8051_ALU_NOP;
2542
              wr <= #1 1'b1;
2543
              psw_set <= #1 `OC8051_PS_NOT;
2544
              cy_sel <= #1 `OC8051_CY_0;
2545
              src_sel3 <= #1 `OC8051_AS3_DC;
2546
              wr_sfr <= #1 `OC8051_WRS_N;
2547
            end
2548
          `OC8051_RET : begin
2549
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2550
              src_sel1 <= #1 `OC8051_AS1_RAM;
2551
              src_sel2 <= #1 `OC8051_AS2_DC;
2552
              alu_op <= #1 `OC8051_ALU_NOP;
2553
              wr <= #1 1'b0;
2554
              psw_set <= #1 `OC8051_PS_NOT;
2555
              cy_sel <= #1 `OC8051_CY_0;
2556
              src_sel3 <= #1 `OC8051_AS3_DC;
2557
              wr_sfr <= #1 `OC8051_WRS_N;
2558
            end
2559
          `OC8051_RETI : begin
2560
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2561
              src_sel1 <= #1 `OC8051_AS1_RAM;
2562
              src_sel2 <= #1 `OC8051_AS2_DC;
2563
              alu_op <= #1 `OC8051_ALU_NOP;
2564
              wr <= #1 1'b0;
2565
              psw_set <= #1 `OC8051_PS_NOT;
2566
              cy_sel <= #1 `OC8051_CY_0;
2567
              src_sel3 <= #1 `OC8051_AS3_DC;
2568
              wr_sfr <= #1 `OC8051_WRS_N;
2569
            end
2570
          `OC8051_RL : begin
2571
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2572
              src_sel1 <= #1 `OC8051_AS1_ACC;
2573
              src_sel2 <= #1 `OC8051_AS2_DC;
2574
              alu_op <= #1 `OC8051_ALU_RL;
2575
              wr <= #1 1'b0;
2576
              psw_set <= #1 `OC8051_PS_NOT;
2577
              cy_sel <= #1 `OC8051_CY_0;
2578
              src_sel3 <= #1 `OC8051_AS3_DC;
2579
              wr_sfr <= #1 `OC8051_WRS_ACC1;
2580
            end
2581
          `OC8051_RLC : begin
2582
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2583
              src_sel1 <= #1 `OC8051_AS1_ACC;
2584
              src_sel2 <= #1 `OC8051_AS2_DC;
2585
              alu_op <= #1 `OC8051_ALU_RLC;
2586
              wr <= #1 1'b0;
2587
              psw_set <= #1 `OC8051_PS_CY;
2588
              cy_sel <= #1 `OC8051_CY_PSW;
2589
              src_sel3 <= #1 `OC8051_AS3_DC;
2590
              wr_sfr <= #1 `OC8051_WRS_ACC1;
2591
            end
2592
          `OC8051_RR : begin
2593
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2594
              src_sel1 <= #1 `OC8051_AS1_ACC;
2595
              src_sel2 <= #1 `OC8051_AS2_DC;
2596
              alu_op <= #1 `OC8051_ALU_RR;
2597
              wr <= #1 1'b0;
2598
              psw_set <= #1 `OC8051_PS_NOT;
2599
              cy_sel <= #1 `OC8051_CY_0;
2600
              src_sel3 <= #1 `OC8051_AS3_DC;
2601
              wr_sfr <= #1 `OC8051_WRS_ACC1;
2602
            end
2603
          `OC8051_RRC : begin
2604
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2605
              src_sel1 <= #1 `OC8051_AS1_ACC;
2606
              src_sel2 <= #1 `OC8051_AS2_DC;
2607
              alu_op <= #1 `OC8051_ALU_RRC;
2608
              wr <= #1 1'b0;
2609
              psw_set <= #1 `OC8051_PS_CY;
2610
              cy_sel <= #1 `OC8051_CY_PSW;
2611
              src_sel3 <= #1 `OC8051_AS3_DC;
2612
              wr_sfr <= #1 `OC8051_WRS_ACC1;
2613
            end
2614
          `OC8051_SETB_C : begin
2615
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2616
              src_sel1 <= #1 `OC8051_AS1_DC;
2617
              src_sel2 <= #1 `OC8051_AS2_DC;
2618
              alu_op <= #1 `OC8051_ALU_NOP;
2619
              wr <= #1 1'b0;
2620
              psw_set <= #1 `OC8051_PS_CY;
2621
              cy_sel <= #1 `OC8051_CY_1;
2622
              src_sel3 <= #1 `OC8051_AS3_PC;
2623
              wr_sfr <= #1 `OC8051_WRS_N;
2624
            end
2625
          `OC8051_SETB_B : begin
2626
              ram_wr_sel <= #1 `OC8051_RWS_D;
2627
              src_sel1 <= #1 `OC8051_AS1_DC;
2628
              src_sel2 <= #1 `OC8051_AS2_DC;
2629
              alu_op <= #1 `OC8051_ALU_NOP;
2630
              wr <= #1 1'b1;
2631
              psw_set <= #1 `OC8051_PS_NOT;
2632
              cy_sel <= #1 `OC8051_CY_1;
2633
              src_sel3 <= #1 `OC8051_AS3_PC;
2634
              wr_sfr <= #1 `OC8051_WRS_N;
2635
            end
2636
          `OC8051_SJMP : begin
2637
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2638
              src_sel1 <= #1 `OC8051_AS1_DC;
2639
              src_sel2 <= #1 `OC8051_AS2_DC;
2640
              alu_op <= #1 `OC8051_ALU_NOP;
2641
              wr <= #1 1'b0;
2642
              psw_set <= #1 `OC8051_PS_NOT;
2643
              cy_sel <= #1 `OC8051_CY_0;
2644
              src_sel3 <= #1 `OC8051_AS3_PC;
2645
              wr_sfr <= #1 `OC8051_WRS_N;
2646
            end
2647
          `OC8051_SUBB_D : begin
2648
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2649
              src_sel1 <= #1 `OC8051_AS1_ACC;
2650
              src_sel2 <= #1 `OC8051_AS2_RAM;
2651
              alu_op <= #1 `OC8051_ALU_SUB;
2652
              wr <= #1 1'b0;
2653
              psw_set <= #1 `OC8051_PS_AC;
2654
              cy_sel <= #1 `OC8051_CY_PSW;
2655
              src_sel3 <= #1 `OC8051_AS3_DC;
2656
              wr_sfr <= #1 `OC8051_WRS_ACC1;
2657
            end
2658
          `OC8051_SUBB_C : begin
2659
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2660
              src_sel1 <= #1 `OC8051_AS1_ACC;
2661
              src_sel2 <= #1 `OC8051_AS2_OP2;
2662
              alu_op <= #1 `OC8051_ALU_SUB;
2663
              wr <= #1 1'b0;
2664
              psw_set <= #1 `OC8051_PS_AC;
2665
              cy_sel <= #1 `OC8051_CY_PSW;
2666
              src_sel3 <= #1 `OC8051_AS3_DC;
2667
              wr_sfr <= #1 `OC8051_WRS_ACC1;
2668
            end
2669
          `OC8051_SWAP : begin
2670
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2671
              src_sel1 <= #1 `OC8051_AS1_ACC;
2672
              src_sel2 <= #1 `OC8051_AS2_DC;
2673
              alu_op <= #1 `OC8051_ALU_RLC;
2674
              wr <= #1 1'b0;
2675
              psw_set <= #1 `OC8051_PS_NOT;
2676
              cy_sel <= #1 `OC8051_CY_0;
2677
              src_sel3 <= #1 `OC8051_AS3_DC;
2678
              wr_sfr <= #1 `OC8051_WRS_ACC2;
2679
            end
2680
          `OC8051_XCH_D : begin
2681
              ram_wr_sel <= #1 `OC8051_RWS_D;
2682
              src_sel1 <= #1 `OC8051_AS1_RAM;
2683
              src_sel2 <= #1 `OC8051_AS2_ACC;
2684
              alu_op <= #1 `OC8051_ALU_XCH;
2685
              wr <= #1 1'b1;
2686
              psw_set <= #1 `OC8051_PS_NOT;
2687
              cy_sel <= #1 `OC8051_CY_1;
2688
              src_sel3 <= #1 `OC8051_AS3_DC;
2689
              wr_sfr <= #1 `OC8051_WRS_ACC2;
2690
            end
2691
          `OC8051_XRL_D : begin
2692
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2693
              src_sel1 <= #1 `OC8051_AS1_RAM;
2694
              src_sel2 <= #1 `OC8051_AS2_ACC;
2695
              alu_op <= #1 `OC8051_ALU_XOR;
2696
              wr <= #1 1'b0;
2697
              psw_set <= #1 `OC8051_PS_NOT;
2698
              cy_sel <= #1 `OC8051_CY_0;
2699
              src_sel3 <= #1 `OC8051_AS3_DC;
2700
              wr_sfr <= #1 `OC8051_WRS_ACC1;
2701
            end
2702
          `OC8051_XRL_C : begin
2703
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2704
              src_sel1 <= #1 `OC8051_AS1_OP2;
2705
              src_sel2 <= #1 `OC8051_AS2_ACC;
2706
              alu_op <= #1 `OC8051_ALU_XOR;
2707
              wr <= #1 1'b0;
2708
              psw_set <= #1 `OC8051_PS_NOT;
2709
              cy_sel <= #1 `OC8051_CY_0;
2710
              src_sel3 <= #1 `OC8051_AS3_DC;
2711
              wr_sfr <= #1 `OC8051_WRS_ACC1;
2712
            end
2713
          `OC8051_XRL_AD : begin
2714
              ram_wr_sel <= #1 `OC8051_RWS_D;
2715
              src_sel1 <= #1 `OC8051_AS1_RAM;
2716
              src_sel2 <= #1 `OC8051_AS2_ACC;
2717
              alu_op <= #1 `OC8051_ALU_XOR;
2718
              wr <= #1 1'b1;
2719
              psw_set <= #1 `OC8051_PS_NOT;
2720
              cy_sel <= #1 `OC8051_CY_0;
2721
              src_sel3 <= #1 `OC8051_AS3_DC;
2722
              wr_sfr <= #1 `OC8051_WRS_N;
2723
            end
2724
          `OC8051_XRL_CD : begin
2725
              ram_wr_sel <= #1 `OC8051_RWS_D;
2726
              src_sel1 <= #1 `OC8051_AS1_OP3;
2727
              src_sel2 <= #1 `OC8051_AS2_RAM;
2728
              alu_op <= #1 `OC8051_ALU_XOR;
2729
              wr <= #1 1'b1;
2730
              psw_set <= #1 `OC8051_PS_NOT;
2731
              cy_sel <= #1 `OC8051_CY_0;
2732
              src_sel3 <= #1 `OC8051_AS3_DC;
2733
              wr_sfr <= #1 `OC8051_WRS_N;
2734
            end
2735
          default: begin
2736
              ram_wr_sel <= #1 `OC8051_RWS_DC;
2737
              src_sel1 <= #1 `OC8051_AS1_DC;
2738
              src_sel2 <= #1 `OC8051_AS2_DC;
2739
              alu_op <= #1 `OC8051_ALU_NOP;
2740
              wr <= #1 1'b0;
2741
              psw_set <= #1 `OC8051_PS_NOT;
2742
              cy_sel <= #1 `OC8051_CY_0;
2743
              src_sel3 <= #1 `OC8051_AS3_DC;
2744
              wr_sfr <= #1 `OC8051_WRS_N;
2745
           end
2746
        endcase
2747
      end
2748
      endcase
2749
  end
2750
end
2751
 
2752
 
2753
//
2754
// remember current instruction
2755
always @(posedge clk or posedge rst)
2756
  if (rst) op <= #1 2'b00;
2757
  else if (state==2'b00) op <= #1 op_in;
2758
 
2759
//
2760
// in case of instructions that needs more than one clock set state
2761
always @(posedge clk or posedge rst)
2762
begin
2763
  if (rst)
2764
    state <= #1 2'b11;
2765
  else if  (!mem_wait & !wait_data) begin
2766
    case (state) /* synopsys parallel_case */
2767
      2'b10: state <= #1 2'b01;
2768
      2'b11: state <= #1 2'b10;
2769
      2'b00:
2770
          casex (op_in) /* synopsys full_case parallel_case */
2771
            `OC8051_ACALL   : state <= #1 2'b10;
2772
            `OC8051_AJMP    : state <= #1 2'b10;
2773
            `OC8051_CJNE_R  : state <= #1 2'b10;
2774
            `OC8051_CJNE_I  : state <= #1 2'b10;
2775
            `OC8051_CJNE_D  : state <= #1 2'b10;
2776
            `OC8051_CJNE_C  : state <= #1 2'b10;
2777
            `OC8051_LJMP    : state <= #1 2'b10;
2778
            `OC8051_DJNZ_R  : state <= #1 2'b10;
2779
            `OC8051_DJNZ_D  : state <= #1 2'b10;
2780
            `OC8051_LCALL   : state <= #1 2'b10;
2781
            `OC8051_MOVC_DP : state <= #1 2'b11;
2782
            `OC8051_MOVC_PC : state <= #1 2'b11;
2783
            `OC8051_MOVX_IA : state <= #1 2'b10;
2784
            `OC8051_MOVX_AI : state <= #1 2'b10;
2785
            `OC8051_MOVX_PA : state <= #1 2'b10;
2786
            `OC8051_MOVX_AP : state <= #1 2'b10;
2787
            `OC8051_RET     : state <= #1 2'b11;
2788
            `OC8051_RETI    : state <= #1 2'b11;
2789
            `OC8051_SJMP    : state <= #1 2'b10;
2790
            `OC8051_JB      : state <= #1 2'b10;
2791
            `OC8051_JBC     : state <= #1 2'b10;
2792
            `OC8051_JC      : state <= #1 2'b10;
2793
            `OC8051_JMP_D   : state <= #1 2'b10;
2794
            `OC8051_JNC     : state <= #1 2'b10;
2795
            `OC8051_JNB     : state <= #1 2'b10;
2796
            `OC8051_JNZ     : state <= #1 2'b10;
2797
            `OC8051_JZ      : state <= #1 2'b10;
2798
            `OC8051_DIV     : state <= #1 2'b11;
2799
            `OC8051_MUL     : state <= #1 2'b11;
2800
//            default         : state <= #1 2'b00;
2801
          endcase
2802
      default: state <= #1 2'b00;
2803
    endcase
2804
  end
2805
end
2806
 
2807
 
2808
//
2809
//in case of writing to external ram
2810
always @(posedge clk or posedge rst)
2811
begin
2812
  if (rst) begin
2813
    mem_act <= #1 `OC8051_MAS_NO;
2814
  end else if (!rd) begin
2815
    mem_act <= #1 `OC8051_MAS_NO;
2816
  end else
2817
    casex (op_cur) /* synopsys parallel_case */
2818
      `OC8051_MOVX_AI : mem_act <= #1 `OC8051_MAS_RI_W;
2819
      `OC8051_MOVX_AP : mem_act <= #1 `OC8051_MAS_DPTR_W;
2820
      `OC8051_MOVX_IA : mem_act <= #1 `OC8051_MAS_RI_R;
2821
      `OC8051_MOVX_PA : mem_act <= #1 `OC8051_MAS_DPTR_R;
2822
      `OC8051_MOVC_DP : mem_act <= #1 `OC8051_MAS_CODE;
2823
      `OC8051_MOVC_PC : mem_act <= #1 `OC8051_MAS_CODE;
2824
      default : mem_act <= #1 `OC8051_MAS_NO;
2825
    endcase
2826
end
2827
 
2828
always @(posedge clk or posedge rst)
2829
begin
2830
  if (rst) begin
2831
    ram_rd_sel_r <= #1 3'h0;
2832
  end else begin
2833
    ram_rd_sel_r <= #1 ram_rd_sel;
2834
  end
2835
end
2836
 
2837
 
2838
 
2839
`ifdef OC8051_SIMULATION
2840
always @(op_cur)
2841
  if (op_cur===8'hxx) begin
2842
    $display("%m:%0tns faulire: invalid instruction (oc8051_decoder)",$time);
2843
#22
2844
    $finish;
2845
 
2846
  end
2847
 
2848
`endif
2849
 
2850
 
2851
 
2852
 
2853
endmodule
2854
 
2855
 

powered by: WebSVN 2.1.0

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