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

Subversion Repositories wf3d

[/] [wf3d/] [trunk/] [implement/] [rtl/] [axi_cmn/] [fm_port_unit.v] - Blame information for rev 9

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 specular
//=======================================================================
2
// Project Monophony
3
//   Wire-Frame 3D Graphics Accelerator IP Core
4
//
5
// File:
6
//   fm_port_unit.v
7
//
8
// Abstract:
9
//   Memory Interconnect port module
10
//
11
// Author:
12 9 specular
//   Kenji Ishimaru (info.info.wf3d@gmail.com)
13 5 specular
//
14
//======================================================================
15
//
16
// Copyright (c) 2016, 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
module fm_port_unit (
43
  clk_core,
44
  rst_x,
45
  // port side
46
  i_req,
47
  i_we,
48
  i_len,
49
  o_ack,
50
  i_strw,
51
  o_ackw,
52
  o_strr,
53
  o_dbr,
54
  // internal
55
  i_cack,
56
  o_wdata_read_end,
57
  i_wdata_ack,
58
  i_strr,
59
  i_dbr
60
);
61
`include "polyphony_params.v"
62
////////////////////////////
63
// Parameter definition
64
////////////////////////////
65
parameter P_SIDLE  = 1'b0;
66
parameter P_SDOUT  = 1'b1;
67
////////////////////////////
68
// I/O definitions
69
////////////////////////////
70
input         i_req;          // command request
71
input         i_we;           // write enable
72
input  [P_IB_LEN_WIDTH-1:0]
73
              i_len;          // burst length
74
output        o_ack;          // command acknowledge
75
input         i_strw;         // write data strobe
76
output        o_ackw;         // write data acknowledge
77
output        o_strr;         // read data strobe
78
output [P_IB_DATA_WIDTH-1:0] o_dbr;          // read data
79
 
80
input         i_cack;         // command acknowledge
81
output        o_wdata_read_end;// write data end
82
input         i_wdata_ack;    // write data acknowledge
83
input         i_strr;         // read data strobe
84
input  [P_IB_DATA_WIDTH-1:0] i_dbr;          // read data
85
 
86
input         clk_core;        // system clock
87
input         rst_x;          // system reset
88
 
89
/////////////////////////
90
//  register definition
91
/////////////////////////
92
reg            r_state;
93
reg [P_IB_LEN_WIDTH-1:0]
94
               r_len;
95
reg            r_strr;
96
reg [P_IB_DATA_WIDTH-1:0]
97
               r_dbr;
98
 
99
/////////////////////////
100
//  wire definition
101
/////////////////////////
102
wire                  w_accept;
103
wire                  w_not_burst;
104
wire                  w_idle_state;
105
wire                  w_wdata_ack;
106
/////////////////////////
107
//  assign statement
108
/////////////////////////
109
assign w_accept = i_req & i_cack & i_we;
110
assign w_not_burst = !i_we | (i_len == 1);
111
assign w_idle_state = (r_state == P_SIDLE);
112
// output port connection
113
assign o_ack = (i_req) ? i_cack : 1'b1;
114
assign w_wdata_ack = (i_req) ? i_cack & i_wdata_ack : 1'b1;
115
 
116
assign o_ackw = (w_idle_state) ? w_wdata_ack : i_wdata_ack;
117
assign o_wdata_read_end = (w_idle_state) ? (i_strw & w_not_burst & i_wdata_ack) :
118
                                           (i_strw & (r_len == 1) & i_wdata_ack);
119
 
120
assign o_strr = r_strr;
121
assign o_dbr = r_dbr;
122
 
123
/////////////////////////
124
//  always statement
125
/////////////////////////
126
 
127
always @(posedge clk_core or negedge rst_x) begin
128
  if (~rst_x) begin
129
    r_state <= P_SIDLE;
130
  end else begin
131
    case (r_state)
132
      P_SIDLE :
133
        begin
134
          if (w_accept & !w_not_burst) begin
135
            r_state <= P_SDOUT;
136
          end
137
        end
138
      P_SDOUT :
139
        begin
140
          if (o_wdata_read_end) begin
141
            r_state <= P_SIDLE;
142
          end
143
        end
144
      default : r_state <= r_state;
145
    endcase
146
  end
147
end
148
 
149
// set input data
150
always @(posedge clk_core or negedge rst_x) begin
151
  if (~rst_x) begin
152
      r_len <= 1;
153
  end else begin
154
    if (w_accept) begin
155
      r_len <= i_len - 1'b1;
156
    end else if (i_strw & i_wdata_ack) begin
157
      r_len <= r_len - 1'b1;
158
    end
159
  end
160
end
161
 
162
// read data
163
always @(posedge clk_core or negedge rst_x) begin
164
  if (~rst_x) begin
165
    r_strr <= 1'b0;
166
  end else begin
167
    r_strr <= i_strr;
168
  end
169
end
170
 
171
always @(posedge clk_core) begin
172
  r_dbr <= i_dbr;
173
end
174
 
175
endmodule
176
 
177
 

powered by: WebSVN 2.1.0

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