`timescale 1ns / 1ps
|
`timescale 1ns / 1ps
|
`include "aDefinitions.v"
|
`include "aDefinitions.v"
|
/**********************************************************************************
|
/**********************************************************************************
|
Theia, Ray Cast Programable graphic Processing Unit.
|
Theia, Ray Cast Programable graphic Processing Unit.
|
Copyright (C) 2010 Diego Valverde (diego.valverde.g@gmail.com)
|
Copyright (C) 2010 Diego Valverde (diego.valverde.g@gmail.com)
|
|
|
This program is free software; you can redistribute it and/or
|
This program is free software; you can redistribute it and/or
|
modify it under the terms of the GNU General Public License
|
modify it under the terms of the GNU General Public License
|
as published by the Free Software Foundation; either version 2
|
as published by the Free Software Foundation; either version 2
|
of the License, or (at your option) any later version.
|
of the License, or (at your option) any later version.
|
|
|
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
GNU General Public License for more details.
|
GNU General Public License for more details.
|
|
|
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
***********************************************************************************/
|
***********************************************************************************/
|
|
|
|
|
|
|
module Module_BusArbitrer
|
module Module_BusArbitrer
|
(
|
(
|
input wire Clock,
|
input wire Clock,
|
input wire Reset,
|
input wire Reset,
|
|
|
input wire [`MAX_CORES-1:0] iRequest,
|
input wire [`MAX_CORES-1:0] iRequest,
|
output wire [`MAX_CORES-1:0] oGrant,
|
output wire [`MAX_CORES-1:0] oGrant,
|
output wire [1:0] oBusSelect
|
output wire [1:0] oBusSelect
|
);
|
);
|
|
|
|
|
|
|
|
|
|
|
wire wFFMS_connect;
|
wire wFFMS_connect;
|
wire wIncRR_pointer;
|
wire wIncRR_pointer;
|
wire[3:0] wCurrentMasterMask;
|
wire[3:0] wCurrentMasterMask;
|
reg[3:0] wCurrentBusMaster;
|
reg[3:0] wCurrentBusMaster;
|
wire wCurrentRequest;
|
wire wCurrentRequest;
|
|
|
//Just one requester can have the bus at a given
|
//Just one requester can have the bus at a given
|
//point in time, the mask makes sure this happens
|
//point in time, the mask makes sure this happens
|
assign oGrant[0] = iRequest[0] & wCurrentMasterMask[0];
|
assign oGrant[0] = iRequest[0] & wCurrentMasterMask[0];
|
assign oGrant[1] = iRequest[1] & wCurrentMasterMask[1];
|
assign oGrant[1] = iRequest[1] & wCurrentMasterMask[1];
|
assign oGrant[2] = iRequest[2] & wCurrentMasterMask[2];
|
assign oGrant[2] = iRequest[2] & wCurrentMasterMask[2];
|
assign oGrant[3] = iRequest[3] & wCurrentMasterMask[3];
|
assign oGrant[3] = iRequest[3] & wCurrentMasterMask[3];
|
|
|
|
|
//When a requester relinquishes the bus (by negating its [iRequest] signal),
|
//When a requester relinquishes the bus (by negating its [iRequest] signal),
|
//the switch is turned to the next position
|
//the switch is turned to the next position
|
//So while iRequest == 1 the ciruclar list will not move
|
//So while iRequest == 1 the ciruclar list will not move
|
CIRCULAR_SHIFTLEFT_POSEDGE_EX # (4) SHL_A
|
CIRCULAR_SHIFTLEFT_POSEDGE_EX # (4) SHL_A
|
(
|
(
|
.Clock( Clock ),
|
.Clock( Clock ),
|
.Enable( ~wCurrentRequest ),
|
.Enable( ~wCurrentRequest ),
|
.Reset( Reset ),
|
.Reset( Reset ),
|
.Initial(4'b1),
|
.Initial(4'b1),
|
.O( wCurrentMasterMask )
|
.O( wCurrentMasterMask )
|
|
|
);
|
);
|
|
|
assign oBusSelect = wCurrentBusMaster;
|
assign oBusSelect = wCurrentBusMaster;
|
|
|
MUXFULLPARALELL_2SEL_GENERIC # ( 1 ) MUXA
|
MUXFULLPARALELL_2SEL_GENERIC # ( 1 ) MUXA
|
(
|
(
|
.Sel(wCurrentBusMaster[1:0]),
|
.Sel(wCurrentBusMaster[1:0]),
|
.I1(iRequest[0]),
|
.I1(iRequest[0]),
|
.I2(iRequest[1]),
|
.I2(iRequest[1]),
|
.I3(iRequest[2]),
|
.I3(iRequest[2]),
|
.I4(iRequest[3]),
|
.I4(iRequest[3]),
|
.O1( wCurrentRequest )
|
.O1( wCurrentRequest )
|
);
|
);
|
|
|
always @ ( * )
|
always @ ( * )
|
begin
|
begin
|
case (wCurrentMasterMask)
|
case (wCurrentMasterMask)
|
4'b0001: wCurrentBusMaster <= 0;
|
4'b0001: wCurrentBusMaster <= 0;
|
4'b0010: wCurrentBusMaster <= 1;
|
4'b0010: wCurrentBusMaster <= 1;
|
4'b0100: wCurrentBusMaster <= 2;
|
4'b0100: wCurrentBusMaster <= 2;
|
4'b1000: wCurrentBusMaster <= 3;
|
4'b1000: wCurrentBusMaster <= 3;
|
default: wCurrentBusMaster <= 0;
|
default: wCurrentBusMaster <= 0;
|
endcase
|
endcase
|
end
|
end
|
|
|
endmodule
|
endmodule
|
|
|