惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Help Net Security
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 【当耐特】
Microsoft Azure Blog
Microsoft Azure Blog
Google DeepMind News
Google DeepMind News
Apple Machine Learning Research
Apple Machine Learning Research
有赞技术团队
有赞技术团队
Y
Y Combinator Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
爱范儿
爱范儿
L
LangChain Blog
IT之家
IT之家
酷 壳 – CoolShell
酷 壳 – CoolShell
MongoDB | Blog
MongoDB | Blog
Hugging Face - Blog
Hugging Face - Blog
G
Google Developers Blog
T
Tailwind CSS Blog
Engineering at Meta
Engineering at Meta
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
宝玉的分享
宝玉的分享
博客园 - 三生石上(FineUI控件)
D
DataBreaches.Net
Recent Announcements
Recent Announcements
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - yf.x

超声波测距#倒车雷达#DE10-Lite 按键计数器#DE10-Lite 按键消抖#DE10-Lite 流水呼吸灯v2#DE10-Lite 流水呼吸灯-v1#DE10-Lite 呼吸灯-#DE10-Lite HDLBits_review 2015fsm 补码FSM-HDLbits 串行数据流输出其中的数据位-HDLbits 串行数据接收判断-HDLbits 输出PS2数据流-HDLbits PS2数据流检测状态机-HDLbits 独热码状态机-HDLbits 旅鼠4-HDLbits 旅鼠游戏3-HDLbits 旅鼠游戏2-HDLbits 旅鼠游戏--HDLbits 水库水位控制问题-HDLbits 康威生命游戏-hdlbits
流水灯#DE10-Lite#Verilog
yf.x · 2026-03-25 · via 博客园 - yf.x

流水灯

实验板:DE10-Lite

资源:1. 按键复位:

2. led

3. 时钟

引脚分配:

信号名

管脚名

管脚号

clk

MAX10_CLK1_50

P11

rst_n

KEY0

B8

led

LEDR9

B11

LEDR8

A11

LEDR7

D14

LEDR6

E14

LEDR5

C13

LEDR4

D13

LEDR3

B10

LEDR2

A10

LEDR1

A9

LEDR0

A8

 代码:

module led_run(
input clk,rst_n,
output reg [ 3:0] led);

reg [24:0] cnt;
reg clk_1s;
parameter T = 2500_0000;

always @(posedge clk,negedge rst_n)
begin
if(!rst_n)
begin
clk_1s <= 0;
cnt <= 0;
end
else
if(cnt < T - 1)
cnt <= cnt + 1;
else
begin
cnt <= 0;
clk_1s <= ~clk_1s;
end
end

always @(posedge clk_1s,negedge rst_n)
begin
if(!rst_n)
led <= 4'b1000;
else
led <= {led[2:0],led[3]};
end

endmodule

测试代码:

`timescale 1ns/1ps
module led_run_tb;
reg clk,rst_n;
wire [ 3:0] led;

defparam dut.T = 25;

led_run dut(
.clk(clk),
.rst_n(rst_n),
.led(led));

initial begin
clk = 0;
rst_n = 0;
#200.1 rst_n = 1;
#5000 $stop;

end

always #10 clk = ~clk;

endmodule

仿真结果:

image