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

Subversion Repositories or1k

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

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

Line No. Rev Author Line
1 2 cvs
/* execute.c -- DLX 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 DLX simulation is done in this file. */
21
 
22
#include <stdlib.h>
23
#include <stdio.h>
24
#include <string.h>
25
 
26
#include "arch.h"
27
 
28
#include "branch_predict.h"
29
#include "abstract.h"
30
#include "parse.h"
31
#include "trace.h"
32
#include "execute.h"
33
#include "stats.h"
34
 
35
/* General purpose registers. */
36
machword reg[MAX_GPRS];
37
 
38
/* Instruction queue */
39
struct iqueue_entry iqueue[20];
40
 
41
/* Benchmark multi issue execution */
42
int multissue[20];
43
int supercycles;
44
 
45
/* Completition queue */
46
struct icomplet_entry icomplet[20];
47
 
48
/* Program counter */
49
unsigned long pc;
50
 
51
/* Temporary program counter */
52
unsigned long pctemp;
53
 
54
/* Cycles counts fetch stages */
55
int cycles;
56
 
57
/* Implementation specific.
58
   Get an actual value of a specific register. */
59
 
60
machword eval_reg(char *regstr)
61
{
62
        int regno;
63
 
64
        regno = atoi(regstr + 1);
65
 
66
        if (regno < MAX_GPRS)
67
                return reg[regno];
68
        else {
69
                printf("\nEXCEPTION: read out of registers\n");
70
                cont_run = 0;
71
                return 0;
72
        }
73
}
74
 
75
/* Implementation specific.
76
   Set a specific register with value. */
77
 
78
void set_reg32(char *regstr, unsigned long value)
79
{
80
        int regno;
81
 
82
        regno = atoi(regstr + 1);
83
 
84
        if (regno == 0)          /* gpr0 is always zero */
85
                value = 0;
86
 
87
        if (regno < MAX_GPRS)
88
                reg[regno] = value;
89
        else {
90
                printf("\nEXCEPTION: write out of registers\n");
91
                cont_run = 0;
92
        }
93
 
94
        return;
95
}
96
 
97
/* Does srcoperand depend on computation of dstoperand? Return
98
   non-zero if yes.
99
 
100
 Cycle t                 Cycle t+1
101
dst: irrelevant         src: immediate                  always 0
102
dst: reg1 direct        src: reg2 direct                0 if reg1 != reg2
103
dst: reg1 disp          src: reg2 direct                always 0
104
dst: reg1 direct        src: reg2 disp                  0 if reg1 != reg2
105
dst: reg1 disp          src: reg2 disp                  always 1 (store must
106
                                                        finish before load)
107
*/
108
 
109
int depend_operands(char *dstoperand, char *srcoperand)
110
{
111
        char dst[OPERANDNAME_LEN];
112
        char src[OPERANDNAME_LEN];
113
 
114
        if (!srcoperand)
115
                return 0;
116
 
117
        if (!dstoperand)
118
                return 0;
119
 
120
        strcpy(dst, dstoperand);
121
        strcpy(src, srcoperand);
122
 
123
        if (*src == '#')                /* immediate */
124
                return 0;
125
        else
126
        if (!strstr(src, "("))
127
                if (*src == 'r') {      /* src: reg direct */
128
                        if (!strstr(dst, "("))
129
                                if (*dst == 'r')
130
                                        if (strcmp(dst, src) == 0)
131
                                                return 1; /* dst: reg direct */
132
                                        else
133
                                                return 0; /* dst: reg direct */
134
                                else
135
                                        return 0; /* dst: addr */
136
                        else
137
                                return 0; /* dst: reg disp */
138
                } else
139
                        return 0;        /* src: addr */
140
        else {                          /* src: register disp */
141
                char *regstr;
142
 
143
                regstr = strstr(src, "(r") + 1; /* regstr == "rXX)" */
144
                *strstr(regstr, ")") = '\0';            /* regstr == "rXX" */
145
 
146
                if (!strstr(dst, "("))
147
                        if (*dst == 'r')
148
                                if (strcmp(dst, regstr) == 0)
149
                                        return 1; /* dst: reg direct */
150
                                else
151
                                        return 0; /* dst: reg direct */
152
                        else
153
                                return 0; /* dst: addr */
154
                else
155
                        return 1; /* dst: reg disp */
156
        }
157
 
158
        return 0;
159
}
160
 
