完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
仿真正确 用波形文件产生不了波形
module snatch(A,B,C,D,clk,reset,out);//light and answering input A,B,C,D; input reset,clk; wire [3:0]key; //output [3:0]led0; //output [2:0]led1; output [3:0]out; assign led0={alARM,s};//warning *** cheat assign led1={c,s};//answer assign key=reset?{D,C,B,A}:0;//who responde firstly reg[1:0]s; reg c; reg[2:0] count; reg[3:0]out; reg [1:0]alarm; always@(posedge clk) if(!reset) begin begin count<=0; s<=0;c<=0;alarm<=0;end if(A || B || C || D)//alarm *** breaking rule begin alarm<=2'b11; end end else begin if (count==4) begin c<=1;count<=0;end else count<=count+1;//beging answering end always@(posedge clk) case(key)//judge which input assign led0={alarm,s}; 4'b0001:s<=2'b00;//A 4'b0010:s<=2'b01;//B 4'b0100:s<=2'b10;//C 4'b1000:s<=2'b11;//D //default:s<=2'bzz;//other endcase always@(posedge clk) case(led0)//warning *** cheat 4'b1100: out<=4'b0001;//A light 4'b1101: out<=4'b0010;//B light 4'b1110: out<=4'b0100;//C light 4'b1111: out<=4'b1000;//D light //default:out<=4'b0000; endcase always@(posedge clk) case(led1) //judge which light assign led1={c,s}; 3'b100:out<=4'b0001;//A light 3'b101:out<=4'b0010;//B light 3'b110:out<=4'b0100;//C light 3'b111:out<=4'b1000;//D light //default:out<=4'b0000; endcase endmodule |
|
相关推荐 |
|
只有小组成员才能发言,加入小组>>
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-27 09:33 , Processed in 0.578068 second(s), Total 38, Slave 30 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号