全文预览

(参考)自动售货机设计Verilog

上传者:梦溪 |  格式:doc  |  页数:10 |  大小:0KB

文档介绍
(posedge clk or negedge rst) if(!rst) begin led_cola_ok<=1; led_diet_ok<=1; end else begin if(cola_out >= no_cola) led_cola_ok <= 0; if(diet_out >= no_diet) led_diet_ok <= 0; end endmodule // 退币处理电路模块 module coin_return(clk,reset,ok_buy,led_return,total_count,total_consum,money_ok,cancel_buy,cancel); input clk,ok_buy,reset,cancel_buy,cancel;//return_clk 来指定给退币闪烁警示灯 input [10:0]total_count,total_consum; output reg [10:0]led_return;// 用来显示退出货币的总数 output reg money_ok; always@(posedge clk or negedge reset) if(!reset) begin led_return<=0; money_ok<=0; end else if(cancel_buy) begin led_return<=total_count; money_ok<=0; end else if(total_count >= total_consum) if(ok_buy) begin led_return<=total_count-total_consum; money_ok<=1; end else begin money_ok<=0; end endmodule 四、实验结果在 DE2 开发板上实现了自动售货机的功能。

收藏

分享

举报
下载此文档