module music(clk,h);
input clk; //-----------50MHZ
output h;
reg clk_4,clk_5;
reg [19:0] div ;
reg [7:0] counter;
reg [19:0] cnt,rnt1,rnt2,rnt3;
//-------------------------音符定义
parameter
D1=
D2=
D3=
M1=
M2=
M3=
H1=
H2=
H3=
//-----------------------节拍控制模块
always @(posedge clk_4)
if(counter== )
counter<=0;
else counter<=counter+1;
case(counter)
0: div=
1: div=
2: div=
3: div=
4: div=
5: div=
6: div=
7: div=
8: div=
defualt: div='bfffffff;
// ------------------------ 频率产生模块
always @(posedge clk_5)
if(cnt==div)
begin
h<=~h;
cnt<=0;
end
else
cnt<=cnt+1;
//-------------------------clk_5产生模块 750 Hz
always @(posedge clk)
if(cnt2== )
begin
cnt2=0;
clk_5<=~clk_5;
end
else cnt2<=cnt2+1;
//--------------------------clk_4 产生模块 4HZ
always @(posedge clk)
if(cnt3==)
begin
cnt3<=0;
clk_4<=~clk_4;
end
else
cnt3<=cnt3+1;
endmodule
节拍时钟clk_4 和 基准时钟 clk_5放到这里没有问题吧?
引用: //-------------------------clk_5产生模块 750 Hz
always @(posedge clk)
if(cnt2== )
begin
cnt2=0;
clk_5<=~clk_5;
end
else cnt2<=cnt2+1;
//--------------------------clk_4 产生模块 4HZ
always @(posedge clk)
if(cnt3==)
begin
cnt3<=0;
clk_4<=~clk_4;
end
else
cnt3<=cnt3+1;
endmodule
节拍时钟clk_4 和 基准时钟 clk_5放到这里没有问题吧?
有点问题!
(CNT==?) 差数据哦!