📄 wsm319.v
字号:
module wsm319(key1,key2,key3,key4,hz1,hz1k,start,sound,l1,l2,l3,s,cn);
input key1,key2,key3,key4,start,hz1,hz1k,s;
output sound,l1,l2,l3,cn;
reg cnt,tt,st,px,ts,W,l1,l2,l3,k,kk,sound,ss,sign,k1,k2,k3,k4,ee;
reg [7:0]cn;
always @ (posedge hz1k)
begin
if (key1==1)
k1=1;
else if(key2==1)
k2=1;
else if (key3==1)
k3=1;
else if (key4==1)
k4=1;
else if(start==1)
ee=1;
else ee=0;
end
always @(posedge hz1)
begin
if (ee==1)
begin
if (k1==1)
begin
if (cnt<30)
begin
cnt=cnt+1;
k=1;
l1=1;
end
else
begin
cnt=0;
k=0;
W=1;
l1=0;
end
end
if (k2==1)
begin
if (cnt<20)
begin
cnt=cnt+1;
k=1;
l2=1;
end
else
begin
cnt=0;
k=0;
W=1;
l2=0;
end
end
if (k3==1)
begin
if (cnt<10)
begin
cnt=cnt+1;
k=1;
l3=1;
end
else
begin
cnt=0;
k=0;
W=1;
l3=0;
end
end
//עˮģʽ
if (k4==1)
begin
if ( cnt<3)
begin
cnt=cnt+1;
k=1;
end
else
begin
cnt=0;
k=0;
end
end
if (W==1 && cnt<3)
begin
cnt=cnt+1;
l3=1;
end
else
begin
cnt=0;
W=0;
l3=0;
sign=1;
end
if (tt!=2 && W==0 )
begin
if (s==1 )
begin
sign=0;
if(cnt<2 && st!=1)
begin
cnt=cnt+1;
sound=hz1k;
ss=1;
end
else
begin
sound=0;
cnt=0;
st=1;
ss=0;
end
end
if (cnt<5 && px==0 && st==1)
begin
cnt=cnt+1;
l2=1;
end
else
begin
cnt=0;
px=1;
l2=0;
ts=0;
px=0;
end
if (ts==0 && px==1 )
begin
if (cnt<5)
begin
cnt=cnt+1;
l3=1;
end
else
begin
cnt=0;
tt=tt+1;
st=0;
px=0;
l3=0;
end
end
end
end
end
always @(posedge hz1)
begin
if (ee==1)
begin
if(k1==1)
begin
kk=1;
cn=49;
end
if(k2==1)
begin
kk=1;
cn=39;
end
if(k3==1)
begin
kk=1;
cn=29;
end
if(k4==1)
begin
kk=1;
cn=3;
end
if (kk==1)
begin
if (cn!=0)
cn=cn-1;
end
end
end
endmodule
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -