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] - Blame information for rev 127

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

Line No. Rev Author Line
1 32 diegovalve
`timescale 1ns / 1ps
2
`include "aDefinitions.v"
3
/**********************************************************************************
4
Theia, Ray Cast Programable graphic Processing Unit.
5
Copyright (C) 2010  Diego Valverde (diego.valverde.g@gmail.com)
6
 
7
This program is free software; you can redistribute it and/or
8
modify it under the terms of the GNU General Public License
9
as published by the Free Software Foundation; either version 2
10
of the License, or (at your option) any later version.
11
 
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
GNU General Public License for more details.
16
 
17
You should have received a copy of the GNU General Public License
18
along with this program; if not, write to the Free Software
19
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20
 
21
***********************************************************************************/
22
/*
23
        In order to read the geometry, we will behave as a master.
24
        Performing single Reads Bus cycles should be sufficient.
25
        Choosing 32 bit for bus width for simplicity.
26
*/
27
 
28
module WishBoneMasterUnit
29
(
30
//WB Input signals
31
input wire                                                 CLK_I,
32
input wire                                                 RST_I,
33 76 diegovalve
input wire                                                 ACK_I,
34
input wire                    GNT_I, //granted signal from bus arbiter
35 32 diegovalve
input wire [`WB_WIDTH-1:0 ]      DAT_I,
36
output wire [`WB_WIDTH-1:0]   DAT_O,
37
 
38
 
39
//WB Output Signals
40
output wire [`WB_WIDTH-1:0 ] ADR_O,
41
output wire                                  WE_O,
42
output wire                                  STB_O,
43
output wire                                  CYC_O,
44
output wire [1:0]                             TGC_O,
45
 
46
//Signals from inside the GPU
47
input wire                                              iEnable,
48
input wire                 iBusCyc_Type,
49
input wire [`WIDTH-1:0 ]         iAddress,
50
input wire                 iAddress_Set,
51
output wire                                             oDataReady,
52
input wire  [`WIDTH-1:0 ]  iData,
53
output wire     [`WIDTH-1:0 ]  oData
54
 
55
 
56
);
57 76 diegovalve
wire wReadOperation;
58
wire wEnable;
59
assign wEnable = iEnable & GNT_I;
60
//If CYC_O is 1, it means we are requesting bus ownership
61
assign CYC_O = iEnable;
62
 
63 32 diegovalve
assign wReadOperation = (iBusCyc_Type == `WB_SIMPLE_READ_CYCLE) ? 1 : 0;
64 76 diegovalve
assign WE_O = (iBusCyc_Type == `WB_SIMPLE_WRITE_CYCLE && wEnable) ? 1 : 0;
65
 
66
 
67
wire wEnable_Delayed;
68
FFD_POSEDGE_SYNCRONOUS_RESET # ( 1 ) FFD88
69
(
70
        .Clock(CLK_I),
71
        .Reset(RST_I),
72
        .Enable(1'b1 ),
73
        .D(wEnable),
74
        .Q(wEnable_Delayed)
75
);
76 32 diegovalve
 
77 76 diegovalve
 
78
 
79
//We only start Strobbing 1 cycle after iEnable and only
80
//if iEnable is 1 and if GNT_I is 1 (meaning we own the bus)
81
assign STB_O = wEnable_Delayed & ~ACK_I & wEnable;
82 32 diegovalve
 
83
 
84 76 diegovalve
assign DAT_O = (wReadOperation | ~wEnable ) ? `WB_WIDTH'bz : iData;
85
 
86
wire [`WB_WIDTH-1:0 ] wReadADR_O,wWriteADR_O;
87
assign ADR_O = ( wReadOperation ) ? wReadADR_O : wWriteADR_O;
88 32 diegovalve
 
89
//The ADR_O, it increments with each ACK_I, and it resets
90
//to the value iAddress everytime iAddress_Set is 1.
91 76 diegovalve
UPCOUNTER_POSEDGE # (`WIDTH) WBM_O_READ_ADDRESS
92 32 diegovalve
(
93
        .Clock(CLK_I),
94
        .Reset( iAddress_Set ),
95 76 diegovalve
        .Enable((ACK_I & GNT_I) | iAddress_Set),
96 32 diegovalve
        .Initial(iAddress),
97 76 diegovalve
        .Q(wReadADR_O)
98 32 diegovalve
);
99 76 diegovalve
wire wDelayWE;
100
FFD_POSEDGE_SYNCRONOUS_RESET # ( 1 ) FFD3
101
(
102
        .Clock(CLK_I),
103
        .Reset(RST_I),
104
        .Enable(1'b1),
105
        .D(WE_O),
106
        .Q(wDelayWE)
107
);
108 32 diegovalve
 
109 76 diegovalve
UPCOUNTER_POSEDGE # (`WIDTH) WBM_O_WRITE_ADDRESS
110
(
111
        .Clock(CLK_I),
112
        .Reset( iAddress_Set ),//RST_I ),
113
        .Enable( (wDelayWE & ACK_I ) | iAddress_Set),
114
        .Initial(iAddress),//`WIDTH'b0),
115
        .Q(wWriteADR_O)
116
);
117 32 diegovalve
 
118
FFD_POSEDGE_SYNCRONOUS_RESET # ( `WIDTH ) FFD1
119
(
120
        .Clock(ACK_I),
121 76 diegovalve
        .Reset(~wEnable),
122
        .Enable(wReadOperation ),
123 32 diegovalve
        .D(DAT_I),
124
        .Q(oData)
125
);
126
 
127
wire wDelayDataReady;
128
FFD_POSEDGE_SYNCRONOUS_RESET # ( 1 ) FFD2
129
(
130
        .Clock(CLK_I),
131 76 diegovalve
        .Reset(~wEnable),
132 32 diegovalve
        .Enable(wReadOperation),
133
        .D(ACK_I),
134
        .Q(wDelayDataReady)
135
);
136
/*
137
always @ (posedge wDelayDataReady)
138
begin
139
        $display("WBM Got data: %h ",oData);
140
        $display("oDataReady = %d",oDataReady );
141
end
142
*/
143
 
144 76 diegovalve
assign oDataReady = wDelayDataReady & wEnable;
145 32 diegovalve
 
146
endmodule
147
 

powered by: WebSVN 2.1.0

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