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

Subversion Repositories ac97

[/] [ac97/] [trunk/] [rtl/] [verilog/] [ac97_in_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_in_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:14  rudi
52
//               Initial Checkin
53
//
54
//
55
//
56
//
57
 
58
`include "ac97_defines.v"
59
 
60
module ac97_in_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   [19:0]   din;
66
input           we;
67
output  [31: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
reg     [31:0]   dout;
81
 
82
reg     [3:0]    wp;
83
reg     [2:0]    rp;
84
 
85
wire    [3:0]    wp_p1;
86
 
87
reg     [1:0]    status;
88
reg     [15:0]   din_tmp1;
89
reg     [31:0]   din_tmp;
90
wire            m16b;
91
reg             full, 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 = m16b ? (wp + 1) : (wp + 2);
106
 
107
always @(posedge clk)
108
        if(!en)         rp <= #1 0;
109
        else
110
        if(re)          rp <= #1 rp + 1;
111
 
112
always @(posedge clk)
113
        status <= #1 ((rp - wp[2:1]) - 1);
114
 
115
always @(posedge clk)
116
        empty <= #1 (wp[3:1] == rp[2:0]) & (m16b ? !wp[0] : 1'b0);
117
 
118
always @(posedge clk)
119
        full  <= #1 (wp[2:1] == rp[1:0]) & (wp[3] != rp[2]);
120
 
121
// Fifo Output
122
always @(posedge clk)
123
        dout <= #1 mem[ rp[1:0] ];
124
 
125
// Fifo Input Half Word Latch
126
always @(posedge clk)
127
        if(we & !wp[0])  din_tmp1 <= #1 din[19:4];
128
 
129
always @(mode or din_tmp1 or din)
130
        case(mode)      // synopsys parallel_case full_case
131
           0: din_tmp = {din[19:4], din_tmp1};           // 16 Bit Output
132
           1: din_tmp = {13'h0, din[17:0]};              // 18 bit Output
133
           2: din_tmp = {11'h0, din[19:0]};              // 20 Bit Output
134
        endcase
135
 
136
always @(posedge clk)
137
        if(we & (!m16b | (m16b & wp[0]) ) )      mem[ wp[2:1] ] <= #1 din_tmp;
138
 
139
endmodule

powered by: WebSVN 2.1.0

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