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

Subversion Repositories theia_gpu

[/] [theia_gpu/] [branches/] [new_alu/] [src/] [Module_InstructionIssue.v] - Blame information for rev 209

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 209 diegovalve
`include "aDefinitions.v"
2
 
3
/**********************************************************************************
4
Theia, Ray Cast Programable graphic Processing Unit.
5
Copyright (C) 2012  Diego Valverde (diego.valverde.g@gmail.com)
6
 
7
This program is free software; you can redistribute it and/or
8
modify it under the terms of the GNU General Public License
9
as published by the Free Software Foundation; either version 2
10
of the License, or (at your option) any later version.
11
 
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
GNU General Public License for more details.
16
 
17
You should have received a copy of the GNU General Public License
18
along with this program; if not, write to the Free Software
19
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20
 
21
***********************************************************************************/
22
 
23
//`define ADDRESSING_MODES_DISABLED 1
24
//`define NO_STALL_ON_BRANCH_DEPS 1
25
 
26
`define II_STATE_AFTER_RESET             0
27
`define II_FETCH_INSTRUCTION             1
28
`define II_ISSUE_REQUEST_WITH_DATA_FWD   2
29
`define II_ISSUE_REQUEST                 3
30
`define II_FIFO_UPDATE                   4
31
`define II_ISSUE_BRANCH_OPERATION        5
32
`define II_UPDATE_PC_BRANCH_OPERATION    6
33
 
34
`define TAGMEM_OWNER_ISSUE      1'b0
35
`define TAGMEM_OWNER_FIFO       1'b1
36
 
37
module InstructionIssue
38
(
39
   input wire                                   Clock,
40
        input wire                                   Reset,
41
        input wire                                   iEnable,
42
        input wire [`INSTRUCTION_WIDTH-1:0]          iInstruction0,        //Instruction fetched from IM
43
        input wire [`INSTRUCTION_WIDTH-1:0]          iInstruction1,                       //Branch taken instruction prefetch
44
        input wire [`DATA_ROW_WIDTH-1:0]             iSourceData0,         //Source0 value from RF
45
        input wire [`DATA_ROW_WIDTH-1:0]             iSourceData1,         //Source1 value from RF
46
        input wire [`NUMBER_OF_RSVR_STATIONS-1:0]    iRStationBusy,
47
        input wire [`COMMIT_PACKET_SIZE-1:0]         iResultBcast,         //Contains DST and RsId from last commited operation
48
        input wire                                   iSignFlag,
49
        input wire                                   iZeroFlag,
50
        output wire [`DATA_ADDRESS_WIDTH-1:0]        oSourceAddress0,
51
        output wire [`DATA_ADDRESS_WIDTH-1:0]        oSourceAddress1,
52
        output wire  [`ISSUE_PACKET_SIZE-1:0]        oIssueBcast,
53
   input wire [`DATA_ADDRESS_WIDTH -1:0]        iFrameOffset,
54
        output wire  [`INSTRUCTION_ADDR_WIDTH -1:0]  oIP0,
