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

Subversion Repositories or1k

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

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
#define ARITH_SET_FLAG  0
46
 
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 615 markom
  flag = temp1 == 0;
672
  setsprbits(SPR_SR, SPR_SR_F, flag);
673
 
674 123 markom
  temp4 = temp1;
675
  if (temp4 == temp1)
676
    mstats.byteadd++;
677
}
678 557 markom
void l_sw() {
679 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_store;
680 221 markom
  set_operand32(0, eval_operand32(1, &breakpoint), &breakpoint);
681 123 markom
}
682
void l_sb() {
683 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_store;
684 221 markom
  set_operand8(0, eval_operand32(1, &breakpoint), &breakpoint);
685 123 markom
}
686
void l_sh() {
687 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_store;
688 221 markom
  set_operand16(0, eval_operand32(1, &breakpoint), &breakpoint);
689 123 markom
}
690
void l_lwz() {
691 437 simons
  unsigned long val;
692 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_load;
693 437 simons
  val = eval_operand32(1, &breakpoint);
694
  /* If eval opreand produced exception don't set anything */
695 558 markom
  if (!pending.valid)
696
    set_operand32(0, val, &breakpoint);
697 123 markom
}
698
void l_lbs() {
699 437 simons
  signed char val;
700 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_load;
701 437 simons
  val = eval_operand8(1, &breakpoint);
702
  /* If eval opreand produced exception don't set anything */
703 558 markom
  if (!pending.valid)
704
    set_operand32(0, val, &breakpoint);
705 123 markom
}
706 221 markom
void l_lbz() {
707 437 simons
  unsigned char val;
708 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_load;
709 437 simons
  val = eval_operand8(1, &breakpoint);
710
  /* If eval opreand produced exception don't set anything */
711 558 markom
  if (!pending.valid)
712
    set_operand32(0, val, &breakpoint);
713 123 markom
}
714 221 markom
void l_lhs() {
715 437 simons
  signed short val;
716 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_load;
717 437 simons
  val = eval_operand16(1, &breakpoint);
718
  /* If eval opreand produced exception don't set anything */
719 558 markom
  if (!pending.valid)
720
    set_operand32(0, val, &breakpoint);
721 123 markom
}
722 221 markom
void l_lhz() {
723 437 simons
  unsigned short val;
724 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_load;
725 437 simons
  val = eval_operand16(1, &breakpoint);
726
  /* If eval opreand produced exception don't set anything */
727 558 markom
  if (!pending.valid)
728
    set_operand32(0, val, &breakpoint);
729 123 markom
}
730
void l_movhi() {
731 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_movimm;
732 221 markom
  set_operand32(0, eval_operand32(1, &breakpoint) << 16, &breakpoint);
733 123 markom
}
734
void l_and() {
735 615 markom
  unsigned long temp1;
736 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_arith;
737 615 markom
  set_operand32(0, temp1 = set_ov_flag (eval_operand32(1, &breakpoint) & (unsigned)eval_operand32(2, &breakpoint)), &breakpoint);
738
  flag = temp1 == 0;
739
  setsprbits(SPR_SR, SPR_SR_F, flag);
740 123 markom
}
741
void l_or() {
742 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_arith;
743 605 markom
  set_operand32(0, set_ov_flag (eval_operand32(1, &breakpoint) | (unsigned)eval_operand32(2, &breakpoint)), &breakpoint);
744 123 markom
}
745
void l_xor() {
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) ^ (signed)eval_operand32(2, &breakpoint)), &breakpoint);
748 123 markom
}
749
void l_sub() {
750 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_arith;
751 605 markom
  set_operand32(0, set_ov_flag ((signed long)eval_operand32(1, &breakpoint) - (signed long)eval_operand32(2, &breakpoint)), &breakpoint);
752 123 markom
}
753 174 markom
/*int mcount = 0;*/
754 123 markom
void l_mul() {
755
  signed long temp3, temp2, temp1;
756
 
757 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_arith;
758 605 markom
  set_operand32(0, set_ov_flag ((signed long)eval_operand32(1, &breakpoint) * (signed long)eval_operand32(2, &breakpoint)), &breakpoint);
759 174 markom
  /*if (!(mcount++ & 1023)) {
760
    printf ("[%i]\n",mcount);
761
    }*/
762 123 markom
}
763
void l_div() {
764
  signed long temp3, temp2, temp1;
765
 
766 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_arith;
767 221 markom
  temp3 = eval_operand32(2, &breakpoint);
768
  temp2 = eval_operand32(1, &breakpoint);
769 123 markom
  if (temp3)
770
    temp1 = temp2 / temp3;
771 458 simons
  else {
772
    except_handle(EXCEPT_ILLEGAL, iqueue[0].insn_addr);
773
    return;
774
  }
775 605 markom
  set_operand32(0, set_ov_flag (temp1), &breakpoint);
776 123 markom
}
777
void l_divu() {
778
  unsigned long temp3, temp2, temp1;
779
 
780 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_arith;
781 221 markom
  temp3 = eval_operand32(2, &breakpoint);
782
  temp2 = eval_operand32(1, &breakpoint);
783 123 markom
  temp1 = temp2 / temp3;
784
  /* cycles += 16; */
785 605 markom
  set_operand32(0, set_ov_flag (temp1), &breakpoint);
786 123 markom
}
787
void l_sll() {
788
  int sign = 1;
789 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_shift;
790 221 markom
  if ((signed)eval_operand32(1, &breakpoint) < 0)
791 123 markom
    sign = -1;
792
  /* cycles += 2; */
793 605 markom
  set_operand32(0, set_ov_flag (eval_operand32(1, &breakpoint) << eval_operand32(2, &breakpoint)), &breakpoint);
794 123 markom
}
795
void l_sra() {
796
  unsigned long sign = 0;
797 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_shift;
798 123 markom
 
799 221 markom
  if ((signed)eval_operand32(1, &breakpoint) < 0)
800 123 markom
    sign = -1;
801
  /* cycles += 2; */
802 605 markom
  set_operand32(0, set_ov_flag ((signed)eval_operand32(1, &breakpoint) >> eval_operand32(2, &breakpoint)), &breakpoint);
803 123 markom
}
804
void l_srl() {
805 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_shift;
806 123 markom
  /* cycles += 2; */
807 605 markom
  set_operand32(0, set_ov_flag (eval_operand32(1, &breakpoint) >> eval_operand32(2, &breakpoint)), &breakpoint);
808 123 markom
}
809 535 markom
void l_bf() {
810 541 markom
  if (config.bpb.enabled) {
811 535 markom
    int fwd = (eval_operand32(0, &breakpoint) >= pc) ? 1 : 0;
812 558 markom
    IFF (config.cpu.dependstats) cur->func_unit = it_branch;
813 535 markom
    mstats.bf[flag][fwd]++;
814
    bpb_update(cur->insn_addr, flag);
815
  }
816
  if (flag) {
817
    debug(5, "\nl.bf relative: pc=%x pcnext=%x\n", pc, pcnext);
818
    pcdelay = pc + (signed)eval_operand32(0, &breakpoint) * 4;
819
    btic_update(pcnext);
820
    next_delay_insn = 1;
821
  } else {
822
    btic_update(pc);
823
  }
824
}
825
void l_bnf() {
826 541 markom
  if (config.bpb.enabled) {
827 535 markom
    int fwd = (eval_operand32(0, &breakpoint) >= pc) ? 1 : 0;
828 558 markom
    IFF (config.cpu.dependstats) cur->func_unit = it_branch;
829 535 markom
    mstats.bnf[!flag][fwd]++;
830
    bpb_update(cur->insn_addr, flag == 0);
831
  }
832
  if (flag == 0) {
833
    debug(5, "\nl.bnf relative: pc=%x pcnext=%x\n", pc, pcnext);
834
    pcdelay = pc + (signed)eval_operand32(0, &breakpoint) * 4;
835
    btic_update(pcnext);
836
    next_delay_insn = 1;
837
  } else {
838
    btic_update(pc);
839
  }
840
}
841 123 markom
void l_j() {
842 344 markom
  debug(5, "\nl.j relative: pc=%x pcnext=%x\n", pc, pcnext);
843 221 markom
  pcdelay = pc + (signed)eval_operand32(0, &breakpoint) * 4;
844 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_jump;
845 123 markom
  next_delay_insn = 1;
846
}
847
void l_jal() {
848 344 markom
  debug(5, "\nl.jal relative: pc=%x pcnext=%x\n", pc, pcnext);
849 221 markom
  pcdelay = pc + (signed)eval_operand32(0, &breakpoint) * 4;
850 123 markom
 
851 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_jump;
852 138 markom
  set_reg32(LINK_REGNO, pc + 8);
853 123 markom
  next_delay_insn = 1;
854 264 markom
  if (config.sim.profile) {
855 262 markom
    struct mem_entry *entry;
856 221 markom
    struct label_entry *tmp;
857 261 markom
    if (verify_memoryarea(pcdelay) && (tmp = get_label (pcdelay)))
858 361 markom
      fprintf (runtime.sim.fprof, "+%08X %08X %08X %s\n", cycles, pc + 8, pcdelay, tmp->name);
859 221 markom
    else
860 361 markom
      fprintf (runtime.sim.fprof, "+%08X %08X %08X @%08X\n", cycles, pc + 8, pcdelay, pcdelay);
861 173 markom
  }
862 123 markom
}
863
void l_jalr() {
864 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_jump;
865 221 markom
  pcdelay = eval_operand32(0, &breakpoint);
866 138 markom
  set_reg32(LINK_REGNO, pc + 8);
867 123 markom
  next_delay_insn = 1;
868
}
869
void l_jr() {
870 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_jump;
871 221 markom
  pcdelay = eval_operand32(0, &breakpoint);
872 123 markom
  next_delay_insn = 1;
873 482 markom
  if (config.sim.profile)
874
    fprintf (runtime.sim.fprof, "-%08X %08X\n", cycles, pcdelay);
875 123 markom
}
876
void l_rfe() {
877 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_exception;
878 416 simons
  pcnext = mfspr(SPR_EPCR_BASE);
879
  mtspr(SPR_SR, mfspr(SPR_ESR_BASE));
880
}
881 123 markom
void l_nop() {
882 511 markom
  unsigned long stackaddr;
883
  int k = eval_operand32(0, &breakpoint);
884 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_nop;
885 511 markom
  switch (k) {
886
    case NOP_NOP:
887
      break;
888
    case NOP_EXIT:
889 560 markom
      printf("exit(%d)\n", evalsim_reg32 (3));
890 511 markom
      if (config.debug.gdb_enabled)
891
        set_stall_state (1);
892
      else
893
        cont_run = 0;
894
      break;
895
    case NOP_PRINTF:
896 560 markom
      stackaddr = evalsim_reg32(4);
897
      simprintf(stackaddr, evalsim_reg32(3));
898 511 markom
      debug(5, "simprintf %x\n", stackaddr);
899
      break;
900
    case NOP_REPORT:
901 560 markom
      printf("report(0x%x);\n", evalsim_reg32(3));
902 511 markom
    default:
903
      if (k >= NOP_REPORT_FIRST && k <= NOP_REPORT_LAST)
904 604 markom
      printf("report %i (0x%x);\n", k - NOP_REPORT_FIRST, evalsim_reg32(3));
905 511 markom
      break;
906
  }
907 123 markom
}
908
void l_sfeq() {
909 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_compare;
910 221 markom
  flag = eval_operand32(0, &breakpoint) == eval_operand32(1, &breakpoint);
911 123 markom
  setsprbits(SPR_SR, SPR_SR_F, flag);
912
}
913 535 markom
void l_sfne() {
914 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_compare;
915 535 markom
  flag = eval_operand32(0, &breakpoint) != eval_operand32(1, &breakpoint);
916
  setsprbits(SPR_SR, SPR_SR_F, flag);
917
}
918 123 markom
void l_sfgts() {
919 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_compare;
920 221 markom
  flag = (signed)eval_operand32(0, &breakpoint) > (signed)eval_operand32(1, &breakpoint);
921 123 markom
  setsprbits(SPR_SR, SPR_SR_F, flag);
922
}
923
void l_sfges() {
924 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_compare;
925 221 markom
  flag = (signed)eval_operand32(0, &breakpoint) >= (signed)eval_operand32(1, &breakpoint);
926 123 markom
  setsprbits(SPR_SR, SPR_SR_F, flag);
927
}
928
void l_sflts() {
929 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_compare;
930 221 markom
  flag = (signed)eval_operand32(0, &breakpoint) < (signed)eval_operand32(1, &breakpoint);
931 123 markom
  setsprbits(SPR_SR, SPR_SR_F, flag);
932
}
933
void l_sfles() {
934 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_compare;
935 221 markom
  flag = (signed)eval_operand32(0, &breakpoint) <= (signed)eval_operand32(1, &breakpoint);
936 123 markom
  setsprbits(SPR_SR, SPR_SR_F, flag);
937
}
938
void l_sfgtu() {
939 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_compare;
940 221 markom
  flag = (unsigned)eval_operand32(0, &breakpoint) > (unsigned)eval_operand32(1, &breakpoint);
941 123 markom
  setsprbits(SPR_SR, SPR_SR_F, flag);
942
}
943
void l_sfgeu() {
944 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_compare;
945 221 markom
  flag = (unsigned)eval_operand32(0, &breakpoint) >= (unsigned) eval_operand32(1, &breakpoint);
946 123 markom
  setsprbits(SPR_SR, SPR_SR_F, flag);
947
}
948
void l_sfltu() {
949 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_compare;
950 221 markom
  flag = (unsigned)eval_operand32(0, &breakpoint) < (unsigned)eval_operand32(1, &breakpoint);
951 123 markom
  setsprbits(SPR_SR, SPR_SR_F, flag);
952
}
953
void l_sfleu() {
954 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_compare;
955 221 markom
  flag = (unsigned)eval_operand32(0, &breakpoint) <= (unsigned)eval_operand32(1, &breakpoint);
956 123 markom
  setsprbits(SPR_SR, SPR_SR_F, flag);
957
}
958 615 markom
void l_extbs() {
959
  unsigned char x;
960
  IFF (config.cpu.dependstats) cur->func_unit = it_move;
961
  x = eval_operand32(1, &breakpoint);
962
  set_operand32(0, (signed long)x, &breakpoint);
963
}
964
void l_extbz() {
965
  unsigned char x;
966
  IFF (config.cpu.dependstats) cur->func_unit = it_move;
967
  x = eval_operand32(1, &breakpoint);
968
  set_operand32(0, (unsigned long)x, &breakpoint);
969
}
970
void l_exths() {
971
  unsigned short x;
972
  IFF (config.cpu.dependstats) cur->func_unit = it_move;
973
  x = eval_operand32(1, &breakpoint);
974
  set_operand32(0, (signed long)x, &breakpoint);
975
}
976
void l_exthz() {
977
  unsigned short x;
978
  IFF (config.cpu.dependstats) cur->func_unit = it_move;
979
  x = eval_operand32(1, &breakpoint);
980
  set_operand32(0, (unsigned long)x, &breakpoint);
981
}
982
void l_extws() {
983
  unsigned int x;
984
  IFF (config.cpu.dependstats) cur->func_unit = it_move;
985
  x = eval_operand32(1, &breakpoint);
986
  set_operand32(0, (signed long)x, &breakpoint);
987
}
988
void l_extwz() {
989
  unsigned int x;
990
  IFF (config.cpu.dependstats) cur->func_unit = it_move;
991
  x = eval_operand32(1, &breakpoint);
992
  set_operand32(0, (unsigned long)x, &breakpoint);
993
}
994 123 markom
void l_mtspr() {
995 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_move;
996 600 simons
  if (mfspr(SPR_SR) & SPR_SR_SM)
997 221 markom
    mtspr(eval_operand32(0, &breakpoint) + eval_operand32(2, &breakpoint), eval_operand32(1, &breakpoint));
998 123 markom
  else {
999
    printf("WARNING: trying to write SPR while SR[SUPV] is cleared.\n");
1000
    cont_run = 0;
1001
  }
1002
}
1003
void l_mfspr() {
1004 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_move;
1005 600 simons
  if (mfspr(SPR_SR) & SPR_SR_SM)
1006 221 markom
    set_operand32(0, mfspr(eval_operand32(1, &breakpoint) + eval_operand32(2, &breakpoint)), &breakpoint);
1007 123 markom
  else {
1008 221 markom
    set_operand32(0, 0, &breakpoint);
1009 123 markom
    printf("WARNING: trying to read SPR while SR[SUPV] is cleared.\n");
1010
    cont_run = 0;
1011
  }
1012
}
1013
void l_sys() {
1014 611 simons
  except_handle(EXCEPT_SYSCALL, mfspr(SPR_EEAR_BASE));
1015 123 markom
}
1016 142 chris
void l_trap() {
1017 479 markom
  /* TODO: some SR related code here! */
1018 611 simons
  except_handle(EXCEPT_TRAP, mfspr(SPR_EEAR_BASE));
1019 142 chris
}
1020 123 markom
void l_mac() {
1021
  sprword lo, hi;
1022
  LONGEST l;
1023 604 markom
  long x, y;
1024 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_mac;
1025 123 markom
  lo = mfspr (SPR_MACLO);
1026
  hi = mfspr (SPR_MACHI);
1027 221 markom
  x = eval_operand32(0, &breakpoint);
1028
  y = eval_operand32(1, &breakpoint);
1029 498 lampret
  printf ("[%08x,%08x]\t", (unsigned long)(x), (unsigned long)(y));
1030 221 markom
  l = (ULONGEST)lo | ((LONGEST)hi << 32);
1031
  l += (LONGEST) x * (LONGEST) y;
1032 123 markom
 
1033
  /* This implementation is very fast - it needs only one cycle for mac.  */
1034 221 markom
  lo = ((ULONGEST)l) & 0xFFFFFFFF;
1035
  hi = ((LONGEST)l) >> 32;
1036 123 markom
  mtspr (SPR_MACLO, lo);
1037
  mtspr (SPR_MACHI, hi);
1038 498 lampret
  printf ("(%08x,%08x)\n", hi, lo);
1039 123 markom
}
1040
void l_msb() {
1041 221 markom
  sprword lo, hi;
1042 123 markom
  LONGEST l;
1043 604 markom
  long x, y;
1044 558 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_mac;
1045 123 markom
  lo = mfspr (SPR_MACLO);
1046
  hi = mfspr (SPR_MACHI);
1047 604 markom
  x = eval_operand32(0, &breakpoint);
1048
  y = eval_operand32(1, &breakpoint);
1049
  printf ("[%08x,%08x]\t", (unsigned long)(x), (unsigned long)(y));
1050 221 markom
  l = (ULONGEST)lo | ((LONGEST)hi << 32);
1051
  l -= (LONGEST) eval_operand32(0, &breakpoint) * (LONGEST)eval_operand32(1, &breakpoint);
1052 123 markom
 
1053
  /* This implementation is very fast - it needs only one cycle for msb.  */
1054 221 markom
  lo = ((ULONGEST)l) & 0xFFFFFFFF;
1055
  hi = ((LONGEST)l) >> 32;
1056 123 markom
  mtspr (SPR_MACLO, lo);
1057 221 markom
  mtspr (SPR_MACHI, hi);
1058 604 markom
  printf ("(%08x,%08x)\n", hi, lo);
1059 123 markom
}
1060
void l_macrc() {
1061
  sprword lo, hi;
1062
  LONGEST l;
1063 615 markom
  IFF (config.cpu.dependstats) cur->func_unit = it_mac;
1064 123 markom
  /* No need for synchronization here -- all MAC instructions are 1 cycle long.  */
1065
  lo =  mfspr (SPR_MACLO);
1066 221 markom
  hi =  mfspr (SPR_MACHI);
1067
  l = (ULONGEST) lo | ((LONGEST)hi << 32);
1068
  l >>= 28;
1069
  //printf ("<%08x>\n", (unsigned long)l);
1070
  set_operand32(0, (long)l, &breakpoint);
1071 123 markom
  mtspr (SPR_MACLO, 0);
1072 221 markom
  mtspr (SPR_MACHI, 0);
1073 123 markom
}
1074 615 markom
void l_cmov() {
1075
  IFF (config.cpu.dependstats) cur->func_unit = it_move;
1076
  set_operand32 (0, flag ? eval_operand32(1, &breakpoint) : eval_operand32(2, &breakpoint), &breakpoint);
1077
}
1078 174 markom
void l_cust1() {
1079
  /*int destr = cur->insn >> 21;
1080
    int src1r = cur->insn >> 15;
1081
    int src2r = cur->insn >> 9;*/
1082
}
1083
void l_cust2() {
1084
}
1085
void l_cust3() {
1086
}
1087
void l_cust4() {
1088
}
1089 123 markom
void l_invalid() {
1090 458 simons
  except_handle(EXCEPT_ILLEGAL, iqueue[0].insn_addr);
1091 123 markom
}

powered by: WebSVN 2.1.0

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