161
/* Implementation specific.
162
   Get an actual value represented by operand (register direct, register
163
   indirect (with displacement), immediate etc.).
164
 
165
   #n           - immediate n
166
   rXX          - register direct
167
   XX           - relative or absolute address (labels)
168
   n(XX)        - register indirect (with displacement) */
169
 
170
machword eval_operand(char *srcoperand)
171
{
172
        char operand[OPERANDNAME_LEN];
173
 
174
        strcpy(operand, srcoperand);
175
 
176
        if (*operand == '#')            /* immediate */
177
                return strtoul(&operand[1], NULL, 0);
178
        else
179
        if (!strstr(operand, "("))      /* not indirect but ...*/
180
                if (*operand == 'r')    /* ... register direct */
181
                        return eval_reg(operand);
182
 
183
                else                    /* ... rel. or abs. address */
184
                        return eval_label(operand);
185
        else {                          /* register indirect */
186
                int disp;               /* with possible displacement */
187
                char *regstr;
188
                unsigned int memaddr;
189
 
190
                disp = atoi(operand);   /* operand == "nn(rXX)" */
191
                regstr = strstr(operand, "(r") + 1;     /* regstr == "rXX)" */
192
                *strstr(regstr, ")") = '\0';            /* regstr == "rXX" */
193
                memaddr = eval_reg(regstr) + disp;
194
 
195
                return eval_mem32(memaddr);
196
        }
197
 
198
        return 0;
199
}
200
 
201
/* Implementation specific.
202
   Set destination operand (register direct, register indirect
203
   (with displacement) with value. */
204
 
205
void set_operand(char *dstoperand, unsigned long value)
206
{
207
        char operand[OPERANDNAME_LEN];
208
 
209
        strcpy(operand, dstoperand);
210
 
211
        if (*operand == '#')            /* immediate */
212
                printf("INTERNAL ERROR: Can't set immediate operand.\n");
213
        else
214
        if (!strstr(operand, "("))      /* not indirect but ...*/
215
                if (*operand == 'r')    /* ... register direct */
216
                        set_reg32(operand, value);
217
                else                    /* ... rel. or abs. address */
218
                        printf("INTERNAL ERROR: Can't set addr operand.\n");
219
        else {                          /* register indirect */
220
                int disp;               /* with possible displacement */
221
                char *regstr;
222
                unsigned int memaddr;
223
 
224
                disp = atoi(operand);   /* operand == "nn(rXX)" */
225
                regstr = strstr(operand, "(r") + 1;     /* regstr == "rXX)" */
226
                *strstr(regstr, ")") = '\0';            /* regstr == "rXX" */
227
                memaddr = eval_reg(regstr) + disp;
228
 
229
                set_mem32(memaddr, value);
230
        }
231
 
232
        return;
233
}
234
 
235
void reset()
236
{
237
        cycles = 0;
238
        supercycles = 0;
239
        memset(reg, 0, sizeof(reg));
240
        memset(iqueue, 0, sizeof(iqueue));
241
        memset(icomplet, 0, sizeof(icomplet));
242
        pctemp = eval_label("_main");
243
        pc = pctemp;
244
        set_reg32(STACK_REG , MEMORY_LEN - STACK_SIZE);
245
}
246
 
247
void fetch()
248
{
249
        /* Cycles after reset. */
250
        cycles++;
251
 
252
        /* Fetch instruction. */
253
        strcpy(iqueue[0].insn, mem[pc].insn);
254
        strcpy(iqueue[0].op1, mem[pc].op1);
255
        strcpy(iqueue[0].op2, mem[pc].op2);
256
        strcpy(iqueue[0].op3, mem[pc].op3);
257
        iqueue[0].insn_addr = pc;
258
        iqueue[0].dependdst = NULL;
259
        iqueue[0].dependsrc1 = NULL;
260
        iqueue[0].dependsrc2 = NULL;
261
 
262
        /* Increment program counter. */
263
        pc = pctemp;
264
        pctemp += 4;
265
 
266
        /* Check for breakpoint. */
267
        if (mem[pc].brk)
268
                cont_run = 0;    /* Breakpoint set. */
269
 
270
        return;
271
}
272
 
