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

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_34/] [or1ksim/] [cpu/] [or32/] [execute.c] - Blame information for rev 620

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

Line No. Rev Author Line
1 2 cvs
/* execute.c -- OR1K architecture dependent simulation
2
   Copyright (C) 1999 Damjan Lampret, lampret@opencores.org
3
 
4
This file is part of OpenRISC 1000 Architectural Simulator.
5
 
6
This program is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2 of the License, or
9
(at your option) any later version.
10
 
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
GNU General Public License for more details.
15
 
16
You should have received a copy of the GNU General Public License
17
along with this program; if not, write to the Free Software
18
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
19
 
20
/* Most of the OR1K simulation is done in here. */
21
 
22
#include <stdlib.h>
23
#include <stdio.h>
24
#include <string.h>
25
#include <ctype.h>
26
 
27 123 markom
#include "config.h"
28 2 cvs
#include "arch.h"
29 133 markom
#include "opcode/or32.h"
30 2 cvs
#include "branch_predict.h"
31
#include "abstract.h"
32 261 markom
#include "labels.h"
33 2 cvs
#include "parse.h"
34
#include "execute.h"
35
#include "stats.h"
36 54 lampret
#include "except.h"
37
#include "sprs.h"
38 102 lampret
#include "sim-config.h"
39 123 markom
#include "debug_unit.h"
40 2 cvs
 
41 615 markom
/* Whether instructions set overflow flag */
42
#define SET_OV_FLAG     1
43
 
44
/* Whether arithmethic instructions set flag on zero */
45 620 markom
#define ARITH_SET_FLAG  1
46 615 markom
 
47 2 cvs
/* General purpose registers. */
48
machword reg[MAX_GPRS];
49
 
50
/* Instruction queue */
51
struct iqueue_entry iqueue[20];
52
 
53 83 lampret
/* Is current insn in execution a delay insn? */
54
int delay_insn;
55
 
56 2 cvs
/* Benchmark multi issue execution */
57
int multissue[20];
58
int supercycles;
59 6 lampret
int issued_per_cycle = 4;
60
int hazardwait = 0;
61 2 cvs
 
62 431 markom
/* Whether break was hit - so we can step over a break */
63
static int break_just_hit = 0;
64
 
65 68 lampret
/* freemem 'pointer' */
66
extern unsigned long freemem;
67
 
68 2 cvs
/* Completition queue */
69 138 markom
struct iqueue_entry icomplet[20];
70 2 cvs
 
71 77 lampret
/* Program counter (and translated PC) */
72 2 cvs
unsigned long pc;
73 77 lampret
unsigned long pc_phy;
74 2 cvs
 
75 378 markom
/* Previous program counter */
76 479 markom
unsigned long pcprev = 0;
77 378 markom
 
78 2 cvs
/* Temporary program counter */
79 83 lampret
unsigned long pcnext;
80 2 cvs
 
81 123 markom
/* Delay instruction effective address register */
82
unsigned long pcdelay;
83
 
84 2 cvs
/* CCR */
85
int flag;
86
 
87
/* CCR (for dependency calculation) */
88
char ccr_flag[10] = "flag";
89
 
90
/* Cycles counts fetch stages */
91
int cycles;
92
 
93 537 markom
/* Each cycle has counter of mem_cycles; this value is joined with cycles
94
   at the end of the cycle; no sim originated memory accesses should be
95
   performed inbetween. */
96
int mem_cycles;
97
 
98 535 markom
/* Instructions executed */
99
int instructions;
100
 
101 6 lampret
/* Load and store stalls */
102
int loadcycles, storecycles;
103
 
104 138 markom
/* Local data needed for execution.  */
105
static struct iqueue_entry *cur;
106
static int next_delay_insn;
107
static int breakpoint;
108
static unsigned long *op;
109
static int num_op;
110
 
111 2 cvs
/* Implementation specific.
112
   Get an actual value of a specific register. */
113
 
114 560 markom
unsigned long evalsim_reg32(int regno)
115 2 cvs
{
116 138 markom
  if (regno < MAX_GPRS) {
117 560 markom
    return reg[regno];
118
  } else {
119
    printf("\nABORT: read out of registers\n");
120
    cont_run = 0;
121
    return 0;
122
  }
123
}
124
 
125
/* Implementation specific.
126
   Set a specific register with value. */
127
 
128
void setsim_reg32(int regno, unsigned long value)
129
{
130
  if (regno == 0)               /* gpr0 is always zero */
131
    value = 0;
132
 
133
  if (regno < MAX_GPRS) {
134
    reg[regno] = value;
135
  } else {
136
    printf("\nABORT: write out of registers\n");
137
    cont_run = 0;
138
  }
139
}
140
 
141
/* Implementation specific.
142
   Get an actual value of a specific register. */
143
 
144
inline static unsigned long eval_reg32(int regno)
145
{
146
  if (regno < MAX_GPRS) {
147
    IFF(config.cpu.raw_range) {
148 535 markom
      int delta = (cycles - raw_stats.reg[regno]);
149 606 markom
      if ((unsigned long)delta < (unsigned long)config.cpu.raw_range)
150 535 markom
        raw_stats.range[delta]++;
151
    }
152 344 markom
    debug(9, "atoi ret1\n");
153 138 markom
    return reg[regno];
154
  } else {
155 393 markom
    printf("\nABORT: read out of registers\n");
156 138 markom
    cont_run = 0;
157
    return 0;
158
  }
159 2 cvs
}
160
 
161
/* Implementation specific.
162
   Set a specific register with value. */
163
 
164 560 markom
inline static void set_reg32(int regno, unsigned long value)
165 2 cvs
{
166 262 markom
#if 0   
167 138 markom
  if (strcmp(regstr, FRAME_REG) == 0) {
168
    printf("FP (%s) modified by insn at %x. ", FRAME_REG, pc);
169
    printf("Old:%.8lx  New:%.8lx\n", eval_reg(regno), value);
170
  }
171
 
172
  if (strcmp(regstr, STACK_REG) == 0) {
173
    printf("SP (%s) modified by insn at %x. ", STACK_REG, pc);
174
    printf("Old:%.8lx  New:%.8lx\n", eval_reg(regmo), value);
175
  }
176 2 cvs
#endif
177 560 markom
 
178 138 markom
  if (regno < MAX_GPRS) {
179
    reg[regno] = value;
180 560 markom
    IFF(config.cpu.raw_range)
181 535 markom
      raw_stats.reg[regno] = cycles;
182 138 markom
  } else {
183 393 markom
    printf("\nABORT: write out of registers\n");
184 138 markom
    cont_run = 0;
185
  }
186 2 cvs
}
187
 
