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

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_47/] [or1ksim/] [cpu/] [or32/] [insnset.c] - Blame information for rev 997

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 706 markom
/* execute.c -- Instruction specific functions.
2
   Copyright (C) 1999 Damjan Lampret, lampret@opencores.org
3
                 2000-2002 Marko Mlinar, markom@opencores.org
4
 
5
This file is part of OpenRISC 1000 Architectural Simulator.
6
 
7
This program is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation; either version 2 of the License, or
10
(at your option) any later version.
11
 
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
GNU General Public License for more details.
16
 
17
You should have received a copy of the GNU General Public License
18
along with this program; if not, write to the Free Software
19
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
20
 
21
INSTRUCTION (l_add) {
22
  signed long temp1;
23
  signed char temp4;
24
 
25 713 markom
  IFF (config.cpu.dependstats) current->func_unit = it_arith;
26 706 markom
  temp1 = (signed long)eval_operand32(2, &breakpoint)+(signed long)eval_operand32(1, &breakpoint);
27
  set_operand32(0, temp1, &breakpoint);
28
  set_ov_flag (temp1);
29
  if (ARITH_SET_FLAG) {
30
    flag = temp1 == 0;
31
    setsprbits(SPR_SR, SPR_SR_F, flag);
32
  }
33
 
34
  temp4 = temp1;
35
  if (temp4 == temp1)
36
    mstats.byteadd++;
37
}
38
INSTRUCTION (l_sw) {
39
  int old_cyc = 0;
40 713 markom
  IFF (config.cpu.dependstats) current->func_unit = it_store;
41 884 markom
  IFF (config.cpu.sbuf_len) old_cyc = runtime.sim.mem_cycles;
42 706 markom
  set_operand32(0, eval_operand32(1, &breakpoint), &breakpoint);
43
  if (config.cpu.sbuf_len) {
44 884 markom
    int t = runtime.sim.mem_cycles;
45
    runtime.sim.mem_cycles = old_cyc;
46 706 markom
    sbuf_store (t - old_cyc);
47
  }
48
}
49
INSTRUCTION (l_sb) {
50
  int old_cyc = 0;
51 713 markom
  IFF (config.cpu.dependstats) current->func_unit = it_store;
52 884 markom
  IFF (config.cpu.sbuf_len) old_cyc = runtime.sim.mem_cycles;
53 706 markom
  set_operand8(0, eval_operand32(1, &breakpoint), &breakpoint);
54
  if (config.cpu.sbuf_len) {
55 884 markom
    int t = runtime.sim.mem_cycles;
56
    runtime.sim.mem_cycles = old_cyc;
57 706 markom
    sbuf_store (t- old_cyc);
58
  }
59
}
60
INSTRUCTION (l_sh) {
61
  int old_cyc = 0;
62 713 markom
  IFF (config.cpu.dependstats) current->func_unit = it_store;
63 884 markom
  IFF (config.cpu.sbuf_len) old_cyc = runtime.sim.mem_cycles;
64 706 markom
  set_operand16(0, eval_operand32(1, &breakpoint), &breakpoint);
65
  if (config.cpu.sbuf_len) {
66 884 markom
    int t = runtime.sim.mem_cycles;
67
    runtime.sim.mem_cycles = old_cyc;
68 706 markom
    sbuf_store (t - old_cyc);
69
  }
70
}
71
INSTRUCTION (l_lwz) {
72
  unsigned long val;
73 713 markom
  IFF (config.cpu.dependstats) current->func_unit = it_load;
74 706 markom
  if (config.cpu.sbuf_len) sbuf_load ();
75
  val = eval_operand32(1, &breakpoint);
76
  /* If eval operand produced exception don't set anything */
77
  if (!pending.valid)
78
    set_operand32(0, val, &breakpoint);