273
void decode(struct iqueue_entry *cur)
274
{
275
 
276
        cur->dependdst = cur->op1;
277
        cur->dependsrc1 = cur->op2;     /* for calculating register */
278
        cur->dependsrc2 = cur->op3;     /* dependency */
279
 
280
        cur->func_unit = unknown;
281
 
282
        if (strcmp(cur->insn, "sw") == 0) {
283
                cur->func_unit = store;
284
                set_operand(cur->op1, eval_operand(cur->op2));
285
        } else
286
        if (strcmp(cur->insn, "sb") == 0) {
287
                cur->func_unit = store;
288
                set_operand(cur->op1, (eval_operand(cur->op2) << 24) + (eval_operand(cur->op1) & 0xffffff));
289
        } else
290
        if (strcmp(cur->insn, "sh") == 0) {
291
                cur->func_unit = store;
292
                set_operand(cur->op1, (eval_operand(cur->op2) << 16) + (eval_operand(cur->op1) & 0xffff));
293
        } else
294
        if (strcmp(cur->insn, "lw") == 0) {
295
                cur->func_unit = load;
296
                set_operand(cur->op1, eval_operand(cur->op2));
297
        } else
298
        if (strcmp(cur->insn, "lb") == 0) {
299
                signed char temp = (eval_operand(cur->op2) >> 24);
300
                cur->func_unit = load;
301
                set_operand(cur->op1, temp);
302
        } else
303
        if (strcmp(cur->insn, "lbu") == 0) {
304
                unsigned char temp = (eval_operand(cur->op2) >> 24);
305
                cur->func_unit = load;
306
                set_operand(cur->op1, temp);
307
        } else
308
        if (strcmp(cur->insn, "lh") == 0) {
309
                signed short temp = (eval_operand(cur->op2) >> 16);
310
                cur->func_unit = load;
311
                set_operand(cur->op1, temp);
312
        } else
313
        if (strcmp(cur->insn, "lhu") == 0) {
314
                unsigned short temp = (eval_operand(cur->op2) >> 16);
315
                cur->func_unit = load;
316
                set_operand(cur->op1, temp);
317
        } else
318
        if (strcmp(cur->insn, "lwi") == 0) {
319
                cur->func_unit = movimm;
320
                set_operand(cur->op1, eval_operand(cur->op2));
321
        } else
322
        if (strcmp(cur->insn, "lhi") == 0) {
323
                cur->func_unit = movimm;
324
                set_operand(cur->op1, eval_operand(cur->op2) << 16);
325
        } else
326
        if (strcmp(cur->insn, "and") == 0) {
327
                cur->func_unit = arith;
328
                set_operand(cur->op1, eval_operand(cur->op2) & eval_operand(cur->op3));
329
        } else
330
        if (strcmp(cur->insn, "andi") == 0) {
331
                cur->func_unit = arith;
332
                set_operand(cur->op1, eval_operand(cur->op2) & eval_operand(cur->op3));
333
        } else
334
        if (strcmp(cur->insn, "or") == 0) {
335
                cur->func_unit = arith;
336
                set_operand(cur->op1, eval_operand(cur->op2) | eval_operand(cur->op3));
337
        } else
338
        if (strcmp(cur->insn, "ori") == 0) {
339
                cur->func_unit = arith;
340
                set_operand(cur->op1, eval_operand(cur->op2) | eval_operand(cur->op3));
341
        } else
342
        if (strcmp(cur->insn, "xor") == 0) {
343
                cur->func_unit = arith;
344
                set_operand(cur->op1, eval_operand(cur->op2) ^ eval_operand(cur->op3));
345
        } else
346
        if (strcmp(cur->insn, "add") == 0) {
347
                signed long temp3, temp2, temp1;
348
                signed char temp4;
349
 
350
                cur->func_unit = arith;
351
                temp3 = eval_operand(cur->op3);
352
                temp2 = eval_operand(cur->op2);
353
                temp1 = temp2 + temp3;
354
                set_operand(cur->op1, temp1);
355
 
356
                temp4 = temp1;
357
                if (temp4 == temp1)
358
                        mstats.byteadd++;
359
        } else
360
        if (strcmp(cur->insn, "addi") == 0) {
361
                signed long temp3, temp2, temp1;
362
                signed char temp4;
363
 
364
                cur->func_unit = arith;
365
                temp3 = eval_operand(cur->op3);
366
                temp2 = eval_operand(cur->op2);
367
                temp1 = temp2 + temp3;
368
                set_operand(cur->op1, temp1);
369
 
370
                temp4 = temp1;
371
                if (temp4 == temp1)
372
                        mstats.byteadd++;
373
        } else
374
        if (strcmp(cur->insn, "addui") == 0) {
375
                unsigned long temp3, temp2, temp1;
376
                unsigned char temp4;
377
 
378
                cur->func_unit = arith;
379
                temp3 = eval_operand(cur->op3);
380
                temp2 = eval_operand(cur->op2);
381
                temp1 = temp2 + temp3;
382
                set_operand(cur->op1, temp1);
383
 
384
                temp4 = temp1;
385
                if (temp4 == temp1)
386
                        mstats.byteadd++;
387
        } else
388
        if (strcmp(cur->insn, "sub") == 0) {
389
                signed long temp3, temp2, temp1;
390
 
391
                cur->func_unit = arith;
392
                temp3 = eval_operand(cur->op3);
393
                temp2 = eval_operand(cur->op2);
394
                temp1 = temp2 - temp3;
395
                set_operand(cur->op1, temp1);
396
        } else
397
        if (strcmp(cur->insn, "subui") == 0) {
398
                unsigned long temp3, temp2, temp1;
399
 
400
                cur->func_unit = arith;
401
                temp3 = eval_operand(cur->op3);
402
                temp2 = eval_operand(cur->op2);
403
                temp1 = temp2 - temp3;
404
                set_operand(cur->op1, temp1);
405
        } else
406
        if (strcmp(cur->insn, "subi") == 0) {
407
                signed long temp3, temp2, temp1;
408
 
409
                cur->func_unit = arith;
410
                temp3 = eval_operand(cur->op3);
411
                temp2 = eval_operand(cur->op2);
412
                temp1 = temp2 - temp3;
413
                set_operand(cur->op1, temp1);
414
        } else
415
        if (strcmp(cur->insn, "mul") == 0) {
416
                signed long temp3, temp2, temp1;
417
 
418
                cur->func_unit = arith;
419
                temp3 = eval_operand(cur->op3);
420
                temp2 = eval_operand(cur->op2);
421
                temp1 = temp2 * temp3;
422
                set_operand(cur->op1, temp1);
423
        } else
424
        if (strcmp(cur->insn, "div") == 0) {
425
                signed long temp3, temp2, temp1;
426
 
427
                cur->func_unit = arith;
428
                temp3 = eval_operand(cur->op3);
429
                temp2 = eval_operand(cur->op2);
430
                temp1 = temp2 / temp3;
431
                set_operand(cur->op1, temp1);
432
        } else
433
        if (strcmp(cur->insn, "divu") == 0) {
434
                unsigned long temp3, temp2, temp1;
435
 
436
                cur->func_unit = arith;
437
                temp3 = eval_operand(cur->op3);
438
                temp2 = eval_operand(cur->op2);
439
                temp1 = temp2 / temp3;
440
                set_operand(cur->op1, temp1);
441
        } else
442
        if (strcmp(cur->insn, "slli") == 0) {
443
                cur->func_unit = shift;
444
                set_operand(cur->op1, eval_operand(cur->op2) << eval_operand(cur->op3));
445
        } else
446
        if (strcmp(cur->insn, "sll") == 0) {
447
                cur->func_unit = shift;
448
                set_operand(cur->op1, eval_operand(cur->op2) << eval_operand(cur->op3));
449
        } else
450
        if (strcmp(cur->insn, "srl") == 0) {
451
                cur->func_unit = shift;
452
                set_operand(cur->op1, eval_operand(cur->op2) >> eval_operand(cur->op3));
453
        } else
454
        if (strcmp(cur->insn, "srai") == 0) {
455
                cur->func_unit = shift;
456
                set_operand(cur->op1, (signed)eval_operand(cur->op2) / (1 << eval_operand(cur->op3)));
457
        } else
458
        if (strcmp(cur->insn, "sra") == 0) {
459
                cur->func_unit = shift;
460
                set_operand(cur->op1, (signed)eval_operand(cur->op2) / (1 << eval_operand(cur->op3)));
461
        } else
462
        if (strcmp(cur->insn, "jal") == 0) {
463
                cur->func_unit = jump;
464
                pctemp = eval_operand(cur->op1);
465
                set_reg32(LINK_REG, pc + 4);
466
        } else
467
        if (strcmp(cur->insn, "jr") == 0) {
468
                cur->func_unit = jump;
469
                cur->dependsrc1 = cur->op1;
470
                pctemp = eval_operand(cur->op1);
471
        } else
472
        if (strcmp(cur->insn, "j") == 0) {
473
                cur->func_unit = jump;
474
                pctemp = eval_operand(cur->op1);
475
        } else
476
        if (strcmp(cur->insn, "nop") == 0) {
477
                cur->func_unit = nop;
478
        } else
479
        if (strcmp(cur->insn, "beqz") == 0) {
480
                cur->func_unit = branch;
481
                cur->dependsrc1 = cur->op1;
482
                if (eval_operand(cur->op1) == 0) {
483
                        pctemp = eval_operand(cur->op2);
484
                        mstats.beqz.taken++;
485
                        bpb_update(cur->insn_addr, 1);
486
                        btic_update(pctemp);
487
                } else {
488
                        mstats.beqz.nottaken++;
489
                        bpb_update(cur->insn_addr, 0);
490
                        btic_update(pc);
491
                }
492
        } else
493
        if (strcmp(cur->insn, "bnez") == 0) {
494
                cur->func_unit = branch;
495
                cur->dependsrc1 = cur->op1;
496
                if (eval_operand(cur->op1) != 0) {
497
                        pctemp = eval_operand(cur->op2);
498
                        mstats.bnez.taken++;
499
                        bpb_update(cur->insn_addr, 1);
500
                        btic_update(pctemp);
501
                } else {
502
                        mstats.bnez.nottaken++;
503
                        bpb_update(cur->insn_addr, 0);
504
                        btic_update(pc);
505
                }
506
        } else
507
        if (strcmp(cur->insn, "seq") == 0) {
508
                cur->func_unit = compare;
509
                if (eval_operand(cur->op2) == eval_operand(cur->op3))
510
                        set_operand(cur->op1, 1);
511
                else
512
                        set_operand(cur->op1, 0);
513
        } else
514
        if (strcmp(cur->insn, "snei") == 0) {
515
                cur->func_unit = compare;
516
                if (eval_operand(cur->op2) != eval_operand(cur->op3))
517
                        set_operand(cur->op1, 1);
518
                else
519
                        set_operand(cur->op1, 0);
520
        } else
521
        if (strcmp(cur->insn, "sne") == 0) {
522
                cur->func_unit = compare;
523
                if (eval_operand(cur->op2) != eval_operand(cur->op3))
524
                        set_operand(cur->op1, 1);
525
                else
526
                        set_operand(cur->op1, 0);
527
        } else
528
        if (strcmp(cur->insn, "seqi") == 0) {
529
                cur->func_unit = compare;
530
                if (eval_operand(cur->op2) == eval_operand(cur->op3))
531
                        set_operand(cur->op1, 1);
532
                else
533
                        set_operand(cur->op1, 0);
534
        } else
535
        if (strcmp(cur->insn, "sgt") == 0) {
536
                cur->func_unit = compare;
537
                if ((signed)eval_operand(cur->op2) >
538
                    (signed)eval_operand(cur->op3))
539
                        set_operand(cur->op1, 1);
540
                else
541
                        set_operand(cur->op1, 0);
542
        } else
543
        if (strcmp(cur->insn, "sgtui") == 0) {
544
                cur->func_unit = compare;
545
                if ((unsigned)eval_operand(cur->op2) >
546
                    (unsigned)eval_operand(cur->op3))
547
                        set_operand(cur->op1, 1);
548
                else
549
                        set_operand(cur->op1, 0);
550
        } else
551
        if (strcmp(cur->insn, "sgeui") == 0) {
552
                cur->func_unit = compare;
553
                if ((unsigned)eval_operand(cur->op2) >=
554
                    (unsigned)eval_operand(cur->op3))
555
                        set_operand(cur->op1, 1);
556
                else
557
                        set_operand(cur->op1, 0);
558
        } else
559
        if (strcmp(cur->insn, "sgei") == 0) {
560
                cur->func_unit = compare;
561
                if ((signed)eval_operand(cur->op2) >= (signed)eval_operand(cur->op3))
562
                        set_operand(cur->op1, 1);
563
                else
564
                        set_operand(cur->op1, 0);
565
        } else
566
        if (strcmp(cur->insn, "sgti") == 0) {
567
                cur->func_unit = compare;
568
                if ((signed)eval_operand(cur->op2) >
569
                    (signed)eval_operand(cur->op3))
570
                        set_operand(cur->op1, 1);
571
                else
572
                        set_operand(cur->op1, 0);
573
        } else
574
        if (strcmp(cur->insn, "slt") == 0) {
575
                cur->func_unit = compare;
576
                if ((signed)eval_operand(cur->op2) <
577
                    (signed)eval_operand(cur->op3))
578
                        set_operand(cur->op1, 1);
579
                else
580
                        set_operand(cur->op1, 0);
581
        } else
582
        if (strcmp(cur->insn, "slti") == 0) {
583
                cur->func_unit = compare;
584
                if ((signed)eval_operand(cur->op2) <
585
                    (signed)eval_operand(cur->op3))
586
                        set_operand(cur->op1, 1);
587
                else
588
                        set_operand(cur->op1, 0);
589
        } else
590
        if (strcmp(cur->insn, "sle") == 0) {
591
                cur->func_unit = compare;
592
                if ((signed)eval_operand(cur->op2) <=
593
                    (signed)eval_operand(cur->op3))
594
                        set_operand(cur->op1, 1);
595
                else
596
                        set_operand(cur->op1, 0);
597
        } else
598
        if (strcmp(cur->insn, "slei") == 0) {
599
                cur->func_unit = compare;
600
                if ((signed)eval_operand(cur->op2) <=
601
                    (signed)eval_operand(cur->op3))
602
                        set_operand(cur->op1, 1);
603
                else
604
                        set_operand(cur->op1, 0);
605
        } else
606
        if (strcmp(cur->insn, "sleui") == 0) {
607
                cur->func_unit = compare;
608
                if ((unsigned)eval_operand(cur->op2) <=
609
                    (unsigned)eval_operand(cur->op3))
610
                        set_operand(cur->op1, 1);
611
                else
612
                        set_operand(cur->op1, 0);
613
        } else
614
        if (strcmp(cur->insn, "sleu") == 0) {
615
                cur->func_unit = compare;
616
                if ((unsigned)eval_operand(cur->op2) <=
617
                    (unsigned)eval_operand(cur->op3))
618
                        set_operand(cur->op1, 1);
619
                else
620
                        set_operand(cur->op1, 0);
621
        } else
622
        if (strcmp(cur->insn, "simrdtsc") == 0) {
623
                set_operand(cur->op1, supercycles);
624
        } else
625
        if (strcmp(cur->insn, "simprintf") == 0) {
626
                unsigned long stackaddr;
627
 
628
                stackaddr = eval_reg(FRAME_REG);
629
                simprintf(stackaddr, 0);
630
                /* printf("simprintf %x %x %x\n", stackaddr, fmtaddr, args); */
631
        } else {
632
                printf("\nEXCEPTION: illegal opcode %s ", cur->insn);
633
                printf("at %.8lx\n", cur->insn_addr);
634
                cont_run = 0;
635
        }
636
 
637
        /* Dynamic, dependency stats. */
638
        adddstats(icomplet[0].insn, iqueue[0].insn, 1, check_depend());
639
 
640
        /* Dynamic, functional units stats. */
641
        addfstats(icomplet[0].func_unit, iqueue[0].func_unit, 1, check_depend());
642
 
643
        /* Dynamic, single stats. */
644
        addsstats(iqueue[0].insn, 1, 0);
645
 
646
        /* Pseudo multiple issue benchmark */
647
        if ((multissue[cur->func_unit] == 0) || (check_depend())) {
648
                int i;
649
                for (i = 0; i < 20; i++)
650
                        multissue[i] = 1;
651
                supercycles++;
652
                multissue[arith] = 2;
653
                multissue[store] = 2;
654
                multissue[load] = 2;
655
        }
656
        multissue[cur->func_unit]--;
657
 
658
        return;
659
}
660
 
