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

Subversion Repositories wf3d

[/] [wf3d/] [trunk/] [rtl/] [core/] [fm_3d_core.v] - Blame information for rev 9

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 specular
//=======================================================================
2
// Project Monophony
3
//   Wire-Frame 3D Graphics Accelerator IP Core
4
//
5
// File:
6
//   fm_3d_core.v
7
//
8
// Abstract:
9
//   IP Core top module
10
//
11
// Author:
12 9 specular
//   Kenji Ishimaru (info.info.wf3d@gmail.com)
13 2 specular
//
14
//======================================================================
15
//
16
// Copyright (c) 2015, Kenji Ishimaru
17
// All rights reserved.
18
//
19
// Redistribution and use in source and binary forms, with or without
20
// modification, are permitted provided that the following conditions are met:
21
//
22
//  -Redistributions of source code must retain the above copyright notice,
23
//   this list of conditions and the following disclaimer.
24
//  -Redistributions in binary form must reproduce the above copyright notice,
25
//   this list of conditions and the following disclaimer in the documentation
26
//   and/or other materials provided with the distribution.
27
//
28
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
29
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
30
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
31
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
32
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
33
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
34
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
35
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
36
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
37
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
38
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39
//
40
// Revision History
41
 
42
`include "fm_3d_define.v"
43
module fm_3d_core (
44
  // system
45
  input         clk_i,
46
  input         rst_i,  // sync reset
47
  output        int_o,
48
`ifdef D3D_WISHBONE
49
  // WishBone Slave
50
  input         s_wb_stb_i,
51
  input         s_wb_we_i,
52
  input  [7:2]  s_wb_adr_i,
53
  output        s_wb_ack_o,
54
  input  [3:0]  s_wb_sel_i,
55
  input  [31:0] s_wb_dat_i,
56
  output [31:0] s_wb_dat_o,
57
 
58
  // WishBone Master
59
  output        m_wb_stb_o,
60
  output        m_wb_we_o,
61
  output [31:2] m_wb_adr_o,
62
  input         m_wb_ack_i,
63
  output [3:0]  m_wb_sel_o,
64
  output [31:0] m_wb_dat_o,
65
  input  [31:0] m_wb_dat_i
66
`else
67
  // Slave I/F
68
  input         i_req_s,
69
  input         i_wr_s,
70
  input  [7:0]  i_adrs_s,
71
  output        o_ack_s,
72
  input  [3:0]  i_be_s,
73
  input  [31:0] i_dbw_s,
74
  output        o_strr_s,
75
  output [31:0] o_dbr_s,
76
  // Master I/F
77
  output        o_req_m,
78
  output        o_wr_m,
79
  output [31:0] o_adrs_m,
80
  output [2:0]  o_len_m,
81
  input         i_ack_m,
82
  output [3:0]  o_be_m,
83
  output [31:0] o_dbw_m,
84
  input         i_strr_m,
85
  input  [31:0] i_dbr_m
86
`endif
87
);
88
 
89
//////////////////////////////////
90
// wire
91
//////////////////////////////////
92
 `ifdef D3D_USE_MATRIX_PALETTE
93
 wire [1:0] w_num_mats;
94
 wire [22*`D3D_NUM_OF_MATS-1:0] w_m00;
95
 wire [22*`D3D_NUM_OF_MATS-1:0] w_m01;
96
 wire [22*`D3D_NUM_OF_MATS-1:0] w_m02;
97
 wire [22*`D3D_NUM_OF_MATS-1:0] w_m03;
98
 wire [22*`D3D_NUM_OF_MATS-1:0] w_m10;
99
 wire [22*`D3D_NUM_OF_MATS-1:0] w_m11;
100
 wire [22*`D3D_NUM_OF_MATS-1:0] w_m12;
101
 wire [22*`D3D_NUM_OF_MATS-1:0] w_m13;
102
 wire [22*`D3D_NUM_OF_MATS-1:0] w_m20;
103
 wire [22*`D3D_NUM_OF_MATS-1:0] w_m21;
104
 wire [22*`D3D_NUM_OF_MATS-1:0] w_m22;
105
 wire [22*`D3D_NUM_OF_MATS-1:0] w_m23;
106
 wire [22*`D3D_NUM_OF_MATS-1:0] w_m30;
107
 wire [22*`D3D_NUM_OF_MATS-1:0] w_m31;
108
 wire [22*`D3D_NUM_OF_MATS-1:0] w_m32;
