[6] | 1 | // ========== Copyright Header Begin ========================================== |
---|
| 2 | // |
---|
| 3 | // OpenSPARC T1 Processor File: spu_maaeqb.v |
---|
| 4 | // Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. |
---|
| 5 | // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES. |
---|
| 6 | // |
---|
| 7 | // The above named program is free software; you can redistribute it and/or |
---|
| 8 | // modify it under the terms of the GNU General Public |
---|
| 9 | // License version 2 as published by the Free Software Foundation. |
---|
| 10 | // |
---|
| 11 | // The above named program is distributed in the hope that it will be |
---|
| 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
| 14 | // General Public License for more details. |
---|
| 15 | // |
---|
| 16 | // You should have received a copy of the GNU General Public |
---|
| 17 | // License along with this work; if not, write to the Free Software |
---|
| 18 | // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
| 19 | // |
---|
| 20 | // ========== Copyright Header End ============================================ |
---|
| 21 | //////////////////////////////////////////////////////////////////////// |
---|
| 22 | /* |
---|
| 23 | // Description: state machine to do MA mul/acc/shf when |
---|
| 24 | // A = B. |
---|
| 25 | */ |
---|
| 26 | //////////////////////////////////////////////////////////////////////// |
---|
| 27 | // Global header file includes |
---|
| 28 | //////////////////////////////////////////////////////////////////////// |
---|
| 29 | |
---|
| 30 | module spu_maaeqb ( |
---|
| 31 | |
---|
| 32 | |
---|
| 33 | /*outputs*/ |
---|
| 34 | spu_maaeqb_memren, |
---|
| 35 | spu_maaeqb_memwen, |
---|
| 36 | |
---|
| 37 | spu_maaeqb_rst_iptr, |
---|
| 38 | spu_maaeqb_rst_jptr, |
---|
| 39 | spu_maaeqb_incr_iptr, |
---|
| 40 | spu_maaeqb_incr_jptr, |
---|
| 41 | |
---|
| 42 | spu_maaeqb_a_rd_oprnd_sel, |
---|
| 43 | spu_maaeqb_ax_rd_oprnd_sel, |
---|
| 44 | spu_maaeqb_m_rd_oprnd_sel, |
---|
| 45 | spu_maaeqb_me_rd_oprnd_sel, |
---|
| 46 | spu_maaeqb_n_rd_oprnd_sel, |
---|
| 47 | spu_maaeqb_m_wr_oprnd_sel, |
---|
| 48 | spu_maaeqb_me_wr_oprnd_sel, |
---|
| 49 | |
---|
| 50 | spu_maaeqb_iminus1_ptr_sel, |
---|
| 51 | spu_maaeqb_j_ptr_sel, |
---|
| 52 | spu_maaeqb_iminusj_ptr_sel, |
---|
| 53 | spu_maaeqb_iminuslenminus1_sel, |
---|
| 54 | spu_maaeqb_irshft_sel, |
---|
| 55 | spu_maaeqb_jjptr_wen, |
---|
| 56 | |
---|
| 57 | spu_maaeqb_oprnd2_wen, |
---|
| 58 | spu_maaeqb_oprnd2_bypass, |
---|
| 59 | spu_maaeqb_a_leftshft, |
---|
| 60 | spu_maaeqb_oprnd1_mxsel, |
---|
| 61 | spu_maaeqb_oprnd1_wen, |
---|
| 62 | |
---|
| 63 | spu_maaeqb_mul_req_vld, |
---|
| 64 | spu_maaeqb_mul_areg_shf, |
---|
| 65 | spu_maaeqb_mul_acc, |
---|
| 66 | spu_maaeqb_mul_areg_rst, |
---|
| 67 | spu_maaeqb_mul_done, |
---|
| 68 | |
---|
| 69 | spu_maaeqb_jjptr_sel, |
---|
| 70 | |
---|
| 71 | /*inputs*/ |
---|
| 72 | spu_mactl_mulop, |
---|
| 73 | |
---|
| 74 | spu_maaddr_iequtwolenplus2, |
---|
| 75 | spu_maaddr_iequtwolenplus1, |
---|
| 76 | spu_maaddr_jequiminus1, |
---|
| 77 | spu_maaddr_jequlen, |
---|
| 78 | spu_maaddr_halfpnt_set, |
---|
| 79 | spu_mactl_iss_pulse_dly, |
---|
| 80 | |
---|
| 81 | |
---|
| 82 | mul_spu_ack, |
---|
| 83 | mul_spu_shf_ack, |
---|
| 84 | |
---|
| 85 | spu_maexp_start_mulred_aequb, |
---|
| 86 | |
---|
| 87 | spu_mactl_expop, |
---|
| 88 | |
---|
| 89 | |
---|
| 90 | spu_maaddr_jequiminus1rshft, |
---|
| 91 | spu_maaddr_iequtwolen, |
---|
| 92 | spu_maaddr_ieven, |
---|
| 93 | spu_maaddr_ieq0, |
---|
| 94 | |
---|
| 95 | spu_maaddr_aequb, |
---|
| 96 | |
---|
| 97 | spu_mactl_kill_op, |
---|
| 98 | spu_mactl_stxa_force_abort, |
---|
| 99 | |
---|
| 100 | se, |
---|
| 101 | reset, |
---|
| 102 | rclk); |
---|
| 103 | |
---|
| 104 | // --------------------------------------------------------------- |
---|
| 105 | input reset; |
---|
| 106 | input rclk; |
---|
| 107 | input se; |
---|
| 108 | |
---|
| 109 | input spu_maaddr_iequtwolenplus2; |
---|
| 110 | input spu_maaddr_iequtwolenplus1; |
---|
| 111 | input spu_maaddr_jequiminus1; |
---|
| 112 | input spu_maaddr_jequlen; |
---|
| 113 | input spu_maaddr_halfpnt_set; |
---|
| 114 | |
---|
| 115 | input mul_spu_ack; |
---|
| 116 | input mul_spu_shf_ack; |
---|
| 117 | input spu_mactl_mulop; |
---|
| 118 | input spu_mactl_iss_pulse_dly; |
---|
| 119 | |
---|
| 120 | |
---|
| 121 | input spu_maexp_start_mulred_aequb; |
---|
| 122 | |
---|
| 123 | input spu_mactl_expop; |
---|
| 124 | |
---|
| 125 | |
---|
| 126 | |
---|
| 127 | input spu_maaddr_jequiminus1rshft; |
---|
| 128 | input spu_maaddr_iequtwolen; |
---|
| 129 | input spu_maaddr_ieven; |
---|
| 130 | input spu_maaddr_ieq0; |
---|
| 131 | |
---|
| 132 | |
---|
| 133 | input spu_maaddr_aequb; |
---|
| 134 | |
---|
| 135 | input spu_mactl_kill_op; |
---|
| 136 | input spu_mactl_stxa_force_abort; |
---|
| 137 | |
---|
| 138 | // --------------------------------------------------------------- |
---|
| 139 | |
---|
| 140 | output spu_maaeqb_memwen; |
---|
| 141 | output spu_maaeqb_memren; |
---|
| 142 | output spu_maaeqb_rst_iptr; |
---|
| 143 | output spu_maaeqb_rst_jptr; |
---|
| 144 | output spu_maaeqb_incr_iptr; |
---|
| 145 | output spu_maaeqb_incr_jptr; |
---|
| 146 | |
---|
| 147 | output spu_maaeqb_a_rd_oprnd_sel; |
---|
| 148 | output spu_maaeqb_ax_rd_oprnd_sel; |
---|
| 149 | output spu_maaeqb_m_rd_oprnd_sel; |
---|
| 150 | output spu_maaeqb_me_rd_oprnd_sel; |
---|
| 151 | output spu_maaeqb_n_rd_oprnd_sel; |
---|
| 152 | output spu_maaeqb_m_wr_oprnd_sel; |
---|
| 153 | output spu_maaeqb_me_wr_oprnd_sel; |
---|
| 154 | |
---|
| 155 | output spu_maaeqb_iminus1_ptr_sel; |
---|
| 156 | output spu_maaeqb_j_ptr_sel; |
---|
| 157 | output spu_maaeqb_iminusj_ptr_sel; |
---|
| 158 | output spu_maaeqb_iminuslenminus1_sel; |
---|
| 159 | output spu_maaeqb_irshft_sel; |
---|
| 160 | output spu_maaeqb_jjptr_wen; |
---|
| 161 | |
---|
| 162 | output spu_maaeqb_oprnd2_wen; |
---|
| 163 | output spu_maaeqb_oprnd2_bypass; |
---|
| 164 | output spu_maaeqb_a_leftshft; |
---|
| 165 | output [1:0] spu_maaeqb_oprnd1_mxsel; |
---|
| 166 | output spu_maaeqb_oprnd1_wen; |
---|
| 167 | |
---|
| 168 | output spu_maaeqb_mul_req_vld; |
---|
| 169 | output spu_maaeqb_mul_areg_shf; |
---|
| 170 | output spu_maaeqb_mul_acc; |
---|
| 171 | output spu_maaeqb_mul_areg_rst; |
---|
| 172 | output spu_maaeqb_mul_done; |
---|
| 173 | |
---|
| 174 | output spu_maaeqb_jjptr_sel; |
---|
| 175 | // --------------------------------------------------------------- |
---|
| 176 | wire tr2mwrite_frm_accumshft_pre; |
---|
| 177 | wire tr2mwrite_frm_accumshft; |
---|
| 178 | wire spu_maaeqb_rd_aj,spu_maaeqb_rd_mj, |
---|
| 179 | spu_maaeqb_rd_niminusj,spu_maaeqb_rd_ai, |
---|
| 180 | spu_maaeqb_wr_mi,spu_maaeqb_wr_miminuslenminus1, |
---|
| 181 | spu_maaeqb_rd_n0; |
---|
| 182 | |
---|
| 183 | wire spu_maaeqb_rd_aiminusj; |
---|
| 184 | |
---|
| 185 | wire tr2accumshft_frm_mwrite; |
---|
| 186 | wire tr2accumshft_frm_iloopn; |
---|
| 187 | wire nxt_mwrite_state; |
---|
| 188 | // --------------------------------------------------------------- |
---|
| 189 | // --------------------------------------------------------------- |
---|
| 190 | // --------------------------------------------------------------- |
---|
| 191 | // --------------------------------------------------------------- |
---|
| 192 | // --------------------------------------------------------------- |
---|
| 193 | |
---|
| 194 | wire local_stxa_abort = nxt_mwrite_state & spu_mactl_stxa_force_abort; |
---|
| 195 | |
---|
| 196 | wire state_reset = reset | spu_mactl_kill_op | local_stxa_abort; |
---|
| 197 | |
---|
| 198 | // --------------------------------------------------------------- |
---|
| 199 | // --------------------------------------------------------------- |
---|
| 200 | // --------------------------------------------------------------- |
---|
| 201 | // --------------------------------------------------------------- |
---|
| 202 | // --------------------------------------------------------------- |
---|
| 203 | // --------------------------------------------------------------- |
---|
| 204 | dff_s #(1) idle_state_ff ( |
---|
| 205 | .din(nxt_idle_state) , |
---|
| 206 | .q(cur_idle_state), |
---|
| 207 | .clk (rclk), .se(se), .si(), .so()); |
---|
| 208 | |
---|
| 209 | dffr_s #(1) jloopa_state_ff ( |
---|
| 210 | .din(nxt_jloopa_state) , |
---|
| 211 | .q(cur_jloopa_state), |
---|
| 212 | .rst(state_reset), .clk (rclk), .se(se), .si(), .so()); |
---|
| 213 | |
---|
| 214 | dffr_s #(1) ijloopa_state_ff ( |
---|
| 215 | .din(nxt_ijloopa_state) , |
---|
| 216 | .q(cur_ijloopa_state), |
---|
| 217 | .rst(state_reset), .clk (rclk), .se(se), .si(), .so()); |
---|
| 218 | |
---|
| 219 | dffr_s #(1) jloopn_state_ff ( |
---|
| 220 | .din(nxt_jloopn_state) , |
---|
| 221 | .q(cur_jloopn_state), |
---|
| 222 | .rst(state_reset), .clk (rclk), .se(se), .si(), .so()); |
---|
| 223 | |
---|
| 224 | dffr_s #(1) jloopm_state_ff ( |
---|
| 225 | .din(nxt_jloopm_state) , |
---|
| 226 | .q(cur_jloopm_state), |
---|
| 227 | .rst(state_reset), .clk (rclk), .se(se), .si(), .so()); |
---|
| 228 | |
---|
| 229 | dffr_s #(1) iloopa1_state_ff ( |
---|
| 230 | .din(nxt_iloopa1_state) , |
---|
| 231 | .q(cur_iloopa1_state), |
---|
| 232 | .rst(state_reset), .clk (rclk), .se(se), .si(), .so()); |
---|
| 233 | |
---|
| 234 | dffr_s #(1) iloopa_state_ff ( |
---|
| 235 | .din(nxt_iloopa_state) , |
---|
| 236 | .q(cur_iloopa_state), |
---|
| 237 | .rst(state_reset), .clk (rclk), .se(se), .si(), .so()); |
---|
| 238 | |
---|
| 239 | |
---|
| 240 | dffr_s #(1) nprime_state_ff ( |
---|
| 241 | .din(nxt_nprime_state) , |
---|
| 242 | .q(cur_nprime_state), |
---|
| 243 | .rst(state_reset), .clk (rclk), .se(se), .si(), .so()); |
---|
| 244 | |
---|
| 245 | dffr_s #(1) mwrite_state_ff ( |
---|
| 246 | .din(nxt_mwrite_state) , |
---|
| 247 | .q(cur_mwrite_state), |
---|
| 248 | .rst(state_reset), .clk (rclk), .se(se), .si(), .so()); |
---|
| 249 | |
---|
| 250 | dffr_s #(1) iloopn_state_ff ( |
---|
| 251 | .din(nxt_iloopn_state) , |
---|
| 252 | .q(cur_iloopn_state), |
---|
| 253 | .rst(state_reset), .clk (rclk), .se(se), .si(), .so()); |
---|
| 254 | |
---|
| 255 | dffr_s #(1) accumshft_state_ff ( |
---|
| 256 | .din(nxt_accumshft_state) , |
---|
| 257 | .q(cur_accumshft_state), |
---|
| 258 | .rst(state_reset), .clk (rclk), .se(se), .si(), .so()); |
---|
| 259 | |
---|
| 260 | // --------------------------------------------------------------- |
---|
| 261 | // --------------------------------------------------------------- |
---|
| 262 | // --------------------------------------------------------------- |
---|
| 263 | |
---|
| 264 | |
---|
| 265 | wire spu_maaddr_aequb_q; |
---|
| 266 | dff_s #(1) spu_maaddr_aequb_ff ( |
---|
| 267 | .din(spu_maaddr_aequb) , |
---|
| 268 | .q(spu_maaddr_aequb_q), |
---|
| 269 | .clk (rclk), .se(se), .si(), .so()); |
---|
| 270 | |
---|
| 271 | |
---|
| 272 | // --------------------------------------------------------------- |
---|
| 273 | // 5 cycle delay for mul result coming back. |
---|
| 274 | // --------------------------------------------------------------- |
---|
| 275 | |
---|
| 276 | wire tr2mwrite_frm_jloopn = cur_jloopn_state & mul_spu_ack & spu_maaddr_halfpnt_set & |
---|
| 277 | spu_maaddr_jequlen; |
---|
| 278 | |
---|
| 279 | |
---|
| 280 | wire mul_result_c0,mul_result_c1,mul_result_c2,mul_result_c3,mul_result_c4,mul_result_c5; |
---|
| 281 | |
---|
| 282 | //assign mul_result_c0 = (cur_nprime_state & mul_spu_ack & ~spu_maaddr_halfpnt_set) | |
---|
| 283 | assign mul_result_c0 = (cur_nprime_state & mul_spu_ack) | |
---|
| 284 | ( tr2mwrite_frm_jloopn ); |
---|
| 285 | |
---|
| 286 | |
---|
| 287 | dffr_s #(5) mul_res_ff ( |
---|
| 288 | .din({mul_result_c0,mul_result_c1,mul_result_c2,mul_result_c3,mul_result_c4}) , |
---|
| 289 | .q({mul_result_c1,mul_result_c2,mul_result_c3,mul_result_c4,mul_result_c5}), |
---|
| 290 | .rst(state_reset), .clk (rclk), .se(se), .si(), .so()); |
---|
| 291 | |
---|
| 292 | |
---|
| 293 | // ---------------------------------------------------------------- |
---|
| 294 | // ---------------------------------------------------------------- |
---|
| 295 | // --------------------------------------------------------------- |
---|
| 296 | wire tr2idle_frm_accumshft = cur_accumshft_state & spu_maaddr_iequtwolenplus2 & |
---|
| 297 | mul_spu_shf_ack; |
---|
| 298 | |
---|
| 299 | |
---|
| 300 | wire spu_maaeqb_mul_done_pre = tr2idle_frm_accumshft; |
---|
| 301 | |
---|
| 302 | wire spu_maaeqb_mul_done_q; |
---|
| 303 | dff_s #(1) muldone_dly_ff ( |
---|
| 304 | .din(spu_maaeqb_mul_done_pre) , |
---|
| 305 | .q(spu_maaeqb_mul_done_q), |
---|
| 306 | .clk (rclk), .se(se), .si(), .so()); |
---|
| 307 | |
---|
| 308 | assign spu_maaeqb_mul_done = spu_maaeqb_mul_done_q | local_stxa_abort; |
---|
| 309 | |
---|
| 310 | |
---|
| 311 | assign spu_maaeqb_rst_iptr = tr2idle_frm_accumshft; |
---|
| 312 | |
---|
| 313 | |
---|
| 314 | // ---------------------------------------------------------------- |
---|
| 315 | // transition to idle state |
---|
| 316 | |
---|
| 317 | wire mulop_start = (spu_mactl_iss_pulse_dly & spu_mactl_mulop & spu_maaddr_aequb_q) | |
---|
| 318 | spu_maexp_start_mulred_aequb; |
---|
| 319 | |
---|
| 320 | assign spu_maaeqb_mul_areg_rst = mulop_start; |
---|
| 321 | |
---|
| 322 | |
---|
| 323 | assign nxt_idle_state = ( |
---|
| 324 | state_reset | |
---|
| 325 | tr2idle_frm_accumshft | |
---|
| 326 | (cur_idle_state & ~mulop_start)); |
---|
| 327 | |
---|
| 328 | |
---|
| 329 | // ---------------------------------------------------------------- |
---|
| 330 | // transition to jloopa state(rdA[j]) |
---|
| 331 | |
---|
| 332 | wire tr2jloopa_frm_ijloopa = cur_ijloopa_state & mul_spu_ack & ~spu_maaddr_jequiminus1rshft; |
---|
| 333 | |
---|
| 334 | wire tr2jloopa_frm_accumshft = cur_accumshft_state & ~spu_maaddr_iequtwolenplus2 & |
---|
| 335 | ~spu_maaddr_iequtwolenplus1 & ~spu_maaddr_iequtwolen & |
---|
| 336 | mul_spu_shf_ack; |
---|
| 337 | |
---|
| 338 | wire tr2jloopa_frm_accumshft_dly; |
---|
| 339 | dffr_s #(1) tr2jloopa_frm_accumshft_dly_ff ( |
---|
| 340 | .din(tr2jloopa_frm_accumshft) , |
---|
| 341 | .q(tr2jloopa_frm_accumshft_dly), |
---|
| 342 | .rst(state_reset), .clk (rclk), .se(se), .si(), .so()); |
---|
| 343 | |
---|
| 344 | |
---|
| 345 | assign nxt_jloopa_state = ( |
---|
| 346 | tr2jloopa_frm_ijloopa | |
---|
| 347 | tr2jloopa_frm_accumshft_dly ); |
---|
| 348 | |
---|
| 349 | //assign spu_maaeqb_rd_aj = nxt_jloopa_state; |
---|
| 350 | assign spu_maaeqb_rd_aj = (cur_ijloopa_state & ~spu_maaddr_jequiminus1rshft) | |
---|
| 351 | tr2jloopa_frm_accumshft_dly; |
---|
| 352 | |
---|
| 353 | // ---------------------------------------------------------------- |
---|
| 354 | // transition to jloopa state(rdA[i-j]) |
---|
| 355 | |
---|
| 356 | |
---|
| 357 | assign nxt_ijloopa_state = ( |
---|
| 358 | cur_jloopa_state | |
---|
| 359 | (cur_ijloopa_state & ~mul_spu_ack)); |
---|
| 360 | |
---|
| 361 | assign spu_maaeqb_a_leftshft = cur_ijloopa_state; |
---|
| 362 | |
---|
| 363 | //assign spu_maaeqb_rd_aiminusj = nxt_ijloopa_state | cur_ijloopa_state; |
---|
| 364 | assign spu_maaeqb_rd_aiminusj = cur_jloopa_state; |
---|
| 365 | |
---|
| 366 | |
---|
| 367 | // ---------------------------------------------------------------- |
---|
| 368 | // transition to iloopa state(rdA[i/2]) |
---|
| 369 | |
---|
| 370 | wire tr2iloopa1_frm_ijloopa = cur_ijloopa_state & mul_spu_ack & spu_maaddr_ieven & |
---|
| 371 | spu_maaddr_jequiminus1rshft; |
---|
| 372 | |
---|
| 373 | wire tr2iloopa1_frm_accumshft = spu_maaddr_ieven & cur_accumshft_state & mul_spu_shf_ack & |
---|
| 374 | //(spu_maaddr_iequtwolenplus1 | spu_maaddr_iequtwolenplus2 | |
---|
| 375 | (spu_maaddr_iequtwolenplus1 | |
---|
| 376 | spu_maaddr_iequtwolen); |
---|
| 377 | |
---|
| 378 | wire tr2iloopa1_frm_accumshft_dly; |
---|
| 379 | dffr_s #(1) tr2iloopa1_frm_accumshft_dly_ff ( |
---|
| 380 | .din(tr2iloopa1_frm_accumshft) , |
---|
| 381 | .q(tr2iloopa1_frm_accumshft_dly), |
---|
| 382 | .rst(state_reset), .clk (rclk), .se(se), .si(), .so()); |
---|
| 383 | |
---|
| 384 | |
---|
| 385 | wire tr2iloopa1_frm_idle = cur_idle_state & mulop_start; |
---|
| 386 | |
---|
| 387 | wire tr2iloopa1_frm_idle_dly; |
---|
| 388 | dffr_s #(1) tr2iloopa1_frm_idle_ff ( |
---|
| 389 | .din(tr2iloopa1_frm_idle) , |
---|
| 390 | .q(tr2iloopa1_frm_idle_dly), |
---|
| 391 | .rst(state_reset), .clk (rclk), .se(se), .si(), .so()); |
---|
| 392 | |
---|
| 393 | |
---|
| 394 | |
---|
| 395 | assign nxt_iloopa1_state = ( |
---|
| 396 | tr2iloopa1_frm_accumshft_dly | |
---|
| 397 | tr2iloopa1_frm_ijloopa | |
---|
| 398 | tr2iloopa1_frm_idle_dly) ; |
---|
| 399 | |
---|
| 400 | wire cur_iloopa1_state_dly; |
---|
| 401 | dffr_s #(1) cur_iloopa1_state_dly_ff ( |
---|
| 402 | .din(cur_iloopa1_state) , |
---|
| 403 | .q(cur_iloopa1_state_dly), |
---|
| 404 | .rst(state_reset), .clk (rclk), .se(se), .si(), .so()); |
---|
| 405 | |
---|
| 406 | |
---|
| 407 | assign nxt_iloopa_state = ( |
---|
| 408 | cur_iloopa1_state_dly | |
---|
| 409 | (cur_iloopa_state & ~mul_spu_ack)); |
---|
| 410 | |
---|
| 411 | |
---|
| 412 | |
---|
| 413 | //assign spu_maaeqb_rd_ai = cur_iloopa1_state | nxt_iloopa_state | cur_iloopa_state; |
---|
| 414 | |
---|
| 415 | assign spu_maaeqb_rd_ai = (cur_ijloopa_state & spu_maaddr_ieven & spu_maaddr_jequiminus1rshft) | |
---|
| 416 | tr2iloopa1_frm_idle_dly | |
---|
| 417 | //(cur_accumshft_state & spu_maaddr_ieven & (spu_maaddr_iequtwolenplus1 | spu_maaddr_iequtwolen)) | |
---|
| 418 | tr2iloopa1_frm_accumshft_dly | |
---|
| 419 | // above are for iloopa1 and below are for iloopa. |
---|
| 420 | (cur_iloopa1_state_dly); |
---|
| 421 | |
---|
| 422 | // ---------------------------------------------------------------- |
---|
| 423 | // transition to jloopm state(rdM[j]) |
---|
| 424 | |
---|
| 425 | wire tr2jloopm_frm_ijloopa = cur_ijloopa_state & mul_spu_ack & ~spu_maaddr_ieven & |
---|
| 426 | spu_maaddr_jequiminus1rshft; |
---|
| 427 | |
---|
| 428 | // the following is needed to reset jptr on the transition |
---|
| 429 | // from ijloopa to jloopm. |
---|
| 430 | wire tr2jloopm_frm_ijloopa_dly; |
---|
| 431 | dffr_s #(1) tr2jloopm_frm_ijloopa_dly_ff ( |
---|
| 432 | .din(tr2jloopm_frm_ijloopa) , |
---|
| 433 | .q(tr2jloopm_frm_ijloopa_dly), |
---|
| 434 | .rst(state_reset), .clk (rclk), .se(se), .si(), .so()); |
---|
| 435 | |
---|
| 436 | |
---|
| 437 | wire tr2jloopm_frm_iloopa = cur_iloopa_state & mul_spu_ack & ~spu_maaddr_ieq0 ; |
---|
| 438 | wire tr2jloopm_frm_iloopa_dly; |
---|
| 439 | dffr_s #(1) tr2jloopm_frm_iloopa_dly_ff ( |
---|
| 440 | .din(tr2jloopm_frm_iloopa) , |
---|
| 441 | .q(tr2jloopm_frm_iloopa_dly), |
---|
| 442 | .rst(state_reset), .clk (rclk), .se(se), .si(), .so()); |
---|
| 443 | |
---|
| 444 | |
---|
| 445 | wire tr2jloopm_frm_jloopn = cur_jloopn_state & mul_spu_ack & |
---|
| 446 | ((~spu_maaddr_jequiminus1 & ~spu_maaddr_halfpnt_set) | |
---|
| 447 | (~spu_maaddr_jequlen & spu_maaddr_halfpnt_set)) ; |
---|
| 448 | |
---|
| 449 | assign nxt_jloopm_state = ( |
---|
| 450 | tr2jloopm_frm_jloopn | |
---|
| 451 | tr2jloopm_frm_ijloopa_dly | |
---|
| 452 | tr2jloopm_frm_iloopa_dly); |
---|
| 453 | |
---|
| 454 | |
---|
| 455 | //assign spu_maaeqb_rd_mj = nxt_jloopm_state; |
---|
| 456 | assign spu_maaeqb_rd_mj = tr2jloopm_frm_ijloopa_dly | tr2jloopm_frm_iloopa_dly | |
---|
| 457 | cur_jloopn_state & |
---|
| 458 | ((~spu_maaddr_jequiminus1 & ~spu_maaddr_halfpnt_set) | |
---|
| 459 | (~spu_maaddr_jequlen & spu_maaddr_halfpnt_set)) ; |
---|
| 460 | |
---|
| 461 | |
---|
| 462 | |
---|
| 463 | // ---------------------------------------------------------------- |
---|
| 464 | // transition to jloopn state(rdN[j]) |
---|
| 465 | |
---|
| 466 | assign nxt_jloopn_state = ( |
---|
| 467 | cur_jloopm_state | |
---|
| 468 | (cur_jloopn_state & ~mul_spu_ack)); |
---|
| 469 | |
---|
| 470 | assign spu_maaeqb_jjptr_wen = cur_jloopa_state | cur_jloopm_state; |
---|
| 471 | assign spu_maaeqb_incr_jptr = tr2jloopa_frm_ijloopa | tr2jloopm_frm_jloopn; |
---|
| 472 | |
---|
| 473 | assign spu_maaeqb_jjptr_sel = cur_ijloopa_state | cur_jloopn_state; |
---|
| 474 | |
---|
| 475 | |
---|
| 476 | //assign spu_maaeqb_rd_niminusj = nxt_jloopn_state; |
---|
| 477 | assign spu_maaeqb_rd_niminusj = cur_jloopm_state; |
---|
| 478 | |
---|
| 479 | |
---|
| 480 | // ---------------------------------------------------------------- |
---|
| 481 | // transition to nprime state |
---|
| 482 | |
---|
| 483 | wire tr2nprime_frm_jloopn = cur_jloopn_state & mul_spu_ack & |
---|
| 484 | spu_maaddr_jequiminus1 & ~spu_maaddr_halfpnt_set; |
---|
| 485 | |
---|
| 486 | wire tr2nprime_frm_iloopa = cur_iloopa_state & mul_spu_ack & spu_maaddr_ieq0; |
---|
| 487 | |
---|
| 488 | assign nxt_nprime_state = ( |
---|
| 489 | tr2nprime_frm_jloopn | |
---|
| 490 | tr2nprime_frm_iloopa | |
---|
| 491 | (cur_nprime_state & ~mul_spu_ack)); |
---|
| 492 | |
---|
| 493 | |
---|
| 494 | |
---|
| 495 | |
---|
| 496 | // the following is to reset jptr on the 1st half. |
---|
| 497 | wire tr2nprime_frm_jloopn_dly; |
---|
| 498 | dffr_s #(1) tr2nprime_frm_jloopn_dly_ff ( |
---|
| 499 | .din(tr2nprime_frm_jloopn) , |
---|
| 500 | .q(tr2nprime_frm_jloopn_dly), |
---|
| 501 | .rst(state_reset), .clk (rclk), .se(se), .si(), .so()); |
---|
| 502 | |
---|
| 503 | // ---------------------------------------------------------------- |
---|
| 504 | // transition to mwrite state |
---|
| 505 | |
---|
| 506 | |
---|
| 507 | assign tr2mwrite_frm_accumshft_pre = cur_accumshft_state & mul_spu_shf_ack & |
---|
| 508 | spu_maaddr_iequtwolenplus1; |
---|
| 509 | |
---|
| 510 | // delaying for one cycle to allow time to do i ptr increment |
---|
| 511 | // and calculate i-len-1(M[i-len-1]).This is due to skipping jloop on last |
---|
| 512 | // i iteration, not enough time to do both. |
---|
| 513 | dffr_s #(1) tr2mwrite_frm_accumshft_ff ( |
---|
| 514 | .din(tr2mwrite_frm_accumshft_pre) , |
---|
| 515 | .q(tr2mwrite_frm_accumshft), |
---|
| 516 | .rst(state_reset), .clk (rclk), .se(se), .si(), .so()); |
---|
| 517 | |
---|
| 518 | |
---|
| 519 | assign nxt_mwrite_state = ( |
---|
| 520 | tr2mwrite_frm_accumshft | |
---|
| 521 | (mul_result_c5)); |
---|
| 522 | |
---|
| 523 | |
---|
| 524 | //assign spu_maaeqb_memwen = nxt_mwrite_state; |
---|
| 525 | |
---|
| 526 | wire spu_maaeqb_wr_mi_oprnd2_wenbyp = nxt_mwrite_state & ~spu_maaddr_halfpnt_set; |
---|
| 527 | wire spu_maaeqb_wr_miminuslenminus1_oprnd2_wenbyp = nxt_mwrite_state & spu_maaddr_halfpnt_set; |
---|
| 528 | |
---|
| 529 | |
---|
| 530 | // --------------------------------------------------------------- |
---|
| 531 | // transition to iloopn state |
---|
| 532 | |
---|
| 533 | assign nxt_iloopn_state = ( |
---|
| 534 | (cur_mwrite_state & ~spu_maaddr_halfpnt_set) | |
---|
| 535 | (cur_iloopn_state & ~mul_spu_ack)); |
---|
| 536 | |
---|
| 537 | |
---|
| 538 | //assign spu_maaeqb_rd_n0 = nxt_iloopn_state | cur_iloopn_state; |
---|
| 539 | assign spu_maaeqb_rd_n0 = cur_mwrite_state; |
---|
| 540 | |
---|
| 541 | // --------------------------------------------------------------- |
---|
| 542 | // transition to accumshft state |
---|
| 543 | |
---|
| 544 | assign tr2accumshft_frm_mwrite = cur_mwrite_state & spu_maaddr_halfpnt_set; |
---|
| 545 | assign tr2accumshft_frm_iloopn = cur_iloopn_state & mul_spu_ack; |
---|
| 546 | |
---|
| 547 | assign nxt_accumshft_state = ( |
---|
| 548 | tr2accumshft_frm_mwrite | |
---|
| 549 | tr2accumshft_frm_iloopn | |
---|
| 550 | (cur_accumshft_state & ~mul_spu_shf_ack)); |
---|
| 551 | |
---|
| 552 | assign spu_maaeqb_incr_iptr = tr2accumshft_frm_mwrite | tr2accumshft_frm_iloopn; |
---|
| 553 | |
---|
| 554 | dff_s #(1) memwen_dly_ff ( |
---|
| 555 | .din(spu_maaeqb_incr_iptr) , |
---|
| 556 | .q(spu_maaeqb_memwen), |
---|
| 557 | .clk (rclk), .se(se), .si(), .so()); |
---|
| 558 | |
---|
| 559 | assign spu_maaeqb_wr_mi = spu_maaeqb_memwen & ~spu_maaddr_halfpnt_set; |
---|
| 560 | assign spu_maaeqb_wr_miminuslenminus1 = spu_maaeqb_memwen & spu_maaddr_halfpnt_set; |
---|
| 561 | |
---|
| 562 | // --------------------------------------------------------------- |
---|
| 563 | |
---|
| 564 | wire cur_accumshft_pulse,cur_accumshft_q; |
---|
| 565 | |
---|
| 566 | dff_s #(1) cur_accumshft_pulse_ff ( |
---|
| 567 | .din(cur_accumshft_state) , |
---|
| 568 | .q(cur_accumshft_q), |
---|
| 569 | .clk (rclk), .se(se), .si(), .so()); |
---|
| 570 | |
---|
| 571 | assign cur_accumshft_pulse = ~cur_accumshft_q & cur_accumshft_state; |
---|
| 572 | |
---|
| 573 | |
---|
| 574 | |
---|
| 575 | |
---|
| 576 | assign spu_maaeqb_rst_jptr = mulop_start | tr2nprime_frm_jloopn_dly | |
---|
| 577 | tr2jloopm_frm_ijloopa | tr2iloopa1_frm_ijloopa | |
---|
| 578 | (cur_accumshft_pulse & |
---|
| 579 | spu_maaddr_halfpnt_set & ~spu_maaddr_iequtwolenplus2 & |
---|
| 580 | ~spu_maaddr_iequtwolenplus1); |
---|
| 581 | |
---|
| 582 | |
---|
| 583 | // --------------------------------------------------------------- |
---|
| 584 | // --------------------------------------------------------------- |
---|
| 585 | // --------------------------------------------------------------- |
---|
| 586 | // --------------------------------------------------------------- |
---|
| 587 | // --------------------------------------------------------------- |
---|
| 588 | // --------------------------------------------------------------- |
---|
| 589 | // send selects to spu_maaddr.v |
---|
| 590 | // --------------------------------------------------------------- |
---|
| 591 | // --------------------------------------------------------------- |
---|
| 592 | assign spu_maaeqb_memren = spu_maaeqb_rd_aj | |
---|
| 593 | spu_maaeqb_rd_aiminusj | |
---|
| 594 | spu_maaeqb_rd_mj | |
---|
| 595 | spu_maaeqb_rd_niminusj | |
---|
| 596 | spu_maaeqb_rd_ai | spu_maaeqb_rd_n0; |
---|
| 597 | |
---|
| 598 | // --------------------------------------------------------------- |
---|
| 599 | // --------------------------------------------------------------- |
---|
| 600 | // --------------------------------------------------------------- |
---|
| 601 | // --------------------------------------------------------------- |
---|
| 602 | assign spu_maaeqb_a_rd_oprnd_sel = (spu_maaeqb_rd_aj | spu_maaeqb_rd_ai | |
---|
| 603 | spu_maaeqb_rd_aiminusj) & ~spu_mactl_expop ; |
---|
| 604 | assign spu_maaeqb_ax_rd_oprnd_sel = (spu_maaeqb_rd_aj | spu_maaeqb_rd_ai | |
---|
| 605 | spu_maaeqb_rd_aiminusj) & spu_mactl_expop ; |
---|
| 606 | |
---|
| 607 | assign spu_maaeqb_m_rd_oprnd_sel = spu_maaeqb_rd_mj & ~spu_mactl_expop; |
---|
| 608 | assign spu_maaeqb_me_rd_oprnd_sel = spu_maaeqb_rd_mj & spu_mactl_expop ; |
---|
| 609 | |
---|
| 610 | |
---|
| 611 | |
---|
| 612 | assign spu_maaeqb_n_rd_oprnd_sel = (spu_maaeqb_rd_niminusj & ~spu_maaeqb_rd_mj) | |
---|
| 613 | spu_maaeqb_rd_n0; |
---|
| 614 | |
---|
| 615 | |
---|
| 616 | // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 617 | |
---|
| 618 | assign spu_maaeqb_m_wr_oprnd_sel = (spu_maaeqb_wr_mi | spu_maaeqb_wr_miminuslenminus1) & |
---|
| 619 | ~spu_mactl_expop; |
---|
| 620 | assign spu_maaeqb_me_wr_oprnd_sel = (spu_maaeqb_wr_mi | spu_maaeqb_wr_miminuslenminus1) & |
---|
| 621 | spu_mactl_expop; |
---|
| 622 | |
---|
| 623 | |
---|
| 624 | |
---|
| 625 | wire spu_maaeqb_m_wr_oprnd2_wen = (spu_maaeqb_wr_mi_oprnd2_wenbyp | |
---|
| 626 | spu_maaeqb_wr_miminuslenminus1_oprnd2_wenbyp) & |
---|
| 627 | ~spu_mactl_expop; |
---|
| 628 | wire spu_maaeqb_me_wr_oprnd2_wen = (spu_maaeqb_wr_mi_oprnd2_wenbyp | |
---|
| 629 | spu_maaeqb_wr_miminuslenminus1_oprnd2_wenbyp) & |
---|
| 630 | spu_mactl_expop; |
---|
| 631 | |
---|
| 632 | // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 633 | |
---|
| 634 | |
---|
| 635 | assign spu_maaeqb_iminus1_ptr_sel = spu_maaeqb_wr_mi; |
---|
| 636 | |
---|
| 637 | assign spu_maaeqb_j_ptr_sel = spu_maaeqb_rd_aj | spu_maaeqb_rd_mj; |
---|
| 638 | assign spu_maaeqb_iminusj_ptr_sel = |
---|
| 639 | (spu_maaeqb_rd_aiminusj | spu_maaeqb_rd_niminusj) & |
---|
| 640 | ~(spu_maaeqb_rd_aj | spu_maaeqb_rd_mj); |
---|
| 641 | |
---|
| 642 | assign spu_maaeqb_iminuslenminus1_sel = spu_maaeqb_wr_miminuslenminus1; |
---|
| 643 | |
---|
| 644 | |
---|
| 645 | assign spu_maaeqb_irshft_sel = spu_maaeqb_rd_ai; |
---|
| 646 | |
---|
| 647 | // --------------------------------------------------------------- |
---|
| 648 | // request to mul unit when asserted |
---|
| 649 | |
---|
| 650 | wire spu_maaeqb_mul_req_vld_pre = nxt_ijloopa_state | nxt_jloopn_state | |
---|
| 651 | nxt_nprime_state | nxt_iloopn_state | |
---|
| 652 | nxt_iloopa_state; |
---|
| 653 | dffr_s #(1) spu_maaeqb_mul_req_vld_ff ( |
---|
| 654 | .din(spu_maaeqb_mul_req_vld_pre) , |
---|
| 655 | .q(spu_maaeqb_mul_req_vld), |
---|
| 656 | .rst(state_reset), .clk (rclk), .se(se), .si(), .so()); |
---|
| 657 | |
---|
| 658 | |
---|
| 659 | /* |
---|
| 660 | assign spu_maaeqb_mul_req_vld = cur_ijloopa_state | cur_jloopn_state | |
---|
| 661 | cur_nprime_state | cur_iloopn_state | |
---|
| 662 | cur_iloopa_state; |
---|
| 663 | */ |
---|
| 664 | |
---|
| 665 | // --------------------------------------------------------------- |
---|
| 666 | |
---|
| 667 | assign spu_maaeqb_mul_areg_shf = cur_accumshft_state; |
---|
| 668 | // --------------------------------------------------------------- |
---|
| 669 | |
---|
| 670 | /* |
---|
| 671 | wire oprnd2_sel = (spu_maaeqb_rd_aj | spu_maaeqb_rd_ai | |
---|
| 672 | spu_maaeqb_m_rd_oprnd_sel | spu_maaeqb_me_rd_oprnd_sel) ; |
---|
| 673 | */ |
---|
| 674 | |
---|
| 675 | //wire oprnd2_sel = nxt_jloopa_state | cur_iloopa1_state | nxt_iloopa_state | nxt_jloopm_state ; |
---|
| 676 | wire oprnd2_sel = nxt_jloopa_state | nxt_iloopa1_state | nxt_jloopm_state ; |
---|
| 677 | |
---|
| 678 | |
---|
| 679 | wire oprnd2_sel_q; |
---|
| 680 | dff_s #(1) oprnd2_wen_ff ( |
---|
| 681 | .din(oprnd2_sel) , |
---|
| 682 | .q(oprnd2_sel_q), |
---|
| 683 | .clk (rclk), .se(se), .si(), .so()); |
---|
| 684 | |
---|
| 685 | assign spu_maaeqb_oprnd2_wen = oprnd2_sel_q | spu_maaeqb_m_wr_oprnd2_wen | |
---|
| 686 | spu_maaeqb_me_wr_oprnd2_wen ; |
---|
| 687 | |
---|
| 688 | |
---|
| 689 | |
---|
| 690 | assign spu_maaeqb_oprnd2_bypass = spu_maaeqb_m_wr_oprnd2_wen | spu_maaeqb_me_wr_oprnd2_wen ; |
---|
| 691 | |
---|
| 692 | |
---|
| 693 | //assign spu_maaeqb_oprnd1_sel = cur_nprime_state; // only select nprime if set |
---|
| 694 | |
---|
| 695 | // --------------------------------------------------------------- |
---|
| 696 | assign spu_maaeqb_mul_acc = spu_maaeqb_mul_req_vld & ~cur_nprime_state; |
---|
| 697 | |
---|
| 698 | // --------------------------------------------------------------- |
---|
| 699 | // --------------------------------------------------------------- |
---|
| 700 | // --------------------------------------------------------------- |
---|
| 701 | |
---|
| 702 | wire spu_maaeqb_memrd4op1 = spu_maaeqb_rd_aiminusj | |
---|
| 703 | //spu_maaeqb_rd_ai | |
---|
| 704 | cur_iloopa1_state_dly | |
---|
| 705 | spu_maaeqb_rd_niminusj | spu_maaeqb_rd_n0; |
---|
| 706 | |
---|
| 707 | wire spu_maaeqb_memrd4op1_q; |
---|
| 708 | dff_s #(1) spu_maaeqb_memrd4op1_ff ( |
---|
| 709 | .din(spu_maaeqb_memrd4op1) , |
---|
| 710 | .q(spu_maaeqb_memrd4op1_q), |
---|
| 711 | .clk (rclk), .se(se), .si(), .so()); |
---|
| 712 | |
---|
| 713 | |
---|
| 714 | wire [1:0] spu_maaeqb_oprnd1_mxsel; |
---|
| 715 | assign spu_maaeqb_oprnd1_mxsel[0] = ~cur_nprime_state & ~spu_maaeqb_memrd4op1_q; |
---|
| 716 | assign spu_maaeqb_oprnd1_mxsel[1] = ~cur_nprime_state & spu_maaeqb_memrd4op1_q; |
---|
| 717 | //assign spu_maaeqb_oprnd1_mxsel[2] = cur_nprime_state; |
---|
| 718 | |
---|
| 719 | |
---|
| 720 | assign spu_maaeqb_oprnd1_wen = spu_maaeqb_memrd4op1_q; |
---|
| 721 | |
---|
| 722 | |
---|
| 723 | |
---|
| 724 | endmodule |
---|
| 725 | |
---|