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

Subversion Repositories mips_enhanced

[/] [mips_enhanced/] [trunk/] [grlib-gpl-1.0.19-b3188/] [lib/] [opencores/] [ac97/] [ac97_top.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dimamali
/////////////////////////////////////////////////////////////////////
2
////                                                             ////
3
////  WISHBONE AC 97 Controller Definitions                      ////
4
////                                                             ////
5
////                                                             ////
6
////  Author: Rudolf Usselmann                                   ////
7
////          rudi@asics.ws                                      ////
8
////                                                             ////
9
////                                                             ////
10
////  Downloaded from: http://www.opencores.org/cores/ac97_ctrl/ ////
11
////                                                             ////
12
/////////////////////////////////////////////////////////////////////
13
////                                                             ////
14
//// Copyright (C) 2000-2002 Rudolf Usselmann                    ////
15
////                         www.asics.ws                        ////
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_top.v,v 1.4 2006/11/20 17:13:43 tame Exp $
42
//
43
//  $Date: 2006/11/20 17:13:43 $
44
//  $Revision: 1.4 $
45
//  $Author: tame $
46
//  $Locker:  $
47
//  $State: Exp $
48
//
49
// Change History:
50
//               $Log: ac97_top.v,v $
51
//               Revision 1.4  2006/11/20 17:13:43  tame
52
//               Originally calculated values used.
53
//
54
//               Revision 1.3  2006/09/11 13:12:13  tame
55
//               Tried out high timing settings - works in hardware.
56
//
57
//               Revision 1.2  2006/08/16 08:46:04  tame
58
//               AC97 core: register set read/writable in first simulations; in hardware, however,
59
//               not yet
60
//
61
//               Revision 1.1  2006/08/14 15:25:09  tame
62
//               added ac97 codec from OpenCores
63
//               adapted configuration in ac97_defines module
64
//
65
//               Revision 1.5  2002/09/19 06:30:56  rudi
66
//               Fixed a bug reported by Igor. Apparently this bug only shows up when
67
//               the WB clock is very low (2x bit_clk). Updated Copyright header.
68
//
69
//               Revision 1.4  2002/03/11 03:21:22  rudi
70
//
71
//               - Added defines to select fifo depth between 4, 8 and 16 entries.
72
//
73
//               Revision 1.3  2002/03/05 04:44:05  rudi
74
//
75
//               - Fixed the order of the thrash hold bits to match the spec.
76
//               - Many minor synthesis cleanup items ...
77
//
78
//               Revision 1.2  2001/08/10 08:09:42  rudi
79
//
80
//               - Removed RTY_O output.
81
//               - Added Clock and Reset Inputs to documentation.
82
//               - Changed IO names to be more clear.
83
//               - Uniquifyed define names to be core specific.
84
//
85
//               Revision 1.1  2001/08/03 06:54:49  rudi
86
//
87
//
88
//               - Changed to new directory structure
89
//
90
//               Revision 1.1.1.1  2001/05/19 02:29:14  rudi
91
//               Initial Checkin
92
//
93
//
94
//
95
//
96
 
97
`timescale 1ns / 10ps
98
 
99
/////////////////////////////////////////////////////////////////////
100
// This AC97 Controller supports up to 6 Output and 3 Input Channels.
101
// Comment out the define statement for which channels you do not wish
102
// to support in your implementation. The main Left and Right channels
103
// are always supported. 
104
 
105
// Surround Left + Right
106
// `define AC97_SURROUND                1
107
 
108
// Center Channel
109
// `define AC97_CENTER          1
110
 
111
// LFE Channel
112
// `define AC97_LFE             1
113
 
114
// Stereo Input
115
// `define AC97_SIN             1
116
 
117
// Mono Microphone Input
118
// `define AC97_MICIN           1
119
 
120
/////////////////////////////////////////////////////////////////////
121
//
122
// This define selects how the WISHBONE interface determines if
123
// the internal register file is selected.
124
// This should be a simple address decoder. "wb_addr_i" is the
125
// WISHBONE address bus (32 bits wide).
126
// **** tame:
127
// The AC97 controller has 16 registers occupying an address space of
128
// 17 32-bit words (1 address is reserved). 5 bits are needed to decode
129
// the individual registers.
130
// With the configuration of AC97_REG_SEL as 0xfff from the MSB's of the
131
// AHB address, the AC97 core must reside in the I/O area of the LEON
132
// AHB controller.
133
`define AC97_REG_SEL            (wb_addr_i[31:20] == 12'h fff)
134
 
135
/////////////////////////////////////////////////////////////////////
136
//
137
// This is a prescaler that generates a pulse every 250 nS.
138
// The value here should one less than the actually calculated
139
// value.
140
// For a 200 MHz wishbone clock, this value is 49 (50-1).
141
// **** tame:
142
// For a 25 MHz clock, the prescaler value is 5, roughly.
143
// (250 ns / 40 ns = 6.25; 6.25 - 1 = 5.25 -> integer 5)
144
`define AC97_250_PS     6'h5
145
 
146
/////////////////////////////////////////////////////////////////////
147
//
148
// AC97 Cold reset Must be asserted for at least 1uS. The AC97
149
// controller will stretch the reset pulse to at least 1uS.
150
// The reset timer is driven by the AC97_250_PS prescaler.
151
// This value should probably be never changed. Adjust the
152
// AC97_250_PS instead.
153
// **** tame:
154
// Since the prescaler cycle is less than only 240 ns instead of
155
// 250 ns, 5 cycles are needed.
156
`define AC97_RST_DEL    3'h4
157
 
158
/////////////////////////////////////////////////////////////////////
159
//
160
// This value indicates for how long the resume signaling (asserting sync)
161
// should be done. This counter is driven by the AC97_250_PS prescaler.
162
// This value times 250nS is the duration of the resume signaling.
163
// The actual value must be incremented by one, as we do not know
164
// the current state of the prescaler, and must somehow insure we
165
// meet the minimum 1uS length. This value should probably be never
166
// changed. Modify the AC97_250_PS instead.
167
`define AC97_RES_SIG    3'h5
168
 
169
/////////////////////////////////////////////////////////////////////
170
//
171
// If the bit clock is absent for at least two "predicted" bit
172
// clock periods (163 nS) we should signal "suspended".
173
// This value defines how many WISHBONE cycles must pass without
174
// any change on the bit clock input before we signal "suspended".
175
// For a 200 MHz WISHBONE clock this would be about (163/5) 33 cycles.
176
`define AC97_SUSP_DET   6'h5
177
 
178
/////////////////////////////////////////////////////////////////////
179
//
180
// Select FIFO Depth. For most applications a FIFO depth of 4 should
181
// be sufficient. For systems with slow interrupt processing or slow
182
// DMA response or systems with low internal bus bandwidth you might
183
// want to increase the FIFO sizes to reduce the interrupt/DMA service
184
// request frequencies.
185
// Service request frequency can be calculated as follows:
186
// Channel bandwidth / FIFO size = Service Request Frequency
187
// For Example: 48KHz / 4 = 12 kHz
188
//
189
// Select Input FIFO depth by uncommenting ONE of the following define
190
// statements:
191
`define AC97_IN_FIFO_DEPTH_4
192
//`define AC97_IN_FIFO_DEPTH_8
193
//`define AC97_IN_FIFO_DEPTH_16
194
//
195
// Select Output FIFO depth by uncommenting ONE of the following define
196
// statements:
197
`define AC97_OUT_FIFO_DEPTH_4
198
//`define AC97_OUT_FIFO_DEPTH_8
199
//`define AC97_OUT_FIFO_DEPTH_16
200
 
201
/////////////////////////////////////////////////////////////////////
202
////                                                             ////
203
////  WISHBONE AC 97 Controller                                  ////
204
////  Codec Register Access Module                               ////
205
////                                                             ////
206
////                                                             ////
207
////  Author: Rudolf Usselmann                                   ////
208
////          rudi@asics.ws                                      ////
209
////                                                             ////
210
////                                                             ////
211
////  Downloaded from: http://www.opencores.org/cores/ac97_ctrl/ ////
212
////                                                             ////
213
/////////////////////////////////////////////////////////////////////
214
////                                                             ////
215
//// Copyright (C) 2000-2002 Rudolf Usselmann                    ////
216
////                         www.asics.ws                        ////
217
////                         rudi@asics.ws                       ////
218
////                                                             ////
219
//// This source file may be used and distributed without        ////
220
//// restriction provided that this copyright statement is not   ////
221
//// removed from the file and that any derivative work contains ////
222
//// the original copyright notice and the associated disclaimer.////
223
////                                                             ////
224
////     THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY     ////
225
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   ////
226
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   ////
227
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      ////
228
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         ////
229
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    ////
230
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   ////
231
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        ////
232
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  ////
233
//// LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  ////
234
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  ////
235
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         ////
236
//// POSSIBILITY OF SUCH DAMAGE.                                 ////
237
////                                                             ////
238
/////////////////////////////////////////////////////////////////////
239
 
240
 
241
//  CVS Log
242
//
243
//  $Id: ac97_top.v,v 1.4 2006/11/20 17:13:43 tame Exp $
244
//
245
//  $Date: 2006/11/20 17:13:43 $
246
//  $Revision: 1.4 $
247
//  $Author: tame $
248
//  $Locker:  $
249
//  $State: Exp $
250
//
251
// Change History:
252
//               $Log: ac97_top.v,v $
253
//               Revision 1.4  2006/11/20 17:13:43  tame
254
//               Originally calculated values used.
255
//
256
//               Revision 1.3  2006/09/11 13:12:13  tame
257
//               Tried out high timing settings - works in hardware.
258
//
259
//               Revision 1.2  2006/08/16 08:46:04  tame
260
//               AC97 core: register set read/writable in first simulations; in hardware, however,
261
//               not yet
262
//
263
//               Revision 1.1  2006/08/14 15:25:09  tame
264
//               added ac97 codec from OpenCores
265
//               adapted configuration in ac97_defines module
266
//
267
//               Revision 1.3  2002/09/19 06:30:56  rudi
268
//               Fixed a bug reported by Igor. Apparently this bug only shows up when
269
//               the WB clock is very low (2x bit_clk). Updated Copyright header.
270
//
271
//               Revision 1.2  2002/03/05 04:44:05  rudi
272
//
273
//               - Fixed the order of the thrash hold bits to match the spec.
274
//               - Many minor synthesis cleanup items ...
275
//
276
//               Revision 1.1  2001/08/03 06:54:49  rudi
277
//
278
//
279
//               - Changed to new directory structure
280
//
281
//               Revision 1.1.1.1  2001/05/19 02:29:18  rudi
282
//               Initial Checkin
283
//
284
//
285
//
286
//
287
 
288
// `include "ac97_defines.v"
289
 
290
module ac97_cra(clk, rst,
291
 
292
                crac_we, crac_din, crac_out,
293
                crac_wr_done, crac_rd_done,
294
 
295
                valid, out_slt1, out_slt2,
296
                in_slt2,
297
 
298
                crac_valid, crac_wr
299
                );
300
 
301
input           clk, rst;
302
input           crac_we;
303
output  [15:0]   crac_din;
304
input   [31:0]   crac_out;
305
output          crac_wr_done, crac_rd_done;
306
 
307
input           valid;
308
output  [19:0]   out_slt1;
309
output  [19:0]   out_slt2;
310
input   [19:0]   in_slt2;
311
 
312
output          crac_valid;
313
output          crac_wr;
314
 
315
 
316
////////////////////////////////////////////////////////////////////
317
//
318
// Local Wires
319
//
320
 
321
reg             crac_wr;
322
reg             crac_rd;
323
reg             crac_rd_done;
324
reg     [15:0]   crac_din;
325
reg             crac_we_r;
326
reg             valid_r;
327
wire            valid_ne;
328
wire            valid_pe;
329
reg             rdd1, rdd2, rdd3;
330
 
331
////////////////////////////////////////////////////////////////////
332
//
333
// Codec Register Data Path
334
//
335
 
336
// Control
337
assign out_slt1[19]    = crac_out[31];
338
assign out_slt1[18:12] = crac_out[22:16];
339
assign out_slt1[11:0]  = 12'h0;
340
 
341
// Write Data
342
assign out_slt2[19:4] = crac_out[15:0];
343
assign out_slt2[3:0] = 4'h0;
344
 
345
// Read Data
346
always @(posedge clk or negedge rst)
347
   begin
348
        if(!rst)                crac_din <= #1 16'h0;
349
        else
350
        if(crac_rd_done)        crac_din <= #1 in_slt2[19:4];
351
   end
352
 
353
////////////////////////////////////////////////////////////////////
354
//
355
// Codec Register Access Tracking
356
//
357
 
358
assign crac_valid = crac_wr | crac_rd;
359
 
360
always @(posedge clk)
361
        crac_we_r <= #1 crac_we;
362
 
363
always @(posedge clk or negedge rst)
364
        if(!rst)                        crac_wr <= #1 1'b0;
365
        else
366
        if(crac_we_r & !crac_out[31])   crac_wr <= #1 1'b1;
367
        else
368
        if(valid_ne)                    crac_wr <= #1 1'b0;
369
 
370
assign crac_wr_done = crac_wr & valid_ne;
371
 
372
always @(posedge clk or negedge rst)
373
        if(!rst)                        crac_rd <= #1 1'b0;
374
        else
375
        if(crac_we_r & crac_out[31])    crac_rd <= #1 1'b1;
376
        else
377
        if(rdd1 & valid_pe)             crac_rd <= #1 1'b0;
378
 
379
always @(posedge clk or negedge rst)
380
        if(!rst)                        rdd1 <= #1 1'b0;
381
        else
382
        if(crac_rd & valid_ne)          rdd1 <= #1 1'b1;
383
        else
384
        if(!crac_rd)                    rdd1 <= #1 1'b0;
385
 
386
always @(posedge clk or negedge rst)
387
        if(!rst)                                        rdd2 <= #1 1'b0;
388
        else
389
        if( (crac_rd & valid_ne) | (!rdd3 & rdd2) )     rdd2 <= #1 1'b1;
390
        else
391
        if(crac_rd_done)                                rdd2 <= #1 1'b0;
392
 
393
always @(posedge clk or negedge rst)
394
        if(!rst)                        rdd3 <= #1 1'b0;
395
        else
396
        if(rdd2 & valid_pe)             rdd3 <= #1 1'b1;
397
        else
398
        if(crac_rd_done)                rdd3 <= #1 1'b0;
399
 
400
always @(posedge clk)
401
        crac_rd_done <= #1 rdd3 & valid_pe;
402
 
403
always @(posedge clk)
404
        valid_r <= #1 valid;
405
 
406
assign valid_ne = !valid & valid_r;
407
 
408
assign valid_pe = valid & !valid_r;
409
 
410
endmodule
411
 
412
/////////////////////////////////////////////////////////////////////
413
////                                                             ////
414
////  WISHBONE AC 97 Controller                                  ////
415
////  DMA Interface                                              ////
416
////                                                             ////
417
////                                                             ////
418
////  Author: Rudolf Usselmann                                   ////
419
////          rudi@asics.ws                                      ////
420
////                                                             ////
421
////                                                             ////
422
////  Downloaded from: http://www.opencores.org/cores/ac97_ctrl/ ////
423
////                                                             ////
424
/////////////////////////////////////////////////////////////////////
425
////                                                             ////
426
//// Copyright (C) 2000-2002 Rudolf Usselmann                    ////
427
////                         www.asics.ws                        ////
428
////                         rudi@asics.ws                       ////
429
////                                                             ////
430
//// This source file may be used and distributed without        ////
431
//// restriction provided that this copyright statement is not   ////
432
//// removed from the file and that any derivative work contains ////
433
//// the original copyright notice and the associated disclaimer.////
434
////                                                             ////
435
////     THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY     ////
436
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   ////
437
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   ////
438
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      ////
439
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         ////
440
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    ////
441
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   ////
442
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        ////
443
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  ////
444
//// LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  ////
445
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  ////
446
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         ////
447
//// POSSIBILITY OF SUCH DAMAGE.                                 ////
448
////                                                             ////
449
/////////////////////////////////////////////////////////////////////
450
 
451
//  CVS Log
452
//
453
//  $Id: ac97_top.v,v 1.4 2006/11/20 17:13:43 tame Exp $
454
//
455
//  $Date: 2006/11/20 17:13:43 $
456
//  $Revision: 1.4 $
457
//  $Author: tame $
458
//  $Locker:  $
459
//  $State: Exp $
460
//
461
// Change History:
462
//               $Log: ac97_top.v,v $
463
//               Revision 1.4  2006/11/20 17:13:43  tame
464
//               Originally calculated values used.
465
//
466
//               Revision 1.3  2006/09/11 13:12:13  tame
467
//               Tried out high timing settings - works in hardware.
468
//
469
//               Revision 1.2  2006/08/16 08:46:04  tame
470
//               AC97 core: register set read/writable in first simulations; in hardware, however,
471
//               not yet
472
//
473
//               Revision 1.1  2006/08/14 15:25:09  tame
474
//               added ac97 codec from OpenCores
475
//               adapted configuration in ac97_defines module
476
//
477
//               Revision 1.4  2002/09/19 06:30:56  rudi
478
//               Fixed a bug reported by Igor. Apparently this bug only shows up when
479
//               the WB clock is very low (2x bit_clk). Updated Copyright header.
480
//
481
//               Revision 1.3  2002/03/05 04:44:05  rudi
482
//
483
//               - Fixed the order of the thrash hold bits to match the spec.
484
//               - Many minor synthesis cleanup items ...
485
//
486
//               Revision 1.2  2001/08/10 08:09:42  rudi
487
//
488
//               - Removed RTY_O output.
489
//               - Added Clock and Reset Inputs to documentation.
490
//               - Changed IO names to be more clear.
491
//               - Uniquifyed define names to be core specific.
492
//
493
//               Revision 1.1  2001/08/03 06:54:49  rudi
494
//
495
//
496
//               - Changed to new directory structure
497
//
498
//               Revision 1.1.1.1  2001/05/19 02:29:18  rudi
499
//               Initial Checkin
500
//
501
//
502
//
503
//
504
 
505
// `include "ac97_defines.v"
506
 
507
module ac97_dma_if(clk, rst,
508
                o3_status, o4_status, o6_status, o7_status, o8_status, o9_status,
509
                o3_empty, o4_empty, o6_empty, o7_empty, o8_empty, o9_empty,
510
                i3_status, i4_status, i6_status,
511
                i3_full, i4_full, i6_full,
512
 
513
                oc0_cfg, oc1_cfg, oc2_cfg, oc3_cfg, oc4_cfg, oc5_cfg,
514
                ic0_cfg, ic1_cfg, ic2_cfg,
515
 
516
                dma_req, dma_ack);
517
 
518
input           clk, rst;
519
input   [1:0]    o3_status, o4_status, o6_status, o7_status, o8_status, o9_status;
520
input           o3_empty, o4_empty, o6_empty, o7_empty, o8_empty, o9_empty;
521
input   [1:0]    i3_status, i4_status, i6_status;
522
input           i3_full, i4_full, i6_full;
523
input   [7:0]    oc0_cfg;
524
input   [7:0]    oc1_cfg;
525
input   [7:0]    oc2_cfg;
526
input   [7:0]    oc3_cfg;
527
input   [7:0]    oc4_cfg;
528
input   [7:0]    oc5_cfg;
529
input   [7:0]    ic0_cfg;
530
input   [7:0]    ic1_cfg;
531
input   [7:0]    ic2_cfg;
532
output  [8:0]    dma_req;
533
input   [8:0]    dma_ack;
534
 
535
////////////////////////////////////////////////////////////////////
536
//
537
// DMA Request Modules
538
//
539
 
540
ac97_dma_req u0(.clk(           clk             ),
541
                .rst(           rst             ),
542
                .cfg(           oc0_cfg         ),
543
                .status(        o3_status       ),
544
                .full_empty(    o3_empty        ),
545
                .dma_req(       dma_req[0]       ),
546
                .dma_ack(       dma_ack[0]       )
547
                );
548
 
549
ac97_dma_req u1(.clk(           clk             ),
550
                .rst(           rst             ),
551
                .cfg(           oc1_cfg         ),
552
                .status(        o4_status       ),
553
                .full_empty(    o4_empty        ),
554
                .dma_req(       dma_req[1]      ),
555
                .dma_ack(       dma_ack[1]      )
556
                );
557
 
558
`ifdef AC97_CENTER
559
ac97_dma_req u2(.clk(           clk             ),
560
                .rst(           rst             ),
561
                .cfg(           oc2_cfg         ),
562
                .status(        o6_status       ),
563
                .full_empty(    o6_empty        ),
564
                .dma_req(       dma_req[2]      ),
565
                .dma_ack(       dma_ack[2]      )
566
                );
567
`else
568
assign dma_req[2] = 1'b0;
569
`endif
570
 
571
`ifdef AC97_SURROUND
572
ac97_dma_req u3(.clk(           clk             ),
573
                .rst(           rst             ),
574
                .cfg(           oc3_cfg         ),
575
                .status(        o7_status       ),
576
                .full_empty(    o7_empty        ),
577
                .dma_req(       dma_req[3]      ),
578
                .dma_ack(       dma_ack[3]      )
579
                );
580
 
581
ac97_dma_req u4(.clk(           clk             ),
582
                .rst(           rst             ),
583
                .cfg(           oc4_cfg         ),
584
                .status(        o8_status       ),
585
                .full_empty(    o8_empty        ),
586
                .dma_req(       dma_req[4]      ),
587
                .dma_ack(       dma_ack[4]      )
588
                );
589
`else
590
assign dma_req[3] = 1'b0;
591
assign dma_req[4] = 1'b0;
592
`endif
593
 
594
`ifdef AC97_LFE
595
ac97_dma_req u5(.clk(           clk             ),
596
                .rst(           rst             ),
597
                .cfg(           oc5_cfg         ),
598
                .status(        o9_status       ),
599
                .full_empty(    o9_empty        ),
600
                .dma_req(       dma_req[5]      ),
601
                .dma_ack(       dma_ack[5]      )
602
                );
603
`else
604
assign dma_req[5] = 1'b0;
605
`endif
606
 
607
`ifdef AC97_SIN
608
ac97_dma_req u6(.clk(           clk             ),
609
                .rst(           rst             ),
610
                .cfg(           ic0_cfg         ),
611
                .status(        i3_status       ),
612
                .full_empty(    i3_full         ),
613
                .dma_req(       dma_req[6]      ),
614
                .dma_ack(       dma_ack[6]      )
615
                );
616
 
617
ac97_dma_req u7(.clk(           clk             ),
618
                .rst(           rst             ),
619
                .cfg(           ic1_cfg         ),
620
                .status(        i4_status       ),
621
                .full_empty(    i4_full         ),
622
                .dma_req(       dma_req[7]      ),
623
                .dma_ack(       dma_ack[7]      )
624
                );
625
`else
626
assign dma_req[6] = 1'b0;
627
assign dma_req[7] = 1'b0;
628
`endif
629
 
630
`ifdef AC97_MICIN
631
ac97_dma_req u8(.clk(           clk             ),
632
                .rst(           rst             ),
633
                .cfg(           ic2_cfg         ),
634
                .status(        i6_status       ),
635
                .full_empty(    i6_full         ),
636
                .dma_req(       dma_req[8]      ),
637
                .dma_ack(       dma_ack[8]      )
638
                );
639
`else
640
assign dma_req[8] = 1'b0;
641
`endif
642
 
643
endmodule
644
 
645
 
646
/////////////////////////////////////////////////////////////////////
647
////                                                             ////
648
////  WISHBONE AC 97 Controller                                  ////
649
////  DMA Request Module                                         ////
650
////                                                             ////
651
////                                                             ////
652
////  Author: Rudolf Usselmann                                   ////
653
////          rudi@asics.ws                                      ////
654
////                                                             ////
655
////                                                             ////
656
////  Downloaded from: http://www.opencores.org/cores/ac97_ctrl/ ////
657
////                                                             ////
658
/////////////////////////////////////////////////////////////////////
659
////                                                             ////
660
//// Copyright (C) 2000-2002 Rudolf Usselmann                    ////
661
////                         www.asics.ws                        ////
662
////                         rudi@asics.ws                       ////
663
////                                                             ////
664
//// This source file may be used and distributed without        ////
665
//// restriction provided that this copyright statement is not   ////
666
//// removed from the file and that any derivative work contains ////
667
//// the original copyright notice and the associated disclaimer.////
668
////                                                             ////
669
////     THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY     ////
670
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   ////
671
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   ////
672
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      ////
673
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         ////
674
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    ////
675
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   ////
676
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        ////
677
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  ////
678
//// LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  ////
679
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  ////
680
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         ////
681
//// POSSIBILITY OF SUCH DAMAGE.                                 ////
682
////                                                             ////
683
/////////////////////////////////////////////////////////////////////
684
 
685
//  CVS Log
686
//
687
//  $Id: ac97_top.v,v 1.4 2006/11/20 17:13:43 tame Exp $
688
//
689
//  $Date: 2006/11/20 17:13:43 $
690
//  $Revision: 1.4 $
691
//  $Author: tame $
692
//  $Locker:  $
693
//  $State: Exp $
694
//
695
// Change History:
696
//               $Log: ac97_top.v,v $
697
//               Revision 1.4  2006/11/20 17:13:43  tame
698
//               Originally calculated values used.
699
//
700
//               Revision 1.3  2006/09/11 13:12:13  tame
701
//               Tried out high timing settings - works in hardware.
702
//
703
//               Revision 1.2  2006/08/16 08:46:04  tame
704
//               AC97 core: register set read/writable in first simulations; in hardware, however,
705
//               not yet
706
//
707
//               Revision 1.1  2006/08/14 15:25:09  tame
708
//               added ac97 codec from OpenCores
709
//               adapted configuration in ac97_defines module
710
//
711
//               Revision 1.3  2002/09/19 06:30:56  rudi
712
//               Fixed a bug reported by Igor. Apparently this bug only shows up when
713
//               the WB clock is very low (2x bit_clk). Updated Copyright header.
714
//
715
//               Revision 1.2  2002/03/05 04:44:05  rudi
716
//
717
//               - Fixed the order of the thrash hold bits to match the spec.
718
//               - Many minor synthesis cleanup items ...
719
//
720
//               Revision 1.1  2001/08/03 06:54:49  rudi
721
//
722
//
723
//               - Changed to new directory structure
724
//
725
//               Revision 1.1.1.1  2001/05/19 02:29:16  rudi
726
//               Initial Checkin
727
//
728
//
729
//
730
//
731
 
732
// `include "ac97_defines.v"
733
 
734
module ac97_dma_req(clk, rst, cfg, status, full_empty, dma_req, dma_ack);
735
input           clk, rst;
736
input   [7:0]    cfg;
737
input   [1:0]    status;
738
input           full_empty;
739
output          dma_req;
740
input           dma_ack;
741
 
742
////////////////////////////////////////////////////////////////////
743
//
744
// Local Wires
745
//
746
reg     dma_req_d;
747
reg     dma_req_r1;
748
reg     dma_req;
749
 
750
////////////////////////////////////////////////////////////////////
751
//
752
// Misc Logic
753
//
754
 
755
always @(cfg or status or full_empty)
756
        case(cfg[5:4])  // synopsys parallel_case full_case
757
                        // REQ = Ch_EN & DMA_EN & Status
758
                        // 1/4 full/empty
759
           2'h2: dma_req_d = cfg[0] & cfg[6] & (full_empty | (status == 2'h0));
