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

Subversion Repositories wf3d

[/] [wf3d/] [trunk/] [rtl/] [core/] [fm_mem_arb.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_mem_arb.v
7
//
8
// Abstract:
9
//   Memory access arbiter.
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_mem_arb (
44
  // system
45
  input         clk_core,
46
  input         rst_x,
47
  // Geometry Engine
48
  input         i_req_geo,
49
  input [31:0]  i_adrs_geo,
50
  input [2:0]   i_len_geo,
51
  output        o_ack_geo,
52
  // Rasterizer
53
  input         i_req_ras,
54
  input [31:0]  i_adrs_ras,
55
  output        o_ack_ras,
56
  // Memory I/F
57
  output        o_req_m,
58
  output        o_wr_m,
59
`ifdef D3D_WISHBONE
60
  output [31:2] o_adrs_m,
61
`else
62
  output [31:0] o_adrs_m,
63
`endif
64
  output [2:0]  o_len_m,
65
  input         i_ack_m
66
);
67
localparam P_IDLE = 'd0;
68
localparam P_WAIT = 'd1;
69
//////////////////////////////////
70
// reg
71
//////////////////////////////////
72
reg r_state;
73
reg r_req_geo;
74
//////////////////////////////////
75
// wire
76
//////////////////////////////////
77
wire w_req;
78
wire w_pri;
79
//////////////////////////////////
80
// assign
81
//////////////////////////////////
82
assign w_req = i_req_geo | i_req_ras;
83
assign w_pri = (r_state == P_WAIT) ? r_req_geo : i_req_geo;
84
assign o_req_m = w_req;
85
`ifdef D3D_WISHBONE
86
assign o_adrs_m = (w_pri) ? i_adrs_geo[31:2] : i_adrs_ras[31:2];
87
`else
88
assign o_adrs_m = (w_pri) ? i_adrs_geo : i_adrs_ras;
89
`endif
90
assign o_len_m = (w_pri) ?  i_len_geo : 3'd1;
91
assign o_ack_geo = i_ack_m & w_pri;
92
assign o_ack_ras = i_ack_m & !w_pri;
93
 
94
assign o_wr_m = ~w_pri;
95
 
96
//////////////////////////////////
97
// always
98
//////////////////////////////////
99
`ifdef D3D_SYNC_RESET
100
always @(posedge clk_core) begin
101
`else
102
always @(posedge clk_core or negedge rst_x) begin
103
`endif
104
  if (rst_x == `D3D_RESET_POL) begin
105
    r_state <= P_IDLE;
106
    r_req_geo <= 1'b0;
107
  end else begin
108
    case (r_state)
109
      P_IDLE:begin
110
        if (w_req) begin
111
          if (!i_ack_m) begin
112
            r_req_geo <= i_req_geo;
113
            r_state <= P_WAIT;
114
          end
115
        end
116
      end
117
      P_WAIT:begin
118
        if (i_ack_m) r_state <= P_IDLE;
119
      end
120
    endcase
121
  end
122
end
123
 
124
endmodule

powered by: WebSVN 2.1.0

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