/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
//// ////
|
//// ////
|
//// WISHBONE AC 97 Controller ////
|
//// WISHBONE AC 97 Controller ////
|
//// Output FIFO ////
|
//// Output FIFO ////
|
//// ////
|
//// ////
|
//// ////
|
//// ////
|
//// Author: Rudolf Usselmann ////
|
//// Author: Rudolf Usselmann ////
|
//// rudi@asics.ws ////
|
//// rudi@asics.ws ////
|
//// ////
|
//// ////
|
//// ////
|
//// ////
|
//// Downloaded from: http://www.opencores.org/cores/ac97_ctrl/ ////
|
//// Downloaded from: http://www.opencores.org/cores/ac97_ctrl/ ////
|
//// ////
|
//// ////
|
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
//// ////
|
//// ////
|
//// Copyright (C) 2001 Rudolf Usselmann ////
|
//// Copyright (C) 2001 Rudolf Usselmann ////
|
//// rudi@asics.ws ////
|
//// rudi@asics.ws ////
|
//// ////
|
//// ////
|
//// This source file may be used and distributed without ////
|
//// This source file may be used and distributed without ////
|
//// restriction provided that this copyright statement is not ////
|
//// restriction provided that this copyright statement is not ////
|
//// removed from the file and that any derivative work contains ////
|
//// removed from the file and that any derivative work contains ////
|
//// the original copyright notice and the associated disclaimer.////
|
//// the original copyright notice and the associated disclaimer.////
|
//// ////
|
//// ////
|
//// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY ////
|
//// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY ////
|
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED ////
|
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED ////
|
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS ////
|
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS ////
|
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR ////
|
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR ////
|
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, ////
|
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, ////
|
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ////
|
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ////
|
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ////
|
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ////
|
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ////
|
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ////
|
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF ////
|
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF ////
|
//// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ////
|
//// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ////
|
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT ////
|
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT ////
|
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ////
|
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ////
|
//// POSSIBILITY OF SUCH DAMAGE. ////
|
//// POSSIBILITY OF SUCH DAMAGE. ////
|
//// ////
|
//// ////
|
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
|
|
// CVS Log
|
// CVS Log
|
//
|
//
|
// $Id: ac97_out_fifo.v,v 1.2 2002-03-05 04:44:05 rudi Exp $
|
// $Id: ac97_out_fifo.v,v 1.3 2002-03-11 03:21:22 rudi Exp $
|
//
|
//
|
// $Date: 2002-03-05 04:44:05 $
|
// $Date: 2002-03-11 03:21:22 $
|
// $Revision: 1.2 $
|
// $Revision: 1.3 $
|
// $Author: rudi $
|
// $Author: rudi $
|
// $Locker: $
|
// $Locker: $
|
// $State: Exp $
|
// $State: Exp $
|
//
|
//
|
// Change History:
|
// Change History:
|
// $Log: not supported by cvs2svn $
|
// $Log: not supported by cvs2svn $
|
// Revision 1.1 2001/08/03 06:54:50 rudi
|
// Revision 1.1 2001/08/03 06:54:50 rudi
|
//
|
//
|
//
|
//
|
// - Changed to new directory structure
|
// - Changed to new directory structure
|
//
|
//
|
// Revision 1.1.1.1 2001/05/19 02:29:16 rudi
|
// Revision 1.1.1.1 2001/05/19 02:29:16 rudi
|
// Initial Checkin
|
// Initial Checkin
|
//
|
//
|
//
|
//
|
//
|
//
|
//
|
//
|
|
|
`include "ac97_defines.v"
|
`include "ac97_defines.v"
|
|
|
|
`ifdef AC97_OUT_FIFO_DEPTH_4
|
|
|
|
// 4 Entry Deep version of the Output FIFO
|
|
|
module ac97_out_fifo(clk, rst, en, mode, din, we, dout, re, status, full, empty);
|
module ac97_out_fifo(clk, rst, en, mode, din, we, dout, re, status, full, empty);
|
|
|
input clk, rst;
|
input clk, rst;
|
input en;
|
input en;
|
input [1:0] mode;
|
input [1:0] mode;
|
input [31:0] din;
|
input [31:0] din;
|
input we;
|
input we;
|
output [19:0] dout;
|
output [19:0] dout;
|
input re;
|
input re;
|
output [1:0] status;
|
output [1:0] status;
|
output full;
|
output full;
|
output empty;
|
output empty;
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
//
|
//
|
// Local Wires
|
// Local Wires
|
//
|
//
|
|
|
reg [31:0] mem[0:3];
|
reg [31:0] mem[0:3];
|
|
|
reg [2:0] wp;
|
reg [2:0] wp;
|
reg [3:0] rp;
|
reg [3:0] rp;
|
|
|
wire [2:0] wp_p1;
|
wire [2:0] wp_p1;
|
|
|
reg [1:0] status;
|
reg [1:0] status;
|
reg [19:0] dout;
|
reg [19:0] dout;
|
wire [31:0] dout_tmp;
|
wire [31:0] dout_tmp;
|
wire [15:0] dout_tmp1;
|
wire [15:0] dout_tmp1;
|
wire m16b;
|
wire m16b;
|
reg empty;
|
reg empty;
|
|
|
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
//
|
//
|
// Misc Logic
|
// Misc Logic
|
//
|
//
|
|
|
assign m16b = (mode == 2'h0); // 16 Bit Mode
|
assign m16b = (mode == 2'h0); // 16 Bit Mode
|
|
|
always @(posedge clk)
|
always @(posedge clk)
|
if(!en) wp <= #1 3'h0;
|
if(!en) wp <= #1 3'h0;
|
else
|
else
|
if(we) wp <= #1 wp_p1;
|
if(we) wp <= #1 wp_p1;
|
|
|
assign wp_p1 = wp + 3'h1;
|
assign wp_p1 = wp + 3'h1;
|
|
|
always @(posedge clk)
|
always @(posedge clk)
|
if(!en) rp <= #1 4'h0;
|
if(!en) rp <= #1 4'h0;
|
else
|
else
|
if(re & m16b) rp <= #1 rp + 4'h1;
|
if(re & m16b) rp <= #1 rp + 4'h1;
|
else
|
else
|
if(re & !m16b) rp <= #1 rp + 4'h2;
|
if(re & !m16b) rp <= #1 rp + 4'h2;
|
|
|
always @(posedge clk)
|
always @(posedge clk)
|
status <= #1 (wp[1:0] - rp[2:1]) - 2'h1;
|
status <= #1 (wp[1:0] - rp[2:1]) - 2'h1;
|
|
|
wire [3:0] rp_p1 = rp[3:0] + 4'h1;
|
wire [3:0] rp_p1 = rp[3:0] + 4'h1;
|
|
|
always @(posedge clk)
|
always @(posedge clk)
|
empty <= #1 (rp_p1[3:1] == wp[2:0]) & (m16b ? rp_p1[0] : 1'b1);
|
empty <= #1 (rp_p1[3:1] == wp[2:0]) & (m16b ? rp_p1[0] : 1'b1);
|
|
|
assign full = (wp[1:0] == rp[2:1]) & (wp[2] != rp[3]);
|
assign full = (wp[1:0] == rp[2:1]) & (wp[2] != rp[3]);
|
|
|
// Fifo Output
|
// Fifo Output
|
assign dout_tmp = mem[ rp[2:1] ];
|
assign dout_tmp = mem[ rp[2:1] ];
|
|
|
// Fifo Output Half Word Select
|
// Fifo Output Half Word Select
|
assign dout_tmp1 = rp[0] ? dout_tmp[31:16] : dout_tmp[15:0];
|
assign dout_tmp1 = rp[0] ? dout_tmp[31:16] : dout_tmp[15:0];
|
|
|
always @(posedge clk)
|
always @(posedge clk)
|
if(!en) dout <= #1 20'h0;
|
if(!en) dout <= #1 20'h0;
|
else
|
else
|
if(re)
|
if(re)
|
case(mode) // synopsys parallel_case full_case
|
case(mode) // synopsys parallel_case full_case
|
0: dout <= #1 {dout_tmp1, 4'h0}; // 16 Bit Output
|
2'h0: dout <= #1 {dout_tmp1, 4'h0}; // 16 Bit Output
|
1: dout <= #1 {dout_tmp[17:0], 2'h0}; // 18 bit Output
|
2'h1: dout <= #1 {dout_tmp[17:0], 2'h0}; // 18 bit Output
|
2: dout <= #1 dout_tmp[19:0]; // 20 Bit Output
|
2'h2: dout <= #1 dout_tmp[19:0]; // 20 Bit Output
|
endcase
|
endcase
|
|
|
always @(posedge clk)
|
always @(posedge clk)
|
if(we) mem[wp[1:0]] <= #1 din;
|
if(we) mem[wp[1:0]] <= #1 din;
|
|
|
endmodule
|
endmodule
|
|
|
|
`endif
|
|
|
|
`ifdef AC97_OUT_FIFO_DEPTH_8
|
|
|
|
// 8 Entry Deep version of the Output FIFO
|
|
|
|
module ac97_out_fifo(clk, rst, en, mode, din, we, dout, re, status, full, empty);
|
|
|
|
input clk, rst;
|
|
input en;
|
|
input [1:0] mode;
|
|
input [31:0] din;
|
|
input we;
|
|
output [19:0] dout;
|
|
input re;
|
|
output [1:0] status;
|
|
output full;
|
|
output empty;
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Local Wires
|
|
//
|
|
|
|
reg [31:0] mem[0:7];
|
|
|
|
reg [3:0] wp;
|
|
reg [4:0] rp;
|
|
|
|
wire [3:0] wp_p1;
|
|
|
|
reg [1:0] status;
|
|
reg [19:0] dout;
|
|
wire [31:0] dout_tmp;
|
|
wire [15:0] dout_tmp1;
|
|
wire m16b;
|
|
reg empty;
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Misc Logic
|
|
//
|
|
|
|
assign m16b = (mode == 2'h0); // 16 Bit Mode
|
|
|
|
always @(posedge clk)
|
|
if(!en) wp <= #1 4'h0;
|
|
else
|
|
if(we) wp <= #1 wp_p1;
|
|
|
|
assign wp_p1 = wp + 4'h1;
|
|
|
|
always @(posedge clk)
|
|
if(!en) rp <= #1 5'h0;
|
|
else
|
|
if(re & m16b) rp <= #1 rp + 5'h1;
|
|
else
|
|
if(re & !m16b) rp <= #1 rp + 5'h2;
|
|
|
|
always @(posedge clk)
|
|
status <= #1 (wp[2:1] - rp[3:2]) - 2'h1;
|
|
|
|
wire [4:0] rp_p1 = rp[4:0] + 5'h1;
|
|
|
|
always @(posedge clk)
|
|
empty <= #1 (rp_p1[4:1] == wp[3:0]) & (m16b ? rp_p1[0] : 1'b1);
|
|
|
|
assign full = (wp[2:0] == rp[3:1]) & (wp[3] != rp[4]);
|
|
|
|
// Fifo Output
|
|
assign dout_tmp = mem[ rp[3:1] ];
|
|
|
|
// Fifo Output Half Word Select
|
|
assign dout_tmp1 = rp[0] ? dout_tmp[31:16] : dout_tmp[15:0];
|
|
|
|
always @(posedge clk)
|
|
if(!en) dout <= #1 20'h0;
|
|
else
|
|
if(re)
|
|
case(mode) // synopsys parallel_case full_case
|
|
2'h0: dout <= #1 {dout_tmp1, 4'h0}; // 16 Bit Output
|
|
2'h1: dout <= #1 {dout_tmp[17:0], 2'h0}; // 18 bit Output
|
|
2'h2: dout <= #1 dout_tmp[19:0]; // 20 Bit Output
|
|
endcase
|
|
|
|
|
|
always @(posedge clk)
|
|
if(we) mem[wp[2:0]] <= #1 din;
|
|
|
|
endmodule
|
|
|
|
`endif
|
|
|
|
|
|
`ifdef AC97_OUT_FIFO_DEPTH_16
|
|
|
|
// 16 Entry Deep version of the Output FIFO
|
|
|
|
module ac97_out_fifo(clk, rst, en, mode, din, we, dout, re, status, full, empty);
|
|
|
|
input clk, rst;
|
|
input en;
|
|
input [1:0] mode;
|
|
input [31:0] din;
|
|
input we;
|
|
output [19:0] dout;
|
|
input re;
|
|
output [1:0] status;
|
|
output full;
|
|
output empty;
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Local Wires
|
|
//
|
|
|
|
reg [31:0] mem[0:15];
|
|
|
|
reg [4:0] wp;
|
|
reg [5:0] rp;
|
|
|
|
wire [4:0] wp_p1;
|
|
|
|
reg [1:0] status;
|
|
reg [19:0] dout;
|
|
wire [31:0] dout_tmp;
|
|
wire [15:0] dout_tmp1;
|
|
wire m16b;
|
|
reg empty;
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Misc Logic
|
|
//
|
|
|
|
assign m16b = (mode == 2'h0); // 16 Bit Mode
|
|
|
|
always @(posedge clk)
|
|
if(!en) wp <= #1 5'h0;
|
|
else
|
|
if(we) wp <= #1 wp_p1;
|
|
|
|
assign wp_p1 = wp + 4'h1;
|
|
|
|
always @(posedge clk)
|
|
if(!en) rp <= #1 6'h0;
|
|
else
|
|
if(re & m16b) rp <= #1 rp + 6'h1;
|
|
else
|
|
if(re & !m16b) rp <= #1 rp + 6'h2;
|
|
|
|
always @(posedge clk)
|
|
status <= #1 (wp[3:2] - rp[4:3]) - 2'h1;
|
|
|
|
wire [5:0] rp_p1 = rp[5:0] + 6'h1;
|
|
|
|
always @(posedge clk)
|
|
empty <= #1 (rp_p1[5:1] == wp[4:0]) & (m16b ? rp_p1[0] : 1'b1);
|
|
|
|
assign full = (wp[3:0] == rp[4:1]) & (wp[4] != rp[5]);
|
|
|
|
// Fifo Output
|
|
assign dout_tmp = mem[ rp[4:1] ];
|
|
|
|
// Fifo Output Half Word Select
|
|
assign dout_tmp1 = rp[0] ? dout_tmp[31:16] : dout_tmp[15:0];
|
|
|
|
always @(posedge clk)
|
|
if(!en) dout <= #1 20'h0;
|
|
else
|
|
if(re)
|
|
case(mode) // synopsys parallel_case full_case
|
|
2'h0: dout <= #1 {dout_tmp1, 4'h0}; // 16 Bit Output
|
|
2'h1: dout <= #1 {dout_tmp[17:0], 2'h0}; // 18 bit Output
|
|
2'h2: dout <= #1 dout_tmp[19:0]; // 20 Bit Output
|
|
endcase
|
|
|
|
|
|
always @(posedge clk)
|
|
if(we) mem[wp[3:0]] <= #1 din;
|
|
|
|
endmodule
|
|
|
|
`endif
|
|
|
No newline at end of file
|
No newline at end of file
|