55
        output wire  [`INSTRUCTION_ADDR_WIDTH -1:0]  oIP1
56
 
57
);
58
 
59
 
60
parameter  SB_ENTRY_WIDTH = 4;
61
 
62
wire[SB_ENTRY_WIDTH-1:0]                wSource0_Station;     //Reservation Station that is currently calculationg Source0, zero means none
63
wire[SB_ENTRY_WIDTH-1:0]                wSource1_Station;     //Reservation Station that is currently calculationg Source1, zero means none
64
wire[SB_ENTRY_WIDTH-1:0]                wSource0_RsSb;
65
wire[`DATA_ADDRESS_WIDTH-1:0]           wSBWriteAddress;
66
wire [SB_ENTRY_WIDTH-1:0]               wSBWriteData;
67
wire                                    wStall;
68
wire [`DATA_ROW_WIDTH-1:0]              wSourceData0;
69
wire [`DATA_ROW_WIDTH-1:0]              wSourceData1;
70
wire                                    wFIFO_ReadEnable;
71
wire [`DATA_ADDRESS_WIDTH-1:0]          wFIFO_Dst;
72
wire [`DATA_ADDRESS_WIDTH-1:0]          wIssue_Dst;
73
wire                                    wSBWriteEnable;
74
wire[`DATA_ROW_WIDTH-1:0]               wSignedSourceData0;
75
wire[`DATA_ROW_WIDTH-1:0]               wSignedSourceData1;
76
wire[`DATA_ROW_WIDTH-1:0]               wSwizzledSourceData0;
77
wire[`DATA_ROW_WIDTH-1:0]               wSwizzledSourceData1;
78
wire [`DATA_ROW_WIDTH-1:0]              wResultData;
79
wire [`DATA_ROW_WIDTH-1:0]              wSourceData1Temp;
80
wire [`DATA_ROW_WIDTH-1:0]              wScaledSourceData0;
81
wire [`DATA_ROW_WIDTH-1:0]              wScaledSourceData1;
82
wire [`DATA_ROW_WIDTH-1:0]              wScaledSourceData0_Pre;
83
wire [`DATA_ROW_WIDTH-1:0]              wScaledSourceData1_Pre;
84
wire [`DATA_ROW_WIDTH-1:0]              wUnscaleSourceData0_Pre;
85
wire [`DATA_ROW_WIDTH-1:0]              wUnscaleSourceData1_Pre;
86
 
87
wire wBranchTaken;
88
wire wCommitBusInputFifo_Empty;
89
wire wCommitBusDataAvailabe;
90
wire wReservationStationBusy;
91
wire [`COMMIT_PACKET_SIZE-1:0] wResultFifoData;
92
reg rTagMemoryWE,rTagMemOwner,rIssueNow,rIncrementPC,rPopFifo,rBypassFifo,rUseForwardedData;
93
reg rSetPCBranchTaken;
94
wire wBranchWithDependency;
95
 
96
assign wStall = 0;//iInstruction0[`INST_EOF_RNG];
97
 
98
reg [4:0]  rCurrentState, rNextState;
99
//Next states logic and Reset sequence
100
always @(posedge Clock )
101
  begin
102
 
103
    if (Reset | ~iEnable)
104
                rCurrentState <= `II_STATE_AFTER_RESET;
105
    else
106
                rCurrentState <= rNextState;
107
 
108
end
109
 
110
 
111
 
112
 
113
always @ ( * )
114
begin
115
        case (rCurrentState)
116
        //--------------------------------------
117
        `II_STATE_AFTER_RESET:
118
        begin
119
           rTagMemoryWE   = 1'b0;
120
                rTagMemOwner   = 1'b0;
121
                rIssueNow      = 1'b0;
122
                rIncrementPC   = 1'b0;
123
                rPopFifo       = 1'b0;
124
                rBypassFifo    = 1'b0;
125
                rUseForwardedData  = 1'b0;
126
                rSetPCBranchTaken  = 1'b0;
127
 
128
                rNextState = `II_FETCH_INSTRUCTION;
129
        end
130
        //--------------------------------------
131
        /*The PC will be incremented except for the scenario where we need to wait
132
        for reservation stations to become available. If we increment the PC, then the
133
        value of PC will get update the next clock cycle, and another clock cycle
134
        after that the instruction will get updated.
135
        1- If there is data waiting on the commit bus input port this cycle,
136
        then do not queue this data into the FIFO but instead set
137
        set the score board write enable to 1, set the wSBWriteAddress
138
        to the CommitPacket Destination range   and update the score board
139
        bit to zero, so than in the next state the score board bit associated
140
        to the commit data has been updated.
141
        2 - If there is no data waiting on the commit bus this clock cycle, but there
142
        is data that has been queued into the input FIFO, then go to a state where this
143
        data status on the scoreboard gets updated.
144
        3 - If there are no available reservation stations left to handle this
145
        instruction (structural hazard) then just stay in these same state to wait for
146
        a reservation station to become availabe.
147
        */
148
        `II_FETCH_INSTRUCTION:
