Module freq3_027M(clkin12_288M, clkout3_027M);
input clkin12_288M; //時(shí)鐘輸入引腳
output clkout3_027M; //時(shí)鐘輸出引腳
reg clkout3_027M; //分頻計(jì)數(shù)器
integer cunt;
always@( posedge clkin12_288M) begin
cunt=cunt+1;
if (cunt<=1)
begin clkout3_027M=1'b0;end
else if((cunt<=3)&&(cunt>=2))
begin clkout3_027M=1'b1;end
else
begin cunt=0;clkout3_027M=1'b0;end
end
endmodule
D_A接口模塊
(1)左右通道切換時(shí)鐘和數(shù)據(jù)位時(shí)鐘
assign LRCLKout = LR_f; //左右通道切換時(shí)鐘
assign BCLKout =(BCLK_f)?BCLKin:1'b1; //數(shù)據(jù)位時(shí)鐘
(2)時(shí)鐘輸出和數(shù)據(jù)的并串轉(zhuǎn)換
always@( negedge BCLKin) begin
if(start) begin //使能信號(hào)為高
cunt=cunt+1;
case (cunt)
1: begin LR_f=~LR_f; //左右通道時(shí)鐘
BCLK_f=1'b1;end //送出位數(shù)據(jù)時(shí)鐘
2: datout=DDSdatin[23];//送出最高位
3: datout=DDSdatin[22]; //送出次高位
4: datout=DDSdatin[21];
5: datout=DDSdatin[20];
6: datout=DDSdatin[19];
7: datout=DDSdatin[18];
8: datout=DDSdatin[17];
9: datout=DDSdatin[16];
10: datout=DDSdatin[15];
11: datout=DDSdatin[14];
12: datout=DDSdatin[13];
13: datout=DDSdatin[12];
14: datout=DDSdatin[11];
15: datout=DDSdatin[10];
16: datout=DDSdatin[9];
17: datout=DDSdatin[8];
18: datout=DDSdatin[7];
19: datout=DDSdatin[6];
20: datout=DDSdatin[5];
21: datout=DDSdatin[4];
22: datout=DDSdatin[3];
23: datout=DDSdatin[2];
24: datout=DDSdatin[1];
25: datout=DDSdatin[0]; //數(shù)據(jù)已經(jīng)發(fā)送完畢
26: datout=0; //剩余的數(shù)據(jù)送0
27: datout=0;
28: datout=0;
29: datout=0;
30: datout=0;
31: datout=0;
32: datout=0;
default:datout=1'bz;
endcase
end
軟件仿真
模塊的仿真也是在軟件QuartusⅡ6.0中實(shí)現(xiàn)的,仿真波形如圖4所示。為了便于仿真,在24位的并行數(shù)據(jù)輸入口輸入十六進(jìn)制的常數(shù)AB15F7H,此時(shí)送入左右通道的數(shù)據(jù)是相同的。從仿真波形中可以看出,當(dāng)start信號(hào)高有效后,位數(shù)據(jù)時(shí)鐘和左右通道數(shù)據(jù)切換時(shí)鐘送出,將并行的24位數(shù)據(jù)AB15F7H從數(shù)據(jù)線上串行送出,在多余的位數(shù)據(jù)時(shí)鐘處數(shù)據(jù)線上的數(shù)據(jù)為0,仿真結(jié)果與I2S接口時(shí)序圖相符合。
結(jié)束語(yǔ)
本文以FPGA為控制單元,完成了AD1836中D/A部分的I2S接口設(shè)計(jì),它在數(shù)字音頻系統(tǒng)的設(shè)計(jì)中有一定的參考和實(shí)用價(jià)值。該設(shè)計(jì)已經(jīng)成功運(yùn)用在某話路特性綜合測(cè)試系統(tǒng)中,性能良好。
評(píng)論