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

Subversion Repositories 8051

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

powered by: WebSVN 2.1.0

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