188
/* Does srcoperand depend on computation of dstoperand? Return
189
   non-zero if yes.
190
 
191 262 markom
 Cycle t                 Cycle t+1
192
dst: irrelevant         src: immediate                  always 0
193
dst: reg1 direct        src: reg2 direct                0 if reg1 != reg2
194
dst: reg1 disp          src: reg2 direct                always 0
195
dst: reg1 direct        src: reg2 disp                  0 if reg1 != reg2
196
dst: reg1 disp          src: reg2 disp                  always 1 (store must
197
                                                        finish before load)
198 138 markom
dst: flag               src: flag                       always 1
199 2 cvs
*/
200
 
201 138 markom
int depend_operands(prev, next)
202
     struct iqueue_entry *prev;
203
     struct iqueue_entry *next;
204 2 cvs
{
205 138 markom
  /* Find destination type. */
206
  unsigned long type = 0;
207
  int i = 0;
208
  if (or32_opcodes[prev->insn_index].flags & OR32_W_FLAG
209
      && or32_opcodes[next->insn_index].flags & OR32_R_FLAG)
210
    return 1;
211 2 cvs
 
212 138 markom
  while (!(prev->op[i + MAX_OPERANDS] & OPTYPE_LAST))
213
    if (prev->op[i + MAX_OPERANDS] & OPTYPE_DST)
214
      {
215 262 markom
        type = prev->op[i + MAX_OPERANDS];
216
        break;
217 138 markom
      }
218
    else
219
      i++;
220 560 markom
 
221 138 markom
  /* We search all source operands - if we find confict => return 1 */
222
  i = 0;
223
  while (!(next->op[i + MAX_OPERANDS] & OPTYPE_LAST))
224
    if (!(next->op[i + MAX_OPERANDS] & OPTYPE_DST))
225
      {
226 262 markom
        if (next->op[i + MAX_OPERANDS] & OPTYPE_DIS)
227
          if (type & OPTYPE_DIS)
228
            return 1;
229
          else if (next->op[i] == prev->op[i]
230
                   && (next->op[i + MAX_OPERANDS] & OPTYPE_REG))
231
            return 1;
232
        if (next->op[i] == prev->op[i]
233
            && (next->op[i + MAX_OPERANDS] & OPTYPE_REG)
234
            && (type & OPTYPE_REG))
235
          return 1;
236
        i++;
237 138 markom
      }
238
    else
239
      i++;
240
  return 0;
241
}
242 2 cvs
 
243 138 markom
/* Implementation specific.
244
   Parses and returns operands. */
245 2 cvs
 
246 138 markom
static void
247
eval_operands (unsigned long insn, int insn_index, int* breakpoint)
248
{
249
  struct insn_op_struct *opd = op_start[insn_index];
250
  unsigned long data = 0;
251
  int dis = 0;
252
  int no = 0;
253 560 markom
 
254 138 markom
  while (1)
255
    {
256
      unsigned long tmp = 0, nbits = 0;
257
      while (1)
258 262 markom
        {
259
          tmp |= ((insn  >> (opd->type & OPTYPE_SHR)) & ((1 << opd->data) - 1)) << nbits;
260
          nbits += opd->data;
261
          if (opd->type & OPTYPE_OP)
262
            break;
263
          opd++;
264
        }
265 2 cvs
 
266 138 markom
      /* Do we have to sign extend? */
267
      if (opd->type & OPTYPE_SIG)
268 262 markom
        {
269
          int sbit = (opd->type & OPTYPE_SBIT) >> OPTYPE_SBIT_SHR;
270
          if (tmp & (1 << sbit))
271
            tmp |= 0xFFFFFFFF << sbit;
272
        }
273 138 markom
      if (opd->type & OPTYPE_DIS) {
274 262 markom
        /* We have to read register later.  */
275
        data += tmp;
276
        dis = 1;
277 138 markom
      } else
278 262 markom
        {
279
          if (dis && (opd->type & OPTYPE_REG))
280 560 markom
            op[no] = data + eval_reg32 (tmp);
281 262 markom
          else
282
            op[no] = tmp;
283
          op[no + MAX_OPERANDS] = opd->type | (dis ? OPTYPE_DIS : 0);
284
          no++;
285
          data = 0;
286
          dis = 0;
287
        }
288 138 markom
      if(opd->type & OPTYPE_LAST)
289 262 markom
        return;
290 138 markom
      opd++;
291
    }
292
  num_op = no;
293 2 cvs
}
294
 
295
/* Implementation specific.
296 138 markom
   Evaluates source operand op_no. */
297
 
298 560 markom
inline static unsigned long eval_operand32 (int op_no, int *breakpoint)
299 2 cvs
{
300 344 markom
  debug (9, "%i %08X\n", op_no, op[op_no + MAX_OPERANDS]);
301 538 markom
  if (op[op_no + MAX_OPERANDS] & OPTYPE_DIS)
302 560 markom
    /* memory accesses are not cached */
303 138 markom
    return eval_mem32 (op[op_no], breakpoint);
304 560 markom
  else if (op[op_no + MAX_OPERANDS] & OPTYPE_REG) {
305
    return eval_reg32 (op[op_no]);
306
  } else {
307 138 markom
    return op[op_no];
308 560 markom
  }
309 2 cvs
}
310
 
311
/* Implementation specific.
312 221 markom
   Evaluates source operand op_no. */
313
 
314 560 markom
static unsigned long eval_operand16 (int op_no, int *breakpoint)
315 221 markom
{
316 344 markom
  debug (9, "%i %08X\n", op_no, op[op_no + MAX_OPERANDS]);
317 458 simons
  if (op[op_no + MAX_OPERANDS] & OPTYPE_DIS) {
318 221 markom
    return eval_mem16 (op[op_no], breakpoint);
319 458 simons
  }
320 221 markom
  else {
321
    fprintf (stderr, "Invalid operand type.\n");
322
    exit (1);
323
  }
324
}
325
 
