1 |
209 |
diegovalve |
`timescale 1ns / 1ps
|
2 |
|
|
`include "aDefinitions.v"
|
3 |
|
|
|
4 |
|
|
/**********************************************************************************
|
5 |
|
|
Theia, Ray Cast Programable graphic Processing Unit.
|
6 |
|
|
Copyright (C) 2012 Diego Valverde (diego.valverde.g@gmail.com)
|
7 |
|
|
|
8 |
|
|
This program is free software; you can redistribute it and/or
|
9 |
|
|
modify it under the terms of the GNU General Public License
|
10 |
|
|
as published by the Free Software Foundation; either version 2
|
11 |
|
|
of the License, or (at your option) any later version.
|
12 |
|
|
|
13 |
|
|
This program is distributed in the hope that it will be useful,
|
14 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
|
|
GNU General Public License for more details.
|
17 |
|
|
|
18 |
|
|
You should have received a copy of the GNU General Public License
|
19 |
|
|
along with this program; if not, write to the Free Software
|
20 |
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
21 |
|
|
|
22 |
|
|
***********************************************************************************/
|
23 |
|
|
|
24 |
|
|
module DIVISION_STATION
|
25 |
|
|
(
|
26 |
|
|
input wire Clock,
|
27 |
|
|
input wire Reset,
|
28 |
|
|
input wire [`MOD_ISSUE_PACKET_SIZE-1:0] iIssueBus,
|
29 |
|
|
input wire [`MOD_COMMIT_PACKET_SIZE-1:0] iCommitBus,
|
30 |
|
|
input wire [3:0] iId,
|
31 |
|
|
output wire [`COMMIT_PACKET_SIZE-1:0] oCommitData,
|
32 |
|
|
output wire oCommitResquest,
|
33 |
|
|
input wire iCommitGranted,
|
34 |
|
|
output wire oBusy
|
35 |
|
|
|
36 |
|
|
);
|
37 |
|
|
|
38 |
|
|
wire wExeDone;
|
39 |
|
|
wire [2:0] wExeDoneTmp;
|
40 |
|
|
wire wRS1_2_ADD_Trigger;
|
41 |
|
|
wire [`DATA_ROW_WIDTH-1:0] wRS1_OperandA;
|
42 |
|
|
wire [`DATA_ROW_WIDTH-1:0] wRS1_OperandB;
|
43 |
|
|
wire [`DATA_ROW_WIDTH-1:0] wResult;
|
44 |
|
|
wire [`LONG_WIDTH-1:0] wDividend64X,wDividendX64_Pre;
|
45 |
|
|
wire [`LONG_WIDTH-1:0] wDividend64Y,wDividendY64_Pre;
|
46 |
|
|
wire [`LONG_WIDTH-1:0] wDividend64Z,wDividendZ64_Pre;
|
47 |
|
|
wire [`LONG_WIDTH-1:0] wDivisor64X,wDivisorX64_Pre;
|
48 |
|
|
wire [`LONG_WIDTH-1:0] wDivisor64Y,wDivisorY64_Pre;
|
49 |
|
|
wire [`LONG_WIDTH-1:0] wDivisor64Z,wDivisorZ64_Pre;
|
50 |
|
|
wire [2:0] wScaleSelect;
|
51 |
|
|
|
52 |
|
|
ReservationStation RS
|
53 |
|
|
(
|
54 |
|
|
.Clock( Clock ),
|
55 |
|
|
.Reset( Reset ),
|
56 |
|
|
.iIssueBus( iIssueBus ),
|
57 |
|
|
.iCommitBus( iCommitBus ),
|
58 |
|
|
.iMyId( iId ),
|
59 |
|
|
.iExecutionDone( wExeDone ),
|
60 |
|
|
.iResult( wResult ),
|
61 |
|
|
.iCommitGranted( iCommitGranted ),
|
62 |
|
|
|
63 |
|
|
.oSource1( wRS1_OperandA ),
|
64 |
|
|
.oSource0( wRS1_OperandB ),
|
65 |
|
|
.oBusy( oBusy ),
|
66 |
|
|
.oTrigger( wRS1_2_ADD_Trigger ),
|
67 |
|
|
.oCommitRequest( oCommitResquest ),
|
68 |
|
|
.oId( oCommitData[`COMMIT_RSID_RNG] ),
|
69 |
|
|
.oWE( oCommitData[`COMMIT_WE_RNG] ),
|
70 |
|
|
.oDestination( oCommitData[`COMMIT_DST_RNG] ),
|
71 |
|
|
.oResult( {oCommitData[`X_RNG],oCommitData[`Y_RNG],oCommitData[`Z_RNG]})
|
72 |
|
|
|
73 |
|
|
);
|
74 |
|
|
|
75 |
|
|
assign wExeDone = wExeDoneTmp[0] & wExeDoneTmp[1] & wExeDoneTmp[2];
|
76 |
|
|
|
77 |
|
|
|
78 |
|
|
|
79 |
|
|
assign wDividendX64_Pre = {{32{wRS1_OperandB[95]}},wRS1_OperandB[`X_RNG]};
|
80 |
|
|
assign wDividendY64_Pre = {{32{wRS1_OperandB[63]}},wRS1_OperandB[`Y_RNG]};
|
81 |
|
|
assign wDividendZ64_Pre = {{32{wRS1_OperandB[31]}},wRS1_OperandB[`Z_RNG]};
|
82 |
|
|
|
83 |
|
|
assign wDivisorX64_Pre = {{32{wRS1_OperandA[95]}},wRS1_OperandA[`X_RNG]};
|
84 |
|
|
assign wDivisorY64_Pre = {{32{wRS1_OperandA[63]}},wRS1_OperandA[`Y_RNG]};
|
85 |
|
|
assign wDivisorZ64_Pre = {{32{wRS1_OperandA[31]}},wRS1_OperandA[`Z_RNG]};
|
86 |
|
|
|
87 |
|
|
assign wScaleSelect = iIssueBus[`MOD_ISSUE_SCALE_RNG];
|
88 |
|
|
//Perform the scale logic, the unscale part is done by the IIU
|
89 |
|
|
assign wDividend64X = (~wScaleSelect[2] & wScaleSelect[1]) ? (wDividendX64_Pre << `SCALE) : wDividendX64_Pre;
|
90 |
|
|
assign wDividend64Y = (~wScaleSelect[2] & wScaleSelect[1]) ? (wDividendY64_Pre << `SCALE) : wDividendY64_Pre;
|
91 |
|
|
assign wDividend64Z = (~wScaleSelect[2] & wScaleSelect[1]) ? (wDividendZ64_Pre << `SCALE) : wDividendZ64_Pre;
|
92 |
|
|
|
93 |
|
|
assign wDivisor64X = (~wScaleSelect[2] & wScaleSelect[0]) ? (wDivisorX64_Pre << `SCALE) : wDivisorX64_Pre;
|
94 |
|
|
assign wDivisor64Y = (~wScaleSelect[2] & wScaleSelect[0]) ? (wDivisorY64_Pre << `SCALE) : wDivisorY64_Pre;
|
95 |
|
|
assign wDivisor64Z = (~wScaleSelect[2] & wScaleSelect[0]) ? (wDivisorZ64_Pre << `SCALE) : wDivisorZ64_Pre;
|
96 |
|
|
|
97 |
|
|
|
98 |
|
|
SignedIntegerDivision DIV_0
|
99 |
|
|
(
|
100 |
|
|
.Clock( Clock ),
|
101 |
|
|
.Reset( Reset ),
|
102 |
|
|
.iInputReady( wRS1_2_ADD_Trigger ),
|
103 |
|
|
.iDividend( wDividend64X ),
|
104 |
|
|
.iDivisor( wDivisor64X ),
|
105 |
|
|
.OutputReady( wExeDoneTmp[0] ),
|
106 |
|
|
.oQuotient( wResult[`X_RNG] )
|
107 |
|
|
);
|
108 |
|
|
|
109 |
|
|
SignedIntegerDivision DIV_1
|
110 |
|
|
(
|
111 |
|
|
.Clock( Clock ),
|
112 |
|
|
.Reset( Reset ),
|
113 |
|
|
.iInputReady( wRS1_2_ADD_Trigger ),
|
114 |
|
|
.iDividend( wDividend64Y ),
|
115 |
|
|
.iDivisor( wDivisor64Y ),
|
116 |
|
|
.OutputReady( wExeDoneTmp[1] ),
|
117 |
|
|
.oQuotient( wResult[`Y_RNG] )
|
118 |
|
|
);
|
119 |
|
|
|
120 |
|
|
SignedIntegerDivision DIV_2
|
121 |
|
|
(
|
122 |
|
|
.Clock( Clock ),
|
123 |
|
|
.Reset( Reset ),
|
124 |
|
|
.iInputReady( wRS1_2_ADD_Trigger ),
|
125 |
|
|
.iDividend( wDividend64Z ),
|
126 |
|
|
.iDivisor( wDivisor64Z ),
|
127 |
|
|
.OutputReady( wExeDoneTmp[2] ),
|
128 |
|
|
.oQuotient( wResult[`Z_RNG] )
|
129 |
|
|
);
|
130 |
|
|
|
131 |
|
|
endmodule
|