vldst.c
19.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
/**************************************************************************
* *
* Copyright (C) 1994, Silicon Graphics, Inc. *
* *
* These coded instructions, statements, and computer programs contain *
* unpublished proprietary information of Silicon Graphics, Inc., and *
* are protected by Federal copyright law. They may not be disclosed *
* to third parties or copied or duplicated in any form, in whole or *
* in part, without the prior written consent of Silicon Graphics, Inc. *
* *
*************************************************************************/
/*
* File: vldst.c
* Creator: hsa@sgi.com
* Create Date: Fri Mar 25 11:29:13 PST 1994
*
* This file holds the LOAD and STORE instructions for the VU.
* Remember that these are actually SU instructions, but they
* have pipelining impact and stall characteristics similar to the VU, so
* we model them in the same way.
*
* Modifier: rww@sgi.com
* Modify Date: Mon May 16 00:23:37 PDT 1994
*
* Added support for Transpose Load and Stores.
*/
#include <stdio.h>
#include "rsp.h"
#include "memory.h"
#include "i128.h"
#include "rspctl.h"
#include "opcode.h"
#include "vu.h"
#include "su.h"
#include "trace_print.h"
rsp_vuPipe_t vu_LdStPipe[rsp_VUPIPEDEPTH+1];
#define LOAD_FLAG 0x01
#define STORE_FLAG 0x02
/****
**** Note: Remember that the 'element' for a vector load/store is
**** a byte index, not the ordinal item-sized field. This means
**** we must access things differently than in the computational
**** instructions...
****
****/
/*
* schedules execution of a VU load instruction:
*/
static void
rsp_VULoadExec(rsp_vuPipe_t *mp)
{
int opcode;
u8 x8;
u16 x16;
u32 x32;
u64 x64;
int stalled;
int rt_base;
int i;
int el_offset;
i128 xpose_tmp;
opcode = ExtractBits(mp->inst, 15, 11);
mp->rt = ExtractBits(mp->inst, 20, 16);
mp->format = ExtractBits(mp->inst, 10, 7);
/* check for register interlock */
if( opcode == rsp_LST ) {
rt_base = mp->rt & 0x18;
stalled = 0;
for(i=0;i<8;i++) {
rsp_VURegLock(rt_base+i, mp->pc);
stalled |= rsp_VURegIsLocked(rt_base+i, mp->pc);
};
} else {
rsp_VURegLock(mp->rt, mp->pc);
stalled = rsp_VURegIsLocked(mp->rt, mp->pc);
stalled |= rsp_SURegIsLocked(ExtractBits(mp->inst, 25, 21));
};
/* check for stall. If okay, execute and decrement delay field */
if (stalled && (!VUZeroPipe) ) {
/* can't do anything right now... */
mp->stalled = TRUE;
rsp_VUStalled = TRUE;
rsp_Verbose(stderr,"VU load stalled... (%08x)\n",mp->pc);
} else {
if( opcode == rsp_LST ) { /* init temp */
for(i=0;i<8;i++)
Set128(&(mp->result8[i]), &(rsp_VUR[rt_base+i]));
} else
Set128(&(mp->result), &(rsp_VUR[mp->rt]));
/*
* these should be proper DMA fetches...
*/
switch (opcode) {
case rsp_LSB:
strcpy(mp->opString, "lbv");
i = 0;
x8 = rsp_MemReadByte(mp->addr+i,rsp_DCACHE_ACCESS);
Set128bytes(&(mp->result), (u8 *) &x8, (mp->format+i) & 0xf, 1);
mp->res16_element = 0x8000 >> ((mp->format+i)&0xf) ;
break;
case rsp_LSS:
strcpy(mp->opString, "lsv");
mp->res16_element = 0;
for(i=0; i<sizeof(x16) ; i++) {
x8 = rsp_MemReadByte(mp->addr + i,rsp_DCACHE_ACCESS);
Set128bytes(&(mp->result), (u8 *) &x8, (mp->format+i) & 0xf, 1);
mp->res16_element |= 0x8000 >> ((mp->format+i)&0xf) ;
if( ((mp->format+i)&0xf) == 0xf )
break; /* Magical early exit */
};
break;
case rsp_LSL:
strcpy(mp->opString, "llv");
mp->res16_element = 0;
for(i=0; i<sizeof(x32) ; i++) {
x8 = rsp_MemReadByte(mp->addr + i,rsp_DCACHE_ACCESS);
Set128bytes(&(mp->result), (u8 *) &x8, (mp->format+i) & 0xf, 1);
mp->res16_element |= 0x8000 >> ((mp->format+i)&0xf) ;
if( ((mp->format+i)&0xf) == 0xf )
break; /* Magical early exit */
};
break;
case rsp_LSD:
strcpy(mp->opString, "ldv");
mp->res16_element = 0;
for(i=0; i<sizeof(x64) ; i++) {
x8 = rsp_MemReadByte(mp->addr + i,rsp_DCACHE_ACCESS);
Set128bytes(&(mp->result), (u8 *) &x8, (mp->format+i) & 0xf, 1);
mp->res16_element |= 0x8000 >> ((mp->format+i)&0xf) ;
if( ((mp->format+i)&0xf) == 0xf )
break; /* Magical early exit */
};
break;
case rsp_LSQ:
strcpy(mp->opString, "lqv");
mp->res16_element = 0;
for(i=0; (i==0) || (((i+mp->addr)&0xf) != 0); i++) {
x8 = rsp_MemReadByte(mp->addr + i,rsp_DCACHE_ACCESS);
Set128bytes(&(mp->result), (u8 *) &x8, (mp->format+i) & 0xf, 1);
mp->res16_element |= 0x8000 >> ((mp->format+i)&0xf) ;
if( ((mp->format+i)&0xf) == 0xf )
break; /* Magical early exit */
};
break;
case rsp_LSR:
strcpy(mp->opString, "lrv");
mp->res16_element = 0;
for(i=15; ((i+mp->addr)&0xf) != 0xf; i--) {
if( (mp->format+i) > 0xf ) /* RWW: Skip bytes off the */
continue; /* end of the vector */
x8 = rsp_MemReadByte((mp->addr-16) + i,rsp_DCACHE_ACCESS);
Set128bytes(&(mp->result), (u8 *) &x8, (mp->format+i) & 0xf, 1);
mp->res16_element |= 0x8000 >> ((mp->format+i)&0xf) ;
};
break;
case rsp_LSU:
strcpy(mp->opString, "luv");
for(i=0; i<8; i++) {
x16 = rsp_MemReadByte(mp->addr + i,rsp_DCACHE_ACCESS);
x16 = x16 << (14-7);
Set128By16(&(mp->result), x16, i);
};
mp->res16_element = 0xffff;
break;
case rsp_LSP:
strcpy(mp->opString, "lpv");
for(i=0; i<8; i++) {
x16 = rsp_MemReadByte(mp->addr +i,rsp_DCACHE_ACCESS);
x16 <<= (15-7);
Set128By16(&(mp->result), x16, i);
};
mp->res16_element = 0xffff;
break;
case rsp_LSH:
strcpy(mp->opString, "lhv");
x8 = mp->addr & 7;
x32 = mp->addr - x8;
for(i=0; i<8; i++) {
x16 = rsp_MemReadByte(x32 + ((x8+2*i)&0xf),rsp_DCACHE_ACCESS);
x16 = x16 << (14-7);
Set128By16(&(mp->result), x16, i);
};
mp->res16_element = 0xffff;
break;
case rsp_LSF:
strcpy(mp->opString, "lfv");
x8 = mp->addr & 7;
x32 = mp->addr - x8; /* Operate on the next double-aligned quadword */
for(i=0; i<4; i++) {
x16 = rsp_MemReadByte(x32 + ((x8+4*i)&0xf),rsp_DCACHE_ACCESS);
x16 = x16 << (14-7);
Set128By16(&(mp->result), x16, i+(mp->format>>1));
};
mp->res16_element = 0xff00 >> mp->format;
break;
case rsp_LST:
strcpy(mp->opString, "ltv");
/* Changed for HW compatibility */
mp->addr = mp->addr & ~0x7;
el_offset = ((mp->addr>>3)&0x1) ? 4 : 0;
for(i=0;i<8;i++) {
int j;
x16 = 0;
for(j=0; j<sizeof(x16) ; j++) {
x8 = rsp_MemReadByte(mp->addr+(i*2)+j,rsp_DCACHE_ACCESS);
x16 = (x16<<8) + x8;
};
Set128By16(&(xpose_tmp), x16, (i+el_offset)%8);
};
for(i=0;i<8;i++) {
int elem;
elem = ((mp->format>>1)+i)&0x7;
x16 = Get128By16(&(xpose_tmp),elem);
/*
printf("i=%d, elm=%d, x16=%x\n",i,elem,x16);
*/
Set128By16(&(mp->result), x16, i);
Set128By16(&(mp->result8[elem]), x16,i);
};
break;
default:
rsp_fprintf(stderr,"LWC2 opcode [%02x] not implemented.\n",opcode);
break;
}
mp->stalled = FALSE;
mp->delay--;
}
}
/*
* schedules execution of a VU store instruction:
*/
static void
rsp_VUStoreExec(rsp_vuPipe_t *mp)
{
int opcode;
u8 x8;
u16 x16;
u32 x32;
u64 x64;
int stalled;
int rt_base;
int i;
i128 trData;
i128 trMask;
int write_true;
opcode = ExtractBits(mp->inst, 15, 11);
mp->rt = ExtractBits(mp->inst, 20, 16);
mp->format = ExtractBits(mp->inst, 10, 7);
/* check for register interlock */
if( opcode == rsp_LST ) {
rt_base = mp->rt & 0x18;
stalled = 0;
for(i=0;i<8;i++) {
/* rsp_VURegLock(rt_base+i, mp->pc);*/
stalled |= rsp_VURegIsLocked(rt_base+i, mp->pc);
};
} else {
/* rsp_VURegLock(mp->rt, mp->pc);*/
stalled = rsp_VURegIsLocked(mp->rt, mp->pc);
};
/* check for stall. If okay, execute and decrement delay field */
if (stalled && (!VUZeroPipe) ) {
/* can't do anything right now... */
mp->stalled = TRUE;
rsp_VUStalled = TRUE;
rsp_Verbose(stderr,"VU store stalled... (%08x)\n",mp->pc);
} else {
/*
* these should be proper DMA fetches...
*/
for (i=0; i<16; i++)
trData.b[i] = trMask.b[i] = 0;
write_true=0;
switch (opcode) {
case rsp_LSB:
strcpy(mp->opString, "sbv");
x8 = Get128By8(&(rsp_VUR[mp->rt]), mp->format);
rsp_MemWriteByte(mp->addr,x8,rsp_DCACHE_ACCESS);
trData.b[mp->addr&0xf] = x8;
trMask.b[mp->addr&0xf] = 1;
traceDM(mp->addr,&(trData), &(trMask),mp->pc,1);
break;
case rsp_LSS:
strcpy(mp->opString, "ssv");
for(i=0; i<sizeof(x16); i++) {
x8 = Get128By8(&(rsp_VUR[mp->rt]), (mp->format + i)&0xf );
rsp_MemWriteByte(mp->addr+i,x8,rsp_DCACHE_ACCESS);
trData.b[(mp->addr+i)&0xf] = x8;
trMask.b[(mp->addr+i)&0xf] = 1;
}
traceDM(mp->addr,&(trData), &(trMask),mp->pc,2);
break;
case rsp_LSL:
strcpy(mp->opString, "slv");
for (i=0; i<4; i++) {
x8 = Get128By8(&(rsp_VUR[mp->rt]), (mp->format + i)&0xf );
rsp_MemWriteByte(mp->addr+i,x8,rsp_DCACHE_ACCESS);
trData.b[(mp->addr+i)&0xf] = x8;
trMask.b[(mp->addr+i)&0xf] = 1;
}
traceDM(mp->addr,&(trData), &(trMask),mp->pc,4);
break;
case rsp_LSD:
strcpy(mp->opString, "sdv");
for (i=0; i<8; i++) {
x8 = Get128By8(&(rsp_VUR[mp->rt]), (mp->format + i)&0xf );
rsp_MemWriteByte(mp->addr+i,x8,rsp_DCACHE_ACCESS);
trData.b[(mp->addr+i)&0xf] = x8;
trMask.b[(mp->addr+i)&0xf] = 1;
}
traceDM(mp->addr,&(trData), &(trMask),mp->pc,8);
break;
case rsp_LSQ:
strcpy(mp->opString, "sqv");
for(i=0; (i==0) || (((i+mp->addr)&0xf) != 0); i++) {
x8 = Get128By8(&(rsp_VUR[mp->rt]), (mp->format + i) & 0xf);
rsp_MemWriteByte(mp->addr+i,x8,rsp_DCACHE_ACCESS);
trData.b[(mp->addr+i)&0xf] = x8;
trMask.b[(mp->addr+i)&0xf] = 1;
};
traceDM(mp->addr,&(trData), &(trMask),mp->pc,16);
break;
case rsp_LSR:
strcpy(mp->opString, "srv");
for(i=15; ((i+mp->addr)&0xf) != 0xf; i--) {
x8 = Get128By8(&(rsp_VUR[mp->rt]), (mp->format + i) & 0xf);
rsp_MemWriteByte(mp->addr+i-16,x8,rsp_DCACHE_ACCESS);
trData.b[(mp->addr+i-16)&0xf] = x8;
trMask.b[(mp->addr+i-16)&0xf] = 1;
write_true = 1;
};
if (write_true) {
traceDM(mp->addr-16+i+1,&(trData), &(trMask),mp->pc,16);
fprintf(stderr,"SRV 0x%03x w/ traceDM_addr = 0x%03x\n",
mp->addr & 0xfff, (mp->addr-16+i+1)&0xfff );
};
break;
case rsp_LSP:
strcpy(mp->opString, "spv");
for(i=0; i<8; i++) {
x16 = Get128By16(&(rsp_VUR[mp->rt]), i);
x8 = x16 >> (15-7);
rsp_MemWriteByte(mp->addr+i,x8,rsp_DCACHE_ACCESS);
trData.b[(mp->addr+i)&0xf] = x8;
trMask.b[(mp->addr+i)&0xf] = 1;
};
traceDM(mp->addr,&(trData), &(trMask),mp->pc,8);
break;
case rsp_LSU:
strcpy(mp->opString, "suv");
for(i=0; i<8; i++) {
x16 = Get128By16(&(rsp_VUR[mp->rt]), i);
x8 = (x16 >> (14-7)) & 0xff;
rsp_MemWriteByte(mp->addr+i,x8,rsp_DCACHE_ACCESS);
trData.b[(mp->addr+i)&0xf] = x8;
trMask.b[(mp->addr+i)&0xf] = 1;
};
traceDM(mp->addr,&(trData), &(trMask),mp->pc,8);
break;
case rsp_LSH:
strcpy(mp->opString, "shv");
x8 = mp->addr & 7;
x32 = mp->addr - x8; /* Operate on the next double-aligned quadword */
for(i=0; i<8; i++) {
x16 = Get128By16(&(rsp_VUR[mp->rt]), i);
x16 = (x16 >> (14-7)) & 0xff;
rsp_MemWriteByte(x32 + ((x8+2*i)&0xf),x16,rsp_DCACHE_ACCESS);
trData.b[(mp->addr+2*i)&0xf] = x16;
trMask.b[(mp->addr+2*i)&0xf] = 1;
};
traceDM(mp->addr,&(trData), &(trMask),mp->pc,16);
break;
case rsp_LSF:
strcpy(mp->opString, "sfv");
x8 = mp->addr & 7;
x32 = mp->addr - x8; /* Operate on the next double-aligned quadword */
for(i=0; i<4; i++) {
x16 = Get128By16(&(rsp_VUR[mp->rt]), i+(mp->format>>1));
x16 = (x16 >> (14-7)) & 0xff;
rsp_MemWriteByte(x32 + ((x8+4*i)&0xf),x16,rsp_DCACHE_ACCESS);
trData.b[(mp->addr+4*i)&0xf] = x16;
trMask.b[(mp->addr+4*i)&0xf] = 1;
};
traceDM(mp->addr,&(trData), &(trMask),mp->pc,16);
break;
case rsp_LST:
case rsp_LSW: /* eyw */
strcpy(mp->opString, (opcode==rsp_LST) ? "stv" : "swv");
for(i=0;i<8;i++) {
if (opcode==rsp_LST)
x16 = Get128By16(&(rsp_VUR[rt_base+((i+(mp->format>>1))&7)]), i );
else
x16 = Get128By16(&(rsp_VUR[mp->rt]),(i+(mp->format>>1))&7);
x8 = x16>>8;
trData.b[(mp->addr+(i*2))&0xf] = x8;
trMask.b[(mp->addr+(i*2))&0xf] = 1;
x8 = x16 & 0xff;
trData.b[(mp->addr+(i*2+1))&0xf] = x8;
trMask.b[(mp->addr+(i*2+1))&0xf] = 1;
};
#ifdef ARB_ADDR
x16 = mp->addr & 7;
x32 = mp->addr - x16; /* Operate on the next double-aligned quadword */
for(i=0;i<16;i++) {
x8 = trData.b[i];
rsp_MemWriteByte(x32+((x16+i)&0xf),x8,rsp_DCACHE_ACCESS);
};
#else
if ((mp->addr&0xf) <8)
for(i=0;i<8;i++) {
x8 = trData.b[i*2];
rsp_MemWriteByte((mp->addr&~0x7)+2*i,x8,rsp_DCACHE_ACCESS);
x8 = trData.b[i*2+1];
rsp_MemWriteByte((mp->addr&~0x7)+2*i+1,x8,rsp_DCACHE_ACCESS);
}
else
for(i=0;i<8;i++) {
x8 = trData.b[((i+4)*2)&0xf];
rsp_MemWriteByte((mp->addr&~0x7)+2*i,x8,rsp_DCACHE_ACCESS);
x8 = trData.b[((i+4)*2+1)&0xf];
rsp_MemWriteByte((mp->addr&~0x7)+2*i+1,x8,rsp_DCACHE_ACCESS);
};
#endif
traceDM(mp->addr&~0x7,&(trData), &(trMask),mp->pc,16);
break;
default:
rsp_fprintf(stderr,"SWC2 opcode [%02x] not implemented.\n",opcode);
break;
}
rsp_Verbose(stderr,"VU STORE did write-back. (0x%08x)\n", mp->addr);
mp->stalled = FALSE;
mp->delay--;
}
}
/* PUBLIC FUNCTIONS */
/*
* check multiply pipeline for stalls
* returns TRUE is stalled.
*/
boolean
rsp_VULoadStoreCheckStall(void)
{
int i;
for (i=0; i<rsp_VUPIPEDEPTH; i++) {
if (vu_LdStPipe[i].delay > 0 && vu_LdStPipe[i].stalled)
return TRUE;
}
return FALSE;
}
int offset_shift[] = {
0,1,2,3, /* byte, short, long, double */
4, /* Quad */
4, /* Rest */
3, /* Pack */
3, /* Unpack */
4, /* Half */
4, /* Fourth */
4, /* Wrap? */
4, /* Transpose */
0,
0,
0,
0,
0,0,0,0, /* (Former?) Extended Versions */
4,0,0,0,
0,0,0,0,
0,0,0,0 };
/*
* install a VU load instruction into the pipeline
*/
void
rsp_VULoadInstall(u32 inst, u32 pc)
{
int i, base;
int offset, opcode;
for (i=0; i<rsp_VUPIPEDEPTH; i++) {
if (vu_LdStPipe[i].delay == 0 || VUZeroPipe) {
vu_LdStPipe[i].inst = inst;
vu_LdStPipe[i].pc = pc;
vu_LdStPipe[i].delay = (VUZeroPipe) ? 1 : rsp_VUPIPEDEPTH;
vu_LdStPipe[i].stalled = FALSE;
vu_LdStPipe[i].flags = LOAD_FLAG;
strcpy(vu_LdStPipe[i].opString, "?");
/* cheat, simulate bypassed SU: */
offset = ExtractBits(inst, 6, 0);
offset <<= (32-7); /* Sign extend! */
offset >>= (32-7);
opcode = ExtractBits(inst, 15, 11);
offset <<= offset_shift[ opcode ];
base = ExtractBits(inst, 25, 21);
vu_LdStPipe[i].addr = (u32) rsp_GPR[base] + offset;
if (VUZeroPipe) rsp_VULoadStorePipeStep();
break;
}
}
}
/*
* install a VU store instruction into the pipeline
*/
void
rsp_VUStoreInstall(u32 inst, u32 pc)
{
int i, base;
int offset, opcode;
for (i=0; i<rsp_VUPIPEDEPTH; i++) {
if (vu_LdStPipe[i].delay == 0 || VUZeroPipe) {
vu_LdStPipe[i].inst = inst;
vu_LdStPipe[i].pc = pc;
vu_LdStPipe[i].delay = (VUZeroPipe) ? 1 : rsp_VUPIPEDEPTH;
vu_LdStPipe[i].stalled = FALSE;
vu_LdStPipe[i].flags = STORE_FLAG;
strcpy(vu_LdStPipe[i].opString, "?");
/* cheat, simulate bypassed SU: */
offset = ExtractBits(inst, 6, 0);
offset <<= (32-7);
offset >>= (32-7);
opcode = ExtractBits(inst, 15, 11);
offset <<= offset_shift[ opcode ];
base = ExtractBits(inst, 25, 21);
vu_LdStPipe[i].addr = (u32) rsp_GPR[base] + offset;
if (VUZeroPipe) rsp_VULoadStorePipeStep();
break;
}
}
}
/*
* this function is called once per clock, advances the load/store
* pipeline one step.
*/
boolean
rsp_VULoadStorePipeStep(void)
{
int i;
/* advance all the things in the pipe */
for (i=0; i<rsp_VUPIPEDEPTH; i++) {
if (vu_LdStPipe[i].delay > 0) {
/*
* this is a hack. We 'decode' loads/stores one clock earlier
* so we can lock the vector registers in the dual-issue
* case. (when su and vu instructions both use same VU register)
*
* hsa, Mon Sep 19 11:55:21 PDT 1994
*/
if (vu_LdStPipe[i].delay == (rsp_VUPIPE_STAGE_EX + 1) || VUZeroPipe) {
if (vu_LdStPipe[i].flags == LOAD_FLAG) {
rsp_VURegLock(ExtractBits(vu_LdStPipe[i].inst, 20, 16),
vu_LdStPipe[i].pc);
}
}
if (vu_LdStPipe[i].delay == rsp_VUPIPE_STAGE_EX || VUZeroPipe) {
/* do decode and exec, if possible */
if (vu_LdStPipe[i].flags == LOAD_FLAG) {
rsp_VULoadExec(&(vu_LdStPipe[i]));
} else if (vu_LdStPipe[i].flags == STORE_FLAG) {
/* wait.. */
rsp_VUStoreExec(&(vu_LdStPipe[i]));
}
} else {
/*
* fakes pipelining by waiting to write-back answer
*/
if (rsp_VUStalled==FALSE ||
vu_LdStPipe[i].delay<rsp_VUPIPE_STAGE_EX)
vu_LdStPipe[i].delay--;
}
if (vu_LdStPipe[i].delay == rsp_VUPIPE_STAGE_WB) {
/* do write-back */
if (vu_LdStPipe[i].flags == LOAD_FLAG) {
rsp_Verbose(stderr,"VU LOAD (%s) did write-back. (v%d)\n",
vu_LdStPipe[i].opString, vu_LdStPipe[i].rt);
if( ExtractBits(vu_LdStPipe[i].inst, 15, 11) == rsp_LST ) {
int j;
for(j=0;j<8;j++)
Set128(&(rsp_VUR[(vu_LdStPipe[i].rt&0x18)+j]),
&(vu_LdStPipe[i].result8[j]));
traceVUbyLTV(vu_LdStPipe[i].rt,
vu_LdStPipe[i].format,
&(vu_LdStPipe[i].result),
vu_LdStPipe[i].pc);
} else {
Set128(&(rsp_VUR[vu_LdStPipe[i].rt]),
&(vu_LdStPipe[i].result));
if (vu_LdStPipe[i].res16_element!=0) /*lrv with address 0*/
traceVUbySU(vu_LdStPipe[i].rt,
vu_LdStPipe[i].res16_element,
&(vu_LdStPipe[i].result),
vu_LdStPipe[i].pc);
}
} else {
/* done */
}
/* mark registers not in use */
if( ExtractBits(vu_LdStPipe[i].inst, 15, 11) == rsp_LST ) {
int j;
if (vu_LdStPipe[i].flags == LOAD_FLAG) {
for(j=0;j<8;j++)
rsp_VURegUnLock( (vu_LdStPipe[i].rt&0x18) + j,
vu_LdStPipe[i].pc);
}
} else {
if (vu_LdStPipe[i].flags == LOAD_FLAG) {
rsp_VURegUnLock(vu_LdStPipe[i].rt, vu_LdStPipe[i].pc);
}
}
}
}
}
}