326
/* Implementation specific.
327
   Evaluates source operand op_no. */
328
 
329 560 markom
static unsigned long eval_operand8 (int op_no, int *breakpoint)
330 221 markom
{
331 344 markom
  debug (9, "%i %08X\n", op_no, op[op_no + MAX_OPERANDS]);
332 221 markom
  if (op[op_no + MAX_OPERANDS] & OPTYPE_DIS)
333
    return eval_mem8 (op[op_no], breakpoint);
334
  else {
335
    fprintf (stderr, "Invalid operand type.\n");
336
    exit (1);
337
  }
338
}
339
 
340
/* Implementation specific.
341 2 cvs
   Set destination operand (register direct, register indirect
342
   (with displacement) with value. */
343
 
344 560 markom
inline static void set_operand32(int op_no, unsigned long value, int* breakpoint)
345 2 cvs
{
346 138 markom
  /* Mark this as destination operand.  */
347 560 markom
  IFF (config.cpu.dependstats) op[op_no + MAX_OPERANDS] |= OPTYPE_DST;
348 458 simons
  if (op[op_no + MAX_OPERANDS] & OPTYPE_DIS) {
349 138 markom
    set_mem32(op[op_no], value, breakpoint);
350 560 markom
  } else if (op[op_no + MAX_OPERANDS] & OPTYPE_REG) {
351 138 markom
    set_reg32(op[op_no], value);
352 560 markom
  } else {
353
    fprintf (stderr, "Invalid operand type.\n");
354
    exit (1);
355 458 simons
  }
356 2 cvs
}
357
 
358 221 markom
/* Implementation specific.
359
   Set destination operand (register direct, register indirect
360
   (with displacement) with value. */
361
 
362
void set_operand16(int op_no, unsigned long value, int* breakpoint)
363
{
364
  /* Mark this as destination operand.  */
365 560 markom
  op[op_no + MAX_OPERANDS] |= OPTYPE_DST;
366 458 simons
  if (op[op_no + MAX_OPERANDS] & OPTYPE_DIS) {
367 221 markom
    set_mem16(op[op_no], value, breakpoint);
368 458 simons
  }
369 574 markom
  else
370 221 markom
    {
371
      fprintf (stderr, "Invalid operand type.\n");
372
      exit (1);
373
    }
374
}
375
 
376
/* Implementation specific.
377
   Set destination operand (register direct, register indirect
378
   (with displacement) with value. */
379
 
380
void set_operand8(int op_no, unsigned long value, int* breakpoint)
381
{
382
  /* Mark this as destination operand.  */
383
  op[op_no + MAX_OPERANDS] |= OPTYPE_DST;
384
  if (op[op_no + MAX_OPERANDS] & OPTYPE_DIS)
385
    set_mem8(op[op_no], value, breakpoint);
386
  else
387
    {
388
      fprintf (stderr, "Invalid operand type.\n");
389
      exit (1);
390
    }
391
}
392
 
393 605 markom
/* Sets a new SPR_SR_OV value, based on next register value */
394
static inline unsigned long set_ov_flag (unsigned long value)
395
{
396 615 markom
#if SET_OV_FLAG
397 605 markom
  value & 0x80000000 ? setsprbits (SPR_SR, SPR_SR_OV, 1) : setsprbits (SPR_SR, SPR_SR_OV, 0);
398 615 markom
#endif
399 605 markom
  return value;
400
}
401
 
402 123 markom
/* Modified by CZ 26/05/01 for new mode execution */
403
/* Fetch returns nonzero if instruction should NOT be executed.  */
404 557 markom
static inline int fetch()
405
{
406 221 markom
  struct mem_entry *entry;
407 344 markom
  debug(5, "fetch()\n");
408 123 markom
 
409 557 markom
  /* Update the pc for pending exceptions, or get physical pc */
410 574 markom
  if (!pending.valid)
411
    pc_phy = translate_vrt_to_phy_add(pc);
412
 
413 557 markom
  if(pending.valid)
414
    except_handle_backend(pending.type, pending.address, pending.saved);
415 464 simons
 
416 557 markom
  if (CHECK_BREAKPOINTS) {
417
    /* MM: Check for breakpoint.  This has to be done in fetch cycle,
418
       because of peripheria.
419
       MM1709: if we cannot access the memory entry, we could not set the
420
       breakpoint earlier, so just chech the breakpoint list.  */
421
    if (has_breakpoint (pc_phy) && !break_just_hit) {
422
      break_just_hit = 1;
423
      return 1; /* Breakpoint set. */
424
    }
425
    break_just_hit = 0;
426 431 markom
  }
427 535 markom
  instructions++;
428 378 markom
 
429 538 markom
  pc_phy &= ~0x03;
430
 
431 378 markom
  /* Fetch instruction. */
432 560 markom
  iqueue[0].insn_addr = pc;
433
  iqueue[0].insn = eval_insn (pc_phy, &breakpoint);;
434 557 markom
 
435 378 markom
  /* update_pc will be called after execution */
436 77 lampret
 
437 378 markom
  return 0;
438 2 cvs
}
439
 
440 479 markom
/* This code actually updates the PC value.  */
441 557 markom
static inline void update_pc()
442 142 chris
{
443 479 markom
  pcprev = pc; /* Store value for later */
444
  pc = pcnext;
445
  pcnext = delay_insn ? pcdelay : pcnext + 4;
446 2 cvs
}
447
 
448 557 markom
static inline void analysis()
449 2 cvs
{
450 394 markom
  if (config.cpu.dependstats)
451 123 markom
    /* Instruction waits in completition buffer until retired. */
452 138 markom
    memcpy (&icomplet[0], &iqueue[0], sizeof (struct iqueue_entry));
453
 
454 394 markom
  if (config.sim.history) {
455 263 markom
    int i;
456
 
457 123 markom
    /* History of execution */
458
    for (i = HISTEXEC_LEN - 1; i; i--)
459
      histexec[i] = histexec[i - 1];
460 262 markom
    histexec[0] = icomplet[0].insn_addr;        /* add last insn */
461 123 markom
  }
462 2 cvs
}
463
 
464 294 markom
 