149
        begin
150
                rTagMemoryWE   = wCommitBusDataAvailabe;
151
                rTagMemOwner   = `TAGMEM_OWNER_ISSUE;
152
                rIssueNow      = 1'b0;
153
                rIncrementPC   = ( ~wReservationStationBusy & ~iInstruction0[`INST_BRANCH_BIT] & wCommitBusInputFifo_Empty) | (~wReservationStationBusy & ~iInstruction0[`INST_BRANCH_BIT] & wCommitBusDataAvailabe);
154
                rPopFifo       = 1'b0;
155
                rBypassFifo    = wCommitBusDataAvailabe;                        //Write iCommitBus data directly into tag mem
156
                rUseForwardedData  = 1'b0;
157
                rSetPCBranchTaken  = 1'b0;
158
 
159
                if (wCommitBusDataAvailabe & ~wReservationStationBusy)
160
                        rNextState = `II_ISSUE_REQUEST_WITH_DATA_FWD;
161
                else if (~wCommitBusInputFifo_Empty)
162
                        rNextState = `II_FIFO_UPDATE;
163
                else if ( wReservationStationBusy )
164
                        rNextState = `II_FETCH_INSTRUCTION;
165
                else
166
                        rNextState = `II_ISSUE_REQUEST;
167
        end
168
                //--------------------------------------
169
                //TODO: If the reservation station is Busy (static hazard)
170
                //Then we shall stall the machine...
171
        `II_ISSUE_REQUEST:
172
        begin
173
                rTagMemoryWE   = ~iInstruction0[`INST_BRANCH_BIT];
174
                rTagMemOwner   = `TAGMEM_OWNER_ISSUE;
175
                rIssueNow      = 1'b1;
176
                rIncrementPC   = (iInstruction0[`INST_BRANCH_BIT] & ~wBranchWithDependency);
177
                rPopFifo       = 1'b0;
178
                rBypassFifo    = 1'b0;
179
                rUseForwardedData  = 1'b0;
180
                rSetPCBranchTaken  = 1'b0;
181
 
182
                if (iInstruction0[`INST_BRANCH_BIT])
183
                        rNextState = `II_UPDATE_PC_BRANCH_OPERATION;
184
                else
185
                   rNextState = `II_FETCH_INSTRUCTION;
186
        end
187
        //--------------------------------------
188
        /*
189
        Here the instruction remains the same as in the
190
        previous clock cycle.
191
        */
192
        `II_ISSUE_REQUEST_WITH_DATA_FWD:
193
        begin
194
                rTagMemoryWE   = ~iInstruction0[`INST_BRANCH_BIT];
195
                rTagMemOwner   = `TAGMEM_OWNER_ISSUE;
196
                rIssueNow      = 1'b1;
197
                rIncrementPC   = (iInstruction0[`INST_BRANCH_BIT] & ~wBranchWithDependency);
198
                rPopFifo       = 1'b1;
199
                rBypassFifo    = 1'b0;
200
                rUseForwardedData  = 1'b1;
201
                rSetPCBranchTaken  = 1'b0;//wBranchTaken;
202
 
