• 已绑定课时
  • 工程师可点评
  • 教务通过

1、串联电阻的作用是什么?

huangxin
95 1
教务通过工程师评优秀1
教务评价

教务通过

3342599708 · 2026-10-29

代码没有问题。

1、串联电阻的作用是什么?

串联电阻的作用是为后面串联的LED限流、分压。

2、请画出利用状态机实现1s流水灯的状态转化图并写出详细的代码。

状态转化框图:

时序逻辑图

代码:

module Zhuangtaiji_liushuideng(
input  sysclk  ,
input  rst_n   ,
output reg [3:0] led
);
parameter TIME_1S = 26'd50_000_000 ;
reg [25:0] count;
parameter IDLE = 4'b1111 ;
parameter   S1 = 4'b1000  ,
S2 = 4'b0100  ,
S3 = 4'b0010  ,
S4 = 4'b0001  ;
reg [3:0] cur_state , next_state ;//声明现态和次态
always @(posedge sysclk)
if(!rst_n)
cur_state <= IDLE;
else
cur_state <= next_state;
//第一段描述现次态跳转
always @(posedge sysclk)
begin
if(!rst_n)
count <= 26'b0 ;
else
if(count == TIME_1S-1)
count <= 26'b0 ;
else
count <= count+26'b1;
end
//描述1S计数器
always @(*)
if(!rst_n)
next_state = IDLE;
else
case(cur_state)
IDLE: next_state = S1;
S1:begin
if(count==TIME_1S-1)
next_state = S2;
else
next_state = S1;
end
S2:begin
if(count==TIME_1S-1)
next_state = S3;
else
next_state = S2;
end
S3:begin
if(count==TIME_1S-1)
next_state = S4;
else
next_state = S3;
end
S4:begin
if(count==TIME_1S-1)
next_state = S1;
else
next_state = S4;
end
default:next_state = IDLE;
endcase
//第二段描述各个状态之间的跳转
always @(posedge sysclk)
if(!rst_n)
led  <= 4'b1111;
else
case(cur_state)
IDLE: led <= 4'b1111;
S1: led <= 4'b1000;
S2: led <= 4'b0100;
S3: led <= 4'b0010;
S4: led <= 4'b0001;
default:led  <= 4'b1111;
endcase
//最后一段各个状态下的动作
endmodule

修改历程

1 条批注

你的每次提交都会留档,老师的每次批注也会保留。按批注修改后重新提交,不会覆盖历史版本。

  1. v1当前
  2. 教务通过
    代码没有问题。

学习上下文

产出状态

评优秀1 位工程师
工程师已阅95 位工程师
教务教务通过