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

Subversion Repositories wf3d

[/] [wf3d/] [trunk/] [implement/] [rtl/] [de0/] [fm_3d_wrapper.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_avalon.v
7
//
8
// Abstract:
9
//   AVALON interface
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_wrapper (
44
  // system
45
  input clk_core,
46
  input rst_x,
47
  output o_int,
48
  // avalon slave I/F
49
  input  [5:0]    i_avs_adr,
50
  input  [3:0]    i_avs_be,
51
  input           i_avs_r,
52
  output [31:0]   o_avs_rd,
53
  input           i_avs_w,
54
  input  [31:0]   i_avs_wd,
55
  output          o_avs_wait,
56
  // avalon geometry DMA I/F
57
  output [25:0]   o_avm_adr,
58
  output [3:0]    o_avm_be,
59
  output [31:0]   o_avm_wd,
60
  output [2:0]    o_avm_blen,
61
  output          o_avm_r,
62
  output          o_avm_w,
63
  input           i_avm_wait,
64
  input           i_avm_rvalid,
65
  input  [31:0]   i_avm_rd
66
);
67
 
68
wire w_req;
69
wire w_wr;
70
wire [5:0] w_adrs;
71
wire w_ack;
72
wire [3:0] w_be;
73
wire [31:0] w_wd;
74
wire w_rstr;
75
wire [31:0] w_rd;
76
wire [3:0] w_avm_be;
77
wire w_avm_ack;
78
 
79
wire w_req_m;
80
wire w_wr_m;
81
`ifdef D3D_WISHBONE
82
reg r_state;
83
assign o_avm_r = w_req_m & (~w_wr_m) & (r_state == P_IDLE);
84
assign w_avm_ack = (r_state == P_READ) ? i_avm_rvalid :
85
                                         (!i_avm_wait & w_wr_m);
86
localparam P_IDLE = 1'b0;
87
localparam P_READ = 1'b1;
88
always @(posedge clk_core or  negedge rst_x) begin
89
  if (~rst_x) begin
90
    r_state <= P_IDLE;
91
  end else begin
92
    case (r_state)
93
      P_IDLE: if (w_req_m & !i_avm_wait & !w_wr_m) r_state <= P_READ;
94
      P_READ:  if (i_avm_rvalid ) r_state <= P_IDLE;
95
    endcase
96
  end
97
end
98
`else
99
assign o_avm_r = w_req_m & (~w_wr_m);
100
`endif
101
assign o_avm_w = w_req_m & (w_wr_m);
102
assign o_avm_be = (~w_wr_m) ? 4'hff: w_avm_be;  // byte enable must be 'hff in read mode to get right data
103
 
104
`ifdef D3D_WISHBONE
105
fm_avalon_wb #(.P_AVALON_ADR_WIDTH(6)) u_avalon_wb (
106
`else
107
fm_avalon #(.P_AVALON_ADR_WIDTH(6)) u_avalon (
108
`endif
109
  .clk_core(clk_core),
110
  .rst_x(rst_x),
111
  // AVALON slave bus
112
  .i_av_adr(i_avs_adr),
113
  .i_av_be(i_avs_be),
114
  .i_av_r(i_avs_r),
115
  .o_av_rd(o_avs_rd),
116
  .i_av_w(i_avs_w),
117
  .i_av_wd(i_avs_wd),
118
  .o_av_wait(o_avs_wait),
119
  // internal side
120
  .o_req(w_req),
121
  .o_wr(w_wr),
122
  .o_adrs(w_adrs),
123
  .i_ack(w_ack),
124
  .o_be(w_be),
125
  .o_wd(w_wd),
126
`ifdef D3D_WISHBONE
127
`else
128
  .i_rstr(w_rstr),
129
`endif
130
  .i_rd(w_rd)
131
);
132
`ifdef D3D_WISHBONE
133
assign o_avm_blen = 3'd1;
134
wire [25:2]   w_avm_adr_t;
135
assign o_avm_adr = {w_avm_adr_t,2'b00};
136
`endif
137
 
138
fm_3d_core u_3d_core (
139
  .clk_i(clk_core),
140
  .rst_i(~rst_x),
141
  .int_o(o_int),
142
`ifdef D3D_WISHBONE
143
  // internal side
144
  .s_wb_stb_i(w_req),
145
  .s_wb_we_i(w_wr),
146
  .s_wb_adr_i(w_adrs),
147
  .s_wb_ack_o(w_ack),
148
  .s_wb_sel_i(w_be),
149
  .s_wb_dat_i(w_wd),
150
  .s_wb_dat_o(w_rd),
151
  // geometry DMA, pixel write
152
  .m_wb_stb_o(w_req_m),
153
  .m_wb_we_o(w_wr_m),
154
  .m_wb_adr_o(w_avm_adr_t),
155
  .m_wb_ack_i(w_avm_ack),
156
  .m_wb_sel_o(w_avm_be),
157
  .m_wb_dat_o(o_avm_wd),
158
  .m_wb_dat_i(i_avm_rd),
159
`else
160
  // internal side
161
  .i_req_s(w_req),
162
  .i_wr_s(w_wr),
163
  .i_adrs_s({w_adrs,2'b0}),
164
  .o_ack_s(w_ack),
165
  .i_be_s(w_be),
166
  .i_dbw_s(w_wd),
167
  .o_strr_s(w_rstr),
168
  .o_dbr_s(w_rd),
169
  // geometry DMA, pixel write
170
  .o_req_m(w_req_m),
171
  .o_wr_m(w_wr_m),
172
  .o_adrs_m(o_avm_adr),
173
  .o_len_m(o_avm_blen),
174
  .i_ack_m(!i_avm_wait),
175
  .o_be_m(w_avm_be),
176
  .o_dbw_m(o_avm_wd),
177
  .i_strr_m(i_avm_rvalid),
178
  .i_dbr_m(i_avm_rd)
179
`endif
180
);
181
 
182
endmodule

powered by: WebSVN 2.1.0

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