OpenCores
URL https://opencores.org/ocsvn/theia_gpu/theia_gpu/trunk

Subversion Repositories theia_gpu

[/] [theia_gpu/] [branches/] [beta_1.2/] [rtl/] [IO/] [Module_WishBoneMaster.v] - Diff between revs 76 and 87

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 76 Rev 87
`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.
 
 
***********************************************************************************/
***********************************************************************************/
/*
/*
        In order to read the geometry, we will behave as a master.
        In order to read the geometry, we will behave as a master.
        Performing single Reads Bus cycles should be sufficient.
        Performing single Reads Bus cycles should be sufficient.
        Choosing 32 bit for bus width for simplicity.
        Choosing 32 bit for bus width for simplicity.
*/
*/
 
 
module WishBoneMasterUnit
module WishBoneMasterUnit
(
(
//WB Input signals
//WB Input signals
input wire                                                 CLK_I,
input wire                                                 CLK_I,
input wire                                                 RST_I,
input wire                                                 RST_I,
input wire                                                 ACK_I,
input wire                                                 ACK_I,
input wire                    GNT_I, //granted signal from bus arbiter
input wire                    GNT_I, //granted signal from bus arbiter
input wire [`WB_WIDTH-1:0 ]      DAT_I,
input wire [`WB_WIDTH-1:0 ]      DAT_I,
output wire [`WB_WIDTH-1:0]   DAT_O,
output wire [`WB_WIDTH-1:0]   DAT_O,
 
 
 
 
//WB Output Signals
//WB Output Signals
output wire [`WB_WIDTH-1:0 ] ADR_O,
output wire [`WB_WIDTH-1:0 ] ADR_O,
output wire                                  WE_O,
output wire                                  WE_O,
output wire                                  STB_O,
output wire                                  STB_O,
output wire                                  CYC_O,
output wire                                  CYC_O,
output wire [1:0]                             TGC_O,
output wire [1:0]                             TGC_O,
 
 
//Signals from inside the GPU
//Signals from inside the GPU
input wire                                              iEnable,
input wire                                              iEnable,
input wire                 iBusCyc_Type,
input wire                 iBusCyc_Type,
input wire [`WIDTH-1:0 ]         iAddress,
input wire [`WIDTH-1:0 ]         iAddress,
input wire                 iAddress_Set,
input wire                 iAddress_Set,
output wire                                             oDataReady,
output wire                                             oDataReady,
input wire  [`WIDTH-1:0 ]  iData,
input wire  [`WIDTH-1:0 ]  iData,
output wire     [`WIDTH-1:0 ]  oData
output wire     [`WIDTH-1:0 ]  oData
 
 
 
 
);
);
wire wReadOperation;
wire wReadOperation;
wire wEnable;
wire wEnable;
assign wEnable = iEnable & GNT_I;
assign wEnable = iEnable & GNT_I;
//If CYC_O is 1, it means we are requesting bus ownership
//If CYC_O is 1, it means we are requesting bus ownership
assign CYC_O = iEnable;
assign CYC_O = iEnable;
 
 
assign wReadOperation = (iBusCyc_Type == `WB_SIMPLE_READ_CYCLE) ? 1 : 0;
assign wReadOperation = (iBusCyc_Type == `WB_SIMPLE_READ_CYCLE) ? 1 : 0;
assign WE_O = (iBusCyc_Type == `WB_SIMPLE_WRITE_CYCLE && wEnable) ? 1 : 0;
assign WE_O = (iBusCyc_Type == `WB_SIMPLE_WRITE_CYCLE && wEnable) ? 1 : 0;
 
 
 
 
wire wEnable_Delayed;
wire wEnable_Delayed;
FFD_POSEDGE_SYNCRONOUS_RESET # ( 1 ) FFD88
FFD_POSEDGE_SYNCRONOUS_RESET # ( 1 ) FFD88
(
(
        .Clock(CLK_I),
        .Clock(CLK_I),
        .Reset(RST_I),
        .Reset(RST_I),
        .Enable(1'b1 ),
        .Enable(1'b1 ),
        .D(wEnable),
        .D(wEnable),
        .Q(wEnable_Delayed)
        .Q(wEnable_Delayed)
);
);
 
 
 
 
 
 
//We only start Strobbing 1 cycle after iEnable and only
//We only start Strobbing 1 cycle after iEnable and only
//if iEnable is 1 and if GNT_I is 1 (meaning we own the bus)
//if iEnable is 1 and if GNT_I is 1 (meaning we own the bus)
assign STB_O = wEnable_Delayed & ~ACK_I & wEnable;
assign STB_O = wEnable_Delayed & ~ACK_I & wEnable;
 
 
 
 
assign DAT_O = (wReadOperation | ~wEnable ) ? `WB_WIDTH'bz : iData;
assign DAT_O = (wReadOperation | ~wEnable ) ? `WB_WIDTH'bz : iData;
 
 
wire [`WB_WIDTH-1:0 ] wReadADR_O,wWriteADR_O;
wire [`WB_WIDTH-1:0 ] wReadADR_O,wWriteADR_O;
assign ADR_O = ( wReadOperation ) ? wReadADR_O : wWriteADR_O;
assign ADR_O = ( wReadOperation ) ? wReadADR_O : wWriteADR_O;
 
 
//The ADR_O, it increments with each ACK_I, and it resets
//The ADR_O, it increments with each ACK_I, and it resets
//to the value iAddress everytime iAddress_Set is 1.
//to the value iAddress everytime iAddress_Set is 1.
UPCOUNTER_POSEDGE # (`WIDTH) WBM_O_READ_ADDRESS
UPCOUNTER_POSEDGE # (`WIDTH) WBM_O_READ_ADDRESS
(
(
        .Clock(CLK_I),
        .Clock(CLK_I),
        .Reset( iAddress_Set ),
        .Reset( iAddress_Set ),
        .Enable((ACK_I & GNT_I) | iAddress_Set),
        .Enable((ACK_I & GNT_I) | iAddress_Set),
        .Initial(iAddress),
        .Initial(iAddress),
        .Q(wReadADR_O)
        .Q(wReadADR_O)
);
);
wire wDelayWE;
wire wDelayWE;
FFD_POSEDGE_SYNCRONOUS_RESET # ( 1 ) FFD3
FFD_POSEDGE_SYNCRONOUS_RESET # ( 1 ) FFD3
(
(
        .Clock(CLK_I),
        .Clock(CLK_I),
        .Reset(RST_I),
        .Reset(RST_I),
        .Enable(1'b1),
        .Enable(1'b1),
        .D(WE_O),
        .D(WE_O),
        .Q(wDelayWE)
        .Q(wDelayWE)
);
);
 
 
UPCOUNTER_POSEDGE # (`WIDTH) WBM_O_WRITE_ADDRESS
UPCOUNTER_POSEDGE # (`WIDTH) WBM_O_WRITE_ADDRESS
(
(
        .Clock(CLK_I),
        .Clock(CLK_I),
        .Reset( iAddress_Set ),//RST_I ),
        .Reset( iAddress_Set ),//RST_I ),
        .Enable( (wDelayWE & ACK_I ) | iAddress_Set),
        .Enable( (wDelayWE & ACK_I ) | iAddress_Set),
        .Initial(iAddress),//`WIDTH'b0),
        .Initial(iAddress),//`WIDTH'b0),
        .Q(wWriteADR_O)
        .Q(wWriteADR_O)
);
);
 
 
FFD_POSEDGE_SYNCRONOUS_RESET # ( `WIDTH ) FFD1
FFD_POSEDGE_SYNCRONOUS_RESET # ( `WIDTH ) FFD1
(
(
        .Clock(ACK_I),
        .Clock(ACK_I),
        .Reset(~wEnable),
        .Reset(~wEnable),
        .Enable(wReadOperation ),
        .Enable(wReadOperation ),
        .D(DAT_I),
        .D(DAT_I),
        .Q(oData)
        .Q(oData)
);
);
 
 
wire wDelayDataReady;
wire wDelayDataReady;
FFD_POSEDGE_SYNCRONOUS_RESET # ( 1 ) FFD2
FFD_POSEDGE_SYNCRONOUS_RESET # ( 1 ) FFD2
(
(
        .Clock(CLK_I),
        .Clock(CLK_I),
        .Reset(~wEnable),
        .Reset(~wEnable),
        .Enable(wReadOperation),
        .Enable(wReadOperation),
        .D(ACK_I),
        .D(ACK_I),
        .Q(wDelayDataReady)
        .Q(wDelayDataReady)
);
);
/*
/*
always @ (posedge wDelayDataReady)
always @ (posedge wDelayDataReady)
begin
begin
        $display("WBM Got data: %h ",oData);
        $display("WBM Got data: %h ",oData);
        $display("oDataReady = %d",oDataReady );
        $display("oDataReady = %d",oDataReady );
end
end
*/
*/
 
 
assign oDataReady = wDelayDataReady & wEnable;
assign oDataReady = wDelayDataReady & wEnable;
 
 
endmodule
endmodule
 
 
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.