465
/* Execution logger.  */
466
inline void dump_exe_log()
467
{
468 479 markom
  unsigned long i = iqueue[0].insn_addr;
469 294 markom
 
470 479 markom
  if (i == 0xffffffff) return;
471 361 markom
  fprintf(runtime.sim.fexe_log, "\nEXECUTED(): %.8lx:  ", i);
472
  fprintf(runtime.sim.fexe_log, "%.2x%.2x", evalsim_mem8(i), evalsim_mem8(i + 1));
473
  fprintf(runtime.sim.fexe_log, "%.2x%.2x", evalsim_mem8(i + 2), evalsim_mem8(i + 3));
474
  for(i = 0; i < MAX_GPRS; i++) {
475
    if (i % 4 == 0)
476
      fprintf(runtime.sim.fexe_log, "\n");
477
    fprintf(runtime.sim.fexe_log, "GPR%2u: %.8lx  ", i, reg[i]);
478
  }
479
  fprintf(runtime.sim.fexe_log, "\n");
480
  fprintf(runtime.sim.fexe_log, "SR   : %.8lx  ", mfspr(SPR_SR));
481
  fprintf(runtime.sim.fexe_log, "EPCR0: %.8lx  ", mfspr(SPR_EPCR_BASE));
482
  fprintf(runtime.sim.fexe_log, "EEAR0: %.8lx  ", mfspr(SPR_EEAR_BASE));
483
  fprintf(runtime.sim.fexe_log, "ESR0 : %.8lx\n", mfspr(SPR_ESR_BASE));
484 294 markom
}
485
 
486 537 markom
#if 0
487 535 markom
void print_time (int cycles, char *output)
488
{
489
  int i = 0, c_ps = config.sim.clkcycle_ps;
490
  while (c_ps % 1000 == 0 && i < 2) {
491
    c_ps /= 1000;
492
    i++;
493
  }
494
  c_ps *= cycles;
495
  sprintf (output, "%i%cs", cycles, i == 0 ? 'p' : i == 1 ? 'n': 'u');
496
}
497 537 markom
#endif
498 535 markom
 
499 2 cvs
void dumpreg()
500
{
501 269 markom
  int i;
502 535 markom
  char temp[100];
503 269 markom
 
504 306 markom
  dumpmemory(iqueue[0].insn_addr, iqueue[0].insn_addr + 4, 1, 0);
505 537 markom
  generate_time_pretty (temp, cycles);
506 535 markom
  printf(" (executed) [time %s, #%i]\n", temp, instructions);
507 293 markom
  if (config.cpu.superscalar)
508
    printf ("Superscalar CYCLES: %u", supercycles);
509
  if (config.cpu.hazards)
510
    printf ("  HAZARDWAIT: %u\n", hazardwait);
511
  else
512
    if (config.cpu.superscalar)
513
      printf ("\n");
514
 
515 306 markom
  dumpmemory(pc, pc + 4, 1, 0);
516 269 markom
  printf(" (next insn) %s", (delay_insn?"(delay insn)":""));
517
  for(i = 0; i < MAX_GPRS; i++) {
518
    if (i % 4 == 0)
519
      printf("\n");
520 560 markom
    printf("GPR%.2u: %.8lx  ", i, evalsim_reg32(i));
521 269 markom
  }
522
  printf("flag: %u\n", flag);
523 2 cvs
}
524 123 markom
 
525
/* Address calculation changed by CZ on 27/05/01 */
526 560 markom
static inline void decode_execute(struct iqueue_entry *current)
527 123 markom
{
528 560 markom
  int insn_index;
529 123 markom
  next_delay_insn = 0;
530
  breakpoint = 0;
531 560 markom
 
532 550 markom
  if(config.debug.enabled && CheckDebugUnit(DebugInstructionFetch, pc_phy))
533 123 markom
    breakpoint++;
534 138 markom
 
535 560 markom
  IFF (config.cpu.dependstats) current->func_unit = it_unknown;
536
 
537
  current->insn_index = insn_index = insn_decode(current->insn);
538 123 markom
 
539
#ifndef HAS_EXECUTION
540
#error HAS_EXECUTION has to be defined in order to execute programs.
541
#endif
542 133 markom
 
543 560 markom
  cur = current;  /* globals; needed by eval/set_operand */
544
 
545
  if (insn_index < 0)
546 123 markom
    l_invalid();
547 560 markom
  else {
548
    op = &cur->op[0];
549
    eval_operands (cur->insn, insn_index, &breakpoint);
550
    or32_opcodes[insn_index].exec();
551
  }
552
 
553 458 simons
  /* Check for range exception */
554 557 markom
  if (testsprbits (SPR_SR, SPR_SR_OVE) && testsprbits (SPR_SR, SPR_SR_OV))
555 611 simons
    except_handle (EXCEPT_RANGE, mfspr(SPR_EEAR_BASE));
556 458 simons
 
557 263 markom
  if (config.cpu.dependstats) {
558 560 markom
    iqueue[0].insn_index = insn_index;
559 123 markom
    /* Dynamic, dependency stats. */
560 535 markom
    adddstats(icomplet[0].insn_index, iqueue[0].insn_index, 1, check_depend());
561 262 markom
 
562 123 markom
    /* Dynamic, functional units stats. */
563
    addfstats(icomplet[0].func_unit, iqueue[0].func_unit, 1, check_depend());
564 262 markom
 
565 123 markom
    /* Dynamic, single stats. */
566 535 markom
    addsstats(iqueue[0].insn_index, 1);
567 123 markom
  }
568 560 markom
 
569 263 markom
  if (config.cpu.superscalar) {
570 479 markom
    if ((cur->func_unit == it_branch) || (cur->func_unit == it_jump))
571 123 markom
      storecycles += 0;
572
 
573 479 markom
    if (cur->func_unit == it_store)
574 389 lampret
      storecycles += 1;
575 123 markom
 
576 479 markom
    if (cur->func_unit == it_load)
577 389 lampret
      loadcycles += 1;
578
#if 0        
579 479 markom
    if ((icomplet[0].func_unit == it_load) && check_depend())
580 123 markom
      loadcycles++;
581 389 lampret
#endif
582 123 markom
 
583
    /* Pseudo multiple issue benchmark */
584
    if ((multissue[cur->func_unit] < 1) || (check_depend())
585 560 markom
     || (issued_per_cycle < 1)) {
586 123 markom
      int i;
587
      for (i = 0; i < 20; i++)
588 262 markom
        multissue[i] = 2;
589 123 markom
      issued_per_cycle = 2;
590
      supercycles++;
591
      if (check_depend())
592 262 markom
        hazardwait++;
593 479 markom
      multissue[it_unknown] = 2;
594
      multissue[it_shift] = 2;
595
      multissue[it_compare] = 1;
596
      multissue[it_branch] = 1;
597
      multissue[it_jump] = 1;
598
      multissue[it_extend] = 2;
599
      multissue[it_nop] = 2;
600
      multissue[it_move] = 2;
601
      multissue[it_movimm] = 2;
602
      multissue[it_arith] = 2;
603
      multissue[it_store] = 2;
604
      multissue[it_load] = 2;
605 123 markom
    }
606
    multissue[cur->func_unit]--;
607
    issued_per_cycle--;
608
  }
609
  delay_insn = next_delay_insn;
610
 
611
  if(breakpoint)
612 611 simons
    except_handle(EXCEPT_TRAP, mfspr(SPR_EEAR_BASE));
613 123 markom
}
614
 
