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

Subversion Repositories ac97

[/] [ac97/] [trunk/] [rtl/] [verilog/] [ac97_in_fifo.v] - Blame information for rev 10

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 10 rudi
//  $Id: ac97_in_fifo.v,v 1.2 2002-03-05 04:44:05 rudi Exp $
42 4 rudi
//
43 10 rudi
//  $Date: 2002-03-05 04:44:05 $
44
//  $Revision: 1.2 $
45 4 rudi
//  $Author: rudi $
46
//  $Locker:  $
47
//  $State: Exp $
48
//
49
// Change History:
50
//               $Log: not supported by cvs2svn $
51 10 rudi
//               Revision 1.1  2001/08/03 06:54:50  rudi
52
//
53
//
54
//               - Changed to new directory structure
55
//
56 4 rudi
//               Revision 1.1.1.1  2001/05/19 02:29:14  rudi
57
//               Initial Checkin
58
//
59
//
60
//
61
//
62
 
63
`include "ac97_defines.v"
64
 
65
module ac97_in_fifo(clk, rst, en, mode, din, we, dout, re, status, full, empty);
66
 
67
input           clk, rst;
68
input           en;
69
input   [1:0]    mode;
70
input   [19:0]   din;
71
input           we;
72
output  [31:0]   dout;
73
input           re;
74
output  [1:0]    status;
75
output          full;
76
output          empty;
77
 
78
 
79
////////////////////////////////////////////////////////////////////
80
//
81
// Local Wires
82
//
83
 
84
reg     [31:0]   mem[0:3];
85
reg     [31:0]   dout;
86
 
87
reg     [3:0]    wp;
88
reg     [2:0]    rp;
89
 
90
wire    [3:0]    wp_p1;
91
 
92
reg     [1:0]    status;
93
reg     [15:0]   din_tmp1;
94
reg     [31:0]   din_tmp;
95
wire            m16b;
96
reg             full, empty;
97
 
98
////////////////////////////////////////////////////////////////////
99
//
100
// Misc Logic
101
//
102
 
103
assign m16b = (mode == 2'h0);   // 16 Bit Mode
104
 
105
always @(posedge clk)
106 10 rudi
        if(!en)         wp <= #1 4'h0;
107 4 rudi
        else
108
        if(we)          wp <= #1 wp_p1;
109
 
110 10 rudi
assign wp_p1 = m16b ? (wp + 4'h1) : (wp + 4'h2);
111 4 rudi
 
112
always @(posedge clk)
113 10 rudi
        if(!en)         rp <= #1 3'h0;
114 4 rudi
        else
115 10 rudi
        if(re)          rp <= #1 rp + 3'h1;
116 4 rudi
 
117
always @(posedge clk)
118 10 rudi
        status <= #1 ((rp - wp[2:1]) - 2'h1);
119 4 rudi
 
120
always @(posedge clk)
121
        empty <= #1 (wp[3:1] == rp[2:0]) & (m16b ? !wp[0] : 1'b0);
122
 
123
always @(posedge clk)
124
        full  <= #1 (wp[2:1] == rp[1:0]) & (wp[3] != rp[2]);
125
 
126
// Fifo Output
127
always @(posedge clk)
128
        dout <= #1 mem[ rp[1:0] ];
129
 
130
// Fifo Input Half Word Latch
131
always @(posedge clk)
132
        if(we & !wp[0])  din_tmp1 <= #1 din[19:4];
133
 
134
always @(mode or din_tmp1 or din)
135
        case(mode)      // synopsys parallel_case full_case
136
           0: din_tmp = {din[19:4], din_tmp1};           // 16 Bit Output
137
           1: din_tmp = {13'h0, din[17:0]};              // 18 bit Output
138
           2: din_tmp = {11'h0, din[19:0]};              // 20 Bit Output
139
        endcase
140
 
141
always @(posedge clk)
142
        if(we & (!m16b | (m16b & wp[0]) ) )      mem[ wp[2:1] ] <= #1 din_tmp;
143
 
144
endmodule

powered by: WebSVN 2.1.0

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