|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
- module zongti(clk,,con,rst,d1,d2,led1,led2,led3,led4,en1,en2,en3);
- input rst,clk,d1,d2,con;
- output led1,led2,led3,led4,en1,en2,en3;
- reg led1,led2,led3,led4,en1,en2,en3;
- reg [11:0]p;
- reg [10:0]q;
- always@(posedge clk or negedge rst)
- begin
- if(!rst)
- begin
- led1<=1'b1; /*dianyuan*/
- led2<=1'b0; /*kaitong*/
- led3<=1'b0; /*guanduan*/
- led4<=1'b0; /*guzhang*/
- en1<=1'b0;
- en2<=1'b0;
- en3<=1'b0;
- q<=0;
- p<=0;
- end
- else
- begin
- if(!d1)
- begin
- led1<=1'b0; /*dianyuan*/
- led2<=1'b0; /*kaitong*/
- led3<=1'b0; /*guanduan*/
- led4<=1'b1; /*guzhang*/
- en1<=1'b0;
- en2<=1'b0;
- en3<=1'b0;
- q<=0;
- p<=0;
- end
- else
- begin
- if((!d2)&&(!con)) /*guanduan--weichiguanduan*/
- begin
- led1<=1'b1; /*dianyuan*/
- led2<=1'b0; /*kaitong*/
- led3<=1'b1; /*guanduan*/
- led4<=1'b0; /*guzhang*/
- en1<=1'b0;
- en2<=1'b0;
- en3<=1'b1;
- q<=0;
- p<=0;
- end
- else if((d2)&&(!con)) /*kaitong--guanduan*/
- begin
- if(q<11'h0C8) /*panduan guanduan xinhao shifou daolai*/
- begin
- p<=p+11'h001;
- led1<=1'b1; /*dianyuan*/
- led2<=1'b1; /*kaitong*/
- led3<=1'b0; /*guanduan*/
- led4<=1'b0; /*guzhang*/
- en1<=1'b0;
- en2<=1'b0;
- en3<=1'b1;
- end
- else
- begin
- led1<=1'b1;
- led2<=1'b1;
- led3<=1'b0;
- led4<=1'b1;
- en1<=1'b0;
- en2<=1'b0;
- en3<=1'b0;
- end
- end
- else if((con)&&(!d2)) /*guanduan--kaitong*/
- begin
- if(p<12'h672)
- begin
- led1<=1'b1; /*dianyuan*/
- led2<=1'b0; /*kaitong*/
- led3<=1'b1; /*guanduan*/
- led4<=1'b0; /*guzhang*/
- en1<=1'b1;
- en2<=1'b0;
- en3<=1'b0;
- p<=p+12'h001;
- end
- else
- begin
- led1<=1'b1; /*dianyuan*/
- led2<=1'b0; /*kaitong*/
- led3<=1'b1; /*guanduan*/
- led4<=1'b0; /*guzhang*/
- en1<=1'b0;
- en2<=1'b1;
- en3<=1'b0;
- end
- end
- else if((con)&&(d2)) /*kaitong--weichikaitong*/
- begin
- led1<=1'b1; /*dianyuan*/
- led2<=1'b1; /*kaitong*/
- led3<=1'b0; /*guanduan*/
- led4<=1'b0; /*guzhang*/
- en1<=1'b0;
- en2<=1'b1;
- en3<=1'b0;
- q<=0;
- p<=0;
- end
- end
- end
- end
- endmodule
复制代码 |
|