推荐使用两级计数器生成内部复位信号,这样可以保证复位信号的宽度符合预期。推荐写法如下:
reg [3:0] rst_init_cnt;
wire rst_init_n;
reg [15:0] rst_temp ;
reg SYS_RST_N;
always @(posedge clk)
begin
if(rst_init_cnt <4'h8)
rst_init_cnt <= rst_init_cnt + 1;
else
rst_init_cnt <= rst_init_cnt ;
end
assign rst_init_n = rst_init_cnt[3];
always@(posedge clk or negedge rst_init_n) begin
if (rst_init_n == 1'b0)
rst_temp <= 'd0;
else if(rst_temp < 16’d50000)
rst_temp <=rst_temp + 1'b1;
else
rst_temp <=16’d50000;
end
always @(posedge clk or negedge rst_init_n) begin
if (rst_init_n == 1'b0)
SYS_RST_N <=1'b0;
else if(rst_temp>32'd5 rst_temp < 16’d30000)
SYS_RST_N <=1'b0;
else
SYS_RST_N <=1'b1;
End
推荐使用两级计数器生成内部复位信号,这样可以保证复位信号的宽度符合预期。推荐写法如下:
reg [3:0] rst_init_cnt;
wire rst_init_n;
reg [15:0] rst_temp ;
reg SYS_RST_N;
always @(posedge clk)
begin
if(rst_init_cnt <4'h8)
rst_init_cnt <= rst_init_cnt + 1;
else
rst_init_cnt <= rst_init_cnt ;
end
assign rst_init_n = rst_init_cnt[3];
always@(posedge clk or negedge rst_init_n) begin
if (rst_init_n == 1'b0)
rst_temp <= 'd0;
else if(rst_temp < 16’d50000)
rst_temp <=rst_temp + 1'b1;
else
rst_temp <=16’d50000;
end
always @(posedge clk or negedge rst_init_n) begin
if (rst_init_n == 1'b0)
SYS_RST_N <=1'b0;
else if(rst_temp>32'd5 rst_temp < 16’d30000)
SYS_RST_N <=1'b0;
else
SYS_RST_N <=1'b1;
End
举报