// ========== Copyright Header Begin ==========================================
// OpenSPARC T2 Processor File: niu_dmc_dmaarb.v
// Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved
// 4150 Network Circle, Santa Clara, California 95054, U.S.A.
// * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 2 of the License.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// For the avoidance of doubt, and except that if any non-GPL license
// choice is available it will apply instead, Sun elects to use only
// the General Public License version 2 (GPLv2) at this time for any
// software where a choice of GPL license versions is made
// available with the language indicating that GPLv2 or any later version
// may be used, or where a choice of which version of the GPL is applied is
// otherwise unspecified.
// Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
// CA 95054 USA or visit www.sun.com if you need additional information or
// ========== Copyright Header End ============================================
/*********************************************************************
**********************************************************************/
`include "niu_dmc_reg_defines.h"
module niu_dmc_dmaarb (/*AUTOARG*/
ArbDone, DMANum, DMAsGranted,
SysClk, Reset_L, Choose_DMAs, DMA_Reqs
output [31:0] DMAsGranted;
reg [31:0] Select_DMA_Grant;
reg [3:0] DMA_Request_ArbState;
parameter DMA_REQ_ARB_IDLE = 4'h0,
// synopsys translate_off
reg [192:1] CACHE_REQ_ARB_STATE;
always @(DMA_Request_ArbState)
case(DMA_Request_ArbState)
DMA_REQ_ARB_IDLE : CACHE_REQ_ARB_STATE = "DMA_REQ_ARB_IDLE";
SELECT_DMA_NUM: CACHE_REQ_ARB_STATE = "SELECT_DMA_NUM";
DMA_REQ_ARB_DONE : CACHE_REQ_ARB_STATE = "DMA_REQ_ARB_DONE";
default : CACHE_REQ_ARB_STATE = "UNKNOWN";
always@(posedge SysClk ) begin
DMA_Request_ArbState <= DMA_REQ_ARB_IDLE;
Select_DMA_Grant <= 32'h0;
case(DMA_Request_ArbState) // synopsys parallel_case
Select_DMA_Grant <= DMA_Reqs & ~DMAsGranted;
DMA_Request_ArbState <= SELECT_DMA_NUM;
end else begin // if (choose_available_dmas)
Select_DMA_Grant <= 32'h0;
end // else: !if(choose_available_dmas)
end // case: DMA_REQ_ARB_IDLE
casex(Select_DMA_Grant) // Synopsys full_case
32'b0000_0000_0000_0000_0000_0000_0000_0001: begin
DMAsGranted <= 32'b0000_0000_0000_0000_0000_0000_0000_0001;
DMANum<= `DMA_CHANNEL_ZERO;
end // case: 32'b0000_0000_0000_0000_0000_0000_0000_0001
32'b????_????_????_????_????_????_????_??1?: begin
DMAsGranted <= 32'b0000_0000_0000_0000_0000_0000_0000_0010;
DMANum<= `DMA_CHANNEL_ONE;
32'b????_????_????_????_????_????_????_?10?: begin
DMAsGranted <= 32'b0000_0000_0000_0000_0000_0000_0000_0100;
DMANum<= `DMA_CHANNEL_TWO;
32'b????_????_????_????_????_????_????_100?: begin
DMAsGranted <= 32'b0000_0000_0000_0000_0000_0000_0000_1000;
DMANum<= `DMA_CHANNEL_THREE;
32'b????_????_????_????_????_????_???1_000?: begin
DMAsGranted <= 32'b0000_0000_0000_0000_0000_0000_0001_0000;
DMANum<= `DMA_CHANNEL_FOUR;
32'b????_????_????_????_????_????_??10_000?: begin
DMAsGranted <= 32'b0000_0000_0000_0000_0000_0000_0010_0000;
DMANum<= `DMA_CHANNEL_FIVE;
32'b????_????_????_????_????_????_?100_000?: begin
DMAsGranted <= 32'b0000_0000_0000_0000_0000_0000_0100_0000;
DMANum<= `DMA_CHANNEL_SIX;
32'b????_????_????_????_????_????_1000_000?: begin
DMAsGranted <= 32'b0000_0000_0000_0000_0000_0000_1000_0000;
DMANum<= `DMA_CHANNEL_SEVEN;
32'b????_????_????_????_????_???1_0000_000?: begin
DMAsGranted <= 32'b0000_0000_0000_0000_0000_0001_0000_0000;
DMANum<= `DMA_CHANNEL_EIGHT;
32'b????_????_????_????_????_??10_0000_000?: begin
DMAsGranted <= 32'b0000_0000_0000_0000_0000_0010_0000_0000;
DMANum<= `DMA_CHANNEL_NINE;
32'b????_????_????_????_????_?100_0000_000?: begin
DMAsGranted <= 32'b0000_0000_0000_0000_0000_0100_0000_0000;
DMANum<= `DMA_CHANNEL_TEN;
32'b????_????_????_????_????_1000_0000_000?: begin
DMAsGranted <= 32'b0000_0000_0000_0000_0000_1000_0000_0000;
DMANum<= `DMA_CHANNEL_ELEVEN;
32'b????_????_????_????_???1_0000_0000_000?: begin
DMAsGranted <= 32'b0000_0000_0000_0000_0001_0000_0000_0000;
DMANum<= `DMA_CHANNEL_TWELVE;
32'b????_????_????_????_??10_0000_0000_000?: begin
DMAsGranted <= 32'b0000_0000_0000_0000_0010_0000_0000_0000;
DMANum<= `DMA_CHANNEL_THIRTEEN;
32'b????_????_????_????_?100_0000_0000_000?: begin
DMAsGranted <= 32'b0000_0000_0000_0000_0100_0000_0000_0000;
DMANum<= `DMA_CHANNEL_FOURTEEN;
32'b????_????_????_????_1000_0000_0000_000?: begin
DMAsGranted <= 32'b0000_0000_0000_0000_1000_0000_0000_0000;
DMANum<= `DMA_CHANNEL_FIFTEEN;
32'b????_????_????_???1_0000_0000_0000_000?: begin
DMAsGranted <= 32'b0000_0000_0000_0001_0000_0000_0000_0000;
DMANum<= `DMA_CHANNEL_SIXTEEN;
32'b????_????_????_??10_0000_0000_0000_000?: begin
DMAsGranted <= 32'b0000_0000_0000_0010_0000_0000_0000_0000;
DMANum<= `DMA_CHANNEL_SEVENTEEN;
32'b????_????_????_?100_0000_0000_0000_000?: begin
DMAsGranted <= 32'b0000_0000_0000_0100_0000_0000_0000_0000;
DMANum<= `DMA_CHANNEL_EIGHTEEN;
32'b????_????_????_1000_0000_0000_0000_000?: begin
DMAsGranted <= 32'b0000_0000_0000_1000_0000_0000_0000_0000;
DMANum<= `DMA_CHANNEL_NINETEEN;
32'b????_????_???1_0000_0000_0000_0000_000?: begin
DMAsGranted <= 32'b0000_0000_0001_0000_0000_0000_0000_0000;
DMANum<= `DMA_CHANNEL_TWENTY;
32'b????_????_??10_0000_0000_0000_0000_000?: begin
DMAsGranted <= 32'b0000_0000_0010_0000_0000_0000_0000_0000;
DMANum<= `DMA_CHANNEL_TWENTYONE;
32'b????_????_?100_0000_0000_0000_0000_000?: begin
DMAsGranted <= 32'b0000_0000_0100_0000_0000_0000_0000_0000;
DMANum<= `DMA_CHANNEL_TWENTYTWO;
32'b????_????_1000_0000_0000_0000_0000_000?: begin
DMAsGranted <= 32'b0000_0000_1000_0000_0000_0000_0000_0000;
DMANum<= `DMA_CHANNEL_TWENTYTHREE;
DMANum<=`DMA_CHANNEL_ZERO;
endcase // case(DMA_Request_ArbState)
DMA_Request_ArbState <= DMA_REQ_ARB_DONE;
end // case: SELECT_DMA_NUM
DMA_Request_ArbState <= DMA_REQ_ARB_IDLE;
end // case: DMA_REQ_ARB_DONE
endcase // case(DMA_Request_ArbState)
end // else: !if(!Reset_L)
end // always@ (posedge SysClk )
endmodule // niu_dmc_dmaarb