615 557 markom
void cpu_reset()
616
{
617 606 markom
  int i;
618 557 markom
  cycles = 0;
619
  instructions = 0;
620
  supercycles = 0;
621
  loadcycles = 0;
622
  storecycles = 0;
623 606 markom
  for (i = 0; i < MAX_GPRS; i++)
624
    set_reg32 (i, 0);
625 557 markom
  memset(iqueue, 0, sizeof(iqueue));
626
  memset(icomplet, 0, sizeof(icomplet));
627
 
628
  /* Cpu configuration */
629
  mtspr(SPR_UPR, config.cpu.upr);
630
  setsprbits(SPR_VR, SPR_VR_VER, config.cpu.ver);
631
  setsprbits(SPR_VR, SPR_VR_REV, config.cpu.rev);
632
  mtspr(SPR_SR, config.cpu.sr);
633
 
634
  pcnext = 0x0; /* MM1409: All programs should start at reset vector entry!  */
635
  printf ("Starting at 0x%08x\n", pcnext);
636
  pc = pcnext;
637
  pc_phy = pc;
638
  pcnext += 4;
639
  debug(1, "reset ...\n");
640
 
641
  /* MM1409: All programs should set their stack pointer!  */
642
  except_handle(EXCEPT_RESET, 0);
643
}
644
 
645
inline int cpu_clock ()
646
{
647
  if(fetch()) {
648
    printf ("Breakpoint hit.\n");
649
    cont_run = 0; /* memory breakpoint encountered */
650
    return 1;
651
  }
652
  decode_execute(&iqueue[0]);
653
  update_pc();
654
  analysis();
655
  if (config.sim.exe_log) dump_exe_log();
656
  return 0;
657
}
658
 
659 123 markom
/******************************************
660
 *    Instruction specific functions.     *
661
 ******************************************/
662
 
