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

Subversion Repositories 8051

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

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

powered by: WebSVN 2.1.0

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