760
                        // 1/2 full/empty
761
           2'h1: dma_req_d = cfg[0] & cfg[6] & (full_empty | (status[1] == 1'h0));
762
                        // 3/4 full/empty
763
           2'h0: dma_req_d = cfg[0] & cfg[6] & (full_empty | (status < 2'h3));
764
           2'h3: dma_req_d = cfg[0] & cfg[6] & full_empty;
765
        endcase
766
 
767
always @(posedge clk)
768
        dma_req_r1 <= #1 dma_req_d & !dma_ack;
769
 
770
always @(posedge clk or negedge rst)
771
        if(!rst)                                dma_req <= #1 1'b0;
772
        else
773
        if(dma_req_r1 & dma_req_d & !dma_ack)   dma_req <= #1 1'b1;
774
        else
775
        if(dma_ack)                             dma_req <= #1 1'b0;
776
 
777
endmodule
778
 
779
/////////////////////////////////////////////////////////////////////
780
////                                                             ////
781
////  WISHBONE AC 97 Controller                                  ////
782
////  FIFO Control Module                                        ////
783
////                                                             ////
784
////                                                             ////
785
////  Author: Rudolf Usselmann                                   ////
786
////          rudi@asics.ws                                      ////
787
////                                                             ////
788
////                                                             ////
789
////  Downloaded from: http://www.opencores.org/cores/ac97_ctrl/ ////
790
////                                                             ////
791
/////////////////////////////////////////////////////////////////////
792
////                                                             ////
793
//// Copyright (C) 2000-2002 Rudolf Usselmann                    ////
794
////                         www.asics.ws                        ////
795
////                         rudi@asics.ws                       ////
796
////                                                             ////
797
//// This source file may be used and distributed without        ////
798
//// restriction provided that this copyright statement is not   ////
799
//// removed from the file and that any derivative work contains ////
800
//// the original copyright notice and the associated disclaimer.////
801
////                                                             ////
802
////     THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY     ////
803
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   ////
804
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   ////
805
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      ////
806
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         ////
807
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    ////
808
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   ////
809
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        ////
810
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  ////
811
//// LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  ////
812
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  ////
813
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         ////
814
//// POSSIBILITY OF SUCH DAMAGE.                                 ////
815
////                                                             ////
816
/////////////////////////////////////////////////////////////////////
817
 
818
//  CVS Log
819
//
820
//  $Id: ac97_top.v,v 1.4 2006/11/20 17:13:43 tame Exp $
821
//
822
//  $Date: 2006/11/20 17:13:43 $
823
//  $Revision: 1.4 $
824
//  $Author: tame $
825
//  $Locker:  $
826
//  $State: Exp $
827
//
828
// Change History:
829
//               $Log: ac97_top.v,v $
830
//               Revision 1.4  2006/11/20 17:13:43  tame
831
//               Originally calculated values used.
832
//
833
//               Revision 1.3  2006/09/11 13:12:13  tame
834
//               Tried out high timing settings - works in hardware.
835
//
836
//               Revision 1.2  2006/08/16 08:46:04  tame
837
//               AC97 core: register set read/writable in first simulations; in hardware, however,
838
//               not yet
839
//
840
//               Revision 1.1  2006/08/14 15:25:09  tame
841
//               added ac97 codec from OpenCores
842
//               adapted configuration in ac97_defines module
843
//
844
//               Revision 1.3  2002/09/19 06:30:56  rudi
845
//               Fixed a bug reported by Igor. Apparently this bug only shows up when
846
//               the WB clock is very low (2x bit_clk). Updated Copyright header.
847
//
848
//               Revision 1.2  2002/03/05 04:44:05  rudi
849
//
850
//               - Fixed the order of the thrash hold bits to match the spec.
851
//               - Many minor synthesis cleanup items ...
852
//
853
//               Revision 1.1  2001/08/03 06:54:49  rudi
854
//
855
//
856
//               - Changed to new directory structure
857
//
858
//               Revision 1.1.1.1  2001/05/19 02:29:18  rudi
859
//               Initial Checkin
860
//
861
//
862
//
863
//
864
 
865
// `include "ac97_defines.v"
866
 
867
module ac97_fifo_ctrl(  clk,
868
                        valid, ch_en, srs, full_empty, req, crdy,
869
                        en_out, en_out_l
870
                        );
871
input           clk;
872
input           valid;
873
input           ch_en;          // Channel Enable
874
input           srs;            // Sample Rate Select
875
input           full_empty;     // Fifo Status
876
input           req;            // Codec Request
877
input           crdy;           // Codec Ready
878
output          en_out;         // Output read/write pulse
879
output          en_out_l;       // Latched Output
880
 
881
////////////////////////////////////////////////////////////////////
882
//
883
// Local Wires
884
//
885
 
886
reg     en_out_l, en_out_l2;
887
reg     full_empty_r;
888
 
889
////////////////////////////////////////////////////////////////////
890
//
891
// Misc Logic
892
//
893
 
894
always @(posedge clk)
895
        if(!valid)      full_empty_r <= #1 full_empty;
896
 
897
always @(posedge clk)
898
        if(valid & ch_en & !full_empty_r & crdy & (!srs | (srs & req) ) )
899
                en_out_l <= #1 1'b1;
900
        else
901
        if(!valid & !(ch_en & !full_empty_r & crdy & (!srs | (srs & req) )) )
902
                en_out_l <= #1 1'b0;
903
 
904
always @(posedge clk)
905
        en_out_l2 <= #1 en_out_l & valid;
906
 
907
assign en_out = en_out_l & !en_out_l2 & valid;
908
 
909
endmodule
910
/////////////////////////////////////////////////////////////////////
911
////                                                             ////
912
////  WISHBONE AC 97 Controller                                  ////
913
////  Output FIFO                                                ////
914
////                                                             ////
915
////                                                             ////
916
////  Author: Rudolf Usselmann                                   ////
917
////          rudi@asics.ws                                      ////
918
////                                                             ////
919
////                                                             ////
920
////  Downloaded from: http://www.opencores.org/cores/ac97_ctrl/ ////
921
////                                                             ////
922
/////////////////////////////////////////////////////////////////////
923
////                                                             ////
924
//// Copyright (C) 2000-2002 Rudolf Usselmann                    ////
925
////                         www.asics.ws                        ////
926
////                         rudi@asics.ws                       ////
927
////                                                             ////
928
//// This source file may be used and distributed without        ////
929
//// restriction provided that this copyright statement is not   ////
930
//// removed from the file and that any derivative work contains ////
931
//// the original copyright notice and the associated disclaimer.////
932
////                                                             ////
933
////     THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY     ////
934
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   ////
935
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   ////
936
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      ////
937
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         ////
938
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    ////
939
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   ////
940
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        ////
941
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  ////
942
//// LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  ////
943
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  ////
944
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         ////
945
//// POSSIBILITY OF SUCH DAMAGE.                                 ////
946
////                                                             ////
947
/////////////////////////////////////////////////////////////////////
948
 
949
//  CVS Log
950
//
951
//  $Id: ac97_top.v,v 1.4 2006/11/20 17:13:43 tame Exp $
952
//
953
//  $Date: 2006/11/20 17:13:43 $
954
//  $Revision: 1.4 $
955
//  $Author: tame $
956
//  $Locker:  $
957
//  $State: Exp $
958
//
959
// Change History:
960
//               $Log: ac97_top.v,v $
961
//               Revision 1.4  2006/11/20 17:13:43  tame
962
//               Originally calculated values used.
963
//
964
//               Revision 1.3  2006/09/11 13:12:13  tame
965
//               Tried out high timing settings - works in hardware.
966
//
967
//               Revision 1.2  2006/08/16 08:46:04  tame
968
//               AC97 core: register set read/writable in first simulations; in hardware, however,
969
//               not yet
970
//
971
//               Revision 1.1  2006/08/14 15:25:09  tame
972
//               added ac97 codec from OpenCores
973
//               adapted configuration in ac97_defines module
974
//
975
//               Revision 1.5  2002/11/14 17:10:12  rudi
976
//               Fixed a bug in the IN-FIFO - 18 bit samples where not alligned correctly.
977
//
978
//               Revision 1.4  2002/09/19 06:30:56  rudi
979
//               Fixed a bug reported by Igor. Apparently this bug only shows up when
980
//               the WB clock is very low (2x bit_clk). Updated Copyright header.
981
//
982
//               Revision 1.3  2002/03/11 03:21:22  rudi
983
//
984
//               - Added defines to select fifo depth between 4, 8 and 16 entries.
985
//
986
//               Revision 1.2  2002/03/05 04:44:05  rudi
987
//
988
//               - Fixed the order of the thrash hold bits to match the spec.
989
//               - Many minor synthesis cleanup items ...
990
//
991
//               Revision 1.1  2001/08/03 06:54:50  rudi
992
//
993
//
994
//               - Changed to new directory structure
995
//
996
//               Revision 1.1.1.1  2001/05/19 02:29:14  rudi
997
//               Initial Checkin
998
//
999
//
1000
//
1001
//
1002
 
1003
// `include "ac97_defines.v"
1004
 
1005
`ifdef AC97_IN_FIFO_DEPTH_4
1006
 
1007
// 4 entry deep verion of the input FIFO
1008
 
1009
module ac97_in_fifo(clk, rst, en, mode, din, we, dout, re, status, full, empty);
1010
 
1011
input           clk, rst;
1012
input           en;
1013
input   [1:0]    mode;
1014
input   [19:0]   din;
1015
input           we;
1016
output  [31:0]   dout;
1017
input           re;
1018
output  [1:0]    status;
1019
output          full;
1020
output          empty;
1021
 
1022
 
1023
////////////////////////////////////////////////////////////////////
1024
//
1025
// Local Wires
1026
//
1027
 
1028
reg     [31:0]   mem[0:3];
1029
reg     [31:0]   dout;
1030
 
1031
reg     [3:0]    wp;
1032
reg     [2:0]    rp;
1033
 
1034
wire    [3:0]    wp_p1;
1035
 
1036
reg     [1:0]    status;
1037
reg     [15:0]   din_tmp1;
1038
reg     [31:0]   din_tmp;
1039
wire            m16b;
1040
reg             full, empty;
1041
 
1042
////////////////////////////////////////////////////////////////////
1043
//
1044
// Misc Logic
1045
//
1046
 
1047
assign m16b = (mode == 2'h0);   // 16 Bit Mode
1048
 
1049
always @(posedge clk)
1050
        if(!en)         wp <= #1 4'h0;
1051
        else
1052
        if(we)          wp <= #1 wp_p1;
1053
 
1054
assign wp_p1 = m16b ? (wp + 4'h1) : (wp + 4'h2);
1055
 
1056
always @(posedge clk)
1057
        if(!en)         rp <= #1 3'h0;
1058
        else
1059
        if(re)          rp <= #1 rp + 3'h1;
1060
 
1061
always @(posedge clk)
1062
        status <= #1 ((rp[1:0] - wp[2:1]) - 2'h1);
1063
 
1064
always @(posedge clk)
1065
        empty <= #1 (wp[3:1] == rp[2:0]) & (m16b ? !wp[0] : 1'b0);
1066
 
1067
always @(posedge clk)
1068
        full  <= #1 (wp[2:1] == rp[1:0]) & (wp[3] != rp[2]);
1069
 
1070
// Fifo Output
1071
always @(posedge clk)
1072
        dout <= #1 mem[ rp[1:0] ];
1073
 
1074
// Fifo Input Half Word Latch
1075
always @(posedge clk)
1076
        if(we & !wp[0])  din_tmp1 <= #1 din[19:4];
1077
 
1078
always @(mode or din_tmp1 or din)
1079
        case(mode)      // synopsys parallel_case full_case
1080
           2'h0: din_tmp = {din[19:4], din_tmp1};       // 16 Bit Output
1081
           2'h1: din_tmp = {14'h0, din[19:2]};          // 18 bit Output
1082
           2'h2: din_tmp = {11'h0, din[19:0]};           // 20 Bit Output
1083
        endcase
1084
 
1085
always @(posedge clk)
1086
        if(we & (!m16b | (m16b & wp[0]) ) )      mem[ wp[2:1] ] <= #1 din_tmp;
1087
 
1088
endmodule
1089
 
1090
`endif
1091
 