203
                if (iInstruction0[`INST_BRANCH_BIT])
204
                        rNextState = `II_UPDATE_PC_BRANCH_OPERATION;
205
                else
206
                   rNextState = `II_FETCH_INSTRUCTION;
207
        end
208
        //--------------------------------------
209
        `II_FIFO_UPDATE:
210
        begin
211
                rTagMemoryWE   = 1'b1;
212
                rTagMemOwner   = `TAGMEM_OWNER_FIFO;
213
                rIssueNow      = 1'b0;
214
                rIncrementPC   = 1'b0;
215
                rPopFifo       = 1'b1;
216
                rBypassFifo    = 1'b0;
217
                rUseForwardedData  = 1'b0;
218
                rSetPCBranchTaken  = 1'b0;
219
 
220
                if (wBranchWithDependency)
221
                        rNextState = `II_UPDATE_PC_BRANCH_OPERATION;
222
                else
223
                        rNextState = `II_FETCH_INSTRUCTION;
224
        end
225
        //--------------------------------------
226
        //FIXME: You are assuming that the branch takes 1 cycle.
227
        //This may noy always be the case..
228
        `II_UPDATE_PC_BRANCH_OPERATION:
229
        begin
230
           rTagMemoryWE   = 1'b0;
231
                rTagMemOwner   = `TAGMEM_OWNER_FIFO;
232
                rIssueNow      = 1'b0;
233
                rIncrementPC   = 1'b0;
234
                rPopFifo       = 1'b1;
235
                rBypassFifo    = 1'b0;
236
                rUseForwardedData  = 1'b0;
237
                rSetPCBranchTaken  = wBranchTaken;
238
 
239
`ifdef NO_STALL_ON_BRANCH_DEPS
240
                rNextState = `II_FETCH_INSTRUCTION;
241
`else
242
                if (~wBranchWithDependency)
243
                        rNextState = `II_FETCH_INSTRUCTION;
244
                else if (~wCommitBusInputFifo_Empty)
245
                        rNextState = `II_FIFO_UPDATE;
246
                else
247
                        rNextState = `II_UPDATE_PC_BRANCH_OPERATION;
248
`endif
249
        end
250
        //--------------------------------------
251
        default:
252
        begin
253
                rTagMemOwner   = `TAGMEM_OWNER_ISSUE;
254
           rTagMemoryWE   = 1'b0;
255
                rIssueNow      = 1'b0;
256
                rIncrementPC   = 1'b0;
257
                rPopFifo       = 1'b0;
258
                rBypassFifo    = 1'b0;
259
                rUseForwardedData  = 1'b0;
260
                rSetPCBranchTaken  = 1'b0;
261
 
262
                rNextState = `II_STATE_AFTER_RESET;
263
        end
264
        //--------------------------------------
265
        endcase
266
 
267
 
268
end
269
 
270
wire [2:0] wInstructionBranchSelection;
271
assign wInstructionBranchSelection = iInstruction0[`INST_BRANCH_OP_RNG];
272
 
273
assign wBranchTaken =
274
iInstruction0[`INST_BRANCH_BIT] &
275
(
276
~wInstructionBranchSelection[2] & ~wInstructionBranchSelection[1] & ~wInstructionBranchSelection[0] |                          //inconditional BRANCH  
277
~wInstructionBranchSelection[2] & ~wInstructionBranchSelection[1] & wInstructionBranchSelection[0] & iZeroFlag |                 //==
278
~wInstructionBranchSelection[2] & wInstructionBranchSelection[1] & ~wInstructionBranchSelection[0] & ~iZeroFlag |                //!=
279
~wInstructionBranchSelection[2] & wInstructionBranchSelection[1] & wInstructionBranchSelection[0] & iSignFlag |                  //<
280
wInstructionBranchSelection[2] & ~wInstructionBranchSelection[1] & ~wInstructionBranchSelection[0] & (~iSignFlag & ~iZeroFlag)|  //>
281
wInstructionBranchSelection[2] & ~wInstructionBranchSelection[1] & wInstructionBranchSelection[0] & (iSignFlag | iZeroFlag) |    //<=
282
wInstructionBranchSelection[2] & wInstructionBranchSelection[1] & ~wInstructionBranchSelection[0] & (~iSignFlag | iZeroFlag)     //>=
283
);
284
 
285
wire [`COMMIT_PACKET_SIZE-1:0] wCommitData_Latched;
286
FFD_POSEDGE_SYNCRONOUS_RESET # ( `COMMIT_PACKET_SIZE ) ICOMMIT_BYPASS_FFD
287
(       Clock, Reset, 1'b1 ,iResultBcast  , wCommitData_Latched  );
288
 
289
 
290
//The Reservation Station scoreboard
291
wire [SB_ENTRY_WIDTH-1:0] wSBDataPort0;
292
wire [SB_ENTRY_WIDTH-1:0] wSBDataPort1;
293
wire[3:0] wReservationStation;
294
 
295
 `ifdef ADDRESSING_MODES_DISABLED
296
 
297
assign wSBWriteAddress
298
 = (rTagMemOwner == `TAGMEM_OWNER_ISSUE) ? ((rBypassFifo)?iResultBcast[`COMMIT_DST_RNG]:iInstruction0[`INST_DST_RNG])
299
 : wResultFifoData[`COMMIT_DST_RNG];
300
 
301
 `else
302
 
303
 assign wSBWriteAddress
304
 = (rTagMemOwner == `TAGMEM_OWNER_ISSUE) ? ((rBypassFifo)?iResultBcast[`COMMIT_DST_RNG]:wDestinationIndex)
305
 : wResultFifoData[`COMMIT_DST_RNG];
306
`endif
307
 
308
assign wSBWriteData
309
= (rTagMemOwner == `TAGMEM_OWNER_ISSUE) ? ((rBypassFifo)?1'b0:wReservationStation) : 4'b0;
310
 
311
 
312
RAM_DUAL_READ_PORT # ( SB_ENTRY_WIDTH, `DATA_ADDRESS_WIDTH ) SB
313
(
314
 .Clock(             Clock                          ),
315
 .iWriteEnable(      rTagMemoryWE                   ),
316
 .iReadAddress0(     oSourceAddress0                ),
317
 .iReadAddress1(     oSourceAddress1                ),
318
 .iWriteAddress(     wSBWriteAddress                ),
319
 .iDataIn(           wSBWriteData                   ),
320
 .oDataOut0(         wSBDataPort0                   ),
321
 .oDataOut1(         wSBDataPort1                   )
322
);
323
 
324
 
325
wire [`INSTRUCTION_ADDR_WIDTH-1:0]  wPCInitialValue;
326
wire [`INSTRUCTION_ADDR_WIDTH-1:0] wPCInitialTmp;
327
assign wPCInitialTmp = (iInstruction0[`INST_IMM])? wSourceData0[7:0] : {2'b0,iInstruction0[`INST_DST_RNG]};
328
 
329
assign wPCInitialValue =  (rSetPCBranchTaken & ~Reset) ? wPCInitialTmp : `INSTRUCTION_ADDR_WIDTH'b0;
330
 
331
 
332
//The program counter
333
UPCOUNTER_POSEDGE # (`INSTRUCTION_ADDR_WIDTH ) PC
334
(
335
        .Clock(    Clock                       ),
336
        .Reset(    Reset | rSetPCBranchTaken   ),
337
        .Enable(   rIncrementPC  & ~wStall     ),
338
        .Initial(  wPCInitialValue             ),
339
        .Q(        oIP0                        )
340
);
341
 
342
assign oIP1 = iInstruction0[`INST_DST_RNG];
343
 
344
 
345
`ifdef ADDRESSING_MODES_DISABLED
346
assign oSourceAddress1     = iInstruction0[`INST_SCR1_ADDR_RNG];
347
`else
348
assign oSourceAddress1     =
349
(iInstruction0[`INST_SRC1_DISPLACED]) ? (iInstruction0[`INST_SCR1_ADDR_RNG] + iFrameOffset): iInstruction0[`INST_SCR1_ADDR_RNG];
350
`endif
351
 
352
 
353
`ifdef ADDRESSING_MODES_DISABLED
354
assign oSourceAddress0     = (iInstruction0[`INST_IMM]) ? iInstruction0[`INST_DST_RNG] : iInstruction0[`INST_SRC0_ADDR_RNG];
355
`else
356
 
357
//(iInstruction0[`INST_IMM])  ? iInstruction0[`INST_DST_RNG] : iInstruction0[`INST_SRC0_ADDR_RNG];//oSourceAddress0;
358
assign oSourceAddress0     = (iInstruction0[`INST_IMM]) ? iInstruction0[`INST_DST_RNG] :
359
((iInstruction0[`INST_SRC0_DISPLACED]) ? (iInstruction0[`INST_SRC0_ADDR_RNG] + iFrameOffset): iInstruction0[`INST_SRC0_ADDR_RNG]);
360
`endif
361
 
362
 
363
assign wCommitBusDataAvailabe = iResultBcast[`COMMIT_RSID_RNG] != `OPERATION_NOP;
364
 
365
 
366
sync_fifo  # (`COMMIT_PACKET_SIZE,2 ) RESULT_IN_FIFO
367
(
368
 .clk(    Clock              ),
369
 .reset(  Reset              ),
370
 .din(    iResultBcast       ),
371
 .wr_en(  wCommitBusDataAvailabe  ),
372
 .rd_en(  rPopFifo           ),
373
 .dout(   wResultFifoData    ),
374
 .empty(  wCommitBusInputFifo_Empty   )
375
 
376
);
377
 
378
 
379
 
380
 
381
 
382
//Source 1 for IMM values is really DST
383
 
384
//Reservation station for SRC0 when handling IMM values is zero
385
 
386
wire wSB0FromInCommit,wSB0ForwardDetected;
387
wire wSB1FromInCommit,wSB1ForwardDetected;
388
 
389
assign wSB0FromInCommit = 1'b0;//(rIssueNow && (iResultBcast[`COMMIT_DST_RNG] == oSourceAddress0)) ? 1'b1 : 1'b0;
390
assign wSB1FromInCommit = 1'b0;//(rIssueNow && (iResultBcast[`COMMIT_DST_RNG] == oSourceAddress1)) ? 1'b1 : 1'b0;
391
 
392
`ifdef ADDRESSING_MODES_DISABLED
393
wire [`DATA_ADDRESS_WIDTH-1:0] wTmpAddr0;
394
assign wTmpAddr0 = (iInstruction0[`INST_IMM])  ? iInstruction0[`INST_DST_RNG] : iInstruction0[`INST_SRC0_ADDR_RNG];
395
 
396
assign wSB0ForwardDetected = (rUseForwardedData && (wCommitData_Latched[`COMMIT_DST_RNG] == wTmpAddr0) ) ? 1'b1 : 1'b0;
397
assign wSB1ForwardDetected = (rUseForwardedData && (wCommitData_Latched[`COMMIT_DST_RNG] == iInstruction0[`INST_SCR1_ADDR_RNG]) ) ? 1'b1 : 1'b0;
398
`else
399
wire [`DATA_ADDRESS_WIDTH-1:0] wTmpAddr0,wTmpAddr1;
400
assign wTmpAddr0 = oSourceAddress0;
401
assign wTmpAddr1 = oSourceAddress1;
402
 
403
assign wSB0ForwardDetected = (rUseForwardedData && (wCommitData_Latched[`COMMIT_DST_RNG] == wTmpAddr0) ) ? 1'b1 : 1'b0;
404
assign wSB1ForwardDetected = (rUseForwardedData && (wCommitData_Latched[`COMMIT_DST_RNG] == wTmpAddr1) ) ? 1'b1 : 1'b0;
405
`endif
406
 
407
assign wSource0_Station = (wSB0FromInCommit | wSB0ForwardDetected) ? 4'b0    : wSBDataPort0;
408
assign wSource1_Station = (iInstruction0[`INST_IMM] | wSB1FromInCommit | wSB1ForwardDetected) ? 4'b0: wSBDataPort1;
409
 
