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

Subversion Repositories ac97

[/] [ac97/] [trunk/] [rtl/] [verilog/] [ac97_out_fifo.v] - Blame information for rev 4

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 rudi
/////////////////////////////////////////////////////////////////////
2
////                                                             ////
3
////  WISHBONE AC 97 Controller                                  ////
4
////  Output FIFO                                                ////
5
////                                                             ////
6
////                                                             ////
7
////  Author: Rudolf Usselmann                                   ////
8
////          rudi@asics.ws                                      ////
9
////                                                             ////
10
////                                                             ////
11
////  Downloaded from: http://www.opencores.org/cores/ac97_ctrl/ ////
12
////                                                             ////
13
/////////////////////////////////////////////////////////////////////
14
////                                                             ////
15
//// Copyright (C) 2001 Rudolf Usselmann                         ////
16
////                    rudi@asics.ws                            ////
17
////                                                             ////
18
//// This source file may be used and distributed without        ////
19
//// restriction provided that this copyright statement is not   ////
20
//// removed from the file and that any derivative work contains ////
21
//// the original copyright notice and the associated disclaimer.////
22
////                                                             ////
23
////     THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY     ////
24
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   ////
25
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   ////
26
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      ////
27
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         ////
28
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    ////
29
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   ////
30
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        ////
31
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  ////
32
//// LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  ////
33
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  ////
34
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         ////
35
//// POSSIBILITY OF SUCH DAMAGE.                                 ////
36
////                                                             ////
37
/////////////////////////////////////////////////////////////////////
38
 
39
//  CVS Log
40
//
41
//  $Id: ac97_out_fifo.v,v 1.1 2001-08-03 06:54:50 rudi Exp $
42
//
43
//  $Date: 2001-08-03 06:54:50 $
44
//  $Revision: 1.1 $
45
//  $Author: rudi $
46
//  $Locker:  $
47
//  $State: Exp $
48
//
49
// Change History:
50
//               $Log: not supported by cvs2svn $
51
//               Revision 1.1.1.1  2001/05/19 02:29:16  rudi
52
//               Initial Checkin
53
//
54
//
55
//
56
//
57
 
58
`include "ac97_defines.v"
59
 
60
module ac97_out_fifo(clk, rst, en, mode, din, we, dout, re, status, full, empty);
61
 
62
input           clk, rst;
63
input           en;
64
input   [1:0]    mode;
65
input   [31:0]   din;
66
input           we;
67
output  [19:0]   dout;
68
input           re;
69
output  [1:0]    status;
70
output          full;
71
output          empty;
72
 
73
 
74
////////////////////////////////////////////////////////////////////
75
//
76
// Local Wires
77
//
78
 
79
reg     [31:0]   mem[0:3];
80
 
81
reg     [2:0]    wp;
82
reg     [3:0]    rp;
83
 
84
wire    [2:0]    wp_p1;
85
 
86
reg     [1:0]    status;
87
reg     [19:0]   dout;
88
wire    [31:0]   dout_tmp;
89
wire    [15:0]   dout_tmp1;
90
wire            m16b;
91
reg             empty;
92
 
93
////////////////////////////////////////////////////////////////////
94
//
95
// Misc Logic
96
//
97
 
98
assign m16b = (mode == 2'h0);   // 16 Bit Mode
99
 
100
always @(posedge clk)
101
        if(!en)         wp <= #1 0;
102
        else
103
        if(we)          wp <= #1 wp_p1;
104
 
105
assign wp_p1 = wp + 1;
106
 
107
always @(posedge clk)
108
        if(!en)         rp <= #1 0;
109
        else
110
        if(re & m16b)   rp <= #1 rp + 1;
111
        else
112
        if(re & !m16b)  rp <= #1 rp + 2;
113
 
114
always @(posedge clk)
115
        status <= #1 (wp[1:0] - rp[2:1]) - 1;
116
 
117
wire    [3:0]    rp_p1 = rp[3:0] + 1;
118
 
119
always @(posedge clk)
120
        empty <= #1 (rp_p1[3:1] == wp[2:0]) & (m16b ? rp_p1[0] : 1'b1);
121
 
122
assign full  = (wp[1:0] == rp[2:1]) & (wp[2] != rp[3]);
123
 
124
// Fifo Output
125
assign dout_tmp = mem[ rp[2:1] ];
126
 
127
// Fifo Output Half Word Select
128
assign dout_tmp1 = rp[0] ? dout_tmp[31:16] : dout_tmp[15:0];
129
 
130
always @(posedge clk)
131
        if(!en)         dout <= #1 20'h0;
132
        else
133
        if(re)
134
                case(mode)      // synopsys parallel_case full_case
135
                   0: dout <= #1 {dout_tmp1, 4'h0};              // 16 Bit Output
136
                   1: dout <= #1 {dout_tmp[17:0], 2'h0}; // 18 bit Output
137
                   2: dout <= #1 dout_tmp[19:0];         // 20 Bit Output
138
                endcase
139
 
140
 
141
always @(posedge clk)
142
        if(we)  mem[wp[1:0]] <= #1 din;
143
 
144
endmodule

powered by: WebSVN 2.1.0

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