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

Subversion Repositories 8051

[/] [8051/] [trunk/] [rtl/] [verilog/] [oc8051_decoder.v] - Blame information for rev 82

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

powered by: WebSVN 2.1.0

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