仅供参考!
input rst; //拔河开始复位按键 input nrst; //计分清零按键 input _25H; // output [2:0] q; //拔河led显示输出 output [2:0] left; //左边分数数码管输出 output [2:0] right; //右边分数数码管输出 reg [2:0]q; reg n; reg [2:0]left,right; //reg寄存器
always @(negedge rst or posedge _25H or negedge nrst) begin
if(~rst) begin q=7;n=1;end //q,led回中点 n使能开 else if(~nrst) begin left=0;right=0;end //计分清零
else if(n) //判断使能是否开! begin case({k1,k2}) // 按键组
2'b01: q=q+1; /// led向右移一位 2'b10: q=q-1; //// led向左移一位 default: q=q; /// 保持 endcase // case(q)
3'b000:begin n=0;left=left+1;end //左+1分,n使能关 3'b110:begin n=0;right=right+1;end //右+1分,n使能关
default:n<=n; //保持 endcase end end
endmodule
图3,仿真波形图 4.2.4LED模块程序设计及仿真 Led设有16个灯。
module led(q, _50M, led); input [2:0] q; input _50M; output [7:0] led;
百度搜索“70edu”或“70教育网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,70教育网,提供经典教育范文eda拔河游戏机课程设计报告(5)在线全文阅读。
相关推荐: