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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [mp3/] [rtl/] [verilog/] [audio/] [audio_codec_if.v] - Blame information for rev 1774

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

Line No. Rev Author Line
1 266 lampret
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  MP3 demo Audio CODEC interface                              ////
4
////                                                              ////
5
////  This file is part of the MP3 demo application               ////
6
////  http://www.opencores.org/cores/or1k/mp3/                    ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  Connects Audio block to XSV board AK4520 codec chip.        ////
10
////                                                              ////
11
////  To Do:                                                      ////
12
////   - nothing really                                           ////
13
////                                                              ////
14
////  Author(s):                                                  ////
15
////      - Lior Shtram, lior.shtram@flextronicssemi.com          ////
16
////                                                              ////
17
//////////////////////////////////////////////////////////////////////
18
////                                                              ////
19
//// Copyright (C) 2001 Authors                                   ////
20
////                                                              ////
21
//// This source file may be used and distributed without         ////
22
//// restriction provided that this copyright statement is not    ////
23
//// removed from the file and that any derivative work contains  ////
24
//// the original copyright notice and the associated disclaimer. ////
25
////                                                              ////
26
//// This source file is free software; you can redistribute it   ////
27
//// and/or modify it under the terms of the GNU Lesser General   ////
28
//// Public License as published by the Free Software Foundation; ////
29
//// either version 2.1 of the License, or (at your option) any   ////
30
//// later version.                                               ////
31
////                                                              ////
32
//// This source is distributed in the hope that it will be       ////
33
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
34
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
35
//// PURPOSE.  See the GNU Lesser General Public License for more ////
36
//// details.                                                     ////
37
////                                                              ////
38
//// You should have received a copy of the GNU Lesser General    ////
39
//// Public License along with this source; if not, download it   ////
40
//// from http://www.opencores.org/lgpl.shtml                     ////
41
////                                                              ////
42
//////////////////////////////////////////////////////////////////////
43
//
44
// CVS Revision History
45
//
46
// $Log: not supported by cvs2svn $
47
//
48
 
49
// synopsys translate_off
50
`include "timescale.v"
51
// synopsys translate_on
52
 
53
module audio_codec_if (
54
  rstn,
55
  clk,
56
  fifo_clk,
57
  fifo_data,
58
  fifo_rd_en,
59
 
60
  sclk,
61
  mclk,
62
  lrclk,
63
  sdout,
64
  sdin
65
);
66
 
67
parameter fifo_width = 16;
68
parameter count_bits = 11;
69
 
70
input   rstn;
71
input   clk;
72
output  fifo_clk;
73
input [fifo_width-1:0]  fifo_data;
74
output    fifo_rd_en;
75
 
76
output    sclk;
77
output    mclk;
78
output    lrclk;
79
input   sdout;
80
output    sdin;
81
 
82
 
83
reg [count_bits-1:0]  counter;
84
reg [16:0]  shift_reg;
85
reg     f_rd_en;
86
reg     sd_sig;
87
 
88
always @(posedge clk or negedge rstn)
89
begin
90
  if(!rstn)
91
    counter <= 0;
92
  else
93
    counter <= #1 counter + 1;
94
end
95
 
96
assign fifo_clk = clk ;
97
assign fifo_rd_en = f_rd_en ;
98
assign mclk = counter[0]; // mclk = clk/2 = 256fs
99
assign sclk = counter[2]; // sclk = mclk/4 = 64fs
100
assign lrclk = counter[8]; //lrclk = sclk/64
101
 
102
always @(posedge clk or negedge rstn)
103
begin
104
  if(!rstn)
105
    begin
106
      sd_sig <= 1'b0;
107
      shift_reg <= 0;
108
    end
109
  else
110
    begin
111
      if(counter[7:3] < 5'd16)
112
        begin
113
          if( counter[2:0] == 3'b101)
114
            shift_reg[fifo_width:1] <= #1 shift_reg[fifo_width-1:0];
115
          else
116
            shift_reg <= #1 shift_reg;
117
          sd_sig <= #1 shift_reg[16];
118
        end
119
      else
120
        begin
121
          sd_sig <= #1 1'b0;
122
          if(counter[7:0] == 8'h80)
123
            shift_reg[16:0] <= { fifo_data[fifo_width-1:0], 1'b0 };
124
        end
125
    end
126
end
127
 
128
// To je nase. Sve ostalo je garbidz.
129
always @(posedge clk or negedge rstn)
130
begin
131
  if(!rstn)
132
    f_rd_en <= 1'b0;
133
  else
134
  if(counter[9:0] == 10'h200)
135
    f_rd_en <= #1 1'b1;
136
  else
137
    f_rd_en <= #1 1'b0;
138
end
139
 
140
 
141
assign sdin = sd_sig;
142
 
143
 
144
endmodule

powered by: WebSVN 2.1.0

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