当前位置:网站首页>FPGA: Basic Getting Started Button Controlling LED Lights
FPGA: Basic Getting Started Button Controlling LED Lights
2022-08-05 10:17:00 【first good morning...】
题目概述:
使用按键控制LED灯亮灭.
无按键按下——LED全灭
按下KEYO——Flowing water light effect from right to left
按下KEY1——Flowing water light effect from left to right
按下KEY2——LED闪烁
按下KEY3——LED全亮
编程:
`timescale 1ns / 1ps
module key_led(
input sys_clk,
input sys_rst_n,
input [3:0] key,
output reg [3:0] led
);
//定义0.2s计数器 0.2s/20ns=10^7
reg [23:0] cnt;
[email protected](posedge sys_clk or negedge sys_rst_n)
begin
if(!sys_rst_n)
cnt<=0;
else if(cnt<24'd999_9999)
cnt<=cnt+1'b1;
else
cnt<=0;
end
reg [1:0] led_control;//4个LED 00 01 10 11
//State transition and state assignment
[email protected](posedge sys_clk or negedge sys_rst_n)
begin
if(!sys_rst_n)
led_control<=4'b0;
else if(cnt==24'd999_9999)
led_control<=led_control+1'b1;
else
led_control<=led_control;
end
[email protected](posedge sys_clk or negedge sys_rst_n)
begin
if(!sys_rst_n)
led<=4'b0000;
else if(key[0]==0)
case(led_control)
2'b00:led<=4'b1000;
2'b01:led<=4'b0100;
2'b10:led<=4'b0010;
2'b11:led<=4'b0001;
endcase
else if(key[1]==0)
case(led_control)
2'b00:led<=4'b0001;
2'b01:led<=4'b0010;
2'b10:led<=4'b0100;
2'b11:led<=4'b1000;
endcase
else if(key[2]==0)
case(led_control)
2'b00:led<=4'b0000;
2'b01:led<=4'b1111;
2'b10:led<=4'b0000;
2'b11:led<=4'b1111;
endcase
else if(key[3]==0)
led<=4'b1111;
else
led<=4'b0000;
end
endmodule
上机实践:
QQ视频20220804160212
边栏推荐
- 2022杭电多校 第6场 1008.Shinobu Loves Segment Tree 规律题
- 首次去中心化抢劫?近2亿美元损失:跨链桥Nomad 被攻击事件分析
- 气象数据数据处理实例——matlab字符串切割匹配与R语言日期匹配(数据拼接)
- [Strong Net Cup 2022] WP-UM
- Confessing in the era of digital transformation: Mai Cong Software allows enterprises to use data in the easiest way
- 蚁剑webshell动态加密连接分析与实践
- Offensive World-PWN-new_easypwn
- Getting started with Polkadot parachain development, this article is enough
- Oracle 19.3 restart 环境
- 2022 Huashu Cup Mathematical Modeling Question A Optimization Design Ideas for Ring Oscillators Code Sharing
猜你喜欢
High-quality DeFi application building guide to help developers enjoy DeFi Summer
Microservice Technology Stack
Oracle临时表空间作用
Pycharm 常用外部工具
Create a Dapp, why choose Polkadot?
Our Web3 Entrepreneurship Project, Yellow
项目成本控制如何帮助项目成功?
STM32+ULN2003 drives 28BYJ4 stepper motor (forward and reverse according to the number of turns)
Which big guy has the 11G GI and ojvm patches in April or January 2020, please help?
three物体围绕一周呈球形排列
随机推荐
Can MySQL use aggregate functions without GROUP BY?
STM32+ULN2003 drives 28BYJ4 stepper motor (forward and reverse according to the number of turns)
Voice-based social software development - making the most of its value
技术干货 | 基于 MindSpore 实现图像分割之豪斯多夫距离
Introduction to SD NAND Flash!
Jenkins manual (2) - software configuration
第四章:redis 数组结构的set和一些通用命令「建议收藏」
第五章:activiti流程分流判断,判断走不同的任务节点
How does the official account operate and maintain?Public account operation and maintenance professional team
Data Middle Office Construction (10): Data Security Management
Qiu Jun, CEO of Eggplant Technology: Focus on users and make products that users really need
第七章,activiti个人任务分配,动态指定和监听器指定任务委派人「建议收藏」
Still looking for a network backup resources?Hurry up to collect the following network backup resource search artifact it is worth collecting!
First Decentralized Heist?Loss of nearly 200 million US dollars: analysis of the attack on the cross-chain bridge Nomad
Keil升级到AC6后,到底有哪些变化?
Advanced usage of C language
Microservice Technology Stack
What is the function of the regular expression replaceFirst() method?
【MindSpore Easy-Diantong Robot-01】You may have seen many knowledge quiz robots, but this one is a bit different
2022 Huashu Cup Mathematical Modeling Question A Optimization Design Ideas for Ring Oscillators Code Sharing