663
void l_add() {
664 221 markom
  signed long temp1;
665 123 markom
  signed char temp4;
666
 
667 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_arith;
668 221 markom
  temp1 = (signed long)eval_operand32(2, &breakpoint)+(signed long)eval_operand32(1, &breakpoint);
669
  set_operand32(0, temp1, &breakpoint);
670 605 markom
  set_ov_flag (temp1);
671 620 markom
  if (ARITH_SET_FLAG) {
672
    flag = temp1 == 0;
673
    setsprbits(SPR_SR, SPR_SR_F, flag);
674
  }
675 615 markom
 
676 123 markom
  temp4 = temp1;
677
  if (temp4 == temp1)
678
    mstats.byteadd++;
679
}
680 557 markom
void l_sw() {
681 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_store;
682 221 markom
  set_operand32(0, eval_operand32(1, &breakpoint), &breakpoint);
683 123 markom
}
684
void l_sb() {
685 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_store;
686 221 markom
  set_operand8(0, eval_operand32(1, &breakpoint), &breakpoint);
687 123 markom
}
688
void l_sh() {
689 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_store;
690 221 markom
  set_operand16(0, eval_operand32(1, &breakpoint), &breakpoint);
691 123 markom
}
692
void l_lwz() {
693 437 simons
  unsigned long val;
694 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_load;
695 437 simons
  val = eval_operand32(1, &breakpoint);
696 619 markom
  /* If eval operand produced exception don't set anything */
697 558 markom
  if (!pending.valid)
698
    set_operand32(0, val, &breakpoint);
699 123 markom
}
700
void l_lbs() {
701 437 simons
  signed char val;
702 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_load;
703 437 simons
  val = eval_operand8(1, &breakpoint);
704
  /* If eval opreand produced exception don't set anything */
705 558 markom
  if (!pending.valid)
706
    set_operand32(0, val, &breakpoint);
707 123 markom
}
708 221 markom
void l_lbz() {
709 437 simons
  unsigned char val;
710 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_load;
711 437 simons
  val = eval_operand8(1, &breakpoint);
712
  /* If eval opreand produced exception don't set anything */
713 558 markom
  if (!pending.valid)
714
    set_operand32(0, val, &breakpoint);
715 123 markom
}
716 221 markom
void l_lhs() {
717 437 simons
  signed short val;
718 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_load;
719 437 simons
  val = eval_operand16(1, &breakpoint);
720
  /* If eval opreand produced exception don't set anything */
721 558 markom
  if (!pending.valid)
722
    set_operand32(0, val, &breakpoint);
723 123 markom
}
724 221 markom
void l_lhz() {
725 437 simons
  unsigned short val;
726 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_load;
727 437 simons
  val = eval_operand16(1, &breakpoint);
728
  /* If eval opreand produced exception don't set anything */
729 558 markom
  if (!pending.valid)
730
    set_operand32(0, val, &breakpoint);
731 123 markom
}
732
void l_movhi() {
733 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_movimm;
734 221 markom
  set_operand32(0, eval_operand32(1, &breakpoint) << 16, &breakpoint);
735 123 markom
}
736
void l_and() {
737 615 markom
  unsigned long temp1;
738 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_arith;
739 615 markom
  set_operand32(0, temp1 = set_ov_flag (eval_operand32(1, &breakpoint) & (unsigned)eval_operand32(2, &breakpoint)), &breakpoint);
740 620 markom
  if (ARITH_SET_FLAG) {
741
    flag = temp1 == 0;
742
    setsprbits(SPR_SR, SPR_SR_F, flag);
743
  }
744 123 markom
}
745
void l_or() {
746 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_arith;
747 605 markom
  set_operand32(0, set_ov_flag (eval_operand32(1, &breakpoint) | (unsigned)eval_operand32(2, &breakpoint)), &breakpoint);
748 123 markom
}
749
void l_xor() {
750 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_arith;
751 605 markom
  set_operand32(0, set_ov_flag (eval_operand32(1, &breakpoint) ^ (signed)eval_operand32(2, &breakpoint)), &breakpoint);
752 123 markom
}
753
void l_sub() {
754 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_arith;
755 605 markom
  set_operand32(0, set_ov_flag ((signed long)eval_operand32(1, &breakpoint) - (signed long)eval_operand32(2, &breakpoint)), &breakpoint);
756 123 markom
}
757 174 markom
/*int mcount = 0;*/
758 123 markom
void l_mul() {
759
  signed long temp3, temp2, temp1;
760
 
761 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_arith;
762 605 markom
  set_operand32(0, set_ov_flag ((signed long)eval_operand32(1, &breakpoint) * (signed long)eval_operand32(2, &breakpoint)), &breakpoint);
763 174 markom
  /*if (!(mcount++ & 1023)) {
764
    printf ("[%i]\n",mcount);
765
    }*/
766 123 markom
}
767
void l_div() {
768
  signed long temp3, temp2, temp1;
769
 
770 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_arith;
771 221 markom
  temp3 = eval_operand32(2, &breakpoint);
772
  temp2 = eval_operand32(1, &breakpoint);
773 123 markom
  if (temp3)
774
    temp1 = temp2 / temp3;
775 458 simons
  else {
776
    except_handle(EXCEPT_ILLEGAL, iqueue[0].insn_addr);
777
    return;
778
  }
779 605 markom
  set_operand32(0, set_ov_flag (temp1), &breakpoint);
780 123 markom
}
781
void l_divu() {
782
  unsigned long temp3, temp2, temp1;
783
 
784 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_arith;
785 221 markom
  temp3 = eval_operand32(2, &breakpoint);
786
  temp2 = eval_operand32(1, &breakpoint);
787 123 markom
  temp1 = temp2 / temp3;
788
  /* cycles += 16; */
789 605 markom
  set_operand32(0, set_ov_flag (temp1), &breakpoint);
790 123 markom
}
791
void l_sll() {
792
  int sign = 1;
793 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_shift;
794 221 markom
  if ((signed)eval_operand32(1, &breakpoint) < 0)
795 123 markom
    sign = -1;
796
  /* cycles += 2; */
797 605 markom
  set_operand32(0, set_ov_flag (eval_operand32(1, &breakpoint) << eval_operand32(2, &breakpoint)), &breakpoint);
798 123 markom
}
799
void l_sra() {
800
  unsigned long sign = 0;
801 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_shift;
802 123 markom
 
803 221 markom
  if ((signed)eval_operand32(1, &breakpoint) < 0)
804 123 markom
    sign = -1;
805
  /* cycles += 2; */
806 605 markom
  set_operand32(0, set_ov_flag ((signed)eval_operand32(1, &breakpoint) >> eval_operand32(2, &breakpoint)), &breakpoint);
807 123 markom
}
808
void l_srl() {
809 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_shift;
810 123 markom
  /* cycles += 2; */
811 605 markom
  set_operand32(0, set_ov_flag (eval_operand32(1, &breakpoint) >> eval_operand32(2, &breakpoint)), &breakpoint);
812 123 markom
}
813 535 markom
void l_bf() {
814 541 markom
  if (config.bpb.enabled) {
815 535 markom
    int fwd = (eval_operand32(0, &breakpoint) >= pc) ? 1 : 0;
816 558 markom
    IFF (config.cpu.dependstats) cur->func_unit = it_branch;
817 535 markom
    mstats.bf[flag][fwd]++;
818
    bpb_update(cur->insn_addr, flag);
819
  }
820
  if (flag) {
821
    debug(5, "\nl.bf relative: pc=%x pcnext=%x\n", pc, pcnext);
822
    pcdelay = pc + (signed)eval_operand32(0, &breakpoint) * 4;
823
    btic_update(pcnext);
824
    next_delay_insn = 1;
825
  } else {
826
    btic_update(pc);
827
  }
828
}
829
void l_bnf() {
830 541 markom
  if (config.bpb.enabled) {
831 535 markom
    int fwd = (eval_operand32(0, &breakpoint) >= pc) ? 1 : 0;
832 558 markom
    IFF (config.cpu.dependstats) cur->func_unit = it_branch;
833 535 markom
    mstats.bnf[!flag][fwd]++;
834
    bpb_update(cur->insn_addr, flag == 0);
835
  }
836
  if (flag == 0) {
837
    debug(5, "\nl.bnf relative: pc=%x pcnext=%x\n", pc, pcnext);
838
    pcdelay = pc + (signed)eval_operand32(0, &breakpoint) * 4;
839
    btic_update(pcnext);
840
    next_delay_insn = 1;
841
  } else {
842
    btic_update(pc);
843
  }
844
}
845 123 markom
void l_j() {
846 344 markom
  debug(5, "\nl.j relative: pc=%x pcnext=%x\n", pc, pcnext);
847 221 markom
  pcdelay = pc + (signed)eval_operand32(0, &breakpoint) * 4;
848 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_jump;
849 123 markom
  next_delay_insn = 1;
850
}
851
void l_jal() {
852 344 markom
  debug(5, "\nl.jal relative: pc=%x pcnext=%x\n", pc, pcnext);
853 221 markom
  pcdelay = pc + (signed)eval_operand32(0, &breakpoint) * 4;
854 123 markom
 
855 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_jump;
856 138 markom
  set_reg32(LINK_REGNO, pc + 8);
857 123 markom
  next_delay_insn = 1;
858 264 markom
  if (config.sim.profile) {
859 262 markom
    struct mem_entry *entry;
860 221 markom
    struct label_entry *tmp;
861 261 markom
    if (verify_memoryarea(pcdelay) && (tmp = get_label (pcdelay)))
862 361 markom
      fprintf (runtime.sim.fprof, "+%08X %08X %08X %s\n", cycles, pc + 8, pcdelay, tmp->name);
863 221 markom
    else
864 361 markom
      fprintf (runtime.sim.fprof, "+%08X %08X %08X @%08X\n", cycles, pc + 8, pcdelay, pcdelay);
865 173 markom
  }
866 123 markom
}
867
void l_jalr() {
868 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_jump;
869 221 markom
  pcdelay = eval_operand32(0, &breakpoint);
870 138 markom
  set_reg32(LINK_REGNO, pc + 8);
871 123 markom
  next_delay_insn = 1;
872
}
873
void l_jr() {
874 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_jump;
875 221 markom
  pcdelay = eval_operand32(0, &breakpoint);
876 123 markom
  next_delay_insn = 1;
877 482 markom
  if (config.sim.profile)
878
    fprintf (runtime.sim.fprof, "-%08X %08X\n", cycles, pcdelay);
879 123 markom
}
880
void l_rfe() {
881 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_exception;
882 416 simons
  pcnext = mfspr(SPR_EPCR_BASE);
883
  mtspr(SPR_SR, mfspr(SPR_ESR_BASE));
884
}
885 123 markom
void l_nop() {
886 511 markom
  unsigned long stackaddr;
887
  int k = eval_operand32(0, &breakpoint);
888 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_nop;
889 511 markom
  switch (k) {
890
    case NOP_NOP:
891
      break;
892
    case NOP_EXIT:
893 560 markom
      printf("exit(%d)\n", evalsim_reg32 (3));
894 511 markom
      if (config.debug.gdb_enabled)
895
        set_stall_state (1);
896
      else
897
        cont_run = 0;
898
      break;
899
    case NOP_PRINTF:
900 560 markom
      stackaddr = evalsim_reg32(4);
901
      simprintf(stackaddr, evalsim_reg32(3));
902 511 markom
      debug(5, "simprintf %x\n", stackaddr);
903
      break;
904
    case NOP_REPORT:
905 560 markom
      printf("report(0x%x);\n", evalsim_reg32(3));
906 511 markom
    default:
907
      if (k >= NOP_REPORT_FIRST && k <= NOP_REPORT_LAST)
908 604 markom
      printf("report %i (0x%x);\n", k - NOP_REPORT_FIRST, evalsim_reg32(3));
909 511 markom
      break;
910
  }
911 123 markom
}
912
void l_sfeq() {
913 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_compare;
914 221 markom
  flag = eval_operand32(0, &breakpoint) == eval_operand32(1, &breakpoint);
915 123 markom
  setsprbits(SPR_SR, SPR_SR_F, flag);
916
}
917 535 markom
void l_sfne() {
918 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_compare;
919 535 markom
  flag = eval_operand32(0, &breakpoint) != eval_operand32(1, &breakpoint);
920
  setsprbits(SPR_SR, SPR_SR_F, flag);
921
}
922 123 markom
void l_sfgts() {
923 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_compare;
924 221 markom
  flag = (signed)eval_operand32(0, &breakpoint) > (signed)eval_operand32(1, &breakpoint);
925 123 markom
  setsprbits(SPR_SR, SPR_SR_F, flag);
926
}
927
void l_sfges() {
928 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_compare;
929 221 markom
  flag = (signed)eval_operand32(0, &breakpoint) >= (signed)eval_operand32(1, &breakpoint);
930 123 markom
  setsprbits(SPR_SR, SPR_SR_F, flag);
931
}
932
void l_sflts() {
933 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_compare;
934 221 markom
  flag = (signed)eval_operand32(0, &breakpoint) < (signed)eval_operand32(1, &breakpoint);
935 123 markom
  setsprbits(SPR_SR, SPR_SR_F, flag);
936
}
937
void l_sfles() {
938 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_compare;
939 221 markom
  flag = (signed)eval_operand32(0, &breakpoint) <= (signed)eval_operand32(1, &breakpoint);
940 123 markom
  setsprbits(SPR_SR, SPR_SR_F, flag);
941
}
942
void l_sfgtu() {
943 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_compare;
944 221 markom
  flag = (unsigned)eval_operand32(0, &breakpoint) > (unsigned)eval_operand32(1, &breakpoint);
945 123 markom
  setsprbits(SPR_SR, SPR_SR_F, flag);
946
}
947
void l_sfgeu() {
948 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_compare;
949 221 markom
  flag = (unsigned)eval_operand32(0, &breakpoint) >= (unsigned) eval_operand32(1, &breakpoint);
950 123 markom
  setsprbits(SPR_SR, SPR_SR_F, flag);
951
}
952
void l_sfltu() {
953 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_compare;
954 221 markom
  flag = (unsigned)eval_operand32(0, &breakpoint) < (unsigned)eval_operand32(1, &breakpoint);
955 123 markom
  setsprbits(SPR_SR, SPR_SR_F, flag);
956
}
957
void l_sfleu() {
958 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_compare;
959 221 markom
  flag = (unsigned)eval_operand32(0, &breakpoint) <= (unsigned)eval_operand32(1, &breakpoint);
960 123 markom
  setsprbits(SPR_SR, SPR_SR_F, flag);
961
}
962 615 markom
void l_extbs() {
963
  unsigned char x;
964
  IFF (config.cpu.dependstats) cur->func_unit = it_move;
965
  x = eval_operand32(1, &breakpoint);
966
  set_operand32(0, (signed long)x, &breakpoint);
967
}
968
void l_extbz() {
969
  unsigned char x;
970
  IFF (config.cpu.dependstats) cur->func_unit = it_move;
971
  x = eval_operand32(1, &breakpoint);
972
  set_operand32(0, (unsigned long)x, &breakpoint);
973
}
974
void l_exths() {
975
  unsigned short x;
976
  IFF (config.cpu.dependstats) cur->func_unit = it_move;
977
  x = eval_operand32(1, &breakpoint);
978
  set_operand32(0, (signed long)x, &breakpoint);
979
}
980
void l_exthz() {
981
  unsigned short x;
982
  IFF (config.cpu.dependstats) cur->func_unit = it_move;
983
  x = eval_operand32(1, &breakpoint);
984
  set_operand32(0, (unsigned long)x, &breakpoint);
985
}
986
void l_extws() {
987
  unsigned int x;
988
  IFF (config.cpu.dependstats) cur->func_unit = it_move;
989
  x = eval_operand32(1, &breakpoint);
990
  set_operand32(0, (signed long)x, &breakpoint);
991
}
992
void l_extwz() {
993
  unsigned int x;
994
  IFF (config.cpu.dependstats) cur->func_unit = it_move;
995
  x = eval_operand32(1, &breakpoint);
996
  set_operand32(0, (unsigned long)x, &breakpoint);
997
}
998 123 markom
void l_mtspr() {
999 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_move;
1000 600 simons
  if (mfspr(SPR_SR) & SPR_SR_SM)
1001 221 markom
    mtspr(eval_operand32(0, &breakpoint) + eval_operand32(2, &breakpoint), eval_operand32(1, &breakpoint));
1002 123 markom
  else {
1003
    printf("WARNING: trying to write SPR while SR[SUPV] is cleared.\n");
1004
    cont_run = 0;
1005
  }
1006
}
1007
void l_mfspr() {
1008 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_move;
1009 600 simons
  if (mfspr(SPR_SR) & SPR_SR_SM)
1010 221 markom
    set_operand32(0, mfspr(eval_operand32(1, &breakpoint) + eval_operand32(2, &breakpoint)), &breakpoint);
1011 123 markom
  else {
1012 221 markom
    set_operand32(0, 0, &breakpoint);
1013 123 markom
    printf("WARNING: trying to read SPR while SR[SUPV] is cleared.\n");
1014
    cont_run = 0;
1015
  }
1016
}
1017
void l_sys() {
1018 611 simons
  except_handle(EXCEPT_SYSCALL, mfspr(SPR_EEAR_BASE));
1019 123 markom
}
1020 142 chris
void l_trap() {
1021 479 markom
  /* TODO: some SR related code here! */
1022 611 simons
  except_handle(EXCEPT_TRAP, mfspr(SPR_EEAR_BASE));
1023 142 chris
}
1024 123 markom
void l_mac() {
1025
  sprword lo, hi;
1026
  LONGEST l;
1027 604 markom
  long x, y;
1028 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_mac;
1029 123 markom
  lo = mfspr (SPR_MACLO);
1030
  hi = mfspr (SPR_MACHI);
1031 221 markom
  x = eval_operand32(0, &breakpoint);
1032
  y = eval_operand32(1, &breakpoint);
1033 498 lampret
  printf ("[%08x,%08x]\t", (unsigned long)(x), (unsigned long)(y));
1034 221 markom
  l = (ULONGEST)lo | ((LONGEST)hi << 32);
1035
  l += (LONGEST) x * (LONGEST) y;
1036 123 markom
 
1037
  /* This implementation is very fast - it needs only one cycle for mac.  */
1038 221 markom
  lo = ((ULONGEST)l) & 0xFFFFFFFF;
1039
  hi = ((LONGEST)l) >> 32;
1040 123 markom
  mtspr (SPR_MACLO, lo);
1041
  mtspr (SPR_MACHI, hi);
1042 498 lampret
  printf ("(%08x,%08x)\n", hi, lo);
1043 123 markom
}
1044
void l_msb() {
1045 221 markom
  sprword lo, hi;
1046 123 markom
  LONGEST l;
1047 604 markom
  long x, y;
1048 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_mac;
1049 123 markom
  lo = mfspr (SPR_MACLO);
1050
  hi = mfspr (SPR_MACHI);
1051 604 markom
  x = eval_operand32(0, &breakpoint);
1052
  y = eval_operand32(1, &breakpoint);
1053
  printf ("[%08x,%08x]\t", (unsigned long)(x), (unsigned long)(y));
1054 221 markom
  l = (ULONGEST)lo | ((LONGEST)hi << 32);
1055
  l -= (LONGEST) eval_operand32(0, &breakpoint) * (LONGEST)eval_operand32(1, &breakpoint);
1056 123 markom
 
1057
  /* This implementation is very fast - it needs only one cycle for msb.  */
1058 221 markom
  lo = ((ULONGEST)l) & 0xFFFFFFFF;
1059
  hi = ((LONGEST)l) >> 32;
1060 123 markom
  mtspr (SPR_MACLO, lo);
1061 221 markom
  mtspr (SPR_MACHI, hi);
1062 604 markom
  printf ("(%08x,%08x)\n", hi, lo);
1063 123 markom
}
1064
void l_macrc() {
1065
  sprword lo, hi;
1066
  LONGEST l;
1067 615 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_mac;
1068 123 markom
  /* No need for synchronization here -- all MAC instructions are 1 cycle long.  */
1069
  lo =  mfspr (SPR_MACLO);
1070 221 markom
  hi =  mfspr (SPR_MACHI);
1071
  l = (ULONGEST) lo | ((LONGEST)hi << 32);
1072
  l >>= 28;
1073
  //printf ("<%08x>\n", (unsigned long)l);
1074
  set_operand32(0, (long)l, &breakpoint);
1075 123 markom
  mtspr (SPR_MACLO, 0);
1076 221 markom
  mtspr (SPR_MACHI, 0);
1077 123 markom
}
1078 615 markom
void l_cmov() {
1079
  IFF (config.cpu.dependstats) cur->func_unit = it_move;
1080
  set_operand32 (0, flag ? eval_operand32(1, &breakpoint) : eval_operand32(2, &breakpoint), &breakpoint);
1081
}
1082 174 markom
void l_cust1() {
1083
  /*int destr = cur->insn >> 21;
1084
    int src1r = cur->insn >> 15;
1085
    int src2r = cur->insn >> 9;*/
1086
}
1087
void l_cust2() {
1088
}
1089
void l_cust3() {
1090
}
1091
void l_cust4() {
1092
}
1093 123 markom
void l_invalid() {
1094 458 simons
  except_handle(EXCEPT_ILLEGAL, iqueue[0].insn_addr);
1095 123 markom
}

powered by: WebSVN 2.1.0

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