1092
`ifdef AC97_IN_FIFO_DEPTH_8
1093
 
1094
// 8 entry deep verion of the input FIFO
1095
 
1096
module ac97_in_fifo(clk, rst, en, mode, din, we, dout, re, status, full, empty);
1097
 
1098
input           clk, rst;
1099
input           en;
1100
input   [1:0]    mode;
1101
input   [19:0]   din;
1102
input           we;
1103
output  [31:0]   dout;
1104
input           re;
1105
output  [1:0]    status;
1106
output          full;
1107
output          empty;
1108
 
1109
 
1110
////////////////////////////////////////////////////////////////////
1111
//
1112
// Local Wires
1113
//
1114
 
1115
reg     [31:0]   mem[0:7];
1116
reg     [31:0]   dout;
1117
 
1118
reg     [4:0]    wp;
1119
reg     [3:0]    rp;
1120
 
1121
wire    [4:0]    wp_p1;
1122
 
1123
reg     [1:0]    status;
1124
reg     [15:0]   din_tmp1;
1125
reg     [31:0]   din_tmp;
1126
wire            m16b;
1127
reg             full, empty;
1128
 
1129
////////////////////////////////////////////////////////////////////
1130
//
1131
// Misc Logic
1132
//
1133
 
1134
assign m16b = (mode == 2'h0);   // 16 Bit Mode
1135
 
1136
always @(posedge clk)
1137
        if(!en)         wp <= #1 5'h0;
1138
        else
1139
        if(we)          wp <= #1 wp_p1;
1140
 
1141
assign wp_p1 = m16b ? (wp + 5'h1) : (wp + 5'h2);
1142
 
1143
always @(posedge clk)
1144
        if(!en)         rp <= #1 4'h0;
1145
        else
1146
        if(re)          rp <= #1 rp + 4'h1;
1147
 
1148
always @(posedge clk)
1149
        status <= #1 ((rp[2:1] - wp[3:2]) - 2'h1);
1150
 
1151
always @(posedge clk)
1152
        empty <= #1 (wp[4:1] == rp[3:0]) & (m16b ? !wp[0] : 1'b0);
1153
 
1154
always @(posedge clk)
1155
        full  <= #1 (wp[3:1] == rp[2:0]) & (wp[4] != rp[3]);
1156
 
1157
// Fifo Output
1158
always @(posedge clk)
1159
        dout <= #1 mem[ rp[2:0] ];
1160
 
1161
// Fifo Input Half Word Latch
1162
always @(posedge clk)
1163
        if(we & !wp[0])  din_tmp1 <= #1 din[19:4];
1164
 
1165
always @(mode or din_tmp1 or din)
1166
        case(mode)      // synopsys parallel_case full_case
1167
           2'h0: din_tmp = {din[19:4], din_tmp1};       // 16 Bit Output
1168
           2'h1: din_tmp = {14'h0, din[19:2]};          // 18 bit Output
1169
           2'h2: din_tmp = {11'h0, din[19:0]};           // 20 Bit Output
1170
        endcase
1171
 
1172
always @(posedge clk)
1173
        if(we & (!m16b | (m16b & wp[0]) ) )      mem[ wp[3:1] ] <= #1 din_tmp;
1174
 
1175
endmodule
1176
 
1177
`endif
1178
 
1179
 
1180
`ifdef AC97_IN_FIFO_DEPTH_16
1181
 
1182
// 16 entry deep verion of the input FIFO
1183
 
1184
module ac97_in_fifo(clk, rst, en, mode, din, we, dout, re, status, full, empty);
1185
 
1186
input           clk, rst;
1187
input           en;
1188
input   [1:0]    mode;
1189
input   [19:0]   din;
1190
input           we;
1191
output  [31:0]   dout;
1192
input           re;
1193
output  [1:0]    status;
1194
output          full;
1195
output          empty;
1196
 
1197
 
1198
////////////////////////////////////////////////////////////////////
1199
//
1200
// Local Wires
1201
//
1202
 
1203
reg     [31:0]   mem[0:15];
1204
reg     [31:0]   dout;
1205
 
1206
reg     [5:0]    wp;
1207
reg     [4:0]    rp;
1208
 
1209
wire    [5:0]    wp_p1;
1210
 
1211
reg     [1:0]    status;
1212
reg     [15:0]   din_tmp1;
1213
reg     [31:0]   din_tmp;
1214
wire            m16b;
1215
reg             full, empty;
1216
 
1217
////////////////////////////////////////////////////////////////////
1218
//
1219
// Misc Logic
1220
//
1221
 
1222
assign m16b = (mode == 2'h0);   // 16 Bit Mode
1223
 
1224
always @(posedge clk)
1225
        if(!en)         wp <= #1 6'h0;
1226
        else
1227
        if(we)          wp <= #1 wp_p1;
1228
 
1229
assign wp_p1 = m16b ? (wp + 6'h1) : (wp + 6'h2);
1230
 
1231
always @(posedge clk)
1232
        if(!en)         rp <= #1 5'h0;
1233
        else
1234
        if(re)          rp <= #1 rp + 5'h1;
1235
 
1236
always @(posedge clk)
1237
        status <= #1 ((rp[3:2] - wp[4:3]) - 2'h1);
1238
 
1239
always @(posedge clk)
1240
        empty <= #1 (wp[5:1] == rp[4:0]) & (m16b ? !wp[0] : 1'b0);
1241
 
1242
always @(posedge clk)
1243
        full  <= #1 (wp[4:1] == rp[3:0]) & (wp[5] != rp[4]);
1244
 
1245
// Fifo Output
1246
always @(posedge clk)
1247
        dout <= #1 mem[ rp[3:0] ];
1248
 
1249
// Fifo Input Half Word Latch
1250
always @(posedge clk)
1251
        if(we & !wp[0])  din_tmp1 <= #1 din[19:4];
1252
 
1253
always @(mode or din_tmp1 or din)
1254
        case(mode)      // synopsys parallel_case full_case
1255
           2'h0: din_tmp = {din[19:4], din_tmp1};       // 16 Bit Output
1256
           2'h1: din_tmp = {14'h0, din[19:2]};          // 18 bit Output
1257
           2'h2: din_tmp = {11'h0, din[19:0]};           // 20 Bit Output
1258
        endcase
1259
 
1260
always @(posedge clk)
1261
        if(we & (!m16b | (m16b & wp[0]) ) )      mem[ wp[4:1] ] <= #1 din_tmp;
1262
 
1263
endmodule
1264
 
1265
`endif
1266
/////////////////////////////////////////////////////////////////////
1267
////                                                             ////
1268
////  WISHBONE AC 97 Controller                                  ////
1269
////  Interrupt Logic                                            ////
1270
////                                                             ////
1271
////                                                             ////
1272
////  Author: Rudolf Usselmann                                   ////
1273
////          rudi@asics.ws                                      ////
1274
////                                                             ////
1275
////                                                             ////
1276
////  Downloaded from: http://www.opencores.org/cores/ac97_ctrl/ ////
1277
////                                                             ////
1278
/////////////////////////////////////////////////////////////////////
1279
////                                                             ////
1280
//// Copyright (C) 2000-2002 Rudolf Usselmann                    ////
1281
////                         www.asics.ws                        ////
1282
////                         rudi@asics.ws                       ////
1283
////                                                             ////
1284
//// This source file may be used and distributed without        ////
1285
//// restriction provided that this copyright statement is not   ////
1286
//// removed from the file and that any derivative work contains ////
1287
//// the original copyright notice and the associated disclaimer.////
1288
////                                                             ////
1289
////     THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY     ////
1290
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   ////
1291
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   ////
1292
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      ////
1293
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         ////
1294
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    ////
1295
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   ////
1296
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        ////
1297
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  ////
1298
//// LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  ////
1299
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  ////
1300
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         ////
1301
//// POSSIBILITY OF SUCH DAMAGE.                                 ////
1302
////                                                             ////
1303
/////////////////////////////////////////////////////////////////////
1304
 
1305
//  CVS Log
1306
//
1307
//  $Id: ac97_top.v,v 1.4 2006/11/20 17:13:43 tame Exp $
1308
//
1309
//  $Date: 2006/11/20 17:13:43 $
1310
//  $Revision: 1.4 $
1311
//  $Author: tame $
1312
//  $Locker:  $
1313
//  $State: Exp $
1314
//
1315
// Change History:
1316
//               $Log: ac97_top.v,v $
1317
//               Revision 1.4  2006/11/20 17:13:43  tame
1318
//               Originally calculated values used.
1319
//
1320
//               Revision 1.3  2006/09/11 13:12:13  tame
1321
//               Tried out high timing settings - works in hardware.
1322
//
1323
//               Revision 1.2  2006/08/16 08:46:04  tame
1324
//               AC97 core: register set read/writable in first simulations; in hardware, however,
1325
//               not yet
1326
//
1327
//               Revision 1.1  2006/08/14 15:25:09  tame
1328
//               added ac97 codec from OpenCores
1329
//               adapted configuration in ac97_defines module
1330
//
1331
//               Revision 1.3  2002/09/19 06:30:56  rudi
1332
//               Fixed a bug reported by Igor. Apparently this bug only shows up when
1333
//               the WB clock is very low (2x bit_clk). Updated Copyright header.
1334
//
1335
//               Revision 1.2  2002/03/05 04:44:05  rudi
1336
//
1337
//               - Fixed the order of the thrash hold bits to match the spec.
1338
//               - Many minor synthesis cleanup items ...
1339
//
1340
//               Revision 1.1  2001/08/03 06:54:50  rudi
1341
//
1342
//
1343
//               - Changed to new directory structure
1344
//
1345
//               Revision 1.1.1.1  2001/05/19 02:29:18  rudi
1346
//               Initial Checkin
1347
//
1348
//
1349
//
1350
//
1351
 
1352
// `include "ac97_defines.v"
1353
 
1354
module ac97_int(clk, rst,
1355
 
1356
                // Register File Interface
1357
                int_set,
1358
 
1359
                // FIFO Interface
1360
                cfg, status, full_empty, full, empty, re, we
1361
                );
1362
 
1363
input           clk, rst;
1364
output  [2:0]    int_set;
1365
 
1366
input   [7:0]    cfg;
1367
input   [1:0]    status;
1368
input           full_empty, full, empty, re, we;
1369
 
1370
////////////////////////////////////////////////////////////////////
1371
//
1372
// Local Wires
1373
//
1374
 
1375
reg     [2:0]    int_set;
1376
 
1377
////////////////////////////////////////////////////////////////////
1378
//
1379
// Interrupt Logic
1380
//
1381
 
1382
always @(posedge clk or negedge rst)
1383
        if(!rst)        int_set[0] <= #1 1'b0;
1384
        else
1385
        case(cfg[5:4])  // synopsys parallel_case full_case
1386
                        // 1/4 full/empty
1387
           2'h2: int_set[0] <= #1 cfg[0] & (full_empty | (status == 2'h0));
1388
                        // 1/2 full/empty
1389
           2'h1: int_set[0] <= #1 cfg[0] & (full_empty | (status[1] == 1'h0));
1390
                        // 3/4 full/empty
1391
           2'h0: int_set[0] <= #1 cfg[0] & (full_empty | (status < 2'h3));
1392
           2'h3: int_set[0] <= #1 cfg[0] & full_empty;
1393
        endcase
1394
 
1395
always @(posedge clk or negedge rst)
1396
        if(!rst)        int_set[1] <= #1 1'b0;
1397
        else
1398
        if(empty & re)  int_set[1] <= #1 1'b1;
1399
 
1400
always @(posedge clk or negedge rst)
1401
        if(!rst)        int_set[2] <= #1 1'b0;
1402
        else
1403
        if(full & we)   int_set[2] <= #1 1'b1;
1404
 
1405
endmodule
1406
/////////////////////////////////////////////////////////////////////
1407
////                                                             ////
1408
////  WISHBONE AC 97 Controller                                  ////
1409
////  Output FIFO                                                ////
1410
////                                                             ////
1411
////                                                             ////
1412
////  Author: Rudolf Usselmann                                   ////
1413
////          rudi@asics.ws                                      ////
1414
////                                                             ////
1415
////                                                             ////
1416
////  Downloaded from: http://www.opencores.org/cores/ac97_ctrl/ ////
1417
////                                                             ////
1418
/////////////////////////////////////////////////////////////////////
1419
////                                                             ////
1420
//// Copyright (C) 2000-2002 Rudolf Usselmann                    ////
1421
////                         www.asics.ws                        ////
1422
////                         rudi@asics.ws                       ////
1423
////                                                             ////
1424
//// This source file may be used and distributed without        ////
1425
//// restriction provided that this copyright statement is not   ////
1426
//// removed from the file and that any derivative work contains ////
1427
//// the original copyright notice and the associated disclaimer.////
1428
////                                                             ////
1429
////     THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY     ////
1430
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   ////
1431
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   ////
1432
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      ////
1433
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         ////
1434
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    ////
1435
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   ////
1436
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        ////
1437
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  ////
1438
//// LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  ////
1439
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  ////
1440
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         ////
1441
//// POSSIBILITY OF SUCH DAMAGE.                                 ////
1442
////                                                             ////
1443
/////////////////////////////////////////////////////////////////////
1444
 
1445
//  CVS Log
1446
//
1447
//  $Id: ac97_top.v,v 1.4 2006/11/20 17:13:43 tame Exp $
1448
//
1449
//  $Date: 2006/11/20 17:13:43 $
1450
//  $Revision: 1.4 $
1451
//  $Author: tame $
1452
//  $Locker:  $
1453
//  $State: Exp $
1454
//
1455
// Change History:
1456
//               $Log: ac97_top.v,v $
1457
//               Revision 1.4  2006/11/20 17:13:43  tame
1458
//               Originally calculated values used.
1459
//
1460
//               Revision 1.3  2006/09/11 13:12:13  tame
1461
//               Tried out high timing settings - works in hardware.
1462
//
1463
//               Revision 1.2  2006/08/16 08:46:04  tame
1464
//               AC97 core: register set read/writable in first simulations; in hardware, however,
1465
//               not yet
1466
//
1467
//               Revision 1.1  2006/08/14 15:25:09  tame
1468
//               added ac97 codec from OpenCores
1469
//               adapted configuration in ac97_defines module
1470
//
1471
//               Revision 1.4  2002/09/19 06:30:56  rudi
1472
//               Fixed a bug reported by Igor. Apparently this bug only shows up when
1473
//               the WB clock is very low (2x bit_clk). Updated Copyright header.
1474
//
1475
//               Revision 1.3  2002/03/11 03:21:22  rudi
1476
//
1477
//               - Added defines to select fifo depth between 4, 8 and 16 entries.
1478
//
1479
//               Revision 1.1  2001/08/03 06:54:50  rudi
1480
//
1481
//
1482
//               - Changed to new directory structure
1483
//
1484
//               Revision 1.1.1.1  2001/05/19 02:29:16  rudi
1485
//               Initial Checkin
1486
//
1487
//
1488
//
1489
//
1490
 
1491
// `include "ac97_defines.v"
1492
 
1493
`ifdef AC97_OUT_FIFO_DEPTH_4
1494
 
1495
// 4 Entry Deep version of the Output FIFO
1496
 
1497
module ac97_out_fifo(clk, rst, en, mode, din, we, dout, re, status, full, empty);
1498
 
1499
input           clk, rst;
1500
input           en;
1501
input   [1:0]    mode;
1502
input   [31:0]   din;
1503
input           we;
1504
output  [19:0]   dout;
1505
input           re;
1506
output  [1:0]    status;
1507
output          full;
1508
output          empty;
1509
 
1510
 
1511
////////////////////////////////////////////////////////////////////
1512
//
1513
// Local Wires
1514
//
1515
 
1516
reg     [31:0]   mem[0:3];
1517
 
1518
reg     [2:0]    wp;
1519
reg     [3:0]    rp;
1520
 
1521
wire    [2:0]    wp_p1;
1522
 
1523
reg     [1:0]    status;
1524
reg     [19:0]   dout;
1525
wire    [31:0]   dout_tmp;
1526
wire    [15:0]   dout_tmp1;
1527
wire            m16b;
1528
reg             empty;
1529
 
1530
////////////////////////////////////////////////////////////////////
1531
//
1532
// Misc Logic
1533
//
1534
 
1535
assign m16b = (mode == 2'h0);   // 16 Bit Mode
1536
 
1537
always @(posedge clk)
1538
        if(!en)         wp <= #1 3'h0;
1539
        else
1540
        if(we)          wp <= #1 wp_p1;
1541
 
1542
assign wp_p1 = wp + 3'h1;
1543
 
1544
always @(posedge clk)
1545
        if(!en)         rp <= #1 4'h0;
1546
        else
1547
        if(re & m16b)   rp <= #1 rp + 4'h1;
1548
        else
1549
        if(re & !m16b)  rp <= #1 rp + 4'h2;
1550
 
1551
always @(posedge clk)
1552
        status <= #1 (wp[1:0] - rp[2:1]) - 2'h1;
1553
 
1554
wire    [3:0]    rp_p1 = rp[3:0] + 4'h1;
1555
 
1556
always @(posedge clk)
1557
        empty <= #1 (rp_p1[3:1] == wp[2:0]) & (m16b ? rp_p1[0] : 1'b1);
1558
 
1559
assign full  = (wp[1:0] == rp[2:1]) & (wp[2] != rp[3]);
1560
 
1561
// Fifo Output
1562
assign dout_tmp = mem[ rp[2:1] ];
1563
 
1564
// Fifo Output Half Word Select
1565
assign dout_tmp1 = rp[0] ? dout_tmp[31:16] : dout_tmp[15:0];
1566
 
1567
always @(posedge clk)
1568
        if(!en)         dout <= #1 20'h0;
1569
        else
1570
        if(re)
1571
                case(mode)      // synopsys parallel_case full_case
1572
                   2'h0: dout <= #1 {dout_tmp1, 4'h0};          // 16 Bit Output
1573
                   2'h1: dout <= #1 {dout_tmp[17:0], 2'h0};      // 18 bit Output
1574
                   2'h2: dout <= #1 dout_tmp[19:0];              // 20 Bit Output
1575
                endcase
1576
 
1577
always @(posedge clk)
1578
        if(we)  mem[wp[1:0]] <= #1 din;
1579
 
1580
endmodule
1581
 
1582
`endif
1583
 