109
 wire [22*`D3D_NUM_OF_MATS-1:0] w_m33;
110
`else
111
 wire [21:0] w_m00;
112
 wire [21:0] w_m01;
113
 wire [21:0] w_m02;
114
 wire [21:0] w_m03;
115
 wire [21:0] w_m10;
116
 wire [21:0] w_m11;
117
 wire [21:0] w_m12;
118
 wire [21:0] w_m13;
119
 wire [21:0] w_m20;
120
 wire [21:0] w_m21;
121
 wire [21:0] w_m22;
122
 wire [21:0] w_m23;
123
 wire [21:0] w_m30;
124
 wire [21:0] w_m31;
125
 wire [21:0] w_m32;
126
 wire [21:0] w_m33;
127
`endif
128
 wire [15:0] w_scr_w_m1;
129
 wire [15:0] w_scr_h_m1;
130
 wire [15:0] w_scr_w;
131
 wire [7:0]  w_pixel_color;
132
 wire [29:0]  w_pixel_top_address;
133
 wire        w_y_flip;
134
 
135
 wire w_dma_start;
136
 wire [29:0] w_dma_top_address;
137
 wire [15:0] w_dma_size;
138
 wire w_geo_state;
139
 
140
 wire w_en_cull;
141
 wire w_ccw;
142
 wire [21:0] w_vw;
143
 wire [21:0] w_vh;
144
 
145
 // Rasterizer I/F
146
 wire w_en;
147
 wire w_ack;
148
 wire [`D3D_FTOI_WIDTH-1:0] w_v0_x;
149
 wire [`D3D_FTOI_WIDTH-1:0] w_v0_y;
150
 wire [`D3D_FTOI_WIDTH-1:0] w_v1_x;
151
 wire [`D3D_FTOI_WIDTH-1:0] w_v1_y;
152
 wire [`D3D_FTOI_WIDTH-1:0] w_v2_x;
153
 wire [`D3D_FTOI_WIDTH-1:0] w_v2_y;
154
 wire w_ras_state;
155
 
156
 wire        w_req_geo;
157
 wire [31:0] w_adrs_geo;
158
 wire        w_ack_geo;
159
 wire        w_req_ras;
160
 wire [31:0] w_adrs_ras;
161
 wire        w_ack_ras;
162
 wire [2:0]  w_len_geo;
163
 
164
 wire        w_debug;
165
 
166
//////////////////////////////////
167
// assign
168
//////////////////////////////////
169
 
170
//////////////////////////////////
171
// module instance
172
//////////////////////////////////
173
 
174
// System Register
175
fm_sys u_sys (
176
  // system
177
  .clk_core(clk_i),
178
  .rst_x(rst_i),
179
  .o_int(int_o),
180
  // Register Bus I/F
181
`ifdef D3D_WISHBONE
182
  .i_wb_stb(s_wb_stb_i),
183
  .i_wb_we(s_wb_we_i),
184
  .i_wb_adr(s_wb_adr_i),
185
  .o_wb_ack(s_wb_ack_o),
186
  .i_wb_sel(s_wb_sel_i),
187
  .i_wb_dat(s_wb_dat_i),
188
  .o_wb_dat(s_wb_dat_o),
189
`else
190
  .i_req(i_req_s),
191
  .i_wr(i_wr_s),
192
  .i_adrs(i_adrs_s),
193
  .o_ack(o_ack_s),
194
  .i_be(i_be_s),
195
  .i_wd(i_dbw_s),
196
  .o_rstr(o_strr_s),
197
  .o_rd(o_dbr_s),
198
`endif
199
  // Geometry Engine Configurations
200
  //   vertex fetch
201
  .o_dma_start(w_dma_start),
202
  .o_dma_top_address(w_dma_top_address),
203
  .o_dma_size(w_dma_size),
204
  .i_geo_state(w_geo_state),
205
  //   matrix elements  
206
`ifdef D3D_USE_MATRIX_PALETTE
207
  .o_num_mats(w_num_mats),
208
`endif
209
  .o_m00(w_m00),
210
  .o_m01(w_m01),
211
  .o_m02(w_m02),
212
  .o_m03(w_m03),
213
  .o_m10(w_m10),
214
  .o_m11(w_m11),
215
  .o_m12(w_m12),
216
  .o_m13(w_m13),
217
  .o_m20(w_m20),
218
  .o_m21(w_m21),
219
  .o_m22(w_m22),
220
  .o_m23(w_m23),
221
  .o_m30(w_m30),
222
  .o_m31(w_m31),
223
  .o_m32(w_m32),
224
  .o_m33(w_m33),
225
  // curring
226
  .o_en_cull(w_en_cull),
227
  .o_ccw(w_ccw),
228
  // viewport
229
  .o_vw(w_vw),
230
  .o_vh(w_vh),
231
   // Rasterizer Configurations
232
  .o_scr_w_m1(w_scr_w_m1),
233
  .o_scr_h_m1(w_scr_h_m1),
234
  .o_scr_w(w_scr_w),
235
  .o_pixel_top_address(w_pixel_top_address),
236
  .o_pixel_color(w_pixel_color),
237
  .o_y_flip(w_y_flip),
238
  .i_ras_state(w_ras_state),
239
  .i_debug(w_debug)
240
);
241
 
