第一范文网 - 专业文章范例文档资料分享平台

基于FPGA的计时器的设计毕业设计

来源:用户分享 时间:2025/8/16 20:35:38 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

图A1 RTL视图

附录B 计费模块的Verilog HDL语言描述

module MONEY( iclk, iclk_50M, irst, imoney, iset, icall, omoney, otime, set, oclk_counter, oLED_warning, oLED_phoneing );

input iclk;

input iclk_50M; input irst; input icall;

input [7:0] imoney; input [1:0] iset;

output [5:0]oclk_counter; output [6:0]omoney; output [6:0]otime; output [1:0] set;

output oLED_phoneing; output oLED_warning;

reg start ; reg [1:0]set_r; reg [5:0]clk_counter_r; reg [6:0]omoney_r; reg [6:0]otime_r; reg LED_phoneing_r; reg LED_warning_r;

// 通话开始,结束变量 // 什么类型的通话 // 秒计数器 // 剩余余额

// 通话多少分钟计数器 // 通话灯

// 余额不足警告灯

reg STOP; // 余额不足一分钟后停止

assign omoney = omoney_r; assign otime = otime_r; assign set = set_r;

assign oclk_counter = clk_counter_r; assign oLED_phoneing = LED_phoneing_r; assign oLED_warning = LED_warning_r;

always@(posedge iclk_50M,negedge irst) begin if (!irst) start <= 0; else if(STOP) start <= 0; else if(icall) start <= 1; else start <= 0; end

//每60秒一分钟

always@(posedge iclk,negedge irst) begin if (!irst) clk_counter_r <= 0; else if(start) begin if(clk_counter_r <6'd59) clk_counter_r <= clk_counter_r + 1; else clk_counter_r <= 0; end end

//通话计时

always@(posedge iclk,negedge irst) begin if (!irst) otime_r <= 0; else if(clk_counter_r == 6'd59) otime_r <= otime_r + 1; end

//先扣费 , 后接通电话

always@(posedge iclk,negedge irst) begin if (!irst) omoney_r <= 0; else if (!icall) begin if(imoney > 99) omoney_r <= 99; else omoney_r <= imoney; set_r <= iset; end else begin if((otime_r == 0)&&(clk_counter_r == 0)) case (set_r) 2'b01 : omoney_r <= omoney_r - 2; 2'b10 : omoney_r <= omoney_r - 7; 2'b11 : omoney_r <= omoney_r - 12; endcase if(!LED_warning_r) begin if(clk_counter_r == 6'd59) case (set_r) 2'b01 : omoney_r <= omoney_r - 2; 2'b10 : omoney_r <= omoney_r - 7; 2'b11 : omoney_r <= omoney_r - 12; endcase end else if(STOP == 1) set_r <= 0; end end

//通话提示

always@(posedge iclk,negedge irst)

begin if (!irst) LED_phoneing_r <= 0; else LED_phoneing_r <= start; end

//余额不足提示

always@(posedge iclk,negedge irst) begin if (!irst) LED_warning_r <= 0; else if(STOP == 1) LED_warning_r <= 0; else case (set_r) 2'b01 : if(omoney_r <3) LED_warning_r <= 1; else LED_warning_r <= 0; 2'b10 : if(omoney_r <6) LED_warning_r <= 1; else LED_warning_r <= 0; 2'b11 : if(omoney_r <12) LED_warning_r <= 1; else LED_warning_r <= 0; endcase end

always@(posedge iclk,negedge irst) begin if (!irst) STOP <= 0; else if((clk_counter_r == 6'd59)&&(LED_warning_r == 1)) STOP <= 1; end

搜索更多关于: 基于FPGA的计时器的设计毕业设计 的文档
基于FPGA的计时器的设计毕业设计.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c5ag972q9vu3y3j84vsq02xzhu2kzn0009v0_9.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top