1584
`ifdef AC97_OUT_FIFO_DEPTH_8
1585
 
1586
// 8 Entry Deep version of the Output FIFO
1587
 
1588
module ac97_out_fifo(clk, rst, en, mode, din, we, dout, re, status, full, empty);
1589
 
1590
input           clk, rst;
1591
input           en;
1592
input   [1:0]    mode;
1593
input   [31:0]   din;
1594
input           we;
1595
output  [19:0]   dout;
1596
input           re;
1597
output  [1:0]    status;
1598
output          full;
1599
output          empty;
1600
 
1601
 
1602
////////////////////////////////////////////////////////////////////
1603
//
1604
// Local Wires
1605
//
1606
 
1607
reg     [31:0]   mem[0:7];
1608
 
1609
reg     [3:0]    wp;
1610
reg     [4:0]    rp;
1611
 
1612
wire    [3:0]    wp_p1;
1613
 
1614
reg     [1:0]    status;
1615
reg     [19:0]   dout;
1616
wire    [31:0]   dout_tmp;
1617
wire    [15:0]   dout_tmp1;
1618
wire            m16b;
1619
reg             empty;
1620
 
1621
////////////////////////////////////////////////////////////////////
1622
//
1623
// Misc Logic
1624
//
1625
 
1626
assign m16b = (mode == 2'h0);   // 16 Bit Mode
1627
 
1628
always @(posedge clk)
1629
        if(!en)         wp <= #1 4'h0;
1630
        else
1631
        if(we)          wp <= #1 wp_p1;
1632
 
1633
assign wp_p1 = wp + 4'h1;
1634
 
1635
always @(posedge clk)
1636
        if(!en)         rp <= #1 5'h0;
1637
        else
1638
        if(re & m16b)   rp <= #1 rp + 5'h1;
1639
        else
1640
        if(re & !m16b)  rp <= #1 rp + 5'h2;
1641
 
1642
always @(posedge clk)
1643
        status <= #1 (wp[2:1] - rp[3:2]) - 2'h1;
1644
 
1645
wire    [4:0]    rp_p1 = rp[4:0] + 5'h1;
1646
 
1647
always @(posedge clk)
1648
        empty <= #1 (rp_p1[4:1] == wp[3:0]) & (m16b ? rp_p1[0] : 1'b1);
1649
 
1650
assign full  = (wp[2:0] == rp[3:1]) & (wp[3] != rp[4]);
1651
 
1652
// Fifo Output
1653
assign dout_tmp = mem[ rp[3:1] ];
1654
 
1655
// Fifo Output Half Word Select
1656
assign dout_tmp1 = rp[0] ? dout_tmp[31:16] : dout_tmp[15:0];
1657
 
1658
always @(posedge clk)
1659
        if(!en)         dout <= #1 20'h0;
1660
        else
1661
        if(re)
1662
                case(mode)      // synopsys parallel_case full_case
1663
                   2'h0: dout <= #1 {dout_tmp1, 4'h0};          // 16 Bit Output
1664
                   2'h1: dout <= #1 {dout_tmp[17:0], 2'h0};      // 18 bit Output
1665
                   2'h2: dout <= #1 dout_tmp[19:0];              // 20 Bit Output
1666
                endcase
1667
 
1668
 
1669
always @(posedge clk)
1670
        if(we)  mem[wp[2:0]] <= #1 din;
1671
 
1672
endmodule
1673
 
1674
`endif
1675
 
1676
 
1677
`ifdef AC97_OUT_FIFO_DEPTH_16
1678
 
1679
// 16 Entry Deep version of the Output FIFO
1680
 
1681
module ac97_out_fifo(clk, rst, en, mode, din, we, dout, re, status, full, empty);
1682
 
1683
input           clk, rst;
1684
input           en;
1685
input   [1:0]    mode;
1686
input   [31:0]   din;
1687
input           we;
1688
output  [19:0]   dout;
1689
input           re;
1690
output  [1:0]    status;
1691
output          full;
1692
output          empty;
1693
 
1694
 
1695
////////////////////////////////////////////////////////////////////
1696
//
1697
// Local Wires
1698
//
1699
 
1700
reg     [31:0]   mem[0:15];
1701
 
1702
reg     [4:0]    wp;
1703
reg     [5:0]    rp;
1704
 
1705
wire    [4:0]    wp_p1;
1706
 
1707
reg     [1:0]    status;
1708
reg     [19:0]   dout;
1709
wire    [31:0]   dout_tmp;
1710
wire    [15:0]   dout_tmp1;
1711
wire            m16b;
1712
reg             empty;
1713
 
1714
////////////////////////////////////////////////////////////////////
1715
//
1716
// Misc Logic
1717
//
1718
 
1719
assign m16b = (mode == 2'h0);   // 16 Bit Mode
1720
 
1721
always @(posedge clk)
1722
        if(!en)         wp <= #1 5'h0;
1723
        else
1724
        if(we)          wp <= #1 wp_p1;
1725
 
1726
assign wp_p1 = wp + 4'h1;
1727
 
1728
always @(posedge clk)
1729
        if(!en)         rp <= #1 6'h0;
1730
        else
1731
        if(re & m16b)   rp <= #1 rp + 6'h1;
1732
        else
1733
        if(re & !m16b)  rp <= #1 rp + 6'h2;
1734
 
1735
always @(posedge clk)
1736
        status <= #1 (wp[3:2] - rp[4:3]) - 2'h1;
1737
 
1738
wire    [5:0]    rp_p1 = rp[5:0] + 6'h1;
1739
 
1740
always @(posedge clk)
1741
        empty <= #1 (rp_p1[5:1] == wp[4:0]) & (m16b ? rp_p1[0] : 1'b1);
1742
 
1743
assign full  = (wp[3:0] == rp[4:1]) & (wp[4] != rp[5]);
1744
 
1745
// Fifo Output
1746
assign dout_tmp = mem[ rp[4:1] ];
1747
 
1748
// Fifo Output Half Word Select
1749
assign dout_tmp1 = rp[0] ? dout_tmp[31:16] : dout_tmp[15:0];
1750
 
1751
always @(posedge clk)
1752
        if(!en)         dout <= #1 20'h0;
1753
        else
1754
        if(re)
1755
                case(mode)      // synopsys parallel_case full_case
1756
                   2'h0: dout <= #1 {dout_tmp1, 4'h0};          // 16 Bit Output
1757
                   2'h1: dout <= #1 {dout_tmp[17:0], 2'h0};      // 18 bit Output
1758
                   2'h2: dout <= #1 dout_tmp[19:0];              // 20 Bit Output
1759
                endcase
1760
 
1761
 
1762
always @(posedge clk)
1763
        if(we)  mem[wp[3:0]] <= #1 din;
1764
 
1765
endmodule
1766
 
1767
`endif
1768
/////////////////////////////////////////////////////////////////////
1769
////                                                             ////
1770
////  WISHBONE AC 97 Controller                                  ////
1771
////  PCM Request Controller                                     ////
1772
////                                                             ////
1773
////                                                             ////
1774
////  Author: Rudolf Usselmann                                   ////
1775
////          rudi@asics.ws                                      ////
1776
////                                                             ////
1777
////                                                             ////
1778
////  Downloaded from: http://www.opencores.org/cores/ac97_ctrl/ ////
1779
////                                                             ////
1780
/////////////////////////////////////////////////////////////////////
1781
////                                                             ////
1782
//// Copyright (C) 2000-2002 Rudolf Usselmann                    ////
1783
////                         www.asics.ws                        ////
1784
////                         rudi@asics.ws                       ////
1785
////                                                             ////
1786
//// This source file may be used and distributed without        ////
1787
//// restriction provided that this copyright statement is not   ////
1788
//// removed from the file and that any derivative work contains ////
1789
//// the original copyright notice and the associated disclaimer.////
1790
////                                                             ////
1791
////     THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY     ////
1792
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   ////
1793
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   ////
1794
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      ////
1795
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         ////
1796
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    ////
1797
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   ////
1798
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        ////
1799
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  ////
1800
//// LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  ////
1801
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  ////
1802
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         ////
1803
//// POSSIBILITY OF SUCH DAMAGE.                                 ////
1804
////                                                             ////
1805
/////////////////////////////////////////////////////////////////////
1806
 
1807
//  CVS Log
1808
//
1809
//  $Id: ac97_top.v,v 1.4 2006/11/20 17:13:43 tame Exp $
1810
//
1811
//  $Date: 2006/11/20 17:13:43 $
1812
//  $Revision: 1.4 $
1813
//  $Author: tame $
1814
//  $Locker:  $
1815
//  $State: Exp $
1816
//
1817
// Change History:
1818
//               $Log: ac97_top.v,v $
1819
//               Revision 1.4  2006/11/20 17:13:43  tame
1820
//               Originally calculated values used.
1821
//
1822
//               Revision 1.3  2006/09/11 13:12:13  tame
1823
//               Tried out high timing settings - works in hardware.
1824
//
1825
//               Revision 1.2  2006/08/16 08:46:04  tame
1826
//               AC97 core: register set read/writable in first simulations; in hardware, however,
1827
//               not yet
1828
//
1829
//               Revision 1.1  2006/08/14 15:25:09  tame
1830
//               added ac97 codec from OpenCores
1831
//               adapted configuration in ac97_defines module
1832
//
1833
//               Revision 1.4  2002/09/19 06:30:56  rudi
1834
//               Fixed a bug reported by Igor. Apparently this bug only shows up when
1835
//               the WB clock is very low (2x bit_clk). Updated Copyright header.
1836
//
1837
//               Revision 1.3  2002/03/05 04:44:05  rudi
1838
//
1839
//               - Fixed the order of the thrash hold bits to match the spec.
1840
//               - Many minor synthesis cleanup items ...
1841
//
1842
//               Revision 1.2  2001/08/10 08:09:42  rudi
1843
//
1844
//               - Removed RTY_O output.
1845
//               - Added Clock and Reset Inputs to documentation.
1846
//               - Changed IO names to be more clear.
1847
//               - Uniquifyed define names to be core specific.
1848
//
1849
//               Revision 1.1  2001/08/03 06:54:50  rudi
1850
//
1851
//
1852
//               - Changed to new directory structure
1853
//
1854
//               Revision 1.1.1.1  2001/05/19 02:29:17  rudi
1855
//               Initial Checkin
1856
//
1857
//
1858
//
1859
//
1860
 
1861
// `include "ac97_defines.v"
1862
 
1863
module ac97_prc(clk, rst,
1864
 
1865
                // SR Slot Interface
1866
                valid, in_valid, out_slt0,
1867
                in_slt0, in_slt1,
1868
 
1869
                // Codec Register Access
1870
                crac_valid, crac_wr,
1871
 
1872
                // Channel Configuration
1873
                oc0_cfg, oc1_cfg, oc2_cfg, oc3_cfg, oc4_cfg, oc5_cfg,
1874
                ic0_cfg, ic1_cfg, ic2_cfg,
1875
 
1876
                // FIFO Status
1877
                o3_empty, o4_empty, o6_empty, o7_empty, o8_empty,
1878
                o9_empty, i3_full, i4_full, i6_full,
1879
 
1880
                // FIFO Control
1881
                o3_re, o4_re, o6_re, o7_re, o8_re, o9_re,
1882
                i3_we, i4_we, i6_we
1883
 
1884
        );
1885
input           clk, rst;
1886
 
1887
input           valid;
1888
input   [2:0]    in_valid;
1889
output  [15:0]   out_slt0;
1890
input   [15:0]   in_slt0;
1891
input   [19:0]   in_slt1;
1892
 
1893
input           crac_valid;
1894
input           crac_wr;
1895
 
1896
input   [7:0]    oc0_cfg;
1897
input   [7:0]    oc1_cfg;
1898
input   [7:0]    oc2_cfg;
1899
input   [7:0]    oc3_cfg;
1900
input   [7:0]    oc4_cfg;
1901
input   [7:0]    oc5_cfg;
1902
 
1903
input   [7:0]    ic0_cfg;
1904
input   [7:0]    ic1_cfg;
1905
input   [7:0]    ic2_cfg;
1906
 
1907
input           o3_empty;
1908
input           o4_empty;
1909
input           o6_empty;
1910
input           o7_empty;
1911
input           o8_empty;
1912
input           o9_empty;
1913
input           i3_full;
1914
input           i4_full;
1915
input           i6_full;
1916
 
1917
output          o3_re;
1918
output          o4_re;
1919
output          o6_re;
1920
output          o7_re;
1921
output          o8_re;
1922
output          o9_re;
1923
output          i3_we;
1924
output          i4_we;
1925
output          i6_we;
1926
 
1927
////////////////////////////////////////////////////////////////////
1928
//
1929
// Local Wires
1930
//
1931
 
1932
wire            o3_re_l;
1933
wire            o4_re_l;
1934
wire            o6_re_l;
1935
wire            o7_re_l;
1936
wire            o8_re_l;
1937
wire            o9_re_l;
1938
 
1939
reg             crac_valid_r;
1940
reg             crac_wr_r;
1941
 
1942
////////////////////////////////////////////////////////////////////
1943
//
1944
// Output Tag Assembly
1945
//
1946
 
1947
assign out_slt0[15] = |out_slt0[14:6];
1948
 
1949
assign out_slt0[14] = crac_valid_r;
1950
assign out_slt0[13] = crac_wr_r;
1951
 
1952
assign out_slt0[12] = o3_re_l;
1953
assign out_slt0[11] = o4_re_l;
1954
assign out_slt0[10] = 1'b0;
1955
assign out_slt0[09] = o6_re_l;
1956
assign out_slt0[08] = o7_re_l;
1957
assign out_slt0[07] = o8_re_l;
1958
assign out_slt0[06] = o9_re_l;
1959
assign out_slt0[5:0] = 6'h0;
1960
 
1961
////////////////////////////////////////////////////////////////////
1962
//
1963
// FIFO Control
1964
//
1965
 
1966
always @(posedge clk)
1967
        if(valid)       crac_valid_r <= #1 crac_valid;
1968
 
1969
always @(posedge clk)
1970
        if(valid)       crac_wr_r <= #1 crac_valid & crac_wr;
1971
 
1972
// Output Channel 0 (Out Slot 3)
1973
ac97_fifo_ctrl u0(
1974
                .clk(           clk             ),
1975
                .valid(         valid           ),
1976
                .ch_en(         oc0_cfg[0]       ),
1977
                .srs(           oc0_cfg[1]      ),
1978
                .full_empty(    o3_empty        ),
1979
                .req(           ~in_slt1[11]    ),
1980
                .crdy(          in_slt0[15]     ),
1981
                .en_out(        o3_re           ),
1982
                .en_out_l(      o3_re_l         )
1983
                );
1984
 
1985
// Output Channel 1 (Out Slot 4)
1986
ac97_fifo_ctrl u1(
1987
                .clk(           clk             ),
1988
                .valid(         valid           ),
1989
                .ch_en(         oc1_cfg[0]       ),
1990
                .srs(           oc1_cfg[1]      ),
1991
                .full_empty(    o4_empty        ),
1992
                .req(           ~in_slt1[10]    ),
1993
                .crdy(          in_slt0[15]     ),
1994
                .en_out(        o4_re           ),
1995
                .en_out_l(      o4_re_l         )
1996
                );
1997
 
1998
`ifdef AC97_CENTER
1999
// Output Channel 2 (Out Slot 6)
2000
ac97_fifo_ctrl u2(
2001
                .clk(           clk             ),
2002
                .valid(         valid           ),
2003
                .ch_en(         oc2_cfg[0]       ),
2004
                .srs(           oc2_cfg[1]      ),
2005
                .full_empty(    o6_empty        ),
2006
                .req(           ~in_slt1[8]     ),
2007
                .crdy(          in_slt0[15]     ),
2008
                .en_out(        o6_re           ),
2009
                .en_out_l(      o6_re_l         )
2010
                );
2011
`else
2012
assign o6_re = 1'b0;
2013
assign o6_re_l = 1'b0;
2014
`endif
2015
 
2016
`ifdef AC97_SURROUND
2017
// Output Channel 3 (Out Slot 7)
2018
ac97_fifo_ctrl u3(
2019
                .clk(           clk             ),
2020
                .valid(         valid           ),
2021
                .ch_en(         oc3_cfg[0]       ),
2022
                .srs(           oc3_cfg[1]      ),
2023
                .full_empty(    o7_empty        ),
2024
                .req(           ~in_slt1[7]     ),
2025
                .crdy(          in_slt0[15]     ),
2026
                .en_out(        o7_re           ),
2027
                .en_out_l(      o7_re_l         )
2028
                );
2029
 
2030
// Output Channel 4 (Out Slot 8)
2031
ac97_fifo_ctrl u4(
2032
                .clk(           clk             ),
2033
                .valid(         valid           ),
2034
                .ch_en(         oc4_cfg[0]       ),
2035
                .srs(           oc4_cfg[1]      ),
2036
                .full_empty(    o8_empty        ),
2037
                .req(           ~in_slt1[6]     ),
2038
                .crdy(          in_slt0[15]     ),
2039
                .en_out(        o8_re           ),
2040
                .en_out_l(      o8_re_l         )
2041
                );
2042
`else
2043
assign o7_re = 1'b0;
2044
assign o7_re_l = 1'b0;
2045
assign o8_re = 1'b0;
2046
assign o8_re_l = 1'b0;
2047
`endif
2048
 
2049
`ifdef AC97_LFE
2050
// Output Channel 5 (Out Slot 9)
2051
ac97_fifo_ctrl u5(
2052
                .clk(           clk             ),
2053
                .valid(         valid           ),
2054
                .ch_en(         oc5_cfg[0]       ),
2055
                .srs(           oc5_cfg[1]      ),
2056
                .full_empty(    o9_empty        ),
2057
                .req(           ~in_slt1[5]     ),
2058
                .crdy(          in_slt0[15]     ),
2059
                .en_out(        o9_re           ),
2060
                .en_out_l(      o9_re_l         )
2061
                );
2062
`else
2063
assign o9_re = 1'b0;
2064
assign o9_re_l = 1'b0;
2065
`endif
2066
 
2067
`ifdef AC97_SIN
2068
// Input Channel 0 (In Slot 3)
2069
ac97_fifo_ctrl u6(
2070
                .clk(           clk             ),
2071
                .valid(         in_valid[0]      ),
2072
                .ch_en(         ic0_cfg[0]       ),
2073
                .srs(           ic0_cfg[1]      ),
2074
                .full_empty(    i3_full         ),
2075
                .req(           in_slt0[12]     ),
2076
                .crdy(          in_slt0[15]     ),
2077
                .en_out(        i3_we           ),
2078
                .en_out_l(                      )
2079
                );
2080
 
2081
// Input Channel 1 (In Slot 4)
2082
ac97_fifo_ctrl u7(
2083
                .clk(           clk             ),
2084
                .valid(         in_valid[1]     ),
2085
                .ch_en(         ic1_cfg[0]       ),
2086
                .srs(           ic1_cfg[1]      ),
2087
                .full_empty(    i4_full         ),
2088
                .req(           in_slt0[11]     ),
2089
                .crdy(          in_slt0[15]     ),
2090
                .en_out(        i4_we           ),
2091
                .en_out_l(                      )
2092
                );
2093
`else
2094
assign i3_we = 1'b0;
2095
assign i4_we = 1'b0;
2096
`endif
2097
 
