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

Subversion Repositories theia_gpu

[/] [theia_gpu/] [branches/] [beta_1.1/] [rtl/] [GEO/] [Module_TreeNodeFetcher.v] - Diff between revs 29 and 58

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

Rev 29 Rev 58
`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.
 
 
***********************************************************************************/
***********************************************************************************/
`define TNF_AFTER_RESET                                 0
`define TNF_AFTER_RESET                                 0
`define TNF_IDLE                                                        1
`define TNF_IDLE                                                        1
`define TNF_REQUEST_AABBMIN                     2
`define TNF_REQUEST_AABBMIN                     2
`define TNF_WAIT_FOR_AABBMIN                    3
`define TNF_WAIT_FOR_AABBMIN                    3
`define TNF_REQUEST_AABBMAX                     4
`define TNF_REQUEST_AABBMAX                     4
`define TNF_WAIT_FOR_AABBMAX                    5
`define TNF_WAIT_FOR_AABBMAX                    5
 
 
`define TNF_REQUEST_NUMBER_OF_TRIANGLES 10
`define TNF_REQUEST_NUMBER_OF_TRIANGLES 10
`define TNF_WAIT_FOR_NUMBER_OF_TRIANGLES 11
`define TNF_WAIT_FOR_NUMBER_OF_TRIANGLES 11
`define TNF_LATCH_NUMBER_OF_TRIANGLES    12
`define TNF_LATCH_NUMBER_OF_TRIANGLES    12
`define TNF_WAIT_NODE_READ_ACK                   13
`define TNF_WAIT_NODE_READ_ACK                   13
`define TNF_REQUEST_DATA_OFFSET                  14
`define TNF_REQUEST_DATA_OFFSET                  14
`define TNF_WAIT_FOR_DATA_OFFSET                         15
`define TNF_WAIT_FOR_DATA_OFFSET                         15
`define TNF_LATCH_DATA_OFFSET                            16
`define TNF_LATCH_DATA_OFFSET                            16
`define TNF_REQUEST_NODE_BROTHER_ADDRESS        17
`define TNF_REQUEST_NODE_BROTHER_ADDRESS        17
`define TNF_WAIT_FOR_NODE_BROTHER_ADDRESS 18
`define TNF_WAIT_FOR_NODE_BROTHER_ADDRESS 18
`define TNF_LACTH_NODE_BROTHER_ADDRESS          19
`define TNF_LACTH_NODE_BROTHER_ADDRESS          19
`define TNF_REQUEST_NODE_PARENT_BROTHER_ADDRESS 20
`define TNF_REQUEST_NODE_PARENT_BROTHER_ADDRESS 20
`define TNF_WAIT_NODE_PARENT_BROTHER_ADDRESS            21
`define TNF_WAIT_NODE_PARENT_BROTHER_ADDRESS            21
`define TNF_LATCH_NODE_PARENT_BROTHER_ADDRESS   22
`define TNF_LATCH_NODE_PARENT_BROTHER_ADDRESS   22
`define TNF_RAM_WRITE_DELAY1                                                    23
`define TNF_RAM_WRITE_DELAY1                                                    23
`define TNF_INC1        24
`define TNF_INC1        24
`define TNF_INC2        25
`define TNF_INC2        25
`define TNF_INC3        26
`define TNF_INC3        26
 
 
/*
/*
 
 
        To fetch node, we need to ask WBM to perform several read cycles.
        To fetch node, we need to ask WBM to perform several read cycles.
        Each read cycle reads 32 bits. The first 6 read cycles requests
        Each read cycle reads 32 bits. The first 6 read cycles requests
        consecutive addresses that represent AABBMAX and AABBMIN corners.
        consecutive addresses that represent AABBMAX and AABBMIN corners.
        These 6 values must be stored into RAM for the ucode to use.
        These 6 values must be stored into RAM for the ucode to use.
        Next value represents the number of vertices this AABB has, or
        Next value represents the number of vertices this AABB has, or
        zero is is not a LEAF.
        zero is is not a LEAF.
        Next value is the offset where of the vertex data.
        Next value is the offset where of the vertex data.
*/
*/
 
 
module TreeNodeFetcher
module TreeNodeFetcher
(
(
        input wire                                      Clock,
        input wire                                      Clock,
        input wire                                      Reset,
        input wire                                      Reset,
        input   wire[`WIDTH-1:0] iData,
        input   wire[`WIDTH-1:0] iData,
        input   wire                                    iDataAvailable,
        input   wire                                    iDataAvailable,
        input   wire                                    iTrigger,
        input   wire                                    iTrigger,
        input wire[`WIDTH-1:0]   iInitialAddress,
        input wire[`WIDTH-1:0]   iInitialAddress,
 
 
        //wires that go into WBM
        //wires that go into WBM
        output reg                                              oSetAddressWBM,
        output reg                                              oSetAddressWBM,
        output reg                                              oEnableWBM,
        output reg                                              oEnableWBM,
        output wire[`WIDTH-1:0]          oAddressWBM,
        output wire[`WIDTH-1:0]          oAddressWBM,
        //The parsed node info
        //The parsed node info
        output wire                                             oNode_IsLeaf,
        output wire                                             oNode_IsLeaf,
        output wire[`WIDTH-1:0]          oNode_DataOffset,
        output wire[`WIDTH-1:0]          oNode_DataOffset,
        output wire     [`WIDTH-1:0]     oNode_TriangleCount,    //Change to 16 bits
        output wire     [`WIDTH-1:0]     oNode_TriangleCount,    //Change to 16 bits
        //output wire [`WIDTH-1:0]      oNode_ChildCount,               //Change to 16 bits
        //output wire [`WIDTH-1:0]      oNode_ChildCount,               //Change to 16 bits
 
 
        output wire [`WIDTH-1:0] oNode_Brother_Address,                  //*
        output wire [`WIDTH-1:0] oNode_Brother_Address,                  //*
        output wire [`WIDTH-1:0] oParents_Brother_Address,               //*
        output wire [`WIDTH-1:0] oParents_Brother_Address,               //*
        //output reg [`WIDTH-1:0]               oNode_FirstChild_Address,
        //output reg [`WIDTH-1:0]               oNode_FirstChild_Address,
 
 
        output reg                                              oNodeReadDone,
        output reg                                              oNodeReadDone,
        output reg                                              oRAMWriteEnable,
        output reg                                              oRAMWriteEnable,
 
 
        output  reg [`DATA_ADDRESS_WIDTH-1:0] oRAMWriteAddress
        output  reg [`DATA_ADDRESS_WIDTH-1:0] oRAMWriteAddress
);
);
 
 
reg [4:0]                        CurrentState;
reg [4:0]                        CurrentState;
reg [4:0]                        NextState;
reg [4:0]                        NextState;
 
 
 
 
assign oAddressWBM = iInitialAddress;
assign oAddressWBM = iInitialAddress;
 
 
reg rFFEnNumVertices;
reg rFFEnNumVertices;
 
 
//Flip Flop D
//Flip Flop D
//FFD_SYNCH_RST_GENERIC FFD32_TNF
//FFD_SYNCH_RST_GENERIC FFD32_TNF
FFD_POSEDGE_SYNCRONOUS_RESET # (`WIDTH) FFD32_TNF
FFD_POSEDGE_SYNCRONOUS_RESET # (`WIDTH) FFD32_TNF
(
(
        .Clock(         Clock ),
        .Clock(         Clock ),
        .Reset(         Reset ),
        .Reset(         Reset ),
        .Enable( rFFEnNumVertices ),
        .Enable( rFFEnNumVertices ),
        .D( iData ),
        .D( iData ),
        .Q( oNode_TriangleCount )
        .Q( oNode_TriangleCount )
 
 
);
);
 
 
 
 
reg rFFEnBrotherAddress;
reg rFFEnBrotherAddress;
//Flip Flop D
//Flip Flop D
FFD_POSEDGE_SYNCRONOUS_RESET # (`WIDTH) FFD32_TNF_NC
FFD_POSEDGE_SYNCRONOUS_RESET # (`WIDTH) FFD32_TNF_NC
//FFD_SYNCH_RST_GENERIC FFD32_TNF_NC
//FFD_SYNCH_RST_GENERIC FFD32_TNF_NC
(
(
        .Clock(         Clock ),
        .Clock(         Clock ),
        .Reset(         Reset ),
        .Reset(         Reset ),
        .Enable( rFFEnBrotherAddress ),
        .Enable( rFFEnBrotherAddress ),
        .D( iData ),
        .D( iData ),
        .Q( oNode_Brother_Address )
        .Q( oNode_Brother_Address )
 
 
);
);
 
 
reg rFFEnParentsBroAddr;
reg rFFEnParentsBroAddr;
//Flip Flop D
//Flip Flop D
FFD_POSEDGE_SYNCRONOUS_RESET  # (`WIDTH) FFD32_TNF_NC2
FFD_POSEDGE_SYNCRONOUS_RESET  # (`WIDTH) FFD32_TNF_NC2
//FFD_SYNCH_RST_GENERIC FFD32_TNF_NC2
//FFD_SYNCH_RST_GENERIC FFD32_TNF_NC2
(
(
        .Clock(         Clock ),
        .Clock(         Clock ),
        .Reset(         Reset ),
        .Reset(         Reset ),
        .Enable( rFFEnParentsBroAddr ),
        .Enable( rFFEnParentsBroAddr ),
        .D( iData ),
        .D( iData ),
        .Q( oParents_Brother_Address )
        .Q( oParents_Brother_Address )
 
 
);
);
 
 
 
 
reg rFFEnDataOffset;
reg rFFEnDataOffset;
//Flip Flop D
//Flip Flop D
FFD_POSEDGE_SYNCRONOUS_RESET  # (`WIDTH) FFD32_TNF2
FFD_POSEDGE_SYNCRONOUS_RESET  # (`WIDTH) FFD32_TNF2
//FFD_SYNCH_RST_GENERIC FFD32_TNF2
//FFD_SYNCH_RST_GENERIC FFD32_TNF2
(
(
        .Clock(         Clock ),
        .Clock(         Clock ),
        .Reset(         Reset ),
        .Reset(         Reset ),
        .Enable( rFFEnDataOffset ),
        .Enable( rFFEnDataOffset ),
        .D( iData ),
        .D( iData ),
        .Q( oNode_DataOffset )
        .Q( oNode_DataOffset )
 
 
);
);
 
 
 
 
assign oNode_IsLeaf = (oNode_TriangleCount != 32'h0);
assign oNode_IsLeaf = (oNode_TriangleCount != 32'h0);
 
 
//------------------------------------------------
//------------------------------------------------
  always @(posedge Clock or posedge Reset)
  always @(posedge Clock or posedge Reset)
  begin
  begin
 
 
    if (Reset)
    if (Reset)
                CurrentState <= `TNF_AFTER_RESET;
                CurrentState <= `TNF_AFTER_RESET;
    else
    else
                CurrentState <= NextState;
                CurrentState <= NextState;
 
 
  end
  end
 
 
//------------------------------------
//------------------------------------
/*
/*
        IDLE State just waiting for something
        IDLE State just waiting for something
        to do...
        to do...
*/
*/
 
 
always @( * )
always @( * )
   begin
   begin
   case (CurrentState)
   case (CurrentState)
        //------------------------------------
        //------------------------------------
        `TNF_AFTER_RESET:
        `TNF_AFTER_RESET:
        begin
        begin
 
 
                oRAMWriteAddress        <= 0;
                oRAMWriteAddress        <= 0;
                oEnableWBM      <= 0;
                oEnableWBM      <= 0;
                oSetAddressWBM          <= 0;
                oSetAddressWBM          <= 0;
                oNodeReadDone           <= 0;
                oNodeReadDone           <= 0;
                oRAMWriteEnable <= 0;
                oRAMWriteEnable <= 0;
                rFFEnNumVertices        <= 0;
                rFFEnNumVertices        <= 0;
                rFFEnDataOffset <= 0;
                rFFEnDataOffset <= 0;
                rFFEnBrotherAddress     <= 0;
                rFFEnBrotherAddress     <= 0;
                rFFEnParentsBroAddr     <=      0;
                rFFEnParentsBroAddr     <=      0;
 
 
                NextState <= `TNF_IDLE;
                NextState <= `TNF_IDLE;
        end
        end
        //------------------------------------
        //------------------------------------
        `TNF_IDLE:
        `TNF_IDLE:
        begin
        begin
                oRAMWriteAddress        <= 0;
                oRAMWriteAddress        <= 0;
                oEnableWBM      <= 0;
                oEnableWBM      <= 0;
                oSetAddressWBM          <= 0;
                oSetAddressWBM          <= 0;
                oNodeReadDone           <= 0;
                oNodeReadDone           <= 0;
                oRAMWriteEnable <= 0;
                oRAMWriteEnable <= 0;
                rFFEnNumVertices        <= 0;
                rFFEnNumVertices        <= 0;
                rFFEnDataOffset <= 0;
                rFFEnDataOffset <= 0;
                rFFEnBrotherAddress     <= 0;
                rFFEnBrotherAddress     <= 0;
                rFFEnParentsBroAddr     <=      0;
                rFFEnParentsBroAddr     <=      0;
 
 
           if (iTrigger)
           if (iTrigger)
                        NextState <= `TNF_REQUEST_AABBMIN;
                        NextState <= `TNF_REQUEST_AABBMIN;
                else
                else
                        NextState <= `TNF_IDLE;
                        NextState <= `TNF_IDLE;
 
 
        end
        end
        //------------------------------------
        //------------------------------------
        /*
        /*
        Here tell WBM to read from address iInitialAddress by seeting
        Here tell WBM to read from address iInitialAddress by seeting
        oSetAddressWBM = 1.
        oSetAddressWBM = 1.
        By setting oRAMWriteEnable = 1, we are also telling WBM to
        By setting oRAMWriteEnable = 1, we are also telling WBM to
        store the the value in iInitialAddress, iInitialAddress+1,
        store the the value in iInitialAddress, iInitialAddress+1,
        and iInitialAddress+2 into RAM, so the WBMAddress is going
        and iInitialAddress+2 into RAM, so the WBMAddress is going
        to increment by 3.
        to increment by 3.
        */
        */
        `TNF_REQUEST_AABBMIN:
        `TNF_REQUEST_AABBMIN:
        begin
        begin
                oRAMWriteAddress        <= `CREG_AABBMIN;
                oRAMWriteAddress        <= `CREG_AABBMIN;
                oEnableWBM      <= 1; //*
                oEnableWBM      <= 1; //*
                oSetAddressWBM          <= 1; //*
                oSetAddressWBM          <= 1; //*
                oNodeReadDone           <= 0;
                oNodeReadDone           <= 0;
                rFFEnNumVertices        <= 0;
                rFFEnNumVertices        <= 0;
                rFFEnDataOffset <= 0;
                rFFEnDataOffset <= 0;
                oRAMWriteEnable         <= 1; //*
                oRAMWriteEnable         <= 1; //*
                rFFEnBrotherAddress     <= 0;
                rFFEnBrotherAddress     <= 0;
                rFFEnParentsBroAddr     <=      0;
                rFFEnParentsBroAddr     <=      0;
 
 
                NextState <= `TNF_WAIT_FOR_AABBMIN;
                NextState <= `TNF_WAIT_FOR_AABBMIN;
 
 
        end
        end
        //------------------------------------
        //------------------------------------
        `TNF_WAIT_FOR_AABBMIN:
        `TNF_WAIT_FOR_AABBMIN:
        begin
        begin
                oRAMWriteAddress        <= `CREG_AABBMIN;
                oRAMWriteAddress        <= `CREG_AABBMIN;
                oEnableWBM      <= 1;
                oEnableWBM      <= 1;
                oSetAddressWBM          <= 0;
                oSetAddressWBM          <= 0;
                oNodeReadDone           <= 0;
                oNodeReadDone           <= 0;
                rFFEnNumVertices        <= 0;
                rFFEnNumVertices        <= 0;
                rFFEnDataOffset <= 0;
                rFFEnDataOffset <= 0;
                oRAMWriteEnable         <= 1;//*
                oRAMWriteEnable         <= 1;//*
                rFFEnBrotherAddress     <= 0;
                rFFEnBrotherAddress     <= 0;
                rFFEnParentsBroAddr     <=      0;
                rFFEnParentsBroAddr     <=      0;
 
 
                if ( iDataAvailable )
                if ( iDataAvailable )
                        NextState <= `TNF_REQUEST_AABBMAX;
                        NextState <= `TNF_REQUEST_AABBMAX;
                else
                else
                        NextState <= `TNF_WAIT_FOR_AABBMIN;
                        NextState <= `TNF_WAIT_FOR_AABBMIN;
        end
        end
        //------------------------------------
        //------------------------------------
        `TNF_REQUEST_AABBMAX:
        `TNF_REQUEST_AABBMAX:
        begin
        begin
                oRAMWriteAddress        <= `CREG_AABBMAX;
                oRAMWriteAddress        <= `CREG_AABBMAX;
                oEnableWBM      <= 1;
                oEnableWBM      <= 1;
                oSetAddressWBM          <= 0;
                oSetAddressWBM          <= 0;
                oNodeReadDone           <= 0;
                oNodeReadDone           <= 0;
                rFFEnNumVertices        <= 0;
                rFFEnNumVertices        <= 0;
                rFFEnDataOffset <= 0;
                rFFEnDataOffset <= 0;
                oRAMWriteEnable         <= 1;//*
                oRAMWriteEnable         <= 1;//*
                rFFEnBrotherAddress     <= 0;
                rFFEnBrotherAddress     <= 0;
                rFFEnParentsBroAddr     <=      0;
                rFFEnParentsBroAddr     <=      0;
 
 
                NextState <= `TNF_WAIT_FOR_AABBMAX;
                NextState <= `TNF_WAIT_FOR_AABBMAX;
        end
        end
        //------------------------------------
        //------------------------------------
        `TNF_WAIT_FOR_AABBMAX:
        `TNF_WAIT_FOR_AABBMAX:
        begin
        begin
                oRAMWriteAddress        <= `CREG_AABBMAX;
                oRAMWriteAddress        <= `CREG_AABBMAX;
                oEnableWBM      <= 1;
                oEnableWBM      <= 1;
                oSetAddressWBM          <= 0;
                oSetAddressWBM          <= 0;
                oNodeReadDone           <= 0;
                oNodeReadDone           <= 0;
                rFFEnNumVertices        <= 0;
                rFFEnNumVertices        <= 0;
                rFFEnDataOffset <= 0;
                rFFEnDataOffset <= 0;
                oRAMWriteEnable         <= 1;//*
                oRAMWriteEnable         <= 1;//*
                rFFEnBrotherAddress     <= 0;
                rFFEnBrotherAddress     <= 0;
                rFFEnParentsBroAddr     <=      0;
                rFFEnParentsBroAddr     <=      0;
 
 
                if ( iDataAvailable )
                if ( iDataAvailable )
                        NextState <= `TNF_REQUEST_NUMBER_OF_TRIANGLES;
                        NextState <= `TNF_REQUEST_NUMBER_OF_TRIANGLES;
                else
                else
                        NextState <= `TNF_WAIT_FOR_AABBMAX;
                        NextState <= `TNF_WAIT_FOR_AABBMAX;
        end
        end
        //------------------------------------
        //------------------------------------
        `TNF_REQUEST_NUMBER_OF_TRIANGLES:
        `TNF_REQUEST_NUMBER_OF_TRIANGLES:
        begin
        begin
                oRAMWriteAddress        <= `CREG_AABBMAX;
                oRAMWriteAddress        <= `CREG_AABBMAX;
                oEnableWBM      <= 1; //*
                oEnableWBM      <= 1; //*
                oSetAddressWBM          <= 0;
                oSetAddressWBM          <= 0;
                oNodeReadDone           <= 0;
                oNodeReadDone           <= 0;
                rFFEnNumVertices        <= 0;
                rFFEnNumVertices        <= 0;
                rFFEnDataOffset <= 0;
                rFFEnDataOffset <= 0;
                oRAMWriteEnable         <= 0; //* to give more time to write
                oRAMWriteEnable         <= 0; //* to give more time to write
                rFFEnBrotherAddress     <= 0;
                rFFEnBrotherAddress     <= 0;
                rFFEnParentsBroAddr     <=      0;
                rFFEnParentsBroAddr     <=      0;
 
 
                NextState <= `TNF_WAIT_FOR_NUMBER_OF_TRIANGLES;
                NextState <= `TNF_WAIT_FOR_NUMBER_OF_TRIANGLES;
        end
        end
        //------------------------------------
        //------------------------------------
        `TNF_WAIT_FOR_NUMBER_OF_TRIANGLES:
        `TNF_WAIT_FOR_NUMBER_OF_TRIANGLES:
        begin
        begin
                oRAMWriteAddress        <= 0;
                oRAMWriteAddress        <= 0;
                oEnableWBM      <= 1;
                oEnableWBM      <= 1;
                oSetAddressWBM          <= 0;
                oSetAddressWBM          <= 0;
                oNodeReadDone           <= 0;
                oNodeReadDone           <= 0;
                rFFEnNumVertices        <= 0;
                rFFEnNumVertices        <= 0;
                rFFEnDataOffset <= 0;
                rFFEnDataOffset <= 0;
                rFFEnBrotherAddress     <= 0;
                rFFEnBrotherAddress     <= 0;
                rFFEnParentsBroAddr     <=      0;
                rFFEnParentsBroAddr     <=      0;
                oRAMWriteEnable    <= 0;
                oRAMWriteEnable    <= 0;
 
 
                if ( iDataAvailable )
                if ( iDataAvailable )
                        NextState <= `TNF_LATCH_NUMBER_OF_TRIANGLES;
                        NextState <= `TNF_LATCH_NUMBER_OF_TRIANGLES;
                else
                else
                        NextState <= `TNF_WAIT_FOR_NUMBER_OF_TRIANGLES;
                        NextState <= `TNF_WAIT_FOR_NUMBER_OF_TRIANGLES;
 
 
        end
        end
        //------------------------------------
        //------------------------------------
        `TNF_LATCH_NUMBER_OF_TRIANGLES:
        `TNF_LATCH_NUMBER_OF_TRIANGLES:
        begin
        begin
 
 
                oRAMWriteAddress        <= 0;
                oRAMWriteAddress        <= 0;
                oEnableWBM      <= 0;
                oEnableWBM      <= 0;
                oSetAddressWBM          <= 0;
                oSetAddressWBM          <= 0;
                oNodeReadDone           <= 0;    //* 
                oNodeReadDone           <= 0;    //* 
                rFFEnNumVertices        <= 1;
                rFFEnNumVertices        <= 1;
                rFFEnDataOffset <= 0;
                rFFEnDataOffset <= 0;
                rFFEnBrotherAddress     <= 0;
                rFFEnBrotherAddress     <= 0;
                rFFEnParentsBroAddr     <=      0;
                rFFEnParentsBroAddr     <=      0;
                oRAMWriteEnable         <= 0;
                oRAMWriteEnable         <= 0;
 
 
                NextState <= `TNF_REQUEST_DATA_OFFSET;
                NextState <= `TNF_REQUEST_DATA_OFFSET;
        end
        end
        //------------------------------------
        //------------------------------------
        `TNF_REQUEST_DATA_OFFSET:
        `TNF_REQUEST_DATA_OFFSET:
        begin
        begin
                oRAMWriteAddress        <= 0;
                oRAMWriteAddress        <= 0;
                oEnableWBM      <= 1; //*
                oEnableWBM      <= 1; //*
                oSetAddressWBM          <= 0;
                oSetAddressWBM          <= 0;
                oNodeReadDone           <= 0;
                oNodeReadDone           <= 0;
                rFFEnNumVertices        <= 0;
                rFFEnNumVertices        <= 0;
                rFFEnDataOffset <= 0;
                rFFEnDataOffset <= 0;
                oRAMWriteEnable         <= 0;
                oRAMWriteEnable         <= 0;
                rFFEnBrotherAddress     <= 0;
                rFFEnBrotherAddress     <= 0;
                rFFEnParentsBroAddr     <=      0;
                rFFEnParentsBroAddr     <=      0;
 
 
                NextState <= `TNF_WAIT_FOR_DATA_OFFSET;
                NextState <= `TNF_WAIT_FOR_DATA_OFFSET;
        end
        end
        //------------------------------------
        //------------------------------------
        `TNF_WAIT_FOR_DATA_OFFSET:
        `TNF_WAIT_FOR_DATA_OFFSET:
        begin
        begin
                oRAMWriteAddress        <= 0;
                oRAMWriteAddress        <= 0;
                oEnableWBM      <= 1; //* 
                oEnableWBM      <= 1; //* 
                oSetAddressWBM          <= 0;
                oSetAddressWBM          <= 0;
                oNodeReadDone           <= 0;
                oNodeReadDone           <= 0;
                rFFEnNumVertices        <= 0;
                rFFEnNumVertices        <= 0;
                rFFEnDataOffset <= 0;
                rFFEnDataOffset <= 0;
                oRAMWriteEnable         <= 0;
                oRAMWriteEnable         <= 0;
                rFFEnBrotherAddress     <= 0;
                rFFEnBrotherAddress     <= 0;
                rFFEnParentsBroAddr     <=      0;
                rFFEnParentsBroAddr     <=      0;
 
 
                if ( iDataAvailable )
                if ( iDataAvailable )
                        NextState <= `TNF_LATCH_DATA_OFFSET;
                        NextState <= `TNF_LATCH_DATA_OFFSET;
                else
                else
                        NextState <= `TNF_WAIT_FOR_DATA_OFFSET;
                        NextState <= `TNF_WAIT_FOR_DATA_OFFSET;
 
 
        end
        end
        //------------------------------------
        //------------------------------------
        `TNF_LATCH_DATA_OFFSET:
        `TNF_LATCH_DATA_OFFSET:
        begin
        begin
                oRAMWriteAddress        <= 0;
                oRAMWriteAddress        <= 0;
                oEnableWBM      <= 0;
                oEnableWBM      <= 0;
                oSetAddressWBM          <= 0;
                oSetAddressWBM          <= 0;
                oNodeReadDone           <= 0;
                oNodeReadDone           <= 0;
                rFFEnNumVertices        <= 0;
                rFFEnNumVertices        <= 0;
                rFFEnDataOffset <= 1; //*
                rFFEnDataOffset <= 1; //*
                oRAMWriteEnable         <= 0;
                oRAMWriteEnable         <= 0;
                rFFEnBrotherAddress     <= 0;
                rFFEnBrotherAddress     <= 0;
                rFFEnParentsBroAddr     <=      0;
                rFFEnParentsBroAddr     <=      0;
 
 
                NextState <= `TNF_REQUEST_NODE_BROTHER_ADDRESS;
                NextState <= `TNF_REQUEST_NODE_BROTHER_ADDRESS;
        end
        end
        //------------------------------------
        //------------------------------------
        `TNF_REQUEST_NODE_BROTHER_ADDRESS:
        `TNF_REQUEST_NODE_BROTHER_ADDRESS:
        begin
        begin
                oRAMWriteAddress        <= 0;
                oRAMWriteAddress        <= 0;
                oEnableWBM      <= 1;   //*
                oEnableWBM      <= 1;   //*
                oSetAddressWBM          <= 0;
                oSetAddressWBM          <= 0;
                oNodeReadDone           <= 0;
                oNodeReadDone           <= 0;
                rFFEnNumVertices        <= 0;
                rFFEnNumVertices        <= 0;
                rFFEnDataOffset <= 1;
                rFFEnDataOffset <= 1;
                oRAMWriteEnable         <= 0;
                oRAMWriteEnable         <= 0;
                rFFEnBrotherAddress     <= 0;
                rFFEnBrotherAddress     <= 0;
                rFFEnParentsBroAddr     <=      0;
                rFFEnParentsBroAddr     <=      0;
 
 
                NextState <= `TNF_WAIT_FOR_NODE_BROTHER_ADDRESS;
                NextState <= `TNF_WAIT_FOR_NODE_BROTHER_ADDRESS;
        end
        end
        //------------------------------------
        //------------------------------------
        `TNF_WAIT_FOR_NODE_BROTHER_ADDRESS:
        `TNF_WAIT_FOR_NODE_BROTHER_ADDRESS:
        begin
        begin
                oRAMWriteAddress        <= 0;
                oRAMWriteAddress        <= 0;
                oEnableWBM      <= 1;   //*
                oEnableWBM      <= 1;   //*
                oSetAddressWBM          <= 0;
                oSetAddressWBM          <= 0;
                oNodeReadDone           <= 0;
                oNodeReadDone           <= 0;
                rFFEnNumVertices        <= 0;
                rFFEnNumVertices        <= 0;
                rFFEnDataOffset <= 0;
                rFFEnDataOffset <= 0;
                oRAMWriteEnable         <= 0;
                oRAMWriteEnable         <= 0;
                rFFEnBrotherAddress     <= 0;
                rFFEnBrotherAddress     <= 0;
                rFFEnParentsBroAddr     <=      0;
                rFFEnParentsBroAddr     <=      0;
 
 
                if ( iDataAvailable )
                if ( iDataAvailable )
                        NextState <= `TNF_LACTH_NODE_BROTHER_ADDRESS;
                        NextState <= `TNF_LACTH_NODE_BROTHER_ADDRESS;
                else
                else
                        NextState <= `TNF_WAIT_FOR_NODE_BROTHER_ADDRESS;
                        NextState <= `TNF_WAIT_FOR_NODE_BROTHER_ADDRESS;
        end
        end
        //------------------------------------
        //------------------------------------
        `TNF_LACTH_NODE_BROTHER_ADDRESS:
        `TNF_LACTH_NODE_BROTHER_ADDRESS:
        begin
        begin
                oRAMWriteAddress        <= 0;
                oRAMWriteAddress        <= 0;
                oEnableWBM      <= 0;
                oEnableWBM      <= 0;
                oSetAddressWBM          <= 0;
                oSetAddressWBM          <= 0;
                oNodeReadDone           <= 0;
                oNodeReadDone           <= 0;
                rFFEnNumVertices        <= 0;
                rFFEnNumVertices        <= 0;
                rFFEnDataOffset <= 0;
                rFFEnDataOffset <= 0;
                oRAMWriteEnable         <= 0;
                oRAMWriteEnable         <= 0;
                rFFEnBrotherAddress     <= 1;   //*
                rFFEnBrotherAddress     <= 1;   //*
                rFFEnParentsBroAddr     <=      0;
                rFFEnParentsBroAddr     <=      0;
 
 
                NextState <= `TNF_REQUEST_NODE_PARENT_BROTHER_ADDRESS;
                NextState <= `TNF_REQUEST_NODE_PARENT_BROTHER_ADDRESS;
        end
        end
        //------------------------------------
        //------------------------------------
        `TNF_REQUEST_NODE_PARENT_BROTHER_ADDRESS:
        `TNF_REQUEST_NODE_PARENT_BROTHER_ADDRESS:
        begin
        begin
                oRAMWriteAddress        <= 0;
                oRAMWriteAddress        <= 0;
                oEnableWBM      <= 1;   //*
                oEnableWBM      <= 1;   //*
                oSetAddressWBM          <= 0;
                oSetAddressWBM          <= 0;
                oNodeReadDone           <= 0;
                oNodeReadDone           <= 0;
                rFFEnNumVertices        <= 0;
                rFFEnNumVertices        <= 0;
                rFFEnDataOffset <= 0;
                rFFEnDataOffset <= 0;
                oRAMWriteEnable         <= 0;
                oRAMWriteEnable         <= 0;
                rFFEnBrotherAddress     <= 0;
                rFFEnBrotherAddress     <= 0;
                rFFEnParentsBroAddr     <=      0;
                rFFEnParentsBroAddr     <=      0;
                //rLastAddress                                          <= 1;
                //rLastAddress                                          <= 1;
 
 
                NextState <= `TNF_WAIT_NODE_PARENT_BROTHER_ADDRESS;
                NextState <= `TNF_WAIT_NODE_PARENT_BROTHER_ADDRESS;
        end
        end
        //------------------------------------
        //------------------------------------
        `TNF_WAIT_NODE_PARENT_BROTHER_ADDRESS:
        `TNF_WAIT_NODE_PARENT_BROTHER_ADDRESS:
        begin
        begin
                oRAMWriteAddress        <= 0;
                oRAMWriteAddress        <= 0;
                oEnableWBM      <= 1;
                oEnableWBM      <= 1;
                oSetAddressWBM          <= 0;
                oSetAddressWBM          <= 0;
                oNodeReadDone           <= 0;
                oNodeReadDone           <= 0;
                rFFEnNumVertices        <= 0;
                rFFEnNumVertices        <= 0;
                rFFEnDataOffset <= 0;
                rFFEnDataOffset <= 0;
                oRAMWriteEnable         <= 0;
                oRAMWriteEnable         <= 0;
                rFFEnBrotherAddress     <= 0;
                rFFEnBrotherAddress     <= 0;
                rFFEnParentsBroAddr     <=      0;
                rFFEnParentsBroAddr     <=      0;
 
 
                if ( iDataAvailable )
                if ( iDataAvailable )
                        NextState <= `TNF_LATCH_NODE_PARENT_BROTHER_ADDRESS;
                        NextState <= `TNF_LATCH_NODE_PARENT_BROTHER_ADDRESS;
                else
                else
                        NextState <= `TNF_WAIT_NODE_PARENT_BROTHER_ADDRESS;
                        NextState <= `TNF_WAIT_NODE_PARENT_BROTHER_ADDRESS;
        end
        end
        //------------------------------------
        //------------------------------------
        `TNF_LATCH_NODE_PARENT_BROTHER_ADDRESS:
        `TNF_LATCH_NODE_PARENT_BROTHER_ADDRESS:
        begin
        begin
                oRAMWriteAddress        <= 0;
                oRAMWriteAddress        <= 0;
                oEnableWBM      <= 0;
                oEnableWBM      <= 0;
                oSetAddressWBM          <= 0;
                oSetAddressWBM          <= 0;
                oNodeReadDone           <= 0;
                oNodeReadDone           <= 0;
                rFFEnNumVertices        <= 0;
                rFFEnNumVertices        <= 0;
                rFFEnDataOffset <= 0;
                rFFEnDataOffset <= 0;
                oRAMWriteEnable         <= 0;
                oRAMWriteEnable         <= 0;
                rFFEnBrotherAddress     <= 0;
                rFFEnBrotherAddress     <= 0;
                rFFEnParentsBroAddr     <=      1;
                rFFEnParentsBroAddr     <=      1;
 
 
                NextState <= `TNF_WAIT_NODE_READ_ACK;
                NextState <= `TNF_WAIT_NODE_READ_ACK;
 
 
        end
        end
        //------------------------------------
        //------------------------------------
        `TNF_WAIT_NODE_READ_ACK:
        `TNF_WAIT_NODE_READ_ACK:
        begin
        begin
 
 
                oRAMWriteAddress        <= 0;
                oRAMWriteAddress        <= 0;
                oEnableWBM      <= 0;
                oEnableWBM      <= 0;
                oSetAddressWBM          <= 0;
                oSetAddressWBM          <= 0;
                oNodeReadDone           <= 1;   //*
                oNodeReadDone           <= 1;   //*
                rFFEnNumVertices        <= 0;
                rFFEnNumVertices        <= 0;
                rFFEnDataOffset <= 0;
                rFFEnDataOffset <= 0;
                oRAMWriteEnable         <= 0;
                oRAMWriteEnable         <= 0;
                rFFEnBrotherAddress     <= 0;
                rFFEnBrotherAddress     <= 0;
                rFFEnParentsBroAddr     <=      0;
                rFFEnParentsBroAddr     <=      0;
 
 
                if (    iTrigger == 0 )
                if (    iTrigger == 0 )
                        NextState <= `TNF_IDLE;
                        NextState <= `TNF_IDLE;
                else
                else
                        NextState <= `TNF_WAIT_NODE_READ_ACK;
                        NextState <= `TNF_WAIT_NODE_READ_ACK;
        end
        end
        //------------------------------------
        //------------------------------------
        default:
        default:
        begin
        begin
                oRAMWriteAddress        <= 0;
                oRAMWriteAddress        <= 0;
                oEnableWBM      <= 0;
                oEnableWBM      <= 0;
                oSetAddressWBM          <= 0;
                oSetAddressWBM          <= 0;
                oNodeReadDone           <= 0;
                oNodeReadDone           <= 0;
                rFFEnNumVertices        <= 0;
                rFFEnNumVertices        <= 0;
                rFFEnDataOffset <= 0;
                rFFEnDataOffset <= 0;
                oRAMWriteEnable         <= 0;
                oRAMWriteEnable         <= 0;
                rFFEnBrotherAddress     <= 0;
                rFFEnBrotherAddress     <= 0;
                rFFEnParentsBroAddr     <=      0;
                rFFEnParentsBroAddr     <=      0;
 
 
                NextState <= `TNF_IDLE;
                NextState <= `TNF_IDLE;
        end
        end
        //------------------------------------
        //------------------------------------
        endcase
        endcase
end //always    
end //always    
endmodule
endmodule
 
 

powered by: WebSVN 2.1.0

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