661
void execute()
662
{
663
        int i;
664
 
665
        /* Here comes real execution someday... */
666
 
667
        /* Instruction waits in completition buffer until retired. */
668
        strcpy(icomplet[0].insn, iqueue[0].insn);
669
        strcpy(icomplet[0].op1, iqueue[0].op1);
670
        strcpy(icomplet[0].op2, iqueue[0].op2);
671
        strcpy(icomplet[0].op3, iqueue[0].op3);
672
        icomplet[0].func_unit = iqueue[0].func_unit;
673
        icomplet[0].insn_addr = iqueue[0].insn_addr;
674
 
675
        if (iqueue[0].dependdst == iqueue[0].op1)
676
                icomplet[0].dependdst = icomplet[0].op1;
677
        else
678
        if (iqueue[0].dependdst == iqueue[0].op2)
679
                icomplet[0].dependdst = icomplet[0].op2;
680
        else
681
        if (iqueue[0].dependdst == iqueue[0].op3)
682
                icomplet[0].dependdst = icomplet[0].op3;
683
        else
684
                icomplet[0].dependdst = NULL;
685
 
686
        if (iqueue[0].dependsrc1 == iqueue[0].op1)
687
                icomplet[0].dependsrc1 = icomplet[0].op1;
688
        else
689
        if (iqueue[0].dependsrc1 == iqueue[0].op2)
690
                icomplet[0].dependsrc1 = icomplet[0].op2;
691
        else
692
        if (iqueue[0].dependsrc1 == iqueue[0].op3)
693
                icomplet[0].dependsrc1 = icomplet[0].op3;
694
        else
695
                icomplet[0].dependsrc1 = NULL;
696
 
697
        if (iqueue[0].dependsrc2 == iqueue[0].op1)
698
                icomplet[0].dependsrc2 = icomplet[0].op1;
699
        else
700
        if (iqueue[0].dependsrc2 == iqueue[0].op2)
701
                icomplet[0].dependsrc2 = icomplet[0].op2;
702
        else
703
        if (iqueue[0].dependsrc2 == iqueue[0].op3)
704
                icomplet[0].dependsrc2 = icomplet[0].op3;
705
        else
706
                icomplet[0].dependsrc2 = NULL;
707
 
708
        /* History of execution */
709
        for (i = HISTEXEC_LEN - 1; i; i--)
710
                histexec[i] = histexec[i - 1];
711
        histexec[0] = icomplet[0].insn_addr;      /* add last insn */
712
 
713
        return;
714
}
715
 
716
void dumpreg()
717
{
718
        int i;
719
 
720
        printf("\n\nIQ[0]:");
721
        dumpmemory(iqueue[0].insn_addr, iqueue[0].insn_addr + 4);
722
        printf(" (just executed)\tCYCLE: %u \tSUPERCYCLE: %u\nPC:", cycles, supercycles);
723
        dumpmemory(pc, pc + 4);
724
        printf(" (next insn)");
725
        for(i = 0; i < MAX_GPRS; i++) {
726
                if (i % 4 == 0)
727
                        printf("\n");
728
                printf("GPR%.2u: %.8lx  ", i, reg[i]);
729
        }
730
}

powered by: WebSVN 2.1.0

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