2098
`ifdef AC97_MICIN
2099
// Input Channel 2 (In Slot 6)
2100
ac97_fifo_ctrl u8(
2101
                .clk(           clk             ),
2102
                .valid(         in_valid[2]     ),
2103
                .ch_en(         ic2_cfg[0]       ),
2104
                .srs(           ic2_cfg[1]      ),
2105
                .full_empty(    i6_full         ),
2106
                .req(           in_slt0[9]      ),
2107
                .crdy(          in_slt0[15]     ),
2108
                .en_out(        i6_we           ),
2109
                .en_out_l(                      )
2110
                );
2111
`else
2112
assign i6_we = 1'b0;
2113
`endif
2114
 
2115
endmodule
2116
 
2117
 
2118
/////////////////////////////////////////////////////////////////////
2119
////                                                             ////
2120
////  WISHBONE AC 97 Controller                                  ////
2121
////  Register File                                              ////
2122
////                                                             ////
2123
////                                                             ////
2124
////  Author: Rudolf Usselmann                                   ////
2125
////          rudi@asics.ws                                      ////
2126
////                                                             ////
2127
////                                                             ////
2128
////  Downloaded from: http://www.opencores.org/cores/ac97_ctrl/ ////
2129
////                                                             ////
2130
/////////////////////////////////////////////////////////////////////
2131
////                                                             ////
2132
//// Copyright (C) 2000-2002 Rudolf Usselmann                    ////
2133
////                         www.asics.ws                        ////
2134
////                         rudi@asics.ws                       ////
2135
////                                                             ////
2136
//// This source file may be used and distributed without        ////
2137
//// restriction provided that this copyright statement is not   ////
2138
//// removed from the file and that any derivative work contains ////
2139
//// the original copyright notice and the associated disclaimer.////
2140
////                                                             ////
2141
////     THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY     ////
2142
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   ////
2143
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   ////
2144
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      ////
2145
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         ////
2146
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    ////
2147
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   ////
2148
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        ////
2149
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  ////
2150
//// LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  ////
2151
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  ////
2152
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         ////
2153
//// POSSIBILITY OF SUCH DAMAGE.                                 ////
2154
////                                                             ////
2155
/////////////////////////////////////////////////////////////////////
2156
 
2157
//  CVS Log
2158
//
2159
//  $Id: ac97_top.v,v 1.4 2006/11/20 17:13:43 tame Exp $
2160
//
2161
//  $Date: 2006/11/20 17:13:43 $
2162
//  $Revision: 1.4 $
2163
//  $Author: tame $
2164
//  $Locker:  $
2165
//  $State: Exp $
2166
//
2167
// Change History:
2168
//               $Log: ac97_top.v,v $
2169
//               Revision 1.4  2006/11/20 17:13:43  tame
2170
//               Originally calculated values used.
2171
//
2172
//               Revision 1.3  2006/09/11 13:12:13  tame
2173
//               Tried out high timing settings - works in hardware.
2174
//
2175
//               Revision 1.2  2006/08/16 08:46:04  tame
2176
//               AC97 core: register set read/writable in first simulations; in hardware, however,
2177
//               not yet
2178
//
2179
//               Revision 1.1  2006/08/14 15:25:09  tame
2180
//               added ac97 codec from OpenCores
2181
//               adapted configuration in ac97_defines module
2182
//
2183
//               Revision 1.4  2002/09/19 06:30:56  rudi
2184
//               Fixed a bug reported by Igor. Apparently this bug only shows up when
2185
//               the WB clock is very low (2x bit_clk). Updated Copyright header.
2186
//
2187
//               Revision 1.3  2002/03/05 04:44:05  rudi
2188
//
2189
//               - Fixed the order of the thrash hold bits to match the spec.
2190
//               - Many minor synthesis cleanup items ...
2191
//
2192
//               Revision 1.2  2001/08/10 08:09:42  rudi
2193
//
2194
//               - Removed RTY_O output.
2195
//               - Added Clock and Reset Inputs to documentation.
2196
//               - Changed IO names to be more clear.
2197
//               - Uniquifyed define names to be core specific.
2198
//
2199
//               Revision 1.1  2001/08/03 06:54:50  rudi
2200
//
2201
//
2202
//               - Changed to new directory structure
2203
//
2204
//               Revision 1.1.1.1  2001/05/19 02:29:17  rudi
2205
//               Initial Checkin
2206
//
2207
//
2208
//
2209
//
2210
 
2211
// `include "ac97_defines.v"
2212
 
2213
module ac97_rf(clk, rst,
2214
 
2215
                adr, rf_dout, rf_din,
2216
                rf_we, rf_re, int, ac97_rst_force,
2217
                resume_req, suspended,
2218
 
2219
                crac_we, crac_din, crac_out,
2220
                crac_rd_done, crac_wr_done,
2221
 
2222
                oc0_cfg, oc1_cfg, oc2_cfg, oc3_cfg, oc4_cfg, oc5_cfg,
2223
                ic0_cfg, ic1_cfg, ic2_cfg,
2224
                oc0_int_set, oc1_int_set, oc2_int_set, oc3_int_set,
2225
                oc4_int_set, oc5_int_set,
2226
                ic0_int_set, ic1_int_set, ic2_int_set
2227
 
2228
                );
2229
 
2230
input           clk,rst;
2231
 
2232
input   [3:0]    adr;
2233
output  [31:0]   rf_dout;
2234
input   [31:0]   rf_din;
2235
input           rf_we;
2236
input           rf_re;
2237
output          int;
2238
output          ac97_rst_force;
2239
output          resume_req;
2240
input           suspended;
2241
 
2242
output          crac_we;
2243
input   [15:0]   crac_din;
2244
output  [31:0]   crac_out;
2245
input           crac_rd_done, crac_wr_done;
2246
 
2247
output  [7:0]    oc0_cfg;
2248
output  [7:0]    oc1_cfg;
2249
output  [7:0]    oc2_cfg;
2250
output  [7:0]    oc3_cfg;
2251
output  [7:0]    oc4_cfg;
2252
output  [7:0]    oc5_cfg;
2253
 
2254
output  [7:0]    ic0_cfg;
2255
output  [7:0]    ic1_cfg;
2256
output  [7:0]    ic2_cfg;
2257
 
2258
input   [2:0]    oc0_int_set;
2259
input   [2:0]    oc1_int_set;
2260
input   [2:0]    oc2_int_set;
2261
input   [2:0]    oc3_int_set;
2262
input   [2:0]    oc4_int_set;
2263
input   [2:0]    oc5_int_set;
2264
input   [2:0]    ic0_int_set;
2265
input   [2:0]    ic1_int_set;
2266
input   [2:0]    ic2_int_set;
2267
 
2268
////////////////////////////////////////////////////////////////////
2269
//
2270
// Local Wires
2271
//
2272
 
2273
reg     [31:0]   rf_dout;
2274
 
2275
reg     [31:0]   csr_r;
2276
reg     [31:0]   occ0_r;
2277
reg     [15:0]   occ1_r;
2278
reg     [23:0]   icc_r;
2279
reg     [31:0]   crac_r;
2280
reg     [28:0]   intm_r;
2281
reg     [28:0]   ints_r;
2282
reg             int;
2283
wire    [28:0]   int_all;
2284
wire    [31:0]   csr, occ0, occ1, icc, crac, intm, ints;
2285
reg     [15:0]   crac_dout_r;
2286
reg             ac97_rst_force;
2287
reg             resume_req;
2288
 
