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

Subversion Repositories theia_gpu

[/] [theia_gpu/] [branches/] [beta_1.2/] [rtl/] [IO/] [Module_WBM2MEM.v] - Blame information for rev 116

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 34 diegovalve
 
2
`timescale 1ns / 1ps
3
`include "aDefinitions.v"
4
/**********************************************************************************
5
Theia, Ray Cast Programable graphic Processing Unit.
6
Copyright (C) 2010  Diego Valverde (diego.valverde.g@gmail.com)
7
 
8
This program is free software; you can redistribute it and/or
9
modify it under the terms of the GNU General Public License
10
as published by the Free Software Foundation; either version 2
11
of the License, or (at your option) any later version.
12
 
13
This program is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
GNU General Public License for more details.
17
 
18
You should have received a copy of the GNU General Public License
19
along with this program; if not, write to the Free Software
20
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21
 
22
***********************************************************************************/
23
/**
24
        The Wish Bone bus has a 32 bit words.
25
        However our internal bus is 96 bits (32 * 3) bits wide
26
        for Data or 64 bits wide for Instructions (Hardvard Architecture).
27
        If the iStore signal is one, WBM2MEMUnit provides a means to
28
        store 2 or 3 incomming 32 bits frames into temporary Flip-Flops,
29
        and then store the 96 or 64 bit value into a specified location
30
        in the internal Instruction or Data Memory.
31
        If the iStore signal is zero, WBMinputFifo passes the
32
        32 bit value comming from the WB bus, directly through the oData
33
        pin without storing it.
34
*/
35
 
36
module WBM2MEMUnit
37
(
38
        input wire                                                                      Clock,
39
        input wire                                                                      Reset,
40
        input wire                                                                      iEnable,
41
        input   wire                                                                    iStore,
42
        input   wire[`DATA_ADDRESS_WIDTH-1:0]    iAdr_DataWriteBack,
43
        input   wire                                                                    iWBMDataAvailable,
44
        input wire                          iWriteBack_Set,
45
        //input wire[`WIDTH-1:0]                                        iWBMInitialAddress,
46
        //input wire                                                                    iSetWBMInitialAddress,
47
        input wire [`WIDTH-1:0]                                  iWBMData,                 //Comes from WBM
48
        output wire[`WIDTH-1:0]                                  oData,                 //Goes back to geo
49
        output wire                                                                     oEnableWBM,
50
        //output wire[`WIDTH-1:0]                                       oAddressWBM,
51
        output wire[`DATA_ADDRESS_WIDTH-1:0] oDataWriteAddress,
52
        inout wire [`DATA_ROW_WIDTH-1:0]         oDataBus,
53
        output wire                                                                     oDataWriteEnable,
54
        output wire                                                             oDone
55
);
56
wire [`WIDTH-1:0] wVx;
57
wire [`WIDTH-1:0] wVy;
58
wire [`WIDTH-1:0] wVz;
59
wire wDelayAfterWriteEnable;
60
 
61
//assign oDataWriteAddress = iAdr_DataWriteBack;
62
 
63
wire CounterClock;
64
assign CounterClock = wDelayAfterWriteEnable | iWriteBack_Set;
65
 
66
UPCOUNTER_POSEDGE # (`DATA_ADDRESS_WIDTH) UP1
67
(
68
        .Clock(Clock),
69
        .Reset(iWriteBack_Set | Reset ),
70
        .Enable(CounterClock),
71
        .Initial(iAdr_DataWriteBack),
72
        .Q(oDataWriteAddress)
73
);
74
 
75
 
76
wire[3:0] wSelXYZ;
77
//Every time WBM says is done, then shift the bit
78
//one position
79
 
80
CIRCULAR_SHIFTLEFT_POSEDGE # (4) SHL_A
81
(
82
 .Clock( Clock ),
83
 .Enable(iWBMDataAvailable),
84
 .Reset(~iEnable | Reset ),
85
 .Initial(4'b1),
86
 .O(wSelXYZ)
87
 
88
);
89
 
90
 
91
FFD_POSEDGE_SYNCRONOUS_RESET # (`WIDTH) FFD32_WBMFIFO_Vx
92
(
93
        .Clock(         Clock ),
94
        .Reset(         ~iEnable | Reset ),
95
        .Enable( wSelXYZ[0] & iWBMDataAvailable ),
96
        .D( iWBMData ),
97
        .Q( wVx )
98
 
99
);
100
 
101
//The data out is equal to the first vertex that has
102
//been captured
103
assign oData = wVx;
104
 
105
 
106
FFD_POSEDGE_SYNCRONOUS_RESET # (`WIDTH) FFD32_WBMFIFO_Vy
107
(
108
        .Clock(         Clock ),
109
        .Reset(         ~iEnable | Reset),
110
        .Enable( wSelXYZ[1] & iWBMDataAvailable ),
111
        .D( iWBMData ),
112
        .Q( wVy )
113
 
114
);
115
 
116
FFD_POSEDGE_SYNCRONOUS_RESET # (`WIDTH) FFD32_WBMFIFO_Vz
117
(
118
        .Clock(         Clock ),
119
        .Reset(         ~iEnable | Reset ),
120
        .Enable( wSelXYZ[2] & iWBMDataAvailable),
121
        .D( iWBMData ),
122
        .Q( wVz )
123
 
124
);
125
 
126
assign oDataBus = {wVx,wVy,wVz};
127
 
128
 
129
assign oDataWriteEnable = wSelXYZ[3];
130
assign oDone = (iStore) ? wSelXYZ[3] : wSelXYZ[1];
131
assign oEnableWBM =  ~oDone;
132
 
133 60 diegovalve
FFD_POSEDGE_SYNCRONOUS_RESET # (1) FFD32_WBMFIFO_V2
134 34 diegovalve
(
135
        .Clock(         Clock ),
136
        .Reset(          Reset ),
137
        .Enable( 1'b1 ),
138
        .D( wSelXYZ[3] ),
139
        .Q(wDelayAfterWriteEnable )
140
 
141
);
142
 
143
/*
144
always @ (posedge iWBMDataAvailable)
145
begin
146
        $display("%d Got something %h!",$time,iWBMData);
147
        $display("%d Got wSelXYZ %b!",$time,wSelXYZ);
148
end
149
*/
150
endmodule
151
 
152
//----------------------------------------------------

powered by: WebSVN 2.1.0

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