-
Notifications
You must be signed in to change notification settings - Fork 0
/
I2S_Audioin.v.bak
87 lines (72 loc) · 1.48 KB
/
I2S_Audioin.v.bak
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
module I2S_Audioin(AUD_XCK,
reset_n,
AUD_BCK,
AUD_DATA,
AUD_LRCK,
audiodata
//AUD_96CLK
);
input AUD_XCK;
input reset_n;
//output reg AUD_96CLK;
output reg AUD_BCK;
//output reg AUD_BCK;
input AUD_DATA;
output reg AUD_LRCK;
output reg [15:0] audiodata;
//=================================
//test
//=================================
reg [7:0] datacount;
////
//input [3:0] voi;
////
reg [7:0] bck_counter;
reg [7:0] lr_counter;
wire [7:0] bitaddr;
//generate BCK 1.536MHz
always @ (posedge AUD_XCK or negedge reset_n)
begin
if(!reset_n)
begin
bck_counter <= 8'd0;
AUD_BCK <= 1'b0;
end
else
begin
if(bck_counter >= 8'd5) //div XCK by 12
begin
bck_counter <= 8'd0;
AUD_BCK <= ~AUD_BCK;
end
else
bck_counter <= bck_counter + 8'd1;
end
end
//generate LRCK, 48kHz, at negedge of BCK
always @ (negedge AUD_BCK or negedge reset_n)
begin
if(!reset_n)
begin
lr_counter <= 8'd0;
AUD_LRCK <= 1'b0;
end
else
begin
if(lr_counter >= 8'd15) //div BCK by 32
begin
lr_counter <= 8'd0;
AUD_LRCK <= ~AUD_LRCK;
end
else
lr_counter <= lr_counter + 8'd1;
end
end
//send data, input data avaible at posedge of lrclk, prepared at the posedge of bck
assign bitaddr = 8'd15- lr_counter;
//assign audiodata[bitaddr[3:0]] = AUD_DATA;
always @(*)
begin
audiodata[bitaddr[3:0]] = AUD_DATA;
end
endmodule