410
 
411
//Handle literal values for IMM. IMM is stored in SRC1.X
412
 
413
 
414
wire [`DATA_ROW_WIDTH-1:0]  wImmValue,wSource1_Temp,wSource0_Temp;
415
assign wImmValue[`X_RNG] = (iInstruction0[`INST_WE_X]) ? iInstruction0[`INST_IMM_RNG] : `WIDTH'b0;
416
assign wImmValue[`Y_RNG] = (iInstruction0[`INST_WE_Y]) ? iInstruction0[`INST_IMM_RNG] : `WIDTH'b0;
417
assign wImmValue[`Z_RNG] = (iInstruction0[`INST_WE_Z]) ? iInstruction0[`INST_IMM_RNG] : `WIDTH'b0;
418
 
419
 
420
 
421
assign wSource1_Temp[`X_RNG] = (wSB1FromInCommit & iResultBcast[`COMMIT_WE_X]) ? iResultBcast[`COMMIT_X_RNG] :
422
( (wSB1ForwardDetected & wCommitData_Latched[`COMMIT_WE_X])? wCommitData_Latched[`X_RNG] : iSourceData1[`X_RNG]);
423
 
424
assign wSource1_Temp[`Y_RNG] = (wSB1FromInCommit & iResultBcast[`COMMIT_WE_Y]) ? iResultBcast[`COMMIT_Y_RNG] :
425
( (wSB1ForwardDetected & wCommitData_Latched[`COMMIT_WE_Y]) ? wCommitData_Latched[`Y_RNG] : iSourceData1[`Y_RNG]);
426
 
427
 
428
assign wSource1_Temp[`Z_RNG] = (wSB1FromInCommit & iResultBcast[`COMMIT_WE_Z]) ? iResultBcast[`COMMIT_Z_RNG] :
429
( (wSB1ForwardDetected & wCommitData_Latched[`COMMIT_WE_Z]) ?  wCommitData_Latched[`Z_RNG] : iSourceData1[`Z_RNG]);
430
 
431
assign wSource0_Temp[`X_RNG] =  (wSB0FromInCommit & iResultBcast[`COMMIT_WE_X]) ? iResultBcast[`COMMIT_X_RNG]:
432
( (wSB0ForwardDetected & & wCommitData_Latched[`COMMIT_WE_X] )? wCommitData_Latched[`X_RNG]:iSourceData0[`X_RNG]);
433
 
434
 
435
assign wSource0_Temp[`Y_RNG] =  (wSB0FromInCommit & iResultBcast[`COMMIT_WE_Y]) ? iResultBcast[`COMMIT_Y_RNG]:
436
( (wSB0ForwardDetected & & wCommitData_Latched[`COMMIT_WE_Y])? wCommitData_Latched[`Y_RNG] : iSourceData0[`Y_RNG]);
437
 
438
assign wSource0_Temp[`Z_RNG] =  (wSB0FromInCommit & iResultBcast[`COMMIT_WE_Z]) ? iResultBcast[`COMMIT_Z_RNG]:
439
( (wSB0ForwardDetected & & wCommitData_Latched[`COMMIT_WE_Z])? wCommitData_Latched[`Z_RNG] : iSourceData0[`Z_RNG]);
440
 
441
 
442
 
443
//If the data we are looking for just arrived at iResultBcast the use that
444
//other wise used the data from the Register file or the Immediate values
445
assign wSourceData1 = (iInstruction0[`INST_IMM]) ? wImmValue : wSource1_Temp;
446
assign wSourceData0 = (iInstruction0[`INST_IMM] && iInstruction0[`INST_DEST_ZERO]) ? `DATA_ROW_WIDTH'd0 : wSource0_Temp;
447
 
448
 
449
 
450
assign wReservationStationBusy =
451
(
452
((iInstruction0[`INST_CODE_RNG] == `OPERATION_ADD ) && (iRStationBusy[ 0  ] && iRStationBusy[ 1  ])) ||
453
((iInstruction0[`INST_CODE_RNG] == `OPERATION_DIV ) &&  iRStationBusy[ 2  ]) ||
454
((iInstruction0[`INST_CODE_RNG] == `OPERATION_MUL ) &&  iRStationBusy[ 3  ])
455
);
456
 
457
assign wBranchWithDependency = (iInstruction0[`INST_BRANCH_BIT] && (wSource0_Station != 0 || wSource1_Station != 0));
458
 
459
wire [6:0] wOp;
460
assign wOp = iInstruction0[`INST_CODE_RNG];
461
 
462
assign wReservationStation[0] =
463
(wOp[0] & ~wOp[1] & ~wOp[2] & ~wOp[3] & ~iRStationBusy[ 0  ]  ) |
464
(~wOp[0] & wOp[1] & ~wOp[2] & ~wOp[3] & ~iRStationBusy[ 2  ]) |
465
(~wOp[0] & ~wOp[1] & wOp[2] & ~wOp[3] & ~iRStationBusy[ 4  ]);
466
 
467
 
468
assign wReservationStation[1] =
469
(wOp[0] & ~wOp[1] & ~wOp[2] & ~wOp[3] & iRStationBusy[ 0  ] & ~iRStationBusy[1]) |
470
(~wOp[0] & wOp[1] & ~wOp[2] & ~wOp[3] & ~iRStationBusy[ 2  ]);
471
 
472
//assign wReservationStation[2] = 1'b0;
473
assign wReservationStation[2] =
474
(wOp[0] & wOp[1] & ~wOp[2] & ~wOp[3] & ~iRStationBusy[3]) |
475
(~wOp[0] & ~wOp[1] & wOp[2] & ~wOp[3] & ~iRStationBusy[ 4  ]);
476
 
477
assign wReservationStation[3] = 1'b0;
478
 
479
//Sign control logic.
480
//Only works for non literal opeations (INST_IMM == 0)
481
wire [`ISSUE_SRCTAG_SIZE-1:0]  wIssueTag0,wIssueTag1;
482
 
483
 assign wIssueTag0 = (iInstruction0[`INST_IMM]) ? `ISSUE_SRCTAG_SIZE'b0 : {iInstruction0[`INST_SRC0_SIGN_RNG],iInstruction0[`INST_SRC0_SWZL_RNG] };
484
 assign wIssueTag1 = (iInstruction0[`INST_IMM]) ? `ISSUE_SRCTAG_SIZE'b0 : {iInstruction0[`INST_SRC1_SIGN_RNG],iInstruction0[`INST_SCR1_SWZL_RNG] };
485
 
486
wire [`DATA_ADDRESS_WIDTH -1:0] wDestinationIndex;
487
 
488
 
489
`ifdef ADDRESSING_MODES_DISABLED
490
assign wDestinationIndex = iInstruction0[`INST_DST_RNG];
491
`else
492
//assign wDestinationIndex = 
493
//(iInstruction0[`INST_IMM] == 0 && iInstruction0[`INST_DEST_ZERO]) ? (iInstruction0[`INST_DST_RNG] + iFrameOffset) : iInstruction0[`INST_DST_RNG];
494
 
495
wire [`DATA_ADDRESS_WIDTH -1:0] wDestIndexDisplaced,wDestinationIndex_NoIMM,wDestinationIndex_IMM;
496
 
497
assign wDestIndexDisplaced     = (iInstruction0[`INST_DST_RNG] + iFrameOffset);
498
assign wDestinationIndex_NoIMM = (iInstruction0[`INST_DEST_ZERO])               ? wDestIndexDisplaced : iInstruction0[`INST_DST_RNG];
499
assign wDestinationIndex_IMM   = (iInstruction0[`INST_SRC0_DISPLACED])  ? wDestIndexDisplaced : iInstruction0[`INST_DST_RNG];
500
 
501
assign wDestinationIndex = (iInstruction0[`INST_IMM]) ? wDestinationIndex_IMM : wDestinationIndex_NoIMM;
502
`endif
503
 
504
assign oIssueBcast = (Reset | ~rIssueNow | wStall ) ? `ISSUE_PACKET_SIZE'b0 :
505
{
506
wReservationStation,
507
//iInstruction0[`INST_DST_RNG],
508
wDestinationIndex,
509
iInstruction0[`INST_WE_RNG],
510
iInstruction0[`INST_SCOP_RNG],
511
wSource1_Station,
512
wIssueTag1,
513
wSourceData1,
514
 
515
wSource0_Station,
516
wIssueTag0,
517
wSourceData0
518
 
519
};
520
 
521
endmodule

powered by: WebSVN 2.1.0

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