242
// Geometry Engine   
243
fm_geo u_geo (
244
  // system
245
  .clk_core(clk_i),
246
  .rst_x(rst_i),
247
  .o_debug(w_debug),
248
  // Vertex Fetch Memory I/F (Read Only)
249
  .o_req_m(w_req_geo),
250
  .o_adrs_m(w_adrs_geo),
251
  .o_len_m(w_len_geo),
252
  .i_ack_m(w_ack_geo),
253
`ifdef D3D_WISHBONE
254
  .i_strr_m(1'b0),
255
  .i_dbr_m(m_wb_dat_i),
256
`else
257
  .i_strr_m(i_strr_m),
258
  .i_dbr_m(i_dbr_m),
259
`endif
260
  // Register Configuration
261
  //   vertex fetch
262
  .i_dma_start(w_dma_start),
263
  .i_dma_top_address(w_dma_top_address),
264
  .i_dma_size(w_dma_size),
265
  .o_state(w_geo_state),
266
  //   matrix elements  
267
`ifdef D3D_USE_MATRIX_PALETTE
268
  .i_num_mats(w_num_mats),
269
`endif
270
  .i_m00(w_m00),
271
  .i_m01(w_m01),
272
  .i_m02(w_m02),
273
  .i_m03(w_m03),
274
  .i_m10(w_m10),
275
  .i_m11(w_m11),
276
  .i_m12(w_m12),
277
  .i_m13(w_m13),
278
  .i_m20(w_m20),
279
  .i_m21(w_m21),
280
  .i_m22(w_m22),
281
  .i_m23(w_m23),
282
  .i_m30(w_m30),
283
  .i_m31(w_m31),
284
  .i_m32(w_m32),
285
  .i_m33(w_m33),
286
  // viewport
287
  .i_vw(w_vw),
288
  .i_vh(w_vh),
289
  // curring
290
  .i_en_cull(w_en_cull),
291
  .i_ccw(w_ccw),
292
  // Rasterizer I/F
293
  .o_en(w_en),
294
  .i_ack(w_ack),
295
  .o_v0_x(w_v0_x),
296
  .o_v0_y(w_v0_y),
297
  .o_v1_x(w_v1_x),
298
  .o_v1_y(w_v1_y),
299
  .o_v2_x(w_v2_x),
300
  .o_v2_y(w_v2_y)
301
);
302
 
303
 
304
// Rasterizer
305
fm_ras u_ras (
306
  // system
307
  .clk_core(clk_i),
308
  .rst_x(rst_i),
309
  // Register Configuration
310
  .i_scr_w_m1(w_scr_w_m1),
311
  .i_scr_h_m1(w_scr_h_m1),
312
  .i_scr_w(w_scr_w),
313
  .i_pixel_top_address(w_pixel_top_address),
314
  .i_pixel_color(w_pixel_color),
315
  .i_y_flip(w_y_flip),
316
  // Geometry Engine I/F
317
  .i_en(w_en),
318
  .o_ack(w_ack),
319
  .i_v0_x(w_v0_x),
320
  .i_v0_y(w_v0_y),
321
  .i_v1_x(w_v1_x),
322
  .i_v1_y(w_v1_y),
323
  .i_v2_x(w_v2_x),
324
  .i_v2_y(w_v2_y),
325
  .o_ras_state(w_ras_state),
326
  // Pixel Write Memory I/F (Write Only)
327
  .o_req_m(w_req_ras),
328
  .o_adrs_m(w_adrs_ras),
329
  .i_ack_m(w_ack_ras),
330
`ifdef D3D_WISHBONE
331
  .o_be_m(m_wb_sel_o),
332
  .o_dbw_m(m_wb_dat_o)
333
`else
334
  .o_be_m(o_be_m),
335
  .o_dbw_m(o_dbw_m)
336
`endif
337
);
338
 
339
// Memory Arbiter
340
fm_mem_arb u_mem_arb (
341
  // system
342
  .clk_core(clk_i),
343
  .rst_x(rst_i),
344
  // Geometry Engine
345
  .i_req_geo(w_req_geo),
346
  .i_adrs_geo(w_adrs_geo),
347
  .i_len_geo(w_len_geo),
348
  .o_ack_geo(w_ack_geo),
349
  // Rasterizer
350
  .i_req_ras(w_req_ras),
351
  .i_adrs_ras(w_adrs_ras),
352
  .o_ack_ras(w_ack_ras),
353
  // Memory I/F
354
`ifdef D3D_WISHBONE
355
  .o_req_m(m_wb_stb_o),
356
  .o_wr_m(m_wb_we_o),
357
  .o_adrs_m(m_wb_adr_o),
358
  .o_len_m(),
359
  .i_ack_m(m_wb_ack_i)
360
`else
361
  .o_req_m(o_req_m),
362
  .o_wr_m(o_wr_m),
363
  .o_adrs_m(o_adrs_m),
364
  .o_len_m(o_len_m),
365
  .i_ack_m(i_ack_m)
366
`endif
367
);
368
 
369
endmodule

powered by: WebSVN 2.1.0

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