1 |
213 |
diegovalve |
`include "aDefinitions.v"
|
2 |
|
|
|
3 |
|
|
module ReservationStation
|
4 |
|
|
(
|
5 |
|
|
input wire Clock,
|
6 |
|
|
input wire Reset,
|
7 |
|
|
input wire [`MOD_ISSUE_PACKET_SIZE-1:0] iIssueBus,
|
8 |
|
|
input wire [`MOD_COMMIT_PACKET_SIZE-1:0] iCommitBus,
|
9 |
|
|
input wire [3:0] iMyId,
|
10 |
|
|
input wire iExecutionDone,
|
11 |
|
|
input wire iCommitGranted,
|
12 |
|
|
input wire [`DATA_ROW_WIDTH-1:0] iResult,
|
13 |
|
|
output wire [`DATA_ROW_WIDTH-1:0] oSource1,
|
14 |
|
|
output wire [`DATA_ROW_WIDTH-1:0] oSource0,
|
15 |
|
|
output wire [`DATA_ADDRESS_WIDTH-1:0] oDestination,
|
16 |
|
|
output wire [`DATA_ROW_WIDTH-1:0] oResult,
|
17 |
|
|
output wire [2:0] oWE,
|
18 |
|
|
output wire [3:0] oId,
|
19 |
|
|
output wire oBusy,
|
20 |
|
|
output wire oTrigger,
|
21 |
|
|
output wire oCommitRequest,
|
22 |
|
|
output wire [`DATA_ROW_WIDTH-1:0] oSrc0Latched,oSrc1Latched
|
23 |
|
|
|
24 |
|
|
);
|
25 |
|
|
|
26 |
|
|
wire wStall;
|
27 |
|
|
wire wLatchRequest;
|
28 |
|
|
wire [3:0] wSource1_RS;
|
29 |
|
|
wire [3:0] wSource0_RS;
|
30 |
|
|
//wire [3:0] wMyId;
|
31 |
|
|
wire wTrigger;
|
32 |
|
|
//wire wFIFO_Pop;
|
33 |
|
|
|
34 |
|
|
wire [`MOD_ISSUE_PACKET_SIZE-1:0] wIssue_Latched;
|
35 |
|
|
wire [`DATA_ADDRESS_WIDTH-1:0] wDestination;
|
36 |
|
|
wire [3:0] wID;
|
37 |
|
|
wire [2:0] wWE;
|
38 |
|
|
wire wCommitFifoFull;
|
39 |
|
|
wire [`ISSUE_SRCTAG_SIZE-1:0] wTag0,wTag1;
|
40 |
|
|
|
41 |
|
|
|
42 |
|
|
//assign wFIFO_Pop = iExecutionDone;
|
43 |
|
|
assign oCommitRequest = iExecutionDone;
|
44 |
|
|
assign wLatchRequest = ( iIssueBus[`MOD_ISSUE_RSID_RNG] == iMyId) ? 1'b1 : 1'b0;
|
45 |
|
|
//If there are no dependencies then just trigger execution
|
46 |
|
|
//assign oTrigger = (wTrigger /*&& (iIssueBus[`ISSUE_SRC0RS_RNG] == 0) && (iIssueBus[`ISSUE_SRC1RS_RNG] == 0)*/ ) ? 1'b1 : 0;
|
47 |
|
|
assign oTrigger = ( (wLatchRequest | wLatchData0FromCommitBus | wLatchData1FromCommitBus) & ~wStall);
|
48 |
|
|
|
49 |
|
|
assign wStall = (wLatchRequest && (iIssueBus[`MOD_ISSUE_SRC1RS_RNG] != 0 || iIssueBus[`MOD_ISSUE_SRC0RS_RNG] != 0)) ? 1'b1 : 1'b0;
|
50 |
|
|
//assign wStall = (wSource1_RS == 0 & wSource0_RS == 0) ? 1'b0 : 1'b1;
|
51 |
|
|
|
52 |
|
|
wire wLatchData0FromCommitBus;
|
53 |
|
|
wire wLatchData1FromCommitBus;
|
54 |
|
|
|
55 |
|
|
|
56 |
|
|
assign wLatchData0FromCommitBus = ((wStall == 1'b1) && (iCommitBus[`MOD_COMMIT_RSID_RNG] == wSource0_RS)) ? 1'b1 : 1'b0;
|
57 |
|
|
assign wLatchData1FromCommitBus = ((wStall == 1'b1) && (iCommitBus[`MOD_COMMIT_RSID_RNG] == wSource1_RS)) ? 1'b1 : 1'b0;
|
58 |
|
|
|
59 |
|
|
wire wBusy;
|
60 |
|
|
assign oBusy = wBusy | wCommitFifoFull & ~iCommitGranted;
|
61 |
|
|
wire wCommitGrantedDelay;
|
62 |
|
|
|
63 |
|
|
UPCOUNTER_POSEDGE # ( 1 ) BUSY
|
64 |
|
|
(
|
65 |
|
|
.Clock( Clock ),
|
66 |
|
|
.Reset( Reset ),
|
67 |
|
|
.Enable( wLatchRequest | iCommitGranted ),
|
68 |
|
|
.Initial( 1'b0 ),
|
69 |
|
|
.Q( wBusy )
|
70 |
|
|
);
|
71 |
|
|
|
72 |
|
|
|
73 |
|
|
|
74 |
|
|
|
75 |
|
|
|
76 |
|
|
assign oSource1 = (wLatchData0FromCommitBus) ? iCommitBus[`MOD_COMMIT_DATA_RNG] : iIssueBus[`MOD_ISSUE_SRC0_DATA_RNG];
|
77 |
|
|
assign oSource0 = (wLatchData1FromCommitBus) ? (/*(wDstZero)?`DATA_ROW_WIDTH'b0:*/iCommitBus[`MOD_COMMIT_DATA_RNG]) : iIssueBus[`MOD_ISSUE_SRC1_DATA_RNG];
|
78 |
|
|
assign wTrigger = ( wLatchRequest | wLatchData0FromCommitBus | wLatchData1FromCommitBus);
|
79 |
|
|
|
80 |
|
|
|
81 |
|
|
wire [`DATA_ROW_WIDTH-1:0] wSrc1,wSrc0;
|
82 |
|
|
//FFD_POSEDGE_SYNCRONOUS_RESET # ( `MOD_ISSUE_PACKET_SIZE ) ISSUE_FFD
|
83 |
|
|
//( Clock, Reset, wLatchRequest , iIssueBus, {wDstZero,wID,wWE,wDestination,wSource1_RS,wSource0_RS,wSrc1,wSrc0} );
|
84 |
|
|
|
85 |
|
|
wire [3:0] wScale;
|
86 |
|
|
FFD_POSEDGE_SYNCRONOUS_RESET # ( `MOD_ISSUE_PACKET_SIZE ) ISSUE_FFD
|
87 |
|
|
( Clock, Reset, wLatchRequest , iIssueBus, {wID,wDestination,wWE,wScale,wSource1_RS,wSrc1,wSource0_RS,wSrc0} );
|
88 |
|
|
|
89 |
|
|
assign oSrc0Latched = wSrc0;
|
90 |
|
|
assign oSrc1Latched = wSrc1;
|
91 |
|
|
|
92 |
|
|
assign wTag0 = wSrc0[`MOD_ISSUE_TAG0_RNG];
|
93 |
|
|
assign wTag1 = wSrc1[`MOD_ISSUE_TAG0_RNG];
|
94 |
|
|
|
95 |
|
|
sync_fifo # (`COMMIT_PACKET_SIZE ) COMMIT_OUT_FIFO
|
96 |
|
|
(
|
97 |
|
|
.clk( Clock ),
|
98 |
|
|
.reset( Reset ),
|
99 |
|
|
.din( {wID,wWE,wDestination,iResult} ),
|
100 |
|
|
.wr_en( iExecutionDone ),
|
101 |
|
|
.rd_en( iCommitGranted ),
|
102 |
|
|
.dout( {oId,oWE,oDestination,oResult} ),
|
103 |
|
|
.full( wCommitFifoFull )
|
104 |
|
|
|
105 |
|
|
);
|
106 |
|
|
|
107 |
|
|
/*
|
108 |
|
|
FFD_POSEDGE_SYNCRONOUS_RESET # ( 1 ) FFD_Trigger
|
109 |
|
|
( Clock, Reset, 1'b1 , wLatchRequest, wTrigger );
|
110 |
|
|
|
111 |
|
|
*/
|
112 |
|
|
endmodule
|
113 |
|
|
|
114 |
|
|
//-------------------------------------------------------------------------------------------------
|
115 |
|
|
module ReservationStation_1Cycle
|
116 |
|
|
(
|
117 |
|
|
input wire Clock,
|
118 |
|
|
input wire Reset,
|
119 |
|
|
input wire [`MOD_ISSUE_PACKET_SIZE-1:0] iIssueBus,
|
120 |
|
|
input wire [`MOD_COMMIT_PACKET_SIZE-1:0] iCommitBus,
|
121 |
|
|
input wire [3:0] iMyId,
|
122 |
|
|
input wire iExecutionDone,
|
123 |
|
|
input wire iCommitGranted,
|
124 |
|
|
input wire [`DATA_ROW_WIDTH-1:0] iResult,
|
125 |
|
|
output wire [`DATA_ROW_WIDTH-1:0] oSource1,
|
126 |
|
|
output wire [`DATA_ROW_WIDTH-1:0] oSource0,
|
127 |
|
|
output wire [`DATA_ADDRESS_WIDTH-1:0] oDestination,
|
128 |
|
|
output wire [`DATA_ROW_WIDTH-1:0] oResult,
|
129 |
|
|
output wire [`SCALE_SIZE-1:0] oScale,
|
130 |
|
|
output wire [2:0] oWE,
|
131 |
|
|
output wire [3:0] oId,
|
132 |
|
|
output wire oBusy,
|
133 |
|
|
output wire oTrigger,
|
134 |
|
|
output wire oCommitRequest
|
135 |
|
|
|
136 |
|
|
);
|
137 |
|
|
|
138 |
|
|
|
139 |
|
|
wire [3:0] wSource1_RS;
|
140 |
|
|
wire [3:0] wSource0_RS;
|
141 |
|
|
wire [3:0] wMyId;
|
142 |
|
|
wire wTrigger;
|
143 |
|
|
wire [`DATA_ADDRESS_WIDTH-1:0] wDestination;
|
144 |
|
|
wire [3:0] wID;
|
145 |
|
|
wire [2:0] wWE;
|
146 |
|
|
wire [`DATA_ROW_WIDTH-1:0] wSrc1,wSrc0,wResult;
|
147 |
|
|
//wire wDstZero;
|
148 |
|
|
wire [`DATA_ROW_WIDTH-1:0] wSrc1_Fwd;
|
149 |
|
|
wire [`DATA_ROW_WIDTH-1:0] wSrc0_Fwd;
|
150 |
|
|
|
151 |
|
|
wire wSrc0_Dependency_Initial, wSrc0_Dependency;
|
152 |
|
|
wire wSrc1_Dependency_Initial, wSrc1_Dependency;
|
153 |
|
|
wire wSrc0_DependencyResolved, wSrc0_DependencyLatch;
|
154 |
|
|
wire wSrc1_DependencyResolved, wSrc1_DependencyLatch;
|
155 |
|
|
wire wWaitingDependency;
|
156 |
|
|
wire wHandleCurrentIssue;
|
157 |
|
|
wire wDependencyResolved;
|
158 |
|
|
wire [`ISSUE_SRCTAG_SIZE-1:0] wTag0,wTag1;
|
159 |
|
|
wire wSrc0_DependencyLatch_Pre,wSrc1_DependencyLatch_Pre;
|
160 |
|
|
|
161 |
|
|
assign wHandleCurrentIssue = ( iIssueBus[`MOD_ISSUE_RSID_RNG] == iMyId) ? 1'b1 : 1'b0;
|
162 |
|
|
assign wSrc0_Dependency_Initial = wHandleCurrentIssue & (iIssueBus[96] | iIssueBus[97] | iIssueBus[98] | iIssueBus[99]);
|
163 |
|
|
assign wSrc1_Dependency_Initial = wHandleCurrentIssue & (iIssueBus[196] | iIssueBus[197] | iIssueBus[198] | iIssueBus[199]);
|
164 |
|
|
|
165 |
|
|
|
166 |
|
|
assign oTrigger =
|
167 |
|
|
(~wWaitingDependency & wHandleCurrentIssue & ~wSrc0_Dependency_Initial & ~wSrc1_Dependency_Initial)
|
168 |
|
|
|(wWaitingDependency & ~wSrc1_Dependency & wSrc0_Dependency & wSrc0_DependencyResolved )
|
169 |
|
|
|(wWaitingDependency & wSrc1_Dependency & ~wSrc0_Dependency & wSrc1_DependencyResolved )
|
170 |
|
|
|(wWaitingDependency & wSrc1_Dependency & wSrc0_Dependency & wSrc1_DependencyResolved & wSrc0_DependencyResolved );
|
171 |
|
|
|
172 |
|
|
assign wDependencyResolved = wWaitingDependency & ~wSrc1_Dependency & ~wSrc0_Dependency;
|
173 |
|
|
|
174 |
|
|
assign wSrc0_DependencyLatch_Pre = ( wSrc0_Dependency && (iCommitBus[`MOD_COMMIT_RSID_RNG] == wSource0_RS && iCommitBus[`MOD_COMMIT_TAG_RNG] == wTag0) ) ? 1'b1 : 1'b0;
|
175 |
|
|
assign wSrc1_DependencyLatch_Pre = ( wSrc1_Dependency && (iCommitBus[`MOD_COMMIT_RSID_RNG] == wSource1_RS && iCommitBus[`MOD_COMMIT_TAG_RNG] == wTag1) ) ? 1'b1 : 1'b0;
|
176 |
|
|
|
177 |
|
|
PULSE P1 ( Clock,Reset, 1'b1, wSrc0_DependencyLatch_Pre, wSrc0_DependencyLatch);
|
178 |
|
|
PULSE P2 ( Clock,Reset, 1'b1, wSrc1_DependencyLatch_Pre, wSrc1_DependencyLatch);
|
179 |
|
|
|
180 |
|
|
wire wWaitingForCommitGranted;
|
181 |
|
|
UPCOUNTER_POSEDGE # ( 1 ) FFD_101
|
182 |
|
|
( Clock, Reset, 1'b0, (oBusy & (iCommitGranted ^ wDependencyResolved) ), wWaitingForCommitGranted );
|
183 |
|
|
|
184 |
|
|
UPCOUNTER_POSEDGE # ( 1 ) FFD_10
|
185 |
|
|
( Clock, Reset, 1'b0, wSrc0_DependencyLatch | wDependencyResolved, wSrc0_DependencyResolved );
|
186 |
|
|
|
187 |
|
|
UPCOUNTER_POSEDGE # ( 1 ) FFD_11
|
188 |
|
|
( Clock, Reset, 1'b0, wSrc1_DependencyLatch | wDependencyResolved, wSrc1_DependencyResolved );
|
189 |
|
|
|
190 |
|
|
FFD_POSEDGE_SYNCRONOUS_RESET # ( `DATA_ROW_WIDTH ) FFD_DEP0
|
191 |
|
|
( Clock, Reset, wSrc1_DependencyLatch, iCommitBus[`MOD_COMMIT_DATA_RNG],wSrc1_Fwd );
|
192 |
|
|
|
193 |
|
|
FFD_POSEDGE_SYNCRONOUS_RESET # ( `DATA_ROW_WIDTH ) FFD_DEP1
|
194 |
|
|
( Clock, Reset, wSrc0_DependencyLatch, iCommitBus[`MOD_COMMIT_DATA_RNG],wSrc0_Fwd );
|
195 |
|
|
|
196 |
|
|
|
197 |
|
|
//assign oBusy = wWaitingDependency;
|
198 |
|
|
UPCOUNTER_POSEDGE # ( 1 ) BUSY
|
199 |
|
|
(
|
200 |
|
|
.Clock( Clock ),
|
201 |
|
|
.Reset( Reset ),
|
202 |
|
|
.Enable( wSrc0_Dependency_Initial | wSrc1_Dependency_Initial | ((wWaitingForCommitGranted|wDependencyResolved)/*WaitingDependency*/ & iCommitGranted) ),//***
|
203 |
|
|
.Initial( 1'b0 ),
|
204 |
|
|
.Q( oBusy )
|
205 |
|
|
);
|
206 |
|
|
|
207 |
|
|
wire wCommitRequest;
|
208 |
|
|
UPCOUNTER_POSEDGE # ( 1 ) CRQ
|
209 |
|
|
(
|
210 |
|
|
.Clock( Clock ),
|
211 |
|
|
.Reset( Reset ),
|
212 |
|
|
.Enable( oTrigger | iCommitGranted ),
|
213 |
|
|
.Initial( 1'b0 ),
|
214 |
|
|
.Q( wCommitRequest )
|
215 |
|
|
);
|
216 |
|
|
assign oCommitRequest = oTrigger | (wCommitRequest & ~iCommitGranted);
|
217 |
|
|
|
218 |
|
|
assign oResult = iResult;
|
219 |
|
|
assign oSource1 = (wWaitingDependency) ? ((wSrc1_Dependency)? (wSrc1_Fwd):wSrc1) : iIssueBus[`MOD_ISSUE_SRC1_DATA_RNG];
|
220 |
|
|
assign oSource0 = (wWaitingDependency) ? ((wSrc0_Dependency)? (wSrc0_Fwd):wSrc0) : iIssueBus[`MOD_ISSUE_SRC0_DATA_RNG];
|
221 |
|
|
|
222 |
|
|
|
223 |
|
|
UPCOUNTER_POSEDGE # ( 1 ) DEP
|
224 |
|
|
(
|
225 |
|
|
.Clock( Clock ),
|
226 |
|
|
.Reset( Reset ),
|
227 |
|
|
.Enable( wSrc0_Dependency_Initial | wSrc1_Dependency_Initial | wDependencyResolved ),//***
|
228 |
|
|
.Initial( 1'b0 ),
|
229 |
|
|
.Q( wWaitingDependency )
|
230 |
|
|
);
|
231 |
|
|
|
232 |
|
|
UPCOUNTER_POSEDGE # ( 1 ) DEPA
|
233 |
|
|
(
|
234 |
|
|
.Clock( Clock ),
|
235 |
|
|
.Reset( Reset ),
|
236 |
|
|
.Enable( wSrc0_Dependency_Initial | wSrc0_DependencyResolved ),
|
237 |
|
|
.Initial( 1'b0 ),
|
238 |
|
|
.Q( wSrc0_Dependency )
|
239 |
|
|
);
|
240 |
|
|
|
241 |
|
|
UPCOUNTER_POSEDGE # ( 1 ) DEPB
|
242 |
|
|
(
|
243 |
|
|
.Clock( Clock ),
|
244 |
|
|
.Reset( Reset ),
|
245 |
|
|
.Enable( wSrc1_Dependency_Initial | wSrc1_DependencyResolved ),
|
246 |
|
|
.Initial( 1'b0 ),
|
247 |
|
|
.Q( wSrc1_Dependency )
|
248 |
|
|
);
|
249 |
|
|
|
250 |
|
|
|
251 |
|
|
FFD_POSEDGE_SYNCRONOUS_RESET # ( `MOD_ISSUE_PACKET_SIZE ) ISSUE_FFD
|
252 |
|
|
( Clock, Reset, wHandleCurrentIssue , iIssueBus, {oId,oDestination,oWE,oScale,wSource1_RS,wSrc1,wSource0_RS,wSrc0} );
|
253 |
|
|
|
254 |
|
|
assign wTag0 = wSrc0[`MOD_ISSUE_TAG0_RNG];
|
255 |
|
|
assign wTag1 = wSrc1[`MOD_ISSUE_TAG0_RNG];
|
256 |
|
|
|
257 |
|
|
endmodule
|
258 |
|
|
|
259 |
|
|
//-------------------------------------------------------------------------------------------------
|