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

Subversion Repositories turbo8051

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

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

powered by: WebSVN 2.1.0

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