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

Subversion Repositories theia_gpu

[/] [theia_gpu/] [branches/] [gpu_16_cores/] [rtl/] [GPU/] [TOP/] [Theia.v] - Diff between revs 135 and 137

Show entire file | Details | Blame | View Log

Rev 135 Rev 137
Line 1... Line 1...
`timescale 1ns / 1ps
`timescale 1ns / 1ps
`include "aDefinitions.v"
`include "aDefinitions.v"
 
/**********************************************************************************
 
Theia, Ray Cast Programable graphic Processing Unit.
 
Copyright (C) 2010  Diego Valverde (diego.valverde.g@gmail.com)
 
 
 
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; either version 2
 
of the License, or (at your option) any later version.
 
 
 
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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 
 
***********************************************************************************/
 
 
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
module THEIA
module THEIA
(
(
 
 
Line 10... Line 29...
//Theia Interfaces
//Theia Interfaces
input wire                    MST_I,    //Master signal, THEIA enters configuration mode
input wire                    MST_I,    //Master signal, THEIA enters configuration mode
                                       //when this gets asserted (see documentation)
                                       //when this gets asserted (see documentation)
//Wish Bone Interface
//Wish Bone Interface
input wire [`WB_WIDTH-1:0]    DAT_I,     //Input data bus  (Wishbone)
input wire [`WB_WIDTH-1:0]    DAT_I,     //Input data bus  (Wishbone)
//output wire [`WB_WIDTH-1:0]   DAT_O,  //Output data bus (Wishbone)
 
input wire                    ACK_I,    //Input ack
input wire                    ACK_I,    //Input ack
output wire                   ACK_O,    //Output ack
output wire                   ACK_O,    //Output ack
//output wire [`WB_WIDTH-1:0]   ADR_O,  //Output address
 
input wire [`WB_WIDTH-1:0]    ADR_I,     //Input address
input wire [`WB_WIDTH-1:0]    ADR_I,     //Input address
//output wire                   WE_O,           //Output write enable
 
input wire                    WE_I,    //Input write enable
input wire                    WE_I,    //Input write enable
//output wire                   STB_O,  //Strobe signal, see wishbone documentation
 
input wire                    STB_I,    //Strobe signal, see wishbone documentation
input wire                    STB_I,    //Strobe signal, see wishbone documentation
//output wire                   CYC_O,  //Bus cycle signal, see wishbone documentation
 
input wire                    CYC_I,   //Bus cycle signal, see wishbone documentation
input wire                    CYC_I,   //Bus cycle signal, see wishbone documentation
//output wire   [1:0]             TGC_O,   //Bus cycle tag, see THEAI documentation
 
input wire [1:0]              TGA_I,   //Input address tag, see THEAI documentation
input wire [1:0]              TGA_I,   //Input address tag, see THEAI documentation
//output wire [1:0]             TGA_O,   //Output address tag, see THEAI documentation
 
//input wire    [1:0]             TGC_I,   //Bus cycle tag, see THEAI documentation
 
input wire [`MAX_CORES-1:0]      SEL_I,  //The WishBone Master uses this signal to configure a specific core (TBD, not sure is needed)
input wire [`MAX_CORES-1:0]      SEL_I,  //The WishBone Master uses this signal to configure a specific core (TBD, not sure is needed)
input wire [`MAX_CORES-1:0]   RENDREN_I,
input wire [`MAX_CORES-1:0]   RENDREN_I,
 
 
input wire [`MAX_CORE_BITS-1:0]      OMBSEL_I,  //Output memory bank select
input wire [`MAX_CORE_BITS-1:0]      OMBSEL_I,  //Output memory bank select
input wire [`WB_WIDTH-1:0]           OMADR_I,  //Output adress (relative to current bank)
input wire [`WB_WIDTH-1:0]           OMADR_I,  //Output adress (relative to current bank)
Line 83... Line 94...
wire [`MAX_CORES-1:0]   wACK_I;
wire [`MAX_CORES-1:0]   wACK_I;
wire [`MAX_CORES-1:0]   wCYC_I;
wire [`MAX_CORES-1:0]   wCYC_I;
wire [1:0]              wTGA_I[`MAX_CORES-1:0];
wire [1:0]              wTGA_I[`MAX_CORES-1:0];
 
 
 
 
//wire [`MAX_CORES-1:0] wTMEM_ACK_I;
 
wire [`WB_WIDTH-1:0]  wTMEM_Data;
wire [`WB_WIDTH-1:0]  wTMEM_Data;
wire [`WB_WIDTH-1:0]  wTMEM_Address[`MAX_CORES-1:0];
wire [`WB_WIDTH-1:0]  wTMEM_Address[`MAX_CORES-1:0];
wire [`WB_WIDTH-1:0]  wTMEM_ReadAddr;
wire [`WB_WIDTH-1:0]  wTMEM_ReadAddr;
//wire [`MAX_CORES-1:0] wTMEM_STB_O;
 
wire [`MAX_CORES-1:0] wTMEM_Resquest;
wire [`MAX_CORES-1:0] wTMEM_Resquest;
wire [`MAX_CORES-1:0] wTMEM_Granted;
wire [`MAX_CORES-1:0] wTMEM_Granted;
 
 
 
 
 
 
Line 111... Line 121...
 
 
wire [`MAX_CORES-1:0]         wBankReadGranted[`MAX_TMEM_BANKS-1:0];
wire [`MAX_CORES-1:0]         wBankReadGranted[`MAX_TMEM_BANKS-1:0];
wire                           wTMEM_2_Core__Grant[`MAX_CORES-1:0];
wire                           wTMEM_2_Core__Grant[`MAX_CORES-1:0];
 
 
wire[`MAX_CORE_BITS-1:0] wCurrentCoreSelected[`MAX_TMEM_BANKS-1:0];
wire[`MAX_CORE_BITS-1:0] wCurrentCoreSelected[`MAX_TMEM_BANKS-1:0];
//wire [`WB_WIDTH-1:0]     wTMEM_2_Core_Data[`MAX_CORES-1:0];                   //Vertical grid Buses going to each core.
wire[`WIDTH-1:0]                wCoreBankSelect[`MAX_CORES-1:0];
wire[7:0]                wCoreBankSelect[`MAX_CORES-1:0];
 
wire [`MAX_CORES-1:0] wGRDY_O;
wire [`MAX_CORES-1:0] wGRDY_O;
 
 
 
 
wire [`MAX_CORES-1:0] wGReady;
wire [`MAX_CORES-1:0] wGReady;
wire [`MAX_CORES-1:0] wRCOMMIT_O;
wire [`MAX_CORES-1:0] wRCOMMIT_O;
wire [`MAX_CORES-1:0] wRCommited;
wire [`MAX_CORES-1:0] wRCommited;
 
 
 
 
assign RCOMMIT_O = wRCommited[0] & wRCommited[1] & wRCommited[2] & wRCommited[3];
assign RCOMMIT_O = wRCommited[0] & wRCommited[1] & wRCommited[2] & wRCommited[3] & wRCommited[4] & wRCommited[5] & wRCommited[6] & wRCommited[7] & wRCommited[8] & wRCommited[9] & wRCommited[10] & wRCommited[11] & wRCommited[12] & wRCommited[13] & wRCommited[14] & wRCommited[15];
assign GRDY_O = wGReady[0] & wGReady[1] & wGReady[2] & wGReady[3];
assign GRDY_O = wGReady[0] &  wGReady[1] &  wGReady[2] &  wGReady[3] &  wGReady[4] &  wGReady[5] &  wGReady[6] &  wGReady[7] &  wGReady[8] &  wGReady[9] &  wGReady[10] &  wGReady[11] &  wGReady[12] &  wGReady[13] &  wGReady[14] &  wGReady[15];
//----------------------------------------------------------------      
assign DONE_O = wDone[0] & wDone[1] & wDone[2] & wDone[3] & wDone[4] & wDone[5] & wDone[6] & wDone[7] & wDone[8] & wDone[9] & wDone[10] & wDone[11] & wDone[12] & wDone[13] & wDone[14] & wDone[15];
//The next secuencial logic just AND all the wDone signals
 
//I know that it would be much more elgant to just do parallel:
 
//assign DONE_O = wDone[0] & wDone[1] & ... & wDone[MAX_CORES-1];
 
//However, I don't know how to achieve this with 'generate' statements
 
//So coding a simple loop instead
 
 
 
/*
 
always @ (posedge CLK_I)
 
begin : AND_DONE_SIGNALS
 
  integer k;
 
  DONE_O = wDone[0];
 
  for (k=0;k<=`MAX_CORES;k=k+1)
 
    DONE_O=DONE_O & wDone[k+1];
 
end
 
*/
 
assign DONE_O = wDone[0] & wDone[1] & wDone[2] & wDone[3];       //Replace this by a counter??
 
//----------------------------------------------------------------      
//----------------------------------------------------------------      
 
 
        Module_BusArbitrer ARB1
        Module_BusArbitrer ARB1
        (
        (
        .Clock( CLK_I ),
        .Clock( CLK_I ),
Line 153... Line 149...
        .oBusSelect( wBusSelect )
        .oBusSelect( wBusSelect )
 
 
        );
        );
//----------------------------------------------------------------
//----------------------------------------------------------------
 
 
 // assign DAT_O = wDAT_O[ wBusSelect ];
 
//  assign TGA_O = wTGA_O[ wBusSelect ];
 
//  assign ADR_O = wADR_O[ wBusSelect ];
 
//  assign STB_O = wSTB_O[ wBusSelect ];
 
//  assign WE_O  = wWE_O[ wBusSelect ];
 
  assign ACK_O = wACK_O[ wBusSelect];
  assign ACK_O = wACK_O[ wBusSelect];
 
 
 wire [`WB_WIDTH-1:0] wDataOut[`MAX_CORES-1:0];
 wire [`WB_WIDTH-1:0] wDataOut[`MAX_CORES-1:0];
 assign OMEM_O = wDataOut[ OMBSEL_I ];
 assign OMEM_O = wDataOut[ OMBSEL_I ];
 
 
Line 190... Line 182...
                .MST_I( wMST_I[i] ),
                .MST_I( wMST_I[i] ),
                .TGA_I( wTGA_I[i] ),
                .TGA_I( wTGA_I[i] ),
                .CREG_I( CREG_I ),
                .CREG_I( CREG_I ),
 
 
                //Master Signals
                //Master Signals
                //.WE_O (       wWE_O[i]  ),
 
                //.STB_O(       wSTB_O[i] ),
 
                .ACK_O(         wACK_O[i] ),
                .ACK_O(         wACK_O[i] ),
        //      .DAT_O(  wDAT_O[i] ),
 
                //.ADR_O(  wADR_O[i] ),
 
                .CYC_O(  wBusRequest[i] ),
                .CYC_O(  wBusRequest[i] ),
                .GNT_I(         wBusGranted[i] ),
                .GNT_I(         wBusGranted[i] ),
                //.TGA_O(       wTGA_O[i] ),
 
                `ifdef DEBUG
                `ifdef DEBUG
                .iDebug_CoreID( i ),
                .iDebug_CoreID( i ),
                `endif
                `endif
 
 
                .OMEM_WE_O( wOMem_WE[i] ),
                .OMEM_WE_O( wOMem_WE[i] ),
                .OMEM_ADR_O( wOMEM_Address[i] ),
                .OMEM_ADR_O( wOMEM_Address[i] ),
                .OMEM_DAT_O( wOMEM_Dat[i] ),
                .OMEM_DAT_O( wOMEM_Dat[i] ),
 
 
 
 
 
 
                .TMEM_DAT_I( wCrossBarDataCollumn[i]    ),
                .TMEM_DAT_I( wCrossBarDataCollumn[i]    ),
                .TMEM_ADR_O( wTMemReadAdr[i]  ),
                .TMEM_ADR_O( wTMemReadAdr[i]  ),
                .TMEM_CYC_O( wCORE_2_TMEM__Req[i]       ),
                .TMEM_CYC_O( wCORE_2_TMEM__Req[i]       ),
                .TMEM_GNT_I( wTMEM_2_Core__Grant[i]     ),
                .TMEM_GNT_I( wTMEM_2_Core__Grant[i]     ),
 
 
Line 242... Line 227...
        .Initial( 1'b0 ),
        .Initial( 1'b0 ),
        .Enable( wGRDY_O[i] ),
        .Enable( wGRDY_O[i] ),
        .Q(wGReady[i])
        .Q(wGReady[i])
        );
        );
 
 
        RAM_SINGLE_READ_PORT # ( `WB_WIDTH, `WB_WIDTH, 500000 ) OMEM //10k mem
        RAM_SINGLE_READ_PORT # ( `WB_WIDTH, `WB_WIDTH, 250000 ) OMEM //500000 ) OMEM 
(
(
        .Clock(         CLK_I                ),
        .Clock(         CLK_I                ),
        .iWriteEnable(  wOMem_WE[i]          ),
        .iWriteEnable(  wOMem_WE[i]          ),
        .iWriteAddress( wOMEM_Address[i]     ),
        .iWriteAddress( wOMEM_Address[i]     ),
        .iDataIn(       wOMEM_Dat[i]         ),
        .iDataIn(       wOMEM_Dat[i]         ),
Line 262... Line 247...
 
 
//Each core has 1 bank request slot
//Each core has 1 bank request slot
//Each slot has MAX_TMEM_BANKS bits. Only 1 bit can
//Each slot has MAX_TMEM_BANKS bits. Only 1 bit can
//be 1 at any given point in time. All bits zero means,
//be 1 at any given point in time. All bits zero means,
//we are not requesting to read from any memory bank.
//we are not requesting to read from any memory bank.
SELECT_1_TO_N # ( 8, 4 ) READDRQ
SELECT_1_TO_N # ( `WIDTH, `MAX_CORES ) READDRQ
                        (
                        (
                        .Sel(wCoreBankSelect[ i]),
                        .Sel(wCoreBankSelect[ i]),
                        .En(wCORE_2_TMEM__Req[i]),
                        .En(wCORE_2_TMEM__Req[i]),
                        .O(wBankReadRequest[i])
                        .O(wBankReadRequest[i])
                        );
                        );
Line 274... Line 259...
//The address coming from the core is  virtual adress, meaning it assumes linear
//The address coming from the core is  virtual adress, meaning it assumes linear
//address space, however, since memory is interleaved in a n-way memory we transform
//address space, however, since memory is interleaved in a n-way memory we transform
//virtual adress into physical adress (relative to the bank) like this
//virtual adress into physical adress (relative to the bank) like this
//fadr = vadr / n = vadr >> log2(n)
//fadr = vadr / n = vadr >> log2(n)
 
 
assign wCrossBarAdressCollumn[i] = (wTMemReadAdr[i] >> ((`MAX_TMEM_BANKS)/2));
assign wCrossBarAdressCollumn[i] = (wTMemReadAdr[i] >> `MAX_CORE_BITS);
 
 
//Connect the granted signal to Arbiter of the Bank we want to read from        
//Connect the granted signal to Arbiter of the Bank we want to read from        
assign wTMEM_2_Core__Grant[i] = wBankReadGranted[wCoreBankSelect[i]][i];
assign wTMEM_2_Core__Grant[i] = wBankReadGranted[wCoreBankSelect[i]][i];
 
 
//Connect the request signal to Arbiter of the Bank we want to read from        
//Connect the request signal to Arbiter of the Bank we want to read from        
Line 312... Line 297...
wire [`MAX_CORES-1:0]         wBankReadGrantedDelay[`MAX_TMEM_BANKS-1:0];
wire [`MAX_CORES-1:0]         wBankReadGrantedDelay[`MAX_TMEM_BANKS-1:0];
        Module_BusArbitrer ARB_TMEM
        Module_BusArbitrer ARB_TMEM
        (
        (
        .Clock( CLK_I ),
        .Clock( CLK_I ),
        .Reset( RST_I ),
        .Reset( RST_I ),
        .iRequest( {wBankReadRequest[3][Bank],wBankReadRequest[2][Bank],wBankReadRequest[1][Bank],wBankReadRequest[0][Bank]}),//wBankReadRequest[Bank] ),   //The cores requesting to read from this Bank
        .iRequest( {wBankReadRequest[15][Bank],wBankReadRequest[14][Bank],wBankReadRequest[13][Bank],wBankReadRequest[12][Bank],wBankReadRequest[11][Bank],wBankReadRequest[10][Bank],wBankReadRequest[9][Bank],wBankReadRequest[8][Bank],wBankReadRequest[7][Bank],wBankReadRequest[6][Bank],wBankReadRequest[5][Bank],wBankReadRequest[4][Bank],wBankReadRequest[3][Bank],wBankReadRequest[2][Bank],wBankReadRequest[1][Bank],wBankReadRequest[0][Bank]}),
        .oGrant(   wBankReadGrantedDelay[Bank]  ),  //The bit of the core granted to read from this Bank
        .oGrant(   wBankReadGrantedDelay[Bank]  ),  //The bit of the core granted to read from this Bank
        .oBusSelect( wCurrentCoreSelected[Bank] )                       //The index of the core granted to read from this Bank
        .oBusSelect( wCurrentCoreSelected[Bank] )                       //The index of the core granted to read from this Bank
 
 
        );
        );
 
 

powered by: WebSVN 2.1.0

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