79
}
80
INSTRUCTION (l_lbs) {
81
  signed char val;
82 713 markom
  IFF (config.cpu.dependstats) current->func_unit = it_load;
83 706 markom
  if (config.cpu.sbuf_len) sbuf_load ();
84
  val = eval_operand8(1, &breakpoint);
85
  /* If eval opreand produced exception don't set anything */
86
  if (!pending.valid)
87
    set_operand32(0, val, &breakpoint);
88
}
89
INSTRUCTION (l_lbz) {
90
  unsigned char val;
91 713 markom
  IFF (config.cpu.dependstats) current->func_unit = it_load;
92 706 markom
  if (config.cpu.sbuf_len) sbuf_load ();
93
  val = eval_operand8(1, &breakpoint);
94
  /* If eval opreand produced exception don't set anything */
95
  if (!pending.valid)
96
    set_operand32(0, val, &breakpoint);
97
}
98
INSTRUCTION (l_lhs) {
99
  signed short val;
100 713 markom
  IFF (config.cpu.dependstats) current->func_unit = it_load;
101 706 markom
  if (config.cpu.sbuf_len) sbuf_load ();
102
  val = eval_operand16(1, &breakpoint);
103
  /* If eval opreand produced exception don't set anything */
104
  if (!pending.valid)
105
    set_operand32(0, val, &breakpoint);
106
}
107
INSTRUCTION (l_lhz) {
108
  unsigned short val;
109 713 markom
  IFF (config.cpu.dependstats) current->func_unit = it_load;
110 706 markom
  if (config.cpu.sbuf_len) sbuf_load ();
111
  val = eval_operand16(1, &breakpoint);
112
  /* If eval opreand produced exception don't set anything */
113
  if (!pending.valid)
114
    set_operand32(0, val, &breakpoint);
115
}
116
INSTRUCTION (l_movhi) {
117 713 markom
  IFF (config.cpu.dependstats) current->func_unit = it_movimm;
118 706 markom
  set_operand32(0, eval_operand32(1, &breakpoint) << 16, &breakpoint);
119
}
120
INSTRUCTION (l_and) {
121
  unsigned long temp1;
122 713 markom
  IFF (config.cpu.dependstats) current->func_unit = it_arith;
123 706 markom
  set_operand32(0, temp1 = set_ov_flag (eval_operand32(1, &breakpoint) & (unsigned)eval_operand32(2, &breakpoint)), &breakpoint);
124
  if (ARITH_SET_FLAG) {
125
    flag = temp1 == 0;
126
    setsprbits(SPR_SR, SPR_SR_F, flag);
127
  }
128
}
129
INSTRUCTION (l_or) {
130 713 markom
  IFF (config.cpu.dependstats) current->func_unit = it_arith;
131 706 markom
  set_operand32(0, set_ov_flag (eval_operand32(1, &breakpoint) | (unsigned)eval_operand32(2, &breakpoint)), &breakpoint);
132
}
133
INSTRUCTION (l_xor) {
134 713 markom
  IFF (config.cpu.dependstats) current->func_unit = it_arith;
135 706 markom
  set_operand32(0, set_ov_flag (eval_operand32(1, &breakpoint) ^ (signed)eval_operand32(2, &breakpoint)), &breakpoint);
136
}
137
INSTRUCTION (l_sub) {
138 713 markom
  IFF (config.cpu.dependstats) current->func_unit = it_arith;
139 706 markom
  set_operand32(0, set_ov_flag ((signed long)eval_operand32(1, &breakpoint) - (signed long)eval_operand32(2, &breakpoint)), &breakpoint);
140
}
141
/*int mcount = 0;*/
142
INSTRUCTION (l_mul) {
143
  signed long temp3, temp2, temp1;
144
 
145 713 markom
  IFF (config.cpu.dependstats) current->func_unit = it_arith;
146 706 markom
  set_operand32(0, set_ov_flag ((signed long)eval_operand32(1, &breakpoint) * (signed long)eval_operand32(2, &breakpoint)), &breakpoint);
147
  /*if (!(mcount++ & 1023)) {
148 997 markom
    PRINTF ("[%i]\n",mcount);
149 706 markom
    }*/
150
}
151
INSTRUCTION (l_div) {
152
  signed long temp3, temp2, temp1;
153
 
154 713 markom
  IFF (config.cpu.dependstats) current->func_unit = it_arith;
155 706 markom
  temp3 = eval_operand32(2, &breakpoint);
156
  temp2 = eval_operand32(1, &breakpoint);
157
  if (temp3)
158
    temp1 = temp2 / temp3;
159
  else {
160
    except_handle(EXCEPT_ILLEGAL, iqueue[0].insn_addr);
161
    return;
162
  }
163
  set_operand32(0, set_ov_flag (temp1), &breakpoint);
164
}
165
INSTRUCTION (l_divu) {
166
  unsigned long temp3, temp2, temp1;
167
 
168 713 markom
  IFF (config.cpu.dependstats) current->func_unit = it_arith;
169 706 markom
  temp3 = eval_operand32(2, &breakpoint);
170
  temp2 = eval_operand32(1, &breakpoint);
171
  temp1 = temp2 / temp3;
172 884 markom
  /* runtime.sim.cycles += 16; */
173 706 markom
  set_operand32(0, set_ov_flag (temp1), &breakpoint);
174
}
175
INSTRUCTION (l_sll) {
176
  int sign = 1;
177 713 markom
  IFF (config.cpu.dependstats) current->func_unit = it_shift;
178 706 markom
  if ((signed)eval_operand32(1, &breakpoint) < 0)
179
    sign = -1;
180 884 markom
  /* runtime.sim.cycles += 2; */
181 706 markom
  set_operand32(0, set_ov_flag (eval_operand32(1, &breakpoint) << eval_operand32(2, &breakpoint)), &breakpoint);
182
}
183
INSTRUCTION (l_sra) {
184
  unsigned long sign = 0;
185 713 markom
  IFF (config.cpu.dependstats) current->func_unit = it_shift;
186 706 markom
 
187
  if ((signed)eval_operand32(1, &breakpoint) < 0)
188
    sign = -1;
189 884 markom
  /* runtime.sim.cycles += 2; */
190 706 markom
  set_operand32(0, set_ov_flag ((signed)eval_operand32(1, &breakpoint) >> eval_operand32(2, &breakpoint)), &breakpoint);
191
}
192
INSTRUCTION (l_srl) {
193 713 markom
  IFF (config.cpu.dependstats) current->func_unit = it_shift;
194 884 markom
  /* runtime.sim.cycles += 2; */
195 706 markom
  set_operand32(0, set_ov_flag (eval_operand32(1, &breakpoint) >> eval_operand32(2, &breakpoint)), &breakpoint);
196
}
197
INSTRUCTION (l_bf) {
198
  if (config.bpb.enabled) {
199
    int fwd = (eval_operand32(0, &breakpoint) >= pc) ? 1 : 0;
200 713 markom
    IFF (config.cpu.dependstats) current->func_unit = it_branch;
201 706 markom
    mstats.bf[flag][fwd]++;
202 713 markom
    bpb_update(current->insn_addr, flag);
203 706 markom
  }
204
  if (flag) {
205
    pcdelay = pc + (signed)eval_operand32(0, &breakpoint) * 4;
206
    btic_update(pcnext);
207
    next_delay_insn = 1;
208
  } else {
209
    btic_update(pc);
210
  }
211
}
212
INSTRUCTION (l_bnf) {
213
  if (config.bpb.enabled) {
214
    int fwd = (eval_operand32(0, &breakpoint) >= pc) ? 1 : 0;
215 713 markom
    IFF (config.cpu.dependstats) current->func_unit = it_branch;
216 706 markom
    mstats.bnf[!flag][fwd]++;
217 713 markom
    bpb_update(current->insn_addr, flag == 0);
218 706 markom
  }
219
  if (flag == 0) {
220
    pcdelay = pc + (signed)eval_operand32(0, &breakpoint) * 4;
221
    btic_update(pcnext);
222
    next_delay_insn = 1;
223
  } else {
224
    btic_update(pc);
225
  }
226
}
227
INSTRUCTION (l_j) {
228
  pcdelay = pc + (signed)eval_operand32(0, &breakpoint) * 4;
229 713 markom
  IFF (config.cpu.dependstats) current->func_unit = it_jump;
230 706 markom
  next_delay_insn = 1;
231
}
232
INSTRUCTION (l_jal) {
233
  pcdelay = pc + (signed)eval_operand32(0, &breakpoint) * 4;
234
 
235 713 markom
  IFF (config.cpu.dependstats) current->func_unit = it_jump;
236 706 markom
  set_reg32(LINK_REGNO, pc + 8);
237
  next_delay_insn = 1;
238
  if (config.sim.profile) {
239
    struct mem_entry *entry;
240
    struct label_entry *tmp;
241
    if (verify_memoryarea(pcdelay) && (tmp = get_label (pcdelay)))
242 884 markom
      fprintf (runtime.sim.fprof, "+%08X %08X %08X %s\n", runtime.sim.cycles, pc + 8, pcdelay, tmp->name);
243 706 markom
    else
244 884 markom
      fprintf (runtime.sim.fprof, "+%08X %08X %08X @%08X\n", runtime.sim.cycles, pc + 8, pcdelay, pcdelay);
245 706 markom
  }
246
}
247
INSTRUCTION (l_jalr) {
248 713 markom
  IFF (config.cpu.dependstats) current->func_unit = it_jump;
249 706 markom
  pcdelay = eval_operand32(0, &breakpoint);
250
  set_reg32(LINK_REGNO, pc + 8);
251
  next_delay_insn = 1;
252
}
253
INSTRUCTION (l_jr) {
254 713 markom
  IFF (config.cpu.dependstats) current->func_unit = it_jump;
255 706 markom
  pcdelay = eval_operand32(0, &breakpoint);
256
  next_delay_insn = 1;
257
  if (config.sim.profile)
258 884 markom
    fprintf (runtime.sim.fprof, "-%08X %08X\n", runtime.sim.cycles, pcdelay);
259 706 markom
}
260
INSTRUCTION (l_rfe) {
261 713 markom
  IFF (config.cpu.dependstats) current->func_unit = it_exception;
262 706 markom
  pcnext = mfspr(SPR_EPCR_BASE);
263
  mtspr(SPR_SR, mfspr(SPR_ESR_BASE));
264
}
265
INSTRUCTION (l_nop) {
266
  unsigned long stackaddr;
267
  int k = eval_operand32(0, &breakpoint);
268 713 markom
  IFF (config.cpu.dependstats) current->func_unit = it_nop;
269 706 markom
  switch (k) {
270
    case NOP_NOP:
271
      break;
272
    case NOP_EXIT:
273 997 markom
      PRINTF("exit(%d)\n", evalsim_reg32 (3));
274 706 markom
      if (config.debug.gdb_enabled)
275
        set_stall_state (1);
276
      else
277 884 markom
        runtime.sim.cont_run = 0;
278 706 markom
      break;
279
    case NOP_PRINTF:
280
      stackaddr = evalsim_reg32(4);
281
      simprintf(stackaddr, evalsim_reg32(3));
282
      debug(5, "simprintf %x\n", stackaddr);
283
      break;
284
    case NOP_REPORT:
285 997 markom
      PRINTF("report(0x%x);\n", evalsim_reg32(3));
286 706 markom
    default:
287
      if (k >= NOP_REPORT_FIRST && k <= NOP_REPORT_LAST)
288 997 markom
      PRINTF("report %i (0x%x);\n", k - NOP_REPORT_FIRST, evalsim_reg32(3));
289 706 markom
      break;
290
  }
291
}
292
INSTRUCTION (l_sfeq) {
293 713 markom
  IFF (config.cpu.dependstats) current->func_unit = it_compare;
294 706 markom
  flag = eval_operand32(0, &breakpoint) == eval_operand32(1, &breakpoint);
295
  setsprbits(SPR_SR, SPR_SR_F, flag);
296
}
297
INSTRUCTION (l_sfne) {
298 713 markom
  IFF (config.cpu.dependstats) current->func_unit = it_compare;
299 706 markom
  flag = eval_operand32(0, &breakpoint) != eval_operand32(1, &breakpoint);
300
  setsprbits(SPR_SR, SPR_SR_F, flag);
301
}
302
INSTRUCTION (l_sfgts) {
303 713 markom
  IFF (config.cpu.dependstats) current->func_unit = it_compare;
304 706 markom
  flag = (signed)eval_operand32(0, &breakpoint) > (signed)eval_operand32(1, &breakpoint);
305
  setsprbits(SPR_SR, SPR_SR_F, flag);
306
}
307
INSTRUCTION (l_sfges) {
308 713 markom
  IFF (config.cpu.dependstats) current->func_unit = it_compare;
309 706 markom
  flag = (signed)eval_operand32(0, &breakpoint) >= (signed)eval_operand32(1, &breakpoint);
310
  setsprbits(SPR_SR, SPR_SR_F, flag);
311
}
312
INSTRUCTION (l_sflts) {
313 713 markom
  IFF (config.cpu.dependstats) current->func_unit = it_compare;
314 706 markom
  flag = (signed)eval_operand32(0, &breakpoint) < (signed)eval_operand32(1, &breakpoint);
315
  setsprbits(SPR_SR, SPR_SR_F, flag);
316
}
317
INSTRUCTION (l_sfles) {
318 713 markom
  IFF (config.cpu.dependstats) current->func_unit = it_compare;
319 706 markom
  flag = (signed)eval_operand32(0, &breakpoint) <= (signed)eval_operand32(1, &breakpoint);
320
  setsprbits(SPR_SR, SPR_SR_F, flag);
321
}
322
INSTRUCTION (l_sfgtu) {
323 713 markom
  IFF (config.cpu.dependstats) current->func_unit = it_compare;
324 706 markom
  flag = (unsigned)eval_operand32(0, &breakpoint) > (unsigned)eval_operand32(1, &breakpoint);
325
  setsprbits(SPR_SR, SPR_SR_F, flag);
326
}
327
INSTRUCTION (l_sfgeu) {
328 713 markom
  IFF (config.cpu.dependstats) current->func_unit = it_compare;
329 706 markom
  flag = (unsigned)eval_operand32(0, &breakpoint) >= (unsigned) eval_operand32(1, &breakpoint);
330
  setsprbits(SPR_SR, SPR_SR_F, flag);
331
}
332
INSTRUCTION (l_sfltu) {
333 713 markom
  IFF (config.cpu.dependstats) current->func_unit = it_compare;
334 706 markom
  flag = (unsigned)eval_operand32(0, &breakpoint) < (unsigned)eval_operand32(1, &breakpoint);
335
  setsprbits(SPR_SR, SPR_SR_F, flag);
336
}
337
INSTRUCTION (l_sfleu) {
338 713 markom
  IFF (config.cpu.dependstats) current->func_unit = it_compare;
339 706 markom
  flag = (unsigned)eval_operand32(0, &breakpoint) <= (unsigned)eval_operand32(1, &breakpoint);
340
  setsprbits(SPR_SR, SPR_SR_F, flag);
341
}
342
INSTRUCTION (l_extbs) {
343
  unsigned char x;
344 713 markom
  IFF (config.cpu.dependstats) current->func_unit = it_move;
345 706 markom
  x = eval_operand32(1, &breakpoint);
346
  set_operand32(0, (signed long)x, &breakpoint);
347
}
348
INSTRUCTION (l_extbz) {
349
  unsigned char x;
350 713 markom
  IFF (config.cpu.dependstats) current->func_unit = it_move;
351 706 markom
  x = eval_operand32(1, &breakpoint);
352
  set_operand32(0, (unsigned long)x, &breakpoint);
353
}
354
INSTRUCTION (l_exths) {
355
  unsigned short x;
356 713 markom
  IFF (config.cpu.dependstats) current->func_unit = it_move;
357 706 markom
  x = eval_operand32(1, &breakpoint);
358
  set_operand32(0, (signed long)x, &breakpoint);
359
}
360
INSTRUCTION (l_exthz) {
361
  unsigned short x;
362 713 markom
  IFF (config.cpu.dependstats) current->func_unit = it_move;
363 706 markom
  x = eval_operand32(1, &breakpoint);
364
  set_operand32(0, (unsigned long)x, &breakpoint);
365
}
366
INSTRUCTION (l_extws) {
367
  unsigned int x;
368 713 markom
  IFF (config.cpu.dependstats) current->func_unit = it_move;
369 706 markom
  x = eval_operand32(1, &breakpoint);
370
  set_operand32(0, (signed long)x, &breakpoint);
371
}
372
INSTRUCTION (l_extwz) {
373
  unsigned int x;
374 713 markom
  IFF (config.cpu.dependstats) current->func_unit = it_move;
375 706 markom
  x = eval_operand32(1, &breakpoint);
376
  set_operand32(0, (unsigned long)x, &breakpoint);
377
}
378
INSTRUCTION (l_mtspr) {
379
  unsigned long regno = eval_operand32(0, &breakpoint) + eval_operand32(2, &breakpoint);
380
  unsigned long value = eval_operand32(1, &breakpoint);
381
 
382
  if (runtime.sim.fspr_log) {
383
    fprintf(runtime.sim.fspr_log, "Write to SPR  : [%08lX] <- [%08lX]\n", regno, value);
384
  }
385
 
386 713 markom
  IFF (config.cpu.dependstats) current->func_unit = it_move;
387 706 markom
  if (mfspr(SPR_SR) & SPR_SR_SM)
388
    mtspr(regno, value);
389
  else {
390 997 markom
    PRINTF("WARNING: trying to write SPR while SR[SUPV] is cleared.\n");
391 884 markom
    runtime.sim.cont_run = 0;
392 706 markom
  }
393
}
394
INSTRUCTION (l_mfspr) {
395
  unsigned long regno = eval_operand32(1, &breakpoint) + eval_operand32(2, &breakpoint);
396
  unsigned long value = mfspr(regno);
397
 
398
  if (runtime.sim.fspr_log) {
399
    fprintf(runtime.sim.fspr_log, "Read from SPR : [%08lX] -> [%08lX]\n", regno, value);
400
  }
401
 
402 713 markom
  IFF (config.cpu.dependstats) current->func_unit = it_move;
403 706 markom
  if (mfspr(SPR_SR) & SPR_SR_SM)
404
    set_operand32(0, value, &breakpoint);
405
  else {
406
    set_operand32(0, 0, &breakpoint);
407 997 markom
    PRINTF("WARNING: trying to read SPR while SR[SUPV] is cleared.\n");
408 884 markom
    runtime.sim.cont_run = 0;
409 706 markom
  }
410
}
411
INSTRUCTION (l_sys) {
412
  except_handle(EXCEPT_SYSCALL, mfspr(SPR_EEAR_BASE));
413
}
414
INSTRUCTION (l_trap) {
415
  /* TODO: some SR related code here! */
416
  except_handle(EXCEPT_TRAP, mfspr(SPR_EEAR_BASE));
417
}
418
INSTRUCTION (l_mac) {
419
  sprword lo, hi;
420
  LONGEST l;
421
  long x, y;
422 713 markom
  IFF (config.cpu.dependstats) current->func_unit = it_mac;
423 706 markom
  lo = mfspr (SPR_MACLO);
424
  hi = mfspr (SPR_MACHI);
425
  x = eval_operand32(0, &breakpoint);
426
  y = eval_operand32(1, &breakpoint);
427 997 markom
  PRINTF ("[%08x,%08x]\t", (unsigned long)(x), (unsigned long)(y));
428 706 markom
  l = (ULONGEST)lo | ((LONGEST)hi << 32);
429
  l += (LONGEST) x * (LONGEST) y;
430
 
431
  /* This implementation is very fast - it needs only one cycle for mac.  */
432
  lo = ((ULONGEST)l) & 0xFFFFFFFF;
433
  hi = ((LONGEST)l) >> 32;
434
  mtspr (SPR_MACLO, lo);
435
  mtspr (SPR_MACHI, hi);
436 997 markom
  PRINTF ("(%08x,%08x)\n", hi, lo);
437 706 markom
}
438
INSTRUCTION (l_msb) {
439
  sprword lo, hi;
440
  LONGEST l;
441
  long x, y;
442 713 markom
  IFF (config.cpu.dependstats) current->func_unit = it_mac;
443 706 markom
  lo = mfspr (SPR_MACLO);
444
  hi = mfspr (SPR_MACHI);
445
  x = eval_operand32(0, &breakpoint);
446
  y = eval_operand32(1, &breakpoint);
447 997 markom
  PRINTF ("[%08x,%08x]\t", (unsigned long)(x), (unsigned long)(y));
448 706 markom
  l = (ULONGEST)lo | ((LONGEST)hi << 32);
449
  l -= (LONGEST) eval_operand32(0, &breakpoint) * (LONGEST)eval_operand32(1, &breakpoint);
450
 
451
  /* This implementation is very fast - it needs only one cycle for msb.  */
452
  lo = ((ULONGEST)l) & 0xFFFFFFFF;
453
  hi = ((LONGEST)l) >> 32;
454
  mtspr (SPR_MACLO, lo);
455
  mtspr (SPR_MACHI, hi);
456 997 markom
  PRINTF ("(%08x,%08x)\n", hi, lo);
457 706 markom
}
458
INSTRUCTION (l_macrc) {
459
  sprword lo, hi;
460
  LONGEST l;
461 713 markom
  IFF (config.cpu.dependstats) current->func_unit = it_mac;
462 706 markom
  /* No need for synchronization here -- all MAC instructions are 1 cycle long.  */
463
  lo =  mfspr (SPR_MACLO);
464
  hi =  mfspr (SPR_MACHI);
465
  l = (ULONGEST) lo | ((LONGEST)hi << 32);
466
  l >>= 28;
467 997 markom
  //PRINTF ("<%08x>\n", (unsigned long)l);
468 706 markom
  set_operand32(0, (long)l, &breakpoint);
469
  mtspr (SPR_MACLO, 0);
470
  mtspr (SPR_MACHI, 0);
471
}
472
INSTRUCTION (l_cmov) {
473 713 markom
  IFF (config.cpu.dependstats) current->func_unit = it_move;
474 712 markom
  set_operand32(0, flag ? eval_operand32(1, &breakpoint) : eval_operand32(2, &breakpoint), &breakpoint);
475 706 markom
}
476 720 markom
/******* Floating point instructions *******/
477
/* Single precision */
478
INSTRUCTION (lf_add_s) {
479
  IFF (config.cpu.dependstats) current->func_unit = it_float;
480 722 markom
  set_operand32(0, (machword)((float)eval_operand32(1, &breakpoint) + (float)eval_operand32(2, &breakpoint)), &breakpoint);
481 720 markom
}
482
INSTRUCTION (lf_div_s) {
483
  IFF (config.cpu.dependstats) current->func_unit = it_float;
484 722 markom
  set_operand32(0, (machword)((float)eval_operand32(1, &breakpoint) / (float)eval_operand32(2, &breakpoint)), &breakpoint);
485 720 markom
}
486 722 markom
/*INSTRUCTION (lf_ftoi_s) {
487 720 markom
  IFF (config.cpu.dependstats) current->func_unit = it_float;
488
  set_operand32(0, freg[get_operand(1)], &breakpoint);
489
}
490
INSTRUCTION (lf_itof_s) {
491
  IFF (config.cpu.dependstats) current->func_unit = it_float;
492
  freg[get_operand(0)] = eval_operand32(1, &breakpoint);
493 722 markom
}*/
494 720 markom
INSTRUCTION (lf_madd_s) {
495
  IFF (config.cpu.dependstats) current->func_unit = it_float;
496 722 markom
  set_operand32(0, (machword)((float)eval_operand32(0, &breakpoint) + (float)eval_operand32(1, &breakpoint) * (float)eval_operand32(2, &breakpoint)), &breakpoint);
497 720 markom
}
498
INSTRUCTION (lf_mul_s) {
499
  IFF (config.cpu.dependstats) current->func_unit = it_float;
500 722 markom
  set_operand32(0, (machword)((float)eval_operand32(1, &breakpoint) * (float)eval_operand32(2, &breakpoint)), &breakpoint);
501 720 markom
}
502
INSTRUCTION (lf_rem_s) {
503 722 markom
  float temp = (float)eval_operand32(1, &breakpoint) / (float)eval_operand32(2, &breakpoint);
504 720 markom
  IFF (config.cpu.dependstats) current->func_unit = it_float;
505 722 markom
  set_operand32(0, temp - (machword)temp, &breakpoint);
506 720 markom
}
507
INSTRUCTION (lf_sfeq_s) {
508
  IFF (config.cpu.dependstats) current->func_unit = it_float;
509 722 markom
  flag = (float)eval_operand32(0, &breakpoint) == (float)eval_operand32(1, &breakpoint);
510 720 markom
  setsprbits(SPR_SR, SPR_SR_F, flag);
511
}
512
INSTRUCTION (lf_sfge_s) {
513
  IFF (config.cpu.dependstats) current->func_unit = it_float;
514 722 markom
  flag = (float)eval_operand32(0, &breakpoint) >= (float)eval_operand32(1, &breakpoint);
515 720 markom
  setsprbits(SPR_SR, SPR_SR_F, flag);
516
}
517
INSTRUCTION (lf_sfgt_s) {
518
  IFF (config.cpu.dependstats) current->func_unit = it_float;
519 722 markom
  flag = (float)eval_operand32(0, &breakpoint) > (float)eval_operand32(1, &breakpoint);
520 720 markom
  setsprbits(SPR_SR, SPR_SR_F, flag);
521
}
522
INSTRUCTION (lf_sfle_s) {
523
  IFF (config.cpu.dependstats) current->func_unit = it_float;
524 722 markom
  flag = (float)eval_operand32(0, &breakpoint) <= (float)eval_operand32(1, &breakpoint);
525 720 markom
  setsprbits(SPR_SR, SPR_SR_F, flag);
526
}
527
INSTRUCTION (lf_sflt_s) {
528
  IFF (config.cpu.dependstats) current->func_unit = it_float;
529 722 markom
  flag = (float)eval_operand32(0, &breakpoint) < (float)eval_operand32(1, &breakpoint);
530 720 markom
  setsprbits(SPR_SR, SPR_SR_F, flag);
531
}
532
INSTRUCTION (lf_sfne_s) {
533
  IFF (config.cpu.dependstats) current->func_unit = it_float;
534 722 markom
  flag = (float)eval_operand32(0, &breakpoint) != (float)eval_operand32(1, &breakpoint);
535 720 markom
  setsprbits(SPR_SR, SPR_SR_F, flag);
536
}
537
INSTRUCTION (lf_sub_s) {
538
  IFF (config.cpu.dependstats) current->func_unit = it_float;
539 722 markom
  set_operand32(0, (machword)((float)eval_operand32(1, &breakpoint) - (float)eval_operand32(2, &breakpoint)), &breakpoint);
540 720 markom
}
541
 
542
/******* Custom instructions *******/
543 706 markom
INSTRUCTION (l_cust1) {
544 713 markom
  /*int destr = current->insn >> 21;
545
    int src1r = current->insn >> 15;
546
    int src2r = current->insn >> 9;*/
547 706 markom
}
548
INSTRUCTION (l_cust2) {
549
}
550
INSTRUCTION (l_cust3) {
551
}
552
INSTRUCTION (l_cust4) {
553
}

powered by: WebSVN 2.1.0

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