课后作业
  • 工程师可点评
  • 需修改

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

刘家宝
142 0
需修改
教务评价

需修改

3342599708 · 2026-11-16

2、状态跳转条件有问题。请补交状态转化图至答疑群。 `timescale 1ns / 1ps module FSMLED( input  sysclk, input  rst_n, output  reg [3:0] led ); parameter   TIME_1s=26'd50_000_000; reg   [25:0]   count; always@(posedge sysclk) if(!rst_n) count<=0; else if(count<TIME_1s-1) count<=count+1; else count<=0; parameter  IDLE=5'b0000_1, s1=5'b0001_0, s2=5'b0010_0, s3=5'b0100_0, s4=5'b1000_0; reg [4:0] cur_state,next_state; always@(posedge sysclk) if(!rst_n) cur_state<=IDLE; else cur_state<=next_state; always@(*) if(!rst_n) next_state=IDLE; else case(cur_state) IDLE:next_state=s1; s1:begin if(count==TIME_1s-1)//计满1s next_state=s2; else next_state=s1; end s2:begin if(count==TIME_1s-1)//计满1s next_state=s3; else next_state=s2; end s3:begin if(count==TIME_1s-1)//计满1s next_state=s4; else next_state=s3; end s4:begin if(count==TIME_1s-1)//计满1s 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’1111; s1:led<=4'b0001; s2:led<=4'b0010; s3:led<=4'b0100; s4:led<=4'b1000; default:led<=4'b1111; endcase endmodule

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

分压

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

`timescale 1ns / 1ps
module FSMLED(
input  sysclk,
input  rst_n,
output  reg [3:0] led
);
parameter   TIME_1s=26'd50_000_000;
reg   [25:0]   count;
always@(posedge sysclk)
if(!rst_n)
count<=0;
else
if(count<TIME_1s-1)
count<=count+1;
else
count<=0;
parameter  IDLE=5'b0000_1,
s1=5'b0001_0,
s2=5'b0010_0,
s3=5'b0100_0,
s4=5'b1000_0;
reg [4:0] cur_state,next_state;
always@(posedge sysclk)
if(!rst_n)
cur_state<=IDLE;
else
cur_state<=next_state;
always@(*)
if(!rst_n)
next_state=IDLE;
else
case(cur_state)
IDLE:next_state=s1;
s1:begin
if(count==2)
next_state=s2;
else
next_state=s1;
end
s2:begin
if(count==1)
next_state=s3;
else
next_state=s2;
end
s3:begin
if(count==1)
next_state=s4;
else
next_state=s3;
end
s4:begin
if(count==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’1111;
s1:led<=4'b0001;
s2:led<=4'b0010;
s3:led<=4'b0100;
s4:led<=4'b1000;
default:led<=4'b1111;
endcase
endmodule

修改历程

2 个版本1 条批注

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

  1. v2当前
  2. 需修改
    2、状态跳转条件有问题。请补交状态转化图至答疑群。 `timescale 1ns / 1ps module FSMLED( input  sysclk, input  rst_n, output  reg [3:0] led ); parameter   TIME_1s=26'd50_000_000; reg   [25:0]   count; always@(posedge sysclk) if(!rst_n) count<=0; else if(count<TIME_1s-1) count<=count+1; else count<=0; parameter  IDLE=5'b0000_1, s1=5'b0001_0, s2=5'b0010_0, s3=5'b0100_0, s4=5'b1000_0; reg [4:0] cur_state,next_state; always@(posedge sysclk) if(!rst_n) cur_state<=IDLE; else cur_state<=next_state; always@(*) if(!rst_n) next_state=IDLE; else case(cur_state) IDLE:next_state=s1; s1:begin if(count==TIME_1s-1)//计满1s next_state=s2; else next_state=s1; end s2:begin if(count==TIME_1s-1)//计满1s next_state=s3; else next_state=s2; end s3:begin if(count==TIME_1s-1)//计满1s next_state=s4; else next_state=s3; end s4:begin if(count==TIME_1s-1)//计满1s 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’1111; s1:led<=4'b0001; s2:led<=4'b0010; s3:led<=4'b0100; s4:led<=4'b1000; default:led<=4'b1111; endcase endmodule
  3. v1

产出状态

工程师已阅142 位工程师
教务需修改