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

Subversion Repositories 8051

[/] [8051/] [tags/] [rel_12/] [rtl/] [verilog/] [oc8051_decoder.v] - Blame information for rev 139

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

powered by: WebSVN 2.1.0

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