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

Subversion Repositories wf3d

[/] [wf3d/] [trunk/] [implement/] [rtl/] [axi_cmn/] [fm_mic_cnv.v] - Blame information for rev 8

Go to most recent revision | 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_mic_cnv.v
7
//
8
// Abstract:
9
//   32-64 bit data bus width conversion
10
//
11
// Author:
12
//   Kenji Ishimaru (info.wf3d@gmail.com)
13
//
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_mic_cnv (
43
    clk_core,
44
    rst_x,
45
  // incoming
46
    i_req_in,
47
    i_wr_in,
48
    i_adrs_in,
49
    i_len_in,
50
    o_ack_in,
51
    i_be_in,
52
    i_wdata_in,
53
    o_rstr_in,
54
    o_rdata_in,
55
  // outcoming
56
    o_req_out,
57
    o_wr_out,
58
    o_adrs_out,
59
    o_len_out,
60
    i_ack_out,
61
    o_be_out,
62
    o_wdata_out,
63
    i_rstr_out,
64
    i_rdata_out
65
);
66
`include "polyphony_params.v"
67
//////////////////////////////////
68
// I/O port definition
69
//////////////////////////////////
70
input          clk_core;
71
input          rst_x;
72
// incoming
73
input          i_req_in;
74
input          i_wr_in;
75
input [31:2]   i_adrs_in;
76
input [2:0]    i_len_in;
77
output         o_ack_in;
78
input [3:0]    i_be_in;
79
input [31:0]   i_wdata_in;
80
output         o_rstr_in;
81
output [31:0]  o_rdata_in;
82
// outcoming
83
output         o_req_out;
84
output         o_wr_out;
85
output [31:3]  o_adrs_out;
86
output [5:0]   o_len_out;
87
input          i_ack_out;
88
output [7:0]   o_be_out;
89
output [63:0]  o_wdata_out;
90
input          i_rstr_out;
91
input [63:0]   i_rdata_out;
92
//////////////////////////////////
93
// regs 
94
//////////////////////////////////
95
reg [2:0] r_cnt;
96
//////////////////////////////////
97
// wires 
98
//////////////////////////////////
99
wire w_sel;
100
wire w_fifo_write;
101
wire [3:0] w_fifo_din;
102
wire w_fifo_full;
103
wire w_read_end;
104
wire [3:0] w_fifo_dout;
105
wire w_empty;
106
wire w_add_lsb;
107
wire w_add_lsb_out;
108
wire [2:0] w_len;
109
 
110
wire w_dread_end;
111
wire [63:0]w_dfifo_dout;
112
wire w_dempty;
113
 
114
//////////////////////////////////
115
// assign statement 
116
//////////////////////////////////
117
assign o_req_out = i_req_in;
118
assign {o_adrs_out[31:3],w_add_lsb} = i_adrs_in[31:2];
119
assign o_len_out = i_len_in[2:1] + i_len_in[0];
120
assign o_be_out = (w_add_lsb) ? {i_be_in,4'h0} : {4'h0,i_be_in};
121
assign o_wdata_out = (w_add_lsb) ? {i_wdata_in,32'h0} : {32'h0,i_wdata_in};
122
assign o_wr_out = i_wr_in;
123
// command
124
assign w_fifo_din = {w_add_lsb,i_len_in};
125
assign {w_add_lsb_out,w_len} = w_fifo_dout;
126
assign w_fifo_write = o_req_out & i_ack_out & (!i_wr_in);
127
assign w_read_end = (!w_dempty) & (w_len == r_cnt);
128
assign o_ack_in = i_ack_out & !w_fifo_full;
129
// data
130
assign w_sel = (w_add_lsb_out) ?  r_cnt[0] : ~r_cnt[0];
131
assign w_dread_end = w_sel | w_read_end;
132
assign o_rstr_in = !w_dempty;
133
assign o_rdata_in = (w_sel) ? w_dfifo_dout[63:32] :w_dfifo_dout[31:0];
134
//////////////////////////////////
135
// module instantiation
136
//////////////////////////////////
137
always @(posedge clk_core or negedge rst_x) begin
138
  if (~rst_x) begin
139
    r_cnt <= 'd1;
140
  end else begin
141
    if (!w_dempty) begin
142
      if (w_len == r_cnt) r_cnt <= 'd1;
143
      else r_cnt <= r_cnt + 1'b1;
144
    end
145
  end
146
end
147
 
148
// len, lsb
149
fm_cmn_bfifo #(4,4) u_fifo (
150
  .clk_core(clk_core),
151
  .rst_x(rst_x),
152
  .i_wstrobe(w_fifo_write),
153
  .i_dt(w_fifo_din),
154
  .o_full(w_fifo_full),
155
  .i_renable(w_read_end),
156
  .o_dt(w_fifo_dout),
157
  .o_empty(w_empty),
158
  .o_dnum()
159
);
160
 
161
fm_cmn_bfifo #(64,4) u_dfifo (
162
  .clk_core(clk_core),
163
  .rst_x(rst_x),
164
  .i_wstrobe(i_rstr_out),
165
  .i_dt(i_rdata_out),
166
  .o_full(),
167
  .i_renable(w_dread_end),
168
  .o_dt(w_dfifo_dout),
169
  .o_empty(w_dempty),
170
  .o_dnum()
171
);
172
 
173
endmodule

powered by: WebSVN 2.1.0

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