2289
// Aliases
2290
assign csr  = {30'h0, suspended, 1'h0};
2291
assign occ0 = occ0_r;
2292
assign occ1 = {16'h0, occ1_r};
2293
assign icc  = {8'h0,  icc_r};
2294
assign crac = {crac_r[7], 8'h0, crac_r[6:0], crac_din};
2295
assign intm = {3'h0, intm_r};
2296
assign ints = {3'h0, ints_r};
2297
 
2298
assign crac_out = {crac_r[7], 8'h0, crac_r[6:0], crac_dout_r};
2299
 
2300
////////////////////////////////////////////////////////////////////
2301
//
2302
// Register WISHBONE Interface
2303
//
2304
 
2305
always @(adr or csr or occ0 or occ1 or icc or crac or intm or ints)
2306
        case(adr[2:0])   // synopsys parallel_case full_case
2307
           0: rf_dout = csr;
2308
           1: rf_dout = occ0;
2309
           2: rf_dout = occ1;
2310
           3: rf_dout = icc;
2311
           4: rf_dout = crac;
2312
           5: rf_dout = intm;
2313
           6: rf_dout = ints;
2314
        endcase
2315
 
2316
always @(posedge clk or negedge rst)
2317
        if(!rst)                        csr_r <= #1 1'b0;
2318
        else
2319
        if(rf_we & (adr[2:0]==3'h0))     csr_r <= #1 rf_din;
2320
 
2321
always @(posedge clk)
2322
        if(rf_we & (adr[2:0]==3'h0))     ac97_rst_force <= #1 rf_din[0];
2323
        else                            ac97_rst_force <= #1 1'b0;
2324
 
2325
always @(posedge clk)
2326
        if(rf_we & (adr[2:0]==3'h0))     resume_req <= #1 rf_din[1];
2327
        else                            resume_req <= #1 1'b0;
2328
 
2329
always @(posedge clk or negedge rst)
2330
        if(!rst)                        occ0_r <= #1 1'b0;
2331
        else
2332
        if(rf_we & (adr[2:0]==3'h1))     occ0_r <= #1 rf_din;
2333
 
2334
always @(posedge clk or negedge rst)
2335
        if(!rst)                        occ1_r <= #1 1'b0;
2336
        else
2337
        if(rf_we & (adr[2:0]==3'h2))     occ1_r <= #1 rf_din[23:0];
2338
 
2339
always @(posedge clk or negedge rst)
2340
        if(!rst)                        icc_r <= #1 1'b0;
2341
        else
2342
        if(rf_we & (adr[2:0]==3'h3))     icc_r <= #1 rf_din[23:0];
2343
 
2344
assign crac_we = rf_we & (adr[2:0]==3'h4);
2345
 
2346
always @(posedge clk or negedge rst)
2347
        if(!rst)                        crac_r <= #1 1'b0;
2348
        else
2349
        if(crac_we)                     crac_r <= #1 {rf_din[31], rf_din[22:16]};
2350
 
2351
always @(posedge clk)
2352
        if(crac_we)                     crac_dout_r <= #1 rf_din[15:0];
2353
 
2354
always @(posedge clk or negedge rst)
2355
        if(!rst)                        intm_r <= #1 1'b0;
2356
        else
2357
        if(rf_we & (adr[2:0]==3'h5))     intm_r <= #1 rf_din[28:0];
2358
 
2359
// Interrupt Source Register
2360
always @(posedge clk or negedge rst)
2361
        if(!rst)                        ints_r <= #1 1'b0;
2362
        else
2363
        if(rf_re & (adr[2:0]==3'h6))     ints_r <= #1 1'b0;
2364
        else
2365
           begin
2366
                if(crac_rd_done)        ints_r[0] <= #1 1'b1;
2367
                if(crac_wr_done)        ints_r[1] <= #1 1'b1;
2368
                if(oc0_int_set[0])       ints_r[2] <= #1 1'b1;
2369
                if(oc0_int_set[1])      ints_r[3] <= #1 1'b1;
2370
                if(oc0_int_set[2])      ints_r[4] <= #1 1'b1;
2371
                if(oc1_int_set[0])       ints_r[5] <= #1 1'b1;
2372
                if(oc1_int_set[1])      ints_r[6] <= #1 1'b1;
2373
                if(oc1_int_set[2])      ints_r[7] <= #1 1'b1;
2374
`ifdef AC97_CENTER
2375
                if(oc2_int_set[0])       ints_r[8] <= #1 1'b1;
2376
                if(oc2_int_set[1])      ints_r[9] <= #1 1'b1;
2377
                if(oc2_int_set[2])      ints_r[10] <= #1 1'b1;
2378
`endif
2379
 
2380
`ifdef AC97_SURROUND
2381
                if(oc3_int_set[0])       ints_r[11] <= #1 1'b1;
2382
                if(oc3_int_set[1])      ints_r[12] <= #1 1'b1;
2383
                if(oc3_int_set[2])      ints_r[13] <= #1 1'b1;
2384
                if(oc4_int_set[0])       ints_r[14] <= #1 1'b1;
2385
                if(oc4_int_set[1])      ints_r[15] <= #1 1'b1;
2386
                if(oc4_int_set[2])      ints_r[16] <= #1 1'b1;
2387
`endif
2388
 
2389
`ifdef AC97_LFE
2390
                if(oc5_int_set[0])       ints_r[17] <= #1 1'b1;
2391
                if(oc5_int_set[1])      ints_r[18] <= #1 1'b1;
2392
                if(oc5_int_set[2])      ints_r[19] <= #1 1'b1;
2393
`endif
2394
 
2395
`ifdef AC97_SIN
2396
                if(ic0_int_set[0])       ints_r[20] <= #1 1'b1;
2397
                if(ic0_int_set[1])      ints_r[21] <= #1 1'b1;
2398
                if(ic0_int_set[2])      ints_r[22] <= #1 1'b1;
2399
                if(ic1_int_set[0])       ints_r[23] <= #1 1'b1;
2400
                if(ic1_int_set[1])      ints_r[24] <= #1 1'b1;
2401
                if(ic1_int_set[2])      ints_r[25] <= #1 1'b1;
2402
`endif
2403
 
2404
`ifdef AC97_MICIN
2405
                if(ic2_int_set[0])       ints_r[26] <= #1 1'b1;
2406
                if(ic2_int_set[1])      ints_r[27] <= #1 1'b1;
2407
                if(ic2_int_set[2])      ints_r[28] <= #1 1'b1;
2408
`endif
2409
           end
2410
 
2411
////////////////////////////////////////////////////////////////////
2412
//
2413
// Register Internal Interface
2414
//
2415
 
2416
assign oc0_cfg = occ0[7:0];
2417
assign oc1_cfg = occ0[15:8];
2418
assign oc2_cfg = occ0[23:16];
2419
assign oc3_cfg = occ0[31:24];
2420
assign oc4_cfg = occ1[7:0];
2421
assign oc5_cfg = occ1[15:8];
2422
 
2423
assign ic0_cfg = icc[7:0];
2424
assign ic1_cfg = icc[15:8];
2425
assign ic2_cfg = icc[23:16];
2426
 
2427
////////////////////////////////////////////////////////////////////
2428
//
2429
// Interrupt Generation
2430
//
2431
 
2432
assign int_all = intm_r & ints_r;
2433
 
2434
always @(posedge clk)
2435
        int <= #1 |int_all;
2436
 
2437
endmodule
2438
/////////////////////////////////////////////////////////////////////
2439
////                                                             ////
2440
////  WISHBONE AC 97 Controller Reset Module                     ////
2441
////                                                             ////
2442
////                                                             ////
2443
////  Author: Rudolf Usselmann                                   ////
2444
////          rudi@asics.ws                                      ////
2445
////                                                             ////
2446
////                                                             ////
2447
////  Downloaded from: http://www.opencores.org/cores/ac97_ctrl/ ////
2448
////                                                             ////
2449
/////////////////////////////////////////////////////////////////////
2450
////                                                             ////
2451
//// Copyright (C) 2001 Rudolf Usselmann                         ////
2452
////                    rudi@asics.ws                            ////
2453
////                                                             ////
2454
//// This source file may be used and distributed without        ////
2455
//// restriction provided that this copyright statement is not   ////
2456
//// removed from the file and that any derivative work contains ////
2457
//// the original copyright notice and the associated disclaimer.////
2458
////                                                             ////
2459
////     THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY     ////
2460
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   ////
2461
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   ////
2462
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      ////
2463
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         ////
2464
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    ////
2465
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   ////
2466
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        ////
2467
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  ////
2468
//// LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  ////
2469
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  ////
2470
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         ////
2471
//// POSSIBILITY OF SUCH DAMAGE.                                 ////
2472
////                                                             ////
2473
/////////////////////////////////////////////////////////////////////
2474
 
2475
//  CVS Log
2476
//
2477
//  $Id: ac97_top.v,v 1.4 2006/11/20 17:13:43 tame Exp $
2478
//
2479
//  $Date: 2006/11/20 17:13:43 $
2480
//  $Revision: 1.4 $
2481
//  $Author: tame $
2482
//  $Locker:  $
2483
//  $State: Exp $
2484
//
2485
// Change History:
2486
//               $Log: ac97_top.v,v $
2487
//               Revision 1.4  2006/11/20 17:13:43  tame
2488
//               Originally calculated values used.
2489
//
2490
//               Revision 1.3  2006/09/11 13:12:13  tame
2491
//               Tried out high timing settings - works in hardware.
2492
//
2493
//               Revision 1.2  2006/08/16 08:46:04  tame
2494
//               AC97 core: register set read/writable in first simulations; in hardware, however,
2495
//               not yet
2496
//
2497
//               Revision 1.1  2006/08/14 15:25:09  tame
2498
//               added ac97 codec from OpenCores
2499
//               adapted configuration in ac97_defines module
2500
//
2501
//               Revision 1.1  2001/08/03 06:54:50  rudi
2502
//
2503
//
2504
//               - Changed to new directory structure
2505
//
2506
//               Revision 1.1.1.1  2001/05/19 02:29:19  rudi
2507
//               Initial Checkin
2508
//
2509
//
2510
//
2511
//
2512
 
2513
// `include "ac97_defines.v"
2514
 
2515
module ac97_rst(clk, rst, rst_force, ps_ce, ac97_rst_);
2516
input           clk, rst;
2517
input           rst_force;
2518
output          ps_ce;
2519
output          ac97_rst_;
2520
 
2521
reg             ac97_rst_;
2522
reg     [2:0]    cnt;
2523
wire            ce;
2524
wire            to;
2525
reg     [5:0]    ps_cnt;
2526
wire            ps_ce;
2527
 
2528
always @(posedge clk or negedge rst)
2529
        if(!rst)        ac97_rst_ <= #1 0;
2530
        else
2531
        if(rst_force)   ac97_rst_ <= #1 0;
2532
        else
2533
        if(to)          ac97_rst_ <= #1 1;
2534
 
2535
assign to = (cnt == `AC97_RST_DEL);
2536
 
2537
always @(posedge clk or negedge rst)
2538
        if(!rst)        cnt <= #1 0;
2539
        else
2540
        if(rst_force)   cnt <= #1 0;
2541
        else
2542
        if(ce)          cnt <= #1 cnt + 1;
2543
 
2544
assign ce = ps_ce & (cnt != `AC97_RST_DEL);
2545
 
2546
always @(posedge clk or negedge rst)
2547
        if(!rst)                ps_cnt <= #1 0;
2548
        else
2549
        if(ps_ce | rst_force)   ps_cnt <= #1 0;
2550
        else                    ps_cnt <= #1 ps_cnt + 1;
2551
 
2552
assign ps_ce = (ps_cnt == `AC97_250_PS);
2553
 
2554
endmodule
2555
/////////////////////////////////////////////////////////////////////
2556
////                                                             ////
2557
////  WISHBONE AC 97 Controller                                  ////
2558
////  Serial Input Block                                         ////
2559
////                                                             ////
2560
////                                                             ////
2561
////  Author: Rudolf Usselmann                                   ////
2562
////          rudi@asics.ws                                      ////
2563
////                                                             ////
2564
////                                                             ////
2565
////  Downloaded from: http://www.opencores.org/cores/ac97_ctrl/ ////
2566
////                                                             ////
2567
/////////////////////////////////////////////////////////////////////
2568
////                                                             ////
2569
//// Copyright (C) 2000-2002 Rudolf Usselmann                    ////
2570
////                         www.asics.ws                        ////
2571
////                         rudi@asics.ws                       ////
2572
////                                                             ////
2573
//// This source file may be used and distributed without        ////
2574
//// restriction provided that this copyright statement is not   ////
2575
//// removed from the file and that any derivative work contains ////
2576
//// the original copyright notice and the associated disclaimer.////
2577
////                                                             ////
2578
////     THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY     ////
2579
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   ////
2580
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   ////
2581
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      ////
2582
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         ////
2583
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    ////
2584
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   ////
2585
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        ////
2586
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  ////
2587
//// LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  ////
2588
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  ////
2589
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         ////
2590
//// POSSIBILITY OF SUCH DAMAGE.                                 ////
2591
////                                                             ////
2592
/////////////////////////////////////////////////////////////////////
2593
 
2594
//  CVS Log
2595
//
2596
//  $Id: ac97_top.v,v 1.4 2006/11/20 17:13:43 tame Exp $
2597
//
2598
//  $Date: 2006/11/20 17:13:43 $
2599
//  $Revision: 1.4 $
2600
//  $Author: tame $
2601
//  $Locker:  $
2602
//  $State: Exp $
2603
//
2604
// Change History:
2605
//               $Log: ac97_top.v,v $
2606
//               Revision 1.4  2006/11/20 17:13:43  tame
2607
//               Originally calculated values used.
2608
//
2609
//               Revision 1.3  2006/09/11 13:12:13  tame
2610
//               Tried out high timing settings - works in hardware.
2611
//
2612
//               Revision 1.2  2006/08/16 08:46:04  tame
2613
//               AC97 core: register set read/writable in first simulations; in hardware, however,
2614
//               not yet
2615
//
2616
//               Revision 1.1  2006/08/14 15:25:09  tame
2617
//               added ac97 codec from OpenCores
2618
//               adapted configuration in ac97_defines module
2619
//
2620
//               Revision 1.2  2002/09/19 06:30:56  rudi
2621
//               Fixed a bug reported by Igor. Apparently this bug only shows up when
2622
//               the WB clock is very low (2x bit_clk). Updated Copyright header.
2623
//
2624
//               Revision 1.1  2001/08/03 06:54:50  rudi
2625
//
2626
//
2627
//               - Changed to new directory structure
2628
//
2629
//               Revision 1.1.1.1  2001/05/19 02:29:15  rudi
2630
//               Initial Checkin
2631
//
2632
//
2633
//
2634
//
2635
 
2636
// `include "ac97_defines.v"
2637
 
2638
module ac97_sin(clk, rst,
2639
 
2640
        out_le, slt0, slt1, slt2, slt3, slt4,
2641
        slt6,
2642
 
2643
        sdata_in
2644
        );
2645
 
2646
input           clk, rst;
2647
 
2648
// --------------------------------------
2649
// Misc Signals
2650
input   [5:0]    out_le;
2651
output  [15:0]   slt0;
2652
output  [19:0]   slt1;
2653
output  [19:0]   slt2;
2654
output  [19:0]   slt3;
2655
output  [19:0]   slt4;
2656
output  [19:0]   slt6;
2657
 
2658
// --------------------------------------
2659
// AC97 Codec Interface
2660
input           sdata_in;
2661
 
2662
////////////////////////////////////////////////////////////////////
2663
//
2664
// Local Wires
2665
//
2666
 
2667
reg             sdata_in_r;
2668
reg     [19:0]   sr;
2669
 
2670
reg     [15:0]   slt0;
2671
reg     [19:0]   slt1;
2672
reg     [19:0]   slt2;
2673
reg     [19:0]   slt3;
2674
reg     [19:0]   slt4;
2675
reg     [19:0]   slt6;
2676
 
2677
////////////////////////////////////////////////////////////////////
2678
//
2679
// Output Registers
2680
//
2681
 
2682
always @(posedge clk)
2683
        if(out_le[0])    slt0 <= #1 sr[15:0];
2684
 
2685
always @(posedge clk)
2686
        if(out_le[1])   slt1 <= #1 sr;
2687
 
2688
always @(posedge clk)
2689
        if(out_le[2])   slt2 <= #1 sr;
2690
 
2691
always @(posedge clk)
2692
        if(out_le[3])   slt3 <= #1 sr;
2693
 
2694
always @(posedge clk)
2695
        if(out_le[4])   slt4 <= #1 sr;
2696
 
2697
always @(posedge clk)
2698
        if(out_le[5])   slt6 <= #1 sr;
2699
 
2700
////////////////////////////////////////////////////////////////////
2701
//
2702
// Serial Shift Register
2703
//
2704
 
2705
always @(negedge clk)
2706
        sdata_in_r <= #1 sdata_in;
2707
 
2708
always @(posedge clk)
2709
        sr <= #1 {sr[18:0], sdata_in_r };
2710
 
2711
endmodule
2712
 
2713
 
2714
/////////////////////////////////////////////////////////////////////
2715
////                                                             ////
2716
////  WISHBONE AC 97 Controller                                  ////
2717
////  Serial Output Controller                                   ////
2718
////                                                             ////
2719
////                                                             ////
2720
////  Author: Rudolf Usselmann                                   ////
2721
////          rudi@asics.ws                                      ////
2722
////                                                             ////
2723
////                                                             ////
2724
////  Downloaded from: http://www.opencores.org/cores/ac97_ctrl/ ////
2725
////                                                             ////
2726
/////////////////////////////////////////////////////////////////////
2727
////                                                             ////
2728
//// Copyright (C) 2000-2002 Rudolf Usselmann                    ////
2729
////                         www.asics.ws                        ////
2730
////                         rudi@asics.ws                       ////
2731
////                                                             ////
2732
//// This source file may be used and distributed without        ////
2733
//// restriction provided that this copyright statement is not   ////
2734
//// removed from the file and that any derivative work contains ////
2735
//// the original copyright notice and the associated disclaimer.////
2736
////                                                             ////
2737
////     THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY     ////
2738
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   ////
2739
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   ////
2740
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      ////
2741
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         ////
2742
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    ////
2743
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   ////
2744
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        ////
2745
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  ////
2746
//// LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  ////
2747
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  ////
2748
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         ////
2749
//// POSSIBILITY OF SUCH DAMAGE.                                 ////
2750
////                                                             ////
2751
/////////////////////////////////////////////////////////////////////
2752
 
2753
//  CVS Log
2754
//
2755
//  $Id: ac97_top.v,v 1.4 2006/11/20 17:13:43 tame Exp $
2756
//
2757
//  $Date: 2006/11/20 17:13:43 $
2758
//  $Revision: 1.4 $
2759
//  $Author: tame $
2760
//  $Locker:  $
2761
//  $State: Exp $
2762
//
2763
// Change History:
2764
//               $Log: ac97_top.v,v $
2765
//               Revision 1.4  2006/11/20 17:13:43  tame
2766
//               Originally calculated values used.
2767
//
2768
//               Revision 1.3  2006/09/11 13:12:13  tame
2769
//               Tried out high timing settings - works in hardware.
2770
//
2771
//               Revision 1.2  2006/08/16 08:46:04  tame
2772
//               AC97 core: register set read/writable in first simulations; in hardware, however,
2773
//               not yet
2774
//
2775
//               Revision 1.1  2006/08/14 15:25:09  tame
2776
//               added ac97 codec from OpenCores
2777
//               adapted configuration in ac97_defines module
2778
//
2779
//               Revision 1.3  2002/09/19 06:30:56  rudi
2780
//               Fixed a bug reported by Igor. Apparently this bug only shows up when
2781
//               the WB clock is very low (2x bit_clk). Updated Copyright header.
2782
//
2783
//               Revision 1.2  2002/03/05 04:44:05  rudi
2784
//
2785
//               - Fixed the order of the thrash hold bits to match the spec.
2786
//               - Many minor synthesis cleanup items ...
2787
//
2788
//               Revision 1.1  2001/08/03 06:54:50  rudi
2789
//
2790
//
2791
//               - Changed to new directory structure
2792
//
2793
//               Revision 1.1.1.1  2001/05/19 02:29:15  rudi
2794
//               Initial Checkin
2795
//
2796
//
2797
//
2798
//
2799
 
2800
// `include "ac97_defines.v"
2801
 
2802
module ac97_soc(clk, wclk, rst,
2803
                ps_ce, resume, suspended,
2804
                sync, out_le, in_valid, ld, valid
2805
                );
2806
 
2807
input           clk, wclk, rst;
2808
input           ps_ce;
2809
input           resume;
2810
output          suspended;
2811
output          sync;
2812
output  [5:0]    out_le;
2813
output  [2:0]    in_valid;
2814
output          ld;
2815
output          valid;
2816
 
2817
////////////////////////////////////////////////////////////////////
2818
//
2819
// Local Wires
2820
//
2821
 
2822
reg     [7:0]    cnt;
2823
reg             sync_beat;
2824
reg             sync_resume;
2825
reg     [5:0]    out_le;
2826
reg             ld;
2827
reg             valid;
2828
reg     [2:0]    in_valid;
2829
reg             bit_clk_r;
2830
reg             bit_clk_r1;
2831
reg             bit_clk_e;
2832
reg             suspended;
2833
wire            to;
2834
reg     [5:0]    to_cnt;
2835
reg     [3:0]    res_cnt;
2836
wire            resume_done;
2837
 
2838
assign sync = sync_beat | sync_resume;
2839
 
2840
////////////////////////////////////////////////////////////////////
2841
//
2842
// Misc Logic
2843
//
2844
 
2845
always @(posedge clk or negedge rst)
2846
        if(!rst)                cnt <= #1 8'hff;
2847
        else
2848
        if(suspended)           cnt <= #1 8'hff;
2849
        else                    cnt <= #1 cnt + 8'h1;
2850
 
2851
always @(posedge clk)
2852
        ld <= #1 (cnt == 8'h00);
2853
 
2854
always @(posedge clk)
2855
        sync_beat <= #1 (cnt == 8'h00) | ((cnt > 8'h00) & (cnt < 8'h10));
2856
 
2857
always @(posedge clk)
2858
        valid <= #1 (cnt > 8'h39);
2859
 
2860
always @(posedge clk)
2861
        out_le[0] <= #1 (cnt == 8'h11);          // Slot 0 Latch Enable
2862
 
2863
always @(posedge clk)
2864
        out_le[1] <= #1 (cnt == 8'h25);         // Slot 1 Latch Enable
2865
 
2866
always @(posedge clk)
2867
        out_le[2] <= #1 (cnt == 8'h39);         // Slot 2 Latch Enable
2868
 
2869
always @(posedge clk)
2870
        out_le[3] <= #1 (cnt == 8'h4d);         // Slot 3 Latch Enable
2871
 
2872
always @(posedge clk)
2873
        out_le[4] <= #1 (cnt == 8'h61);         // Slot 4 Latch Enable
2874
 
2875
always @(posedge clk)
2876
        out_le[5] <= #1 (cnt == 8'h89);         // Slot 6 Latch Enable
2877
 
2878
always @(posedge clk)
2879
        in_valid[0] <= #1 (cnt > 8'h4d); // Input Slot 3 Valid
2880
 
2881
always @(posedge clk)
2882
        in_valid[1] <= #1 (cnt > 8'h61);        // Input Slot 3 Valid
2883
 
2884
always @(posedge clk)
2885
        in_valid[2] <= #1 (cnt > 8'h89);        // Input Slot 3 Valid
2886
 
2887
////////////////////////////////////////////////////////////////////
2888
//
2889
// Suspend Detect
2890
//
2891
 
2892
always @(posedge wclk)
2893
        bit_clk_r <= #1 clk;
2894
 
2895
always @(posedge wclk)
2896
        bit_clk_r1 <= #1 bit_clk_r;
2897
 
2898
always @(posedge wclk)
2899
        bit_clk_e <= #1 (bit_clk_r & !bit_clk_r1) | (!bit_clk_r & bit_clk_r1);
2900
 
2901
always @(posedge wclk)
2902
        suspended <= #1 to;
2903
 
2904
assign to = (to_cnt == `AC97_SUSP_DET);
2905
 
2906
always @(posedge wclk or negedge rst)
2907
        if(!rst)                to_cnt <= #1 6'h0;
2908
        else
2909
        if(bit_clk_e)           to_cnt <= #1 6'h0;
2910
        else
2911
        if(!to)                 to_cnt <= #1 to_cnt + 6'h1;
2912
 
2913
////////////////////////////////////////////////////////////////////
2914
//
2915
// Resume Signaling
2916
//
2917
 
2918
always @(posedge wclk or negedge rst)
2919
        if(!rst)                        sync_resume <= #1 1'b0;
2920
        else
2921
        if(resume_done)                 sync_resume <= #1 1'b0;
2922
        else
2923
        if(suspended & resume)          sync_resume <= #1 1'b1;
2924
 
2925
assign resume_done = (res_cnt == `AC97_RES_SIG);
2926
 
2927
always @(posedge wclk)
2928
        if(!sync_resume)        res_cnt <= #1 4'h0;
2929
        else
2930
        if(ps_ce)               res_cnt <= #1 res_cnt + 4'h1;
2931
 
2932
endmodule
2933
/////////////////////////////////////////////////////////////////////
2934
////                                                             ////
2935
////  WISHBONE AC 97 Controller                                  ////
2936
////  Serial Output Block                                        ////
2937
////                                                             ////
2938
////                                                             ////
2939
////  Author: Rudolf Usselmann                                   ////
2940
////          rudi@asics.ws                                      ////
2941
////                                                             ////
2942
////                                                             ////
2943
////  Downloaded from: http://www.opencores.org/cores/ac97_ctrl/ ////
2944
////                                                             ////
2945
/////////////////////////////////////////////////////////////////////
2946
////                                                             ////
2947
//// Copyright (C) 2000-2002 Rudolf Usselmann                    ////
2948
////                         www.asics.ws                        ////
2949
////                         rudi@asics.ws                       ////
2950
////                                                             ////
2951
//// This source file may be used and distributed without        ////
2952
//// restriction provided that this copyright statement is not   ////
2953
//// removed from the file and that any derivative work contains ////
2954
//// the original copyright notice and the associated disclaimer.////
2955
////                                                             ////
2956
////     THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY     ////
2957
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   ////
2958
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   ////
2959
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      ////
2960
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         ////
2961
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    ////
2962
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   ////
2963
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        ////
2964
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  ////
2965
//// LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  ////
2966
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  ////
2967
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         ////
2968
//// POSSIBILITY OF SUCH DAMAGE.                                 ////
2969
////                                                             ////
2970
/////////////////////////////////////////////////////////////////////
2971
 
2972
//  CVS Log
2973
//
2974
//  $Id: ac97_top.v,v 1.4 2006/11/20 17:13:43 tame Exp $
2975
//
2976
//  $Date: 2006/11/20 17:13:43 $
2977
//  $Revision: 1.4 $
2978
//  $Author: tame $
2979
//  $Locker:  $
2980
//  $State: Exp $
2981
//
2982
// Change History:
2983
//               $Log: ac97_top.v,v $
2984
//               Revision 1.4  2006/11/20 17:13:43  tame
2985
//               Originally calculated values used.
2986
//
2987
//               Revision 1.3  2006/09/11 13:12:13  tame
2988
//               Tried out high timing settings - works in hardware.
2989
//
2990
//               Revision 1.2  2006/08/16 08:46:04  tame
2991
//               AC97 core: register set read/writable in first simulations; in hardware, however,
2992
//               not yet
2993
//
2994
//               Revision 1.1  2006/08/14 15:25:09  tame
2995
//               added ac97 codec from OpenCores
2996
//               adapted configuration in ac97_defines module
2997
//
2998
//               Revision 1.2  2002/09/19 06:30:56  rudi
2999
//               Fixed a bug reported by Igor. Apparently this bug only shows up when
3000
//               the WB clock is very low (2x bit_clk). Updated Copyright header.
3001
//
3002
//               Revision 1.1  2001/08/03 06:54:50  rudi
3003
//
3004
//
3005
//               - Changed to new directory structure
3006
//
3007
//               Revision 1.1.1.1  2001/05/19 02:29:15  rudi
3008
//               Initial Checkin
3009
//
3010
//
3011
//
3012
//
3013
 
3014
// `include "ac97_defines.v"
3015
 
3016
module ac97_sout(clk, rst,
3017
 
3018
        so_ld, slt0, slt1, slt2, slt3, slt4,
3019
        slt6, slt7, slt8, slt9,
3020
 
3021
        sdata_out
3022
        );
3023
 
3024
input           clk, rst;
3025
 
3026
// --------------------------------------
3027
// Misc Signals
3028
input           so_ld;
3029
input   [15:0]   slt0;
3030
input   [19:0]   slt1;
3031
input   [19:0]   slt2;
3032
input   [19:0]   slt3;
3033
input   [19:0]   slt4;
3034
input   [19:0]   slt6;
3035
input   [19:0]   slt7;
3036
input   [19:0]   slt8;
3037
input   [19:0]   slt9;
3038
 
3039
// --------------------------------------
3040
// AC97 Codec Interface
3041
output          sdata_out;
3042
 
3043
////////////////////////////////////////////////////////////////////
3044
//
3045
// Local Wires
3046
//
3047
 
3048
wire            sdata_out;
3049
 
3050
reg     [15:0]   slt0_r;
3051
reg     [19:0]   slt1_r;
3052
reg     [19:0]   slt2_r;
3053
reg     [19:0]   slt3_r;
3054
reg     [19:0]   slt4_r;
3055
reg     [19:0]   slt5_r;
3056
reg     [19:0]   slt6_r;
3057
reg     [19:0]   slt7_r;
3058
reg     [19:0]   slt8_r;
3059
reg     [19:0]   slt9_r;
3060
reg     [19:0]   slt10_r;
3061
reg     [19:0]   slt11_r;
3062
reg     [19:0]   slt12_r;
3063
 
3064
////////////////////////////////////////////////////////////////////
3065
//
3066
// Misc Logic
3067
//
3068
 
3069
////////////////////////////////////////////////////////////////////
3070
//
3071
// Serial Shift Register
3072
//
3073
 
3074
assign  sdata_out = slt0_r[15];
3075
 
3076
always @(posedge clk)
3077
        if(so_ld)       slt0_r <= #1 slt0;
3078
        else            slt0_r <= #1 {slt0_r[14:0], slt1_r[19]};
3079
 
3080
always @(posedge clk)
3081
        if(so_ld)       slt1_r <= #1 slt1;
3082
        else            slt1_r <= #1 {slt1_r[18:0], slt2_r[19]};
3083
 
3084
always @(posedge clk)
3085
        if(so_ld)       slt2_r <= #1 slt2;
3086
        else            slt2_r <= #1 {slt2_r[18:0], slt3_r[19]};
3087
 
3088
always @(posedge clk)
3089
        if(so_ld)       slt3_r <= #1 slt3;
3090
        else            slt3_r <= #1 {slt3_r[18:0], slt4_r[19]};
3091
 
3092
always @(posedge clk)
3093
        if(so_ld)       slt4_r <= #1 slt4;
3094
        else            slt4_r <= #1 {slt4_r[18:0], slt5_r[19]};
3095
 
3096
always @(posedge clk)
3097
        if(so_ld)       slt5_r <= #1 20'h0;
3098
        else            slt5_r <= #1 {slt5_r[18:0], slt6_r[19]};
3099
 
3100
always @(posedge clk)
3101
        if(so_ld)       slt6_r <= #1 slt6;
3102
        else            slt6_r <= #1 {slt6_r[18:0], slt7_r[19]};
3103
 
3104
always @(posedge clk)
3105
        if(so_ld)       slt7_r <= #1 slt7;
3106
        else            slt7_r <= #1 {slt7_r[18:0], slt8_r[19]};
3107
 
3108
always @(posedge clk)
3109
        if(so_ld)       slt8_r <= #1 slt8;
3110
        else            slt8_r <= #1 {slt8_r[18:0], slt9_r[19]};
3111
 
3112
always @(posedge clk)
3113
        if(so_ld)       slt9_r <= #1 slt9;
3114
        else            slt9_r <= #1 {slt9_r[18:0], slt10_r[19]};
3115
 
3116
always @(posedge clk)
3117
        if(so_ld)       slt10_r <= #1 20'h0;
3118
        else            slt10_r <= #1 {slt10_r[18:0], slt11_r[19]};
3119
 
3120
always @(posedge clk)
3121
        if(so_ld)       slt11_r <= #1 20'h0;
3122
        else            slt11_r <= #1 {slt11_r[18:0], slt12_r[19]};
3123
 
3124
always @(posedge clk)
3125
        if(so_ld)       slt12_r <= #1 20'h0;
3126
        else            slt12_r <= #1 {slt12_r[18:0], 1'b0 };
3127
 
3128
endmodule
3129
 
3130
/////////////////////////////////////////////////////////////////////
3131
////                                                             ////
3132
////  WISHBONE AC 97 Controller                                  ////
3133
////  WISHBONE Interface Module                                  ////
3134
////                                                             ////
3135
////                                                             ////
3136
////  Author: Rudolf Usselmann                                   ////
3137
////          rudi@asics.ws                                      ////
3138
////                                                             ////
3139
////                                                             ////
3140
////  Downloaded from: http://www.opencores.org/cores/ac97_ctrl/ ////
3141
////                                                             ////
3142
/////////////////////////////////////////////////////////////////////
3143
////                                                             ////
3144
//// Copyright (C) 2000-2002 Rudolf Usselmann                    ////
3145
////                         www.asics.ws                        ////
3146
////                         rudi@asics.ws                       ////
3147
////                                                             ////
3148
//// This source file may be used and distributed without        ////
3149
//// restriction provided that this copyright statement is not   ////
3150
//// removed from the file and that any derivative work contains ////
3151
//// the original copyright notice and the associated disclaimer.////
3152
////                                                             ////
3153
////     THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY     ////
3154
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   ////
3155
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   ////
3156
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      ////
3157
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         ////
3158
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    ////
3159
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   ////
3160
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        ////
3161
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  ////
3162
//// LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  ////
3163
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  ////
3164
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         ////
3165
//// POSSIBILITY OF SUCH DAMAGE.                                 ////
3166
////                                                             ////
3167
/////////////////////////////////////////////////////////////////////
3168
 
3169
//  CVS Log
3170
//
3171
//  $Id: ac97_top.v,v 1.4 2006/11/20 17:13:43 tame Exp $
3172
//
3173
//  $Date: 2006/11/20 17:13:43 $
3174
//  $Revision: 1.4 $
3175
//  $Author: tame $
3176
//  $Locker:  $
3177
//  $State: Exp $
3178
//
3179
// Change History:
3180
//               $Log: ac97_top.v,v $
3181
//               Revision 1.4  2006/11/20 17:13:43  tame
3182
//               Originally calculated values used.
3183
//
3184
//               Revision 1.3  2006/09/11 13:12:13  tame
3185
//               Tried out high timing settings - works in hardware.
3186
//
3187
//               Revision 1.2  2006/08/16 08:46:04  tame
3188
//               AC97 core: register set read/writable in first simulations; in hardware, however,
3189
//               not yet
3190
//
3191
//               Revision 1.1  2006/08/14 15:25:09  tame
3192
//               added ac97 codec from OpenCores
3193
//               adapted configuration in ac97_defines module
3194
//
3195
//               Revision 1.4  2002/09/19 06:30:56  rudi
3196
//               Fixed a bug reported by Igor. Apparently this bug only shows up when
3197
//               the WB clock is very low (2x bit_clk). Updated Copyright header.
3198
//
3199
//               Revision 1.3  2002/03/05 04:44:05  rudi
3200
//
3201
//               - Fixed the order of the thrash hold bits to match the spec.
3202
//               - Many minor synthesis cleanup items ...
3203
//
3204
//               Revision 1.2  2001/08/10 08:09:42  rudi
3205
//
3206
//               - Removed RTY_O output.
3207
//               - Added Clock and Reset Inputs to documentation.
3208
//               - Changed IO names to be more clear.
3209
//               - Uniquifyed define names to be core specific.
3210
//
3211
//               Revision 1.1  2001/08/03 06:54:50  rudi
3212
//
3213
//
3214
//               - Changed to new directory structure
3215
//
3216
//               Revision 1.1.1.1  2001/05/19 02:29:16  rudi
3217
//               Initial Checkin
3218
//
3219
//
3220
//
3221
//
3222
 
3223
// `include "ac97_defines.v"
3224
 
3225
module ac97_wb_if(clk, rst,
3226
 
3227
                wb_data_i, wb_data_o, wb_addr_i, wb_sel_i, wb_we_i, wb_cyc_i,
3228
                wb_stb_i, wb_ack_o, wb_err_o,
3229
 
3230
                adr, dout, rf_din, i3_din, i4_din, i6_din,
3231
                rf_we, rf_re, o3_we, o4_we, o6_we, o7_we, o8_we, o9_we,
3232
                i3_re, i4_re, i6_re
3233
 
3234
                );
3235
 
3236
input           clk,rst;
3237
 
3238
// WISHBONE Interface
3239
input   [31:0]   wb_data_i;
3240
output  [31:0]   wb_data_o;
3241
input   [31:0]   wb_addr_i;
3242
input   [3:0]    wb_sel_i;
3243
input           wb_we_i;
3244
input           wb_cyc_i;
3245
input           wb_stb_i;
3246
output          wb_ack_o;
3247
output          wb_err_o;
3248
 
3249
// Internal Interface
3250
output  [3:0]    adr;
3251
output  [31:0]   dout;
3252
input   [31:0]   rf_din, i3_din, i4_din, i6_din;
3253
output          rf_we;
3254
output          rf_re;
3255
output          o3_we, o4_we, o6_we, o7_we, o8_we, o9_we;
3256
output          i3_re, i4_re, i6_re;
3257
 
3258
////////////////////////////////////////////////////////////////////
3259
//
3260
// Local Wires
3261
//
3262
 
3263
reg     [31:0]   wb_data_o;
3264
reg     [31:0]   dout;
3265
reg             wb_ack_o;
3266
 
3267
reg             rf_we;
3268
reg             o3_we, o4_we, o6_we, o7_we, o8_we, o9_we;
3269
reg             i3_re, i4_re, i6_re;
3270
 
3271
reg             we1, we2;
3272
wire            we;
3273
reg             re2, re1;
3274
wire            re;
3275
 
3276
////////////////////////////////////////////////////////////////////
3277
//
3278
// Modules
3279
//
3280
 
3281
assign adr = wb_addr_i[5:2];
3282
 
3283
assign wb_err_o = 1'b0;
3284
 
3285
always @(posedge clk)
3286
        dout <= #1 wb_data_i;
3287
 
3288
always @(posedge clk)
3289
        case(wb_addr_i[6:2])    // synopsys parallel_case full_case
3290
           5'he: wb_data_o <= #1 i3_din;
3291
           5'hf: wb_data_o <= #1 i4_din;
3292
           5'h10: wb_data_o <= #1 i6_din;
3293
           default: wb_data_o <= #1 rf_din;
3294
        endcase
3295
 
3296
always @(posedge clk)
3297
        re1 <= #1 !re2 & wb_cyc_i & wb_stb_i & !wb_we_i & `AC97_REG_SEL;
3298
 
3299
always @(posedge clk)
3300
        re2 <= #1 re & wb_cyc_i & wb_stb_i & !wb_we_i ;
3301
 
3302
assign re = re1 & !re2 & wb_cyc_i & wb_stb_i & !wb_we_i;
3303
 
3304
assign rf_re = re & (wb_addr_i[6:2] < 5'h8);
3305
 
3306
always @(posedge clk)
3307
        we1 <= #1 !we & wb_cyc_i & wb_stb_i & wb_we_i & `AC97_REG_SEL;
3308
 
3309
always @(posedge clk)
3310
        we2 <= #1 we1 & wb_cyc_i & wb_stb_i & wb_we_i;
3311
 
3312
assign we = we1 & !we2 & wb_cyc_i & wb_stb_i & wb_we_i;
3313
 
3314
always @(posedge clk)
3315
        wb_ack_o <= #1 (re | we) & wb_cyc_i & wb_stb_i & ~wb_ack_o;
3316
 
3317
always @(posedge clk)
3318
        rf_we <= #1 we & (wb_addr_i[6:2] < 5'h8);
3319
 
3320
always @(posedge clk)
3321
        o3_we <= #1 we & (wb_addr_i[6:2] == 5'h8);
3322
 
3323
always @(posedge clk)
3324
        o4_we <= #1 we & (wb_addr_i[6:2] == 5'h9);
3325
 
3326
always @(posedge clk)
3327
        o6_we <= #1 we & (wb_addr_i[6:2] == 5'ha);
3328
 
3329
always @(posedge clk)
3330
        o7_we <= #1 we & (wb_addr_i[6:2] == 5'hb);
3331
 
3332
always @(posedge clk)
3333
        o8_we <= #1 we & (wb_addr_i[6:2] == 5'hc);
3334
 
3335
always @(posedge clk)
3336
        o9_we <= #1 we & (wb_addr_i[6:2] == 5'hd);
3337
 
3338
always @(posedge clk)
3339
        i3_re <= #1 re & (wb_addr_i[6:2] == 5'he);
3340
 
3341
always @(posedge clk)
3342
        i4_re <= #1 re & (wb_addr_i[6:2] == 5'hf);
3343
 
3344
always @(posedge clk)
3345
        i6_re <= #1 re & (wb_addr_i[6:2] == 5'h10);
3346
 
3347
endmodule
3348
 
3349
/////////////////////////////////////////////////////////////////////
3350
////                                                             ////
3351
////  WISHBONE AC 97 Controller Top Level                        ////
3352
////                                                             ////
3353
////                                                             ////
3354
////  Author: Rudolf Usselmann                                   ////
3355
////          rudi@asics.ws                                      ////
3356
////                                                             ////
3357
////                                                             ////
3358
////  Downloaded from: http://www.opencores.org/cores/ac97_ctrl/ ////
3359
////                                                             ////
3360
/////////////////////////////////////////////////////////////////////
3361
////                                                             ////
3362
//// Copyright (C) 2000-2002 Rudolf Usselmann                    ////
3363
////                         www.asics.ws                        ////
3364
////                         rudi@asics.ws                       ////
3365
////                                                             ////
3366
//// This source file may be used and distributed without        ////
3367
//// restriction provided that this copyright statement is not   ////
3368
//// removed from the file and that any derivative work contains ////
3369
//// the original copyright notice and the associated disclaimer.////
3370
////                                                             ////
3371
////     THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY     ////
3372
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   ////
3373
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   ////
3374
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      ////
3375
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         ////
3376
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    ////
3377
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   ////
3378
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        ////
3379
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  ////
3380
//// LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  ////
3381
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  ////
3382
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         ////
3383
//// POSSIBILITY OF SUCH DAMAGE.                                 ////
3384
////                                                             ////
3385
/////////////////////////////////////////////////////////////////////
3386
 
3387
//  CVS Log
3388
//
3389
//  $Id: ac97_top.v,v 1.4 2006/11/20 17:13:43 tame Exp $
3390
//
3391
//  $Date: 2006/11/20 17:13:43 $
3392
//  $Revision: 1.4 $
3393
//  $Author: tame $
3394
//  $Locker:  $
3395
//  $State: Exp $
3396
//
3397
// Change History:
3398
//               $Log: ac97_top.v,v $
3399
//               Revision 1.4  2006/11/20 17:13:43  tame
3400
//               Originally calculated values used.
3401
//
3402
//               Revision 1.3  2006/09/11 13:12:13  tame
3403
//               Tried out high timing settings - works in hardware.
3404
//
3405
//               Revision 1.2  2006/08/16 08:46:04  tame
3406
//               AC97 core: register set read/writable in first simulations; in hardware, however,
3407
//               not yet
3408
//
3409
//               Revision 1.1  2006/08/14 15:25:09  tame
3410
//               added ac97 codec from OpenCores
3411
//               adapted configuration in ac97_defines module
3412
//
3413
//               Revision 1.4  2002/09/19 06:30:56  rudi
3414
//               Fixed a bug reported by Igor. Apparently this bug only shows up when
3415
//               the WB clock is very low (2x bit_clk). Updated Copyright header.
3416
//
3417
//               Revision 1.3  2002/03/05 04:44:05  rudi
3418
//
3419
//               - Fixed the order of the thrash hold bits to match the spec.
3420
//               - Many minor synthesis cleanup items ...
3421
//
3422
//               Revision 1.2  2001/08/10 08:09:42  rudi
3423
//
3424
//               - Removed RTY_O output.
3425
//               - Added Clock and Reset Inputs to documentation.
3426
//               - Changed IO names to be more clear.
3427
//               - Uniquifyed define names to be core specific.
3428
//
3429
//               Revision 1.1  2001/08/03 06:54:50  rudi
3430
//
3431
//
3432
//               - Changed to new directory structure
3433
//
3434
//               Revision 1.1.1.1  2001/05/19 02:29:14  rudi
3435
//               Initial Checkin
3436
//
3437
//
3438
//
3439
//
3440
 
3441
// `include "ac97_defines.v"
3442
 
3443
module ac97_top(clk_i, rst_i,
3444
 
3445
        wb_data_i, wb_data_o, wb_addr_i, wb_sel_i, wb_we_i, wb_cyc_i,
3446
        wb_stb_i, wb_ack_o, wb_err_o,
3447
 
3448
        int_o, dma_req_o, dma_ack_i,
3449
        suspended_o,
3450
 
3451
        bit_clk_pad_i, sync_pad_o, sdata_pad_o, sdata_pad_i,
3452
        ac97_resetn_pad_o
3453
        );
3454
 
3455
input           clk_i, rst_i;
3456
 
3457
// --------------------------------------
3458
// WISHBONE SLAVE INTERFACE 
3459
input   [31:0]   wb_data_i;
3460
output  [31:0]   wb_data_o;
3461
input   [31:0]   wb_addr_i;
3462
input   [3:0]    wb_sel_i;
3463
input           wb_we_i;
3464
input           wb_cyc_i;
3465
input           wb_stb_i;
3466
output          wb_ack_o;
3467
output          wb_err_o;
3468
 
3469
// --------------------------------------
3470
// Misc Signals
3471
output          int_o;
3472
output  [8:0]    dma_req_o;
3473
input   [8:0]    dma_ack_i;
3474
 
3475
// --------------------------------------
3476
// Suspend Resume Interface
3477
output          suspended_o;
3478
 
3479
// --------------------------------------
3480
// AC97 Codec Interface
3481
input           bit_clk_pad_i;
3482
output          sync_pad_o;
3483
output          sdata_pad_o;
3484
input           sdata_pad_i;
3485
output          ac97_resetn_pad_o;
3486
 
3487
////////////////////////////////////////////////////////////////////
3488
//
3489
// Local Wires
3490
//
3491
 
3492
// Serial Output register interface
3493
wire    [15:0]   out_slt0;
3494
wire    [19:0]   out_slt1;
3495
wire    [19:0]   out_slt2;
3496
wire    [19:0]   out_slt3;
3497
wire    [19:0]   out_slt4;
3498
wire    [19:0]   out_slt6;
3499
wire    [19:0]   out_slt7;
3500
wire    [19:0]   out_slt8;
3501
wire    [19:0]   out_slt9;
3502
 
3503
// Serial Input register interface
3504
wire    [15:0]   in_slt0;
3505
wire    [19:0]   in_slt1;
3506
wire    [19:0]   in_slt2;
3507
wire    [19:0]   in_slt3;
3508
wire    [19:0]   in_slt4;
3509
wire    [19:0]   in_slt6;
3510
 
3511
// Serial IO Controller Interface
3512
wire            ld;
3513
wire            valid;
3514
wire    [5:0]    out_le;
3515
wire    [2:0]    in_valid;
3516
wire            ps_ce;
3517
 
3518
// Valid Sync
3519
reg             valid_s1, valid_s;
3520
reg     [2:0]    in_valid_s1, in_valid_s;
3521
 
3522
// Out FIFO interface
3523
wire    [31:0]   wb_din;
3524
wire    [1:0]    o3_mode, o4_mode, o6_mode, o7_mode, o8_mode, o9_mode;
3525
wire            o3_re, o4_re, o6_re, o7_re, o8_re, o9_re;
3526
wire            o3_we, o4_we, o6_we, o7_we, o8_we, o9_we;
3527
wire    [1:0]    o3_status, o4_status, o6_status, o7_status, o8_status, o9_status;
3528
wire            o3_full, o4_full, o6_full, o7_full, o8_full, o9_full;
3529
wire            o3_empty, o4_empty, o6_empty, o7_empty, o8_empty, o9_empty;
3530
 
3531
// In FIFO interface
3532
wire    [31:0]   i3_dout, i4_dout, i6_dout;
3533
wire    [1:0]    i3_mode, i4_mode, i6_mode;
3534
wire            i3_we, i4_we, i6_we;
3535
wire            i3_re, i4_re, i6_re;
3536
wire    [1:0]    i3_status, i4_status, i6_status;
3537
wire            i3_full, i4_full, i6_full;
3538
wire            i3_empty, i4_empty, i6_empty;
3539
 
3540
// Register File Interface
3541
wire    [3:0]    adr;
3542
wire    [31:0]   rf_dout;
3543
wire    [31:0]   rf_din;
3544
wire            rf_we;
3545
wire            rf_re;
3546
wire            ac97_rst_force;
3547
wire            resume_req;
3548
wire            crac_we;
3549
wire    [15:0]   crac_din;
3550
wire    [31:0]   crac_out;
3551
wire    [7:0]    oc0_cfg;
3552
wire    [7:0]    oc1_cfg;
3553
wire    [7:0]    oc2_cfg;
3554
wire    [7:0]    oc3_cfg;
3555
wire    [7:0]    oc4_cfg;
3556
wire    [7:0]    oc5_cfg;
3557
wire    [7:0]    ic0_cfg;
3558
wire    [7:0]    ic1_cfg;
3559
wire    [7:0]    ic2_cfg;
3560
wire    [2:0]    oc0_int_set;
3561
wire    [2:0]    oc1_int_set;
3562
wire    [2:0]    oc2_int_set;
3563
wire    [2:0]    oc3_int_set;
3564
wire    [2:0]    oc4_int_set;
3565
wire    [2:0]    oc5_int_set;
3566
wire    [2:0]    ic0_int_set;
3567
wire    [2:0]    ic1_int_set;
3568
wire    [2:0]    ic2_int_set;
3569
 
3570
// CRA Module interface
3571
wire            crac_valid;
3572
wire            crac_wr;
3573
wire            crac_wr_done, crac_rd_done;
3574
 
3575
////////////////////////////////////////////////////////////////////
3576
//
3577
// Misc Logic
3578
//
3579
 
3580
// Sync Valid to WISHBONE Clock
3581
always @(posedge clk_i)
3582
        valid_s1 <= #1 valid;
3583
 
3584
always @(posedge clk_i)
3585
        valid_s <= #1 valid_s1;
3586
 
3587
always @(posedge clk_i)
3588
        in_valid_s1 <= #1 in_valid;
3589
 
3590
always @(posedge clk_i)
3591
        in_valid_s <= #1 in_valid_s1;
3592
 
3593
// "valid_s" Indicates when any of the outputs to the output S/R may
3594
// change or when outputs from input S/R may be sampled
3595
assign o3_mode = oc0_cfg[3:2];
3596
assign o4_mode = oc1_cfg[3:2];
3597
assign o6_mode = oc2_cfg[3:2];
3598
assign o7_mode = oc3_cfg[3:2];
3599
assign o8_mode = oc4_cfg[3:2];
3600
assign o9_mode = oc5_cfg[3:2];
3601
assign i3_mode = ic0_cfg[3:2];
3602
assign i4_mode = ic1_cfg[3:2];
3603
assign i6_mode = ic2_cfg[3:2];
3604
 
3605
////////////////////////////////////////////////////////////////////
3606
//
3607
// Modules
3608
//
3609
 
3610
ac97_sout       u0(
3611
                .clk(           bit_clk_pad_i   ),
3612
                .rst(           rst_i           ),
3613
                .so_ld(         ld              ),
3614
                .slt0(          out_slt0        ),
3615
                .slt1(          out_slt1        ),
3616
                .slt2(          out_slt2        ),
3617
                .slt3(          out_slt3        ),
3618
                .slt4(          out_slt4        ),
3619
                .slt6(          out_slt6        ),
3620
                .slt7(          out_slt7        ),
3621
                .slt8(          out_slt8        ),
3622
                .slt9(          out_slt9        ),
3623
                .sdata_out(     sdata_pad_o     )
3624
                );
3625
 
3626
ac97_sin        u1(
3627
                .clk(           bit_clk_pad_i   ),
3628
                .rst(           rst_i           ),
3629
                .out_le(        out_le          ),
3630
                .slt0(          in_slt0         ),
3631
                .slt1(          in_slt1         ),
3632
                .slt2(          in_slt2         ),
3633
                .slt3(          in_slt3         ),
3634
                .slt4(          in_slt4         ),
3635
                .slt6(          in_slt6         ),
3636
                .sdata_in(      sdata_pad_i     )
3637
                );
3638
 
3639
ac97_soc        u2(
3640
                .clk(           bit_clk_pad_i   ),
3641
                .wclk(          clk_i           ),
3642
                .rst(           rst_i           ),
3643
                .ps_ce(         ps_ce           ),
3644
                .resume(        resume_req      ),
3645
                .suspended(     suspended_o     ),
3646
                .sync(          sync_pad_o      ),
3647
                .out_le(        out_le          ),
3648
                .in_valid(      in_valid        ),
3649
                .ld(            ld              ),
3650
                .valid(         valid           )
3651
                );
3652
 
3653
ac97_out_fifo   u3(
3654
                .clk(           clk_i           ),
3655
                .rst(           rst_i           ),
3656
                .en(            oc0_cfg[0]       ),
3657
                .mode(          o3_mode         ),
3658
                .din(           wb_din          ),
3659
                .we(            o3_we           ),
3660
                .dout(          out_slt3        ),
3661
                .re(            o3_re           ),
3662
                .status(        o3_status       ),
3663
                .full(          o3_full         ),
3664
                .empty(         o3_empty        )
3665
                );
3666
 
3667
ac97_out_fifo   u4(
3668
                .clk(           clk_i           ),
3669
                .rst(           rst_i           ),
3670
                .en(            oc1_cfg[0]       ),
3671
                .mode(          o4_mode         ),
3672
                .din(           wb_din          ),
3673
                .we(            o4_we           ),
3674
                .dout(          out_slt4        ),
3675
                .re(            o4_re           ),
3676
                .status(        o4_status       ),
3677
                .full(          o4_full         ),
3678
                .empty(         o4_empty        )
3679
                );
3680
 
3681
`ifdef AC97_CENTER
3682
ac97_out_fifo   u5(
3683
                .clk(           clk_i           ),
3684
                .rst(           rst_i           ),
3685
                .en(            oc2_cfg[0]       ),
3686
                .mode(          o6_mode         ),
3687
                .din(           wb_din          ),
3688
                .we(            o6_we           ),
3689
                .dout(          out_slt6        ),
3690
                .re(            o6_re           ),
3691
                .status(        o6_status       ),
3692
                .full(          o6_full         ),
3693
                .empty(         o6_empty        )
3694
                );
3695
`else
3696
assign out_slt6 = 20'h0;
3697
assign o6_status = 2'h0;
3698
assign o6_full = 1'b0;
3699
assign o6_empty = 1'b0;
3700
`endif
3701
 
3702
`ifdef AC97_SURROUND
3703
ac97_out_fifo   u6(
3704
                .clk(           clk_i           ),
3705
                .rst(           rst_i           ),
3706
                .en(            oc3_cfg[0]       ),
3707
                .mode(          o7_mode         ),
3708
                .din(           wb_din          ),
3709
                .we(            o7_we           ),
3710
                .dout(          out_slt7        ),
3711
                .re(            o7_re           ),
3712
                .status(        o7_status       ),
3713
                .full(          o7_full         ),
3714
                .empty(         o7_empty        )
3715
                );
3716
 
3717
ac97_out_fifo   u7(
3718
                .clk(           clk_i           ),
3719
                .rst(           rst_i           ),
3720
                .en(            oc4_cfg[0]       ),
3721
                .mode(          o8_mode         ),
3722
                .din(           wb_din          ),
3723
                .we(            o8_we           ),
3724
                .dout(          out_slt8        ),
3725
                .re(            o8_re           ),
3726
                .status(        o8_status       ),
3727
                .full(          o8_full         ),
3728
                .empty(         o8_empty        )
3729
                );
3730
`else
3731
assign out_slt7 = 20'h0;
3732
assign o7_status = 2'h0;
3733
assign o7_full = 1'b0;
3734
assign o7_empty = 1'b0;
3735
assign out_slt8 = 20'h0;
3736
assign o8_status = 2'h0;
3737
assign o8_full = 1'b0;
3738
assign o8_empty = 1'b0;
3739
`endif
3740
 
3741
`ifdef AC97_LFE
3742
ac97_out_fifo   u8(
3743
                .clk(           clk_i           ),
3744
                .rst(           rst_i           ),
3745
                .en(            oc5_cfg[0]       ),
3746
                .mode(          o9_mode         ),
3747
                .din(           wb_din          ),
3748
                .we(            o9_we           ),
3749
                .dout(          out_slt9        ),
3750
                .re(            o9_re           ),
3751
                .status(        o9_status       ),
3752
                .full(          o9_full         ),
3753
                .empty(         o9_empty        )
3754
                );
3755
`else
3756
assign out_slt9 = 20'h0;
3757
assign o9_status = 2'h0;
3758
assign o9_full = 1'b0;
3759
assign o9_empty = 1'b0;
3760
`endif
3761
 
3762
`ifdef AC97_SIN
3763
ac97_in_fifo    u9(
3764
                .clk(           clk_i           ),
3765
                .rst(           rst_i           ),
3766
                .en(            ic0_cfg[0]       ),
3767
                .mode(          i3_mode         ),
3768
                .din(           in_slt3         ),
3769
                .we(            i3_we           ),
3770
                .dout(          i3_dout         ),
3771
                .re(            i3_re           ),
3772
                .status(        i3_status       ),
3773
                .full(          i3_full         ),
3774
                .empty(         i3_empty        )
3775
                );
3776
 
3777
ac97_in_fifo    u10(
3778
                .clk(           clk_i           ),
3779
                .rst(           rst_i           ),
3780
                .en(            ic1_cfg[0]       ),
3781
                .mode(          i4_mode         ),
3782
                .din(           in_slt4         ),
3783
                .we(            i4_we           ),
3784
                .dout(          i4_dout         ),
3785
                .re(            i4_re           ),
3786
                .status(        i4_status       ),
3787
                .full(          i4_full         ),
3788
                .empty(         i4_empty        )
3789
                );
3790
`else
3791
assign i3_dout = 20'h0;
3792
assign i3_status = 2'h0;
3793
assign i3_full = 1'b0;
3794
assign i3_empty = 1'b0;
3795
assign i4_dout = 20'h0;
3796
assign i4_status = 2'h0;
3797
assign i4_full = 1'b0;
3798
assign i4_empty = 1'b0;
3799
`endif
3800
 
3801
`ifdef AC97_MICIN
3802
ac97_in_fifo    u11(
3803
                .clk(           clk_i           ),
3804
                .rst(           rst_i           ),
3805
                .en(            ic2_cfg[0]       ),
3806
                .mode(          i6_mode         ),
3807
                .din(           in_slt6         ),
3808
                .we(            i6_we           ),
3809
                .dout(          i6_dout         ),
3810
                .re(            i6_re           ),
3811
                .status(        i6_status       ),
3812
                .full(          i6_full         ),
3813
                .empty(         i6_empty        )
3814
                );
3815
`else
3816
assign i6_dout = 20'h0;
3817
assign i6_status = 2'h0;
3818
assign i6_full = 1'b0;
3819
assign i6_empty = 1'b0;
3820
`endif
3821
 
3822
ac97_wb_if      u12(
3823
                .clk(           clk_i           ),
3824
                .rst(           rst_i           ),
3825
                .wb_data_i(     wb_data_i       ),
3826
                .wb_data_o(     wb_data_o       ),
3827
                .wb_addr_i(     wb_addr_i       ),
3828
                .wb_sel_i(      wb_sel_i        ),
3829
                .wb_we_i(       wb_we_i         ),
3830
                .wb_cyc_i(      wb_cyc_i        ),
3831
                .wb_stb_i(      wb_stb_i        ),
3832
                .wb_ack_o(      wb_ack_o        ),
3833
                .wb_err_o(      wb_err_o        ),
3834
                .adr(           adr             ),
3835
                .dout(          wb_din          ),
3836
                .rf_din(        rf_dout         ),
3837
                .i3_din(        i3_dout         ),
3838
                .i4_din(        i4_dout         ),
3839
                .i6_din(        i6_dout         ),
3840
                .rf_we(         rf_we           ),
3841
                .rf_re(         rf_re           ),
3842
                .o3_we(         o3_we           ),
3843
                .o4_we(         o4_we           ),
3844
                .o6_we(         o6_we           ),
3845
                .o7_we(         o7_we           ),
3846
                .o8_we(         o8_we           ),
3847
                .o9_we(         o9_we           ),
3848
                .i3_re(         i3_re           ),
3849
                .i4_re(         i4_re           ),
3850
                .i6_re(         i6_re           )
3851
                );
3852
 
3853
ac97_rf u13(    .clk(           clk_i           ),
3854
                .rst(           rst_i           ),
3855
                .adr(           adr             ),
3856
                .rf_dout(       rf_dout         ),
3857
                .rf_din(        wb_din          ),
3858
                .rf_we(         rf_we           ),
3859
                .rf_re(         rf_re           ),
3860
                .int(           int_o           ),
3861
                .ac97_rst_force(ac97_rst_force  ),
3862
                .resume_req(    resume_req      ),
3863
                .suspended(     suspended_o     ),
3864
                .crac_we(       crac_we         ),
3865
                .crac_din(      crac_din        ),
3866
                .crac_out(      crac_out        ),
3867
                .crac_wr_done(  crac_wr_done    ),
3868
                .crac_rd_done(  crac_rd_done    ),
3869
                .oc0_cfg(       oc0_cfg         ),
3870
                .oc1_cfg(       oc1_cfg         ),
3871
                .oc2_cfg(       oc2_cfg         ),
3872
                .oc3_cfg(       oc3_cfg         ),
3873
                .oc4_cfg(       oc4_cfg         ),
3874
                .oc5_cfg(       oc5_cfg         ),
3875
                .ic0_cfg(       ic0_cfg         ),
3876
                .ic1_cfg(       ic1_cfg         ),
3877
                .ic2_cfg(       ic2_cfg         ),
3878
                .oc0_int_set(   oc0_int_set     ),
3879
                .oc1_int_set(   oc1_int_set     ),
3880
                .oc2_int_set(   oc2_int_set     ),
3881
                .oc3_int_set(   oc3_int_set     ),
3882
                .oc4_int_set(   oc4_int_set     ),
3883
                .oc5_int_set(   oc5_int_set     ),
3884
                .ic0_int_set(   ic0_int_set     ),
3885
                .ic1_int_set(   ic1_int_set     ),
3886
                .ic2_int_set(   ic2_int_set     )
3887
                );
3888
 
3889
ac97_prc u14(   .clk(           clk_i           ),
3890
                .rst(           rst_i           ),
3891
                .valid(         valid_s         ),
3892
                .in_valid(      in_valid_s      ),
3893
                .out_slt0(      out_slt0        ),
3894
                .in_slt0(       in_slt0         ),
3895
                .in_slt1(       in_slt1         ),
3896
                .crac_valid(    crac_valid      ),
3897
                .crac_wr(       crac_wr         ),
3898
                .oc0_cfg(       oc0_cfg         ),
3899
                .oc1_cfg(       oc1_cfg         ),
3900
                .oc2_cfg(       oc2_cfg         ),
3901
                .oc3_cfg(       oc3_cfg         ),
3902
                .oc4_cfg(       oc4_cfg         ),
3903
                .oc5_cfg(       oc5_cfg         ),
3904
                .ic0_cfg(       ic0_cfg         ),
3905
                .ic1_cfg(       ic1_cfg         ),
3906
                .ic2_cfg(       ic2_cfg         ),
3907
                .o3_empty(      o3_empty        ),
3908
                .o4_empty(      o4_empty        ),
3909
                .o6_empty(      o6_empty        ),
3910
                .o7_empty(      o7_empty        ),
3911
                .o8_empty(      o8_empty        ),
3912
                .o9_empty(      o9_empty        ),
3913
                .i3_full(       i3_full         ),
3914
                .i4_full(       i4_full         ),
3915
                .i6_full(       i6_full         ),
3916
                .o3_re(         o3_re           ),
3917
                .o4_re(         o4_re           ),
3918
                .o6_re(         o6_re           ),
3919
                .o7_re(         o7_re           ),
3920
                .o8_re(         o8_re           ),
3921
                .o9_re(         o9_re           ),
3922
                .i3_we(         i3_we           ),
3923
                .i4_we(         i4_we           ),
3924
                .i6_we(         i6_we           )
3925
                );
3926
 
3927
ac97_cra u15(   .clk(           clk_i           ),
3928
                .rst(           rst_i           ),
3929
                .crac_we(       crac_we         ),
3930
                .crac_din(      crac_din        ),
3931
                .crac_out(      crac_out        ),
3932
                .crac_wr_done(  crac_wr_done    ),
3933
                .crac_rd_done(  crac_rd_done    ),
3934
                .valid(         valid_s         ),
3935
                .out_slt1(      out_slt1        ),
3936
                .out_slt2(      out_slt2        ),
3937
                .in_slt2(       in_slt2         ),
3938
                .crac_valid(    crac_valid      ),
3939
                .crac_wr(       crac_wr         )
3940
                );
3941
 
3942
ac97_dma_if u16(.clk(           clk_i           ),
3943
                .rst(           rst_i           ),
3944
                .o3_status(     o3_status       ),
3945
                .o4_status(     o4_status       ),
3946
                .o6_status(     o6_status       ),
3947
                .o7_status(     o7_status       ),
3948
                .o8_status(     o8_status       ),
3949
                .o9_status(     o9_status       ),
3950
                .o3_empty(      o3_empty        ),
3951
                .o4_empty(      o4_empty        ),
3952
                .o6_empty(      o6_empty        ),
3953
                .o7_empty(      o7_empty        ),
3954
                .o8_empty(      o8_empty        ),
3955
                .o9_empty(      o9_empty        ),
3956
                .i3_status(     i3_status       ),
3957
                .i4_status(     i4_status       ),
3958
                .i6_status(     i6_status       ),
3959
                .i3_full(       i3_full         ),
3960
                .i4_full(       i4_full         ),
3961
                .i6_full(       i6_full         ),
3962
                .oc0_cfg(       oc0_cfg         ),
3963
                .oc1_cfg(       oc1_cfg         ),
3964
                .oc2_cfg(       oc2_cfg         ),
3965
                .oc3_cfg(       oc3_cfg         ),
3966
                .oc4_cfg(       oc4_cfg         ),
3967
                .oc5_cfg(       oc5_cfg         ),
3968
                .ic0_cfg(       ic0_cfg         ),
3969
                .ic1_cfg(       ic1_cfg         ),
3970
                .ic2_cfg(       ic2_cfg         ),
3971
                .dma_req(       dma_req_o       ),
3972
                .dma_ack(       dma_ack_i       )
3973
                );
3974
 
3975
ac97_int        u17(
3976
                .clk(           clk_i           ),
3977
                .rst(           rst_i           ),
3978
                .int_set(       oc0_int_set     ),
3979
                .cfg(           oc0_cfg         ),
3980
                .status(        o3_status       ),
3981
                .full_empty(    o3_empty        ),
3982
                .full(          o3_full         ),
3983
                .empty(         o3_empty        ),
3984
                .re(            o3_re           ),
3985
                .we(            o3_we           )
3986
                );
3987
 
3988
ac97_int        u18(
3989
                .clk(           clk_i           ),
3990
                .rst(           rst_i           ),
3991
                .int_set(       oc1_int_set     ),
3992
                .cfg(           oc1_cfg         ),
3993
                .status(        o4_status       ),
3994
                .full_empty(    o4_empty        ),
3995
                .full(          o4_full         ),
3996
                .empty(         o4_empty        ),
3997
                .re(            o4_re           ),
3998
                .we(            o4_we           )
3999
                );
4000
 
4001
`ifdef AC97_CENTER
4002
ac97_int        u19(
4003
                .clk(           clk_i           ),
4004
                .rst(           rst_i           ),
4005
                .int_set(       oc2_int_set     ),
4006
                .cfg(           oc2_cfg         ),
4007
                .status(        o6_status       ),
4008
                .full_empty(    o6_empty        ),
4009
                .full(          o6_full         ),
4010
                .empty(         o6_empty        ),
4011
                .re(            o6_re           ),
4012
                .we(            o6_we           )
4013
                );
4014
`else
4015
assign oc2_int_set = 1'b0;
4016
`endif
4017
 
4018
`ifdef AC97_SURROUND
4019
ac97_int        u20(
4020
                .clk(           clk_i           ),
4021
                .rst(           rst_i           ),
4022
                .int_set(       oc3_int_set     ),
4023
                .cfg(           oc3_cfg         ),
4024
                .status(        o7_status       ),
4025
                .full_empty(    o7_empty        ),
4026
                .full(          o7_full         ),
4027
                .empty(         o7_empty        ),
4028
                .re(            o7_re           ),
4029
                .we(            o7_we           )
4030
                );
4031
 
4032
ac97_int        u21(
4033
                .clk(           clk_i           ),
4034
                .rst(           rst_i           ),
4035
                .int_set(       oc4_int_set     ),
4036
                .cfg(           oc4_cfg         ),
4037
                .status(        o8_status       ),
4038
                .full_empty(    o8_empty        ),
4039
                .full(          o8_full         ),
4040
                .empty(         o8_empty        ),
4041
                .re(            o8_re           ),
4042
                .we(            o8_we           )
4043
                );
4044
`else
4045
assign oc3_int_set = 1'b0;
4046
assign oc4_int_set = 1'b0;
4047
`endif
4048
 
4049
`ifdef AC97_LFE
4050
ac97_int        u22(
4051
                .clk(           clk_i           ),
4052
                .rst(           rst_i           ),
4053
                .int_set(       oc5_int_set     ),
4054
                .cfg(           oc5_cfg         ),
4055
                .status(        o9_status       ),
4056
                .full_empty(    o9_empty        ),
4057
                .full(          o9_full         ),
4058
                .empty(         o9_empty        ),
4059
                .re(            o9_re           ),
4060
                .we(            o9_we           )
4061
                );
4062
`else
4063
assign oc5_int_set = 1'b0;
4064
`endif
4065
 
4066
`ifdef AC97_SIN
4067
ac97_int        u23(
4068
                .clk(           clk_i           ),
4069
                .rst(           rst_i           ),
4070
                .int_set(       ic0_int_set     ),
4071
                .cfg(           ic0_cfg         ),
4072
                .status(        i3_status       ),
4073
                .full_empty(    i3_full         ),
4074
                .full(          i3_full         ),
4075
                .empty(         i3_empty        ),
4076
                .re(            i3_re           ),
4077
                .we(            i3_we           )
4078
                );
4079
 
4080
ac97_int        u24(
4081
                .clk(           clk_i           ),
4082
                .rst(           rst_i           ),
4083
                .int_set(       ic1_int_set     ),
4084
                .cfg(           ic1_cfg         ),
4085
                .status(        i4_status       ),
4086
                .full_empty(    i4_full         ),
4087
                .full(          i4_full         ),
4088
                .empty(         i4_empty        ),
4089
                .re(            i4_re           ),
4090
                .we(            i4_we           )
4091
                );
4092
`else
4093
assign ic0_int_set = 1'b0;
4094
assign ic1_int_set = 1'b0;
4095
`endif
4096
 
4097
`ifdef AC97_MICIN
4098
ac97_int        u25(
4099
                .clk(           clk_i           ),
4100
                .rst(           rst_i           ),
4101
                .int_set(       ic2_int_set     ),
4102
                .cfg(           ic2_cfg         ),
4103
                .status(        i6_status       ),
4104
                .full_empty(    i6_full         ),
4105
                .full(          i6_full         ),
4106
                .empty(         i6_empty        ),
4107
                .re(            i6_re           ),
4108
                .we(            i6_we           )
4109
                );
4110
`else
4111
assign ic2_int_set = 1'b0;
4112
`endif
4113
 
4114
ac97_rst        u26(
4115
                .clk(           clk_i                           ),
4116
                .rst(           rst_i                           ),
4117
                .rst_force(     ac97_rst_force                  ),
4118
                .ps_ce(         ps_ce                           ),
4119
                .ac97_rst_(     ac97_resetn_pad_o               )
4120
                );
4121
 
4122
endmodule
4123
 
4124
 

powered by: WebSVN 2.1.0

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