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

Subversion Repositories 8051

[/] [8051/] [tags/] [rel_1/] [rtl/] [verilog/] [oc8051_decoder.v] - Blame information for rev 186

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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