版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、明德扬科技教育南北交通灯练习官网:淘宝:群目录counter_3 模块3明德扬科技公司主要是以 FPGA 为,专业从事 FPGA 配套开发板、FPGA 培训班或其他培训、研发 FPGA 技术开发、承接 FPGA 项目开发。欢迎加入明德扬 FPGA 和 ASIC97925396。明德扬以 PDF 格式提供源代码,是为了鼓励大家多思考,不要拿来就用,否则是学不好 FPGA 的。本代码对应的设计思路,请参考明德扬课程。counter_3 模块module counter_3( clk,rst_n, led_east, led_wast, led_south, led_nouth);/参数定义para
2、meterTIME_1S =50_000_000;/输入信号定义 inputinputclkrst_n;/输出信号定义output 2:0output 2:0led_east ;led_south;output 2:0output 2:0led_wast ;led_nouth;/输出信号 reg 定义regreg2:0led_east ;2:0led_south;/*regreg2:0led_wast ;2:0led_nouth;*/*另外一种写法*/wirewire2:0led_wast ;2:0led_nouth;/中间信号定义regreg29:04 :0cnt;cnt_o;/时序逻辑写法
3、/东面always(edge clk or negedge rst_n)beginif(rst_n=1b0)begin led_east = 3b110;endelse if(cnt_o=9)&(cnt=TIME_1S-1)begin led_east = 3b101;endelse if(cnt_o=14)&(cnt=TIME_1S-1)begin led_east = 3b011;endelse if(cnt_o=29)&(cnt=TIME_1S-1)begin led_east = 3b110;endelse beginled_east = led_east;endend/西面/*alw
4、ays(edge clk or negedge rst_n)beginif(rst_n=1b0)begin led_wast = 3b110;endelse if(cnt_o=9)&(cnt=TIME_1S-1)begin led_wast = 3b101;endelse if(cnt_o=14)&(cnt=TIME_1S-1)begin led_wast = 3b011;endelse if(cnt_o=29)&(cnt=TIME_1S-1)begin led_wast = 3b110;endelse beginled_wast = led_wast;endend*/*led_wast 使用
5、 wire 型*/ assign led_wast = led_east;/南面always(edge clk or negedge rst_n)beginif(rst_n=1b0)begin led_south = 3b011;endelse if(cnt_o=14)&(cnt=TIME_1S-1)begin led_south = 3b110;endelse if(cnt_o=24)&(cnt=TIME_1S-1)begin led_south = 3b101;endelse if(cnt_o=29)&(cnt=TIME_1S-1)begin led_south = 3b011;endel
6、se beginled_south = led_south;endend/北面/*always(edge clk or negedge rst_n)beginif(rst_n=1b0)begin led_nouth = 3b011;endelse if(cnt_o=14)&(cnt=TIME_1S-1)begin led_nouth = 3b110;endelse if(cnt_o=24)&(cnt=TIME_1S-1)beginled_nouth = 3b101;endelse if(cnt_o=29)&(cnt=TIME_1S-1)begin led_nouth = 3b011;endel
7、se beginled_nouth = led_nouth;endend*/*led_nouth 使用 wire 型*/ assign led_nouth = led_south;/计数器设计/基本计数器 always(edge clk or negedge rst_n)beginif(rst_n=1b0)begin cnt = 0;endelse if(cnt=TIME_1S-1)begin cnt = 0;endelse begincnt = cnt + 1;endend/计数器 oalways(edge clk or negedge rst_n)beginif(rst_n=1b0)begin cnt_o = 0;end/*else if(cnt_o=29)&(cnt=TIME_1S-1)begin cnt_o = 0;endelse if(cnt=TIME_1S-1)begin cnt_o = cnt_o + 1;endelse
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 论语演讲稿两分钟
- 2026年京东集团电子商务基础常识及案例分析试题
- 口才做最好的自己演讲稿
- 2026年经济法学前沿问题探讨与案例分析
- 沈阳失业保险培训
- 2026年县级新一轮退耕还林补助政策知识试题
- 转业干部培训演讲稿标题
- 2026年窗口单位服务明星评选综合测试题
- 游戏模型大师培训
- 业务合同制作培训
- YC/T 177-2024卷烟工业企业标准体系构成及指南
- 预拌粉生产线智能化改造提升项目可行性研究报告
- 第5课《黄河颂》课件-2023-2024学年统编版语文七年级下册
- 客车运用维修-客车A1级检修要求及质量标准(铁道车辆管理)
- 免费模式6种核心方式
- GB/T 7332-2011电子设备用固定电容器第2部分:分规范金属化聚乙烯对苯二甲酸酯膜介质直流固定电容器
- GB/T 6109.20-2008漆包圆绕组线第20部分:200级聚酰胺酰亚胺复合聚酯或聚酯亚胺漆包铜圆线
- 发酵乳制品中食品添加剂的使用与意义,食品安全论文
- GB/T 26523-2022精制硫酸钴
- 职业健康检查机构卫生管理自查表(2018年版)
- 大学生学习资料
评论
0/150
提交评论