Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | // ========== Copyright Header Begin ========================================== |
2 | // | |
3 | // OpenSPARC T2 Processor File: niu_smx_sm_req_dv.v | |
4 | // Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved | |
5 | // 4150 Network Circle, Santa Clara, California 95054, U.S.A. | |
6 | // | |
7 | // * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
8 | // | |
9 | // This program is free software; you can redistribute it and/or modify | |
10 | // it under the terms of the GNU General Public License as published by | |
11 | // the Free Software Foundation; version 2 of the License. | |
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 | // | |
22 | // For the avoidance of doubt, and except that if any non-GPL license | |
23 | // choice is available it will apply instead, Sun elects to use only | |
24 | // the General Public License version 2 (GPLv2) at this time for any | |
25 | // software where a choice of GPL license versions is made | |
26 | // available with the language indicating that GPLv2 or any later version | |
27 | // may be used, or where a choice of which version of the GPL is applied is | |
28 | // otherwise unspecified. | |
29 | // | |
30 | // Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
31 | // CA 95054 USA or visit www.sun.com if you need additional information or | |
32 | // have any questions. | |
33 | // | |
34 | // ========== Copyright Header End ============================================ | |
35 | ||
36 | module niu_smx_sm_req_dv( | |
37 | /*AUTOARG*/ | |
38 | // Outputs | |
39 | ff_wr, ff_wdata, pcmd_ff_wr, pcmd_ff_wdata, lnen_ff_rd, | |
40 | dv_pad_done, dv_cs, | |
41 | // Inputs | |
42 | clk, reset_l, dv, data, data_status, xfer_comp, lnen_ff_rdata, | |
43 | lnen_ff_empty | |
44 | ); | |
45 | ||
46 | input clk; | |
47 | input reset_l; | |
48 | ||
49 | // dmc if | |
50 | input dv; | |
51 | input [127:0] data; | |
52 | input [3:0] data_status; // ??? | |
53 | input xfer_comp; | |
54 | ||
55 | // dataff if | |
56 | output ff_wr; | |
57 | output [127:0] ff_wdata; | |
58 | ||
59 | // reqcmd if | |
60 | // output eop; | |
61 | ||
62 | // pcmd_ff if | |
63 | output pcmd_ff_wr; | |
64 | output [3:0] pcmd_ff_wdata; // ??? not sure what to write yet | |
65 | ||
66 | // lnen ff if | |
67 | input [4:0] lnen_ff_rdata; // {eop, line_en[3:0]} | |
68 | input lnen_ff_empty; | |
69 | output lnen_ff_rd; | |
70 | ||
71 | // datareq if | |
72 | output dv_pad_done; | |
73 | ||
74 | output[1:0] dv_cs; | |
75 | ||
76 | parameter s0= 2'h0, | |
77 | s1= 2'h1, | |
78 | s2= 2'h2, | |
79 | s3= 2'h3; | |
80 | ||
81 | reg ff_wr_n; | |
82 | wire ff_wr= ff_wr_n; | |
83 | wire [127:0] ff_wdata_n= (dv)? data : 128'h0; | |
84 | wire [127:0] ff_wdata= ff_wdata_n; | |
85 | ||
86 | reg lnen_ff_rd_n; | |
87 | wire lnen_ff_rd= lnen_ff_rd_n; | |
88 | ||
89 | reg[1:0] dv_cs, dv_ns; | |
90 | reg comp0, comp0_n; | |
91 | reg comp1, comp1_n; | |
92 | reg comp2, comp2_n; | |
93 | // reg comp3, comp3_n; | |
94 | // reg eop, eop_n; | |
95 | reg eop_n; | |
96 | ||
97 | reg ld_status_n; | |
98 | reg [3:0] status; | |
99 | wire [3:0] data_status_or_status_n= (data_status | status); | |
100 | ||
101 | reg or_status_n; | |
102 | reg pcmd_ff_wr_n; | |
103 | wire pcmd_ff_wr= pcmd_ff_wr_n; | |
104 | wire [3:0] pcmd_ff_wdata_n= (or_status_n)? status : | |
105 | data_status_or_status_n; | |
106 | // sample at s3; need to look at data_status if dv | |
107 | wire [3:0] pcmd_ff_wdata= pcmd_ff_wdata_n; | |
108 | ||
109 | wire dv_pad_done= ~(&lnen_ff_rdata[3:0]) & eop_n; | |
110 | ||
111 | // lnen_ff (line enable) added to match expected dv; | |
112 | // this is incase client dv comes back as non-contiguous 64B; | |
113 | // client must "space out" per datareq in order to pad | |
114 | always @ (/*AUTOSENSE*/comp0 or comp1 or comp2 or dv or dv_cs | |
115 | or lnen_ff_empty or lnen_ff_rdata or xfer_comp) begin | |
116 | ff_wr_n= 1'b0; | |
117 | pcmd_ff_wr_n= 1'b0; | |
118 | lnen_ff_rd_n= 1'b0; | |
119 | ld_status_n= 1'b0; | |
120 | or_status_n= 1'b0; | |
121 | dv_ns= dv_cs; | |
122 | comp0_n= comp0; | |
123 | comp1_n= comp1; | |
124 | comp2_n= comp2; | |
125 | eop_n= 1'b0; | |
126 | case(dv_cs) | |
127 | s0: begin | |
128 | if(!lnen_ff_empty) begin | |
129 | // lnen_ff_rdata[3:0] check if 0; handle spc??? | |
130 | if(dv) begin | |
131 | ff_wr_n= 1'b1; | |
132 | ld_status_n= 1'b1; | |
133 | dv_ns= s1; | |
134 | comp0_n= xfer_comp; | |
135 | end | |
136 | end | |
137 | end | |
138 | s1: begin | |
139 | if(lnen_ff_rdata[1]) begin | |
140 | ff_wr_n= dv; | |
141 | dv_ns= (dv)? s2 : s1; | |
142 | end | |
143 | else begin | |
144 | ff_wr_n= 1'b1; | |
145 | dv_ns= s2; | |
146 | end | |
147 | or_status_n= dv; | |
148 | comp1_n= dv&xfer_comp; | |
149 | end | |
150 | s2: begin | |
151 | if(lnen_ff_rdata[2]) begin | |
152 | ff_wr_n= dv; | |
153 | dv_ns= (dv)? s3 : s2; | |
154 | end | |
155 | else begin | |
156 | ff_wr_n= 1'b1; | |
157 | dv_ns= s3; | |
158 | end | |
159 | or_status_n= dv; | |
160 | comp2_n= dv&xfer_comp; | |
161 | end | |
162 | s3: begin | |
163 | if(lnen_ff_rdata[3]) begin | |
164 | ff_wr_n= dv; | |
165 | dv_ns= (dv)? s0 : s3; | |
166 | lnen_ff_rd_n= dv; | |
167 | pcmd_ff_wr_n= dv; // move data comp to the 4th line | |
168 | eop_n= dv & (xfer_comp | comp2 | comp1 | comp0 | lnen_ff_rdata[4]); | |
169 | end | |
170 | else begin | |
171 | ff_wr_n= 1'b1; | |
172 | dv_ns= s0; | |
173 | lnen_ff_rd_n= 1'b1; | |
174 | pcmd_ff_wr_n= 1'b1; | |
175 | eop_n= (dv&xfer_comp) | comp2 | comp1 | comp0 | lnen_ff_rdata[4]; | |
176 | end | |
177 | or_status_n= dv; | |
178 | end | |
179 | endcase | |
180 | end | |
181 | ||
182 | always @(posedge clk) begin | |
183 | if(!reset_l) begin | |
184 | dv_cs<= `SMX_PD s0; | |
185 | comp0<= `SMX_PD 1'b0; | |
186 | comp1<= `SMX_PD 1'b0; | |
187 | comp2<= `SMX_PD 1'b0; | |
188 | // eop<= `SMX_PD 1'b0; | |
189 | end | |
190 | else begin | |
191 | dv_cs<= `SMX_PD dv_ns; | |
192 | comp0<= `SMX_PD comp0_n; | |
193 | comp1<= `SMX_PD comp1_n; | |
194 | comp2<= `SMX_PD comp2_n; | |
195 | // eop<= `SMX_PD eop_n; | |
196 | end | |
197 | end | |
198 | ||
199 | always @(posedge clk) begin | |
200 | if(!reset_l) | |
201 | status<= `SMX_PD 4'h0; | |
202 | else begin | |
203 | if(ld_status_n) status<= `SMX_PD data_status; | |
204 | else | |
205 | if(or_status_n) status<= `SMX_PD data_status_or_status_n; | |
206 | end | |
207 | end | |
208 | ||
209 | ||
210 | endmodule |