FPGA——上电自复位方式(非常简单)

上电自复位对FPGA的稳定性及其重要,因为对于某些设计,上电之后需要进行一些状态寄存器的初始化,或者系统自己初始化都需要一个复位信号。在这里我就介绍一个比较好用的方法,大家一起学习一下。

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use IEEE.numeric_std.all;
library WORK;
library UNISIM;
use UNISIM.VComponents.all;

entity top is
port(
clk : in std_logic;
rst : out std_logic
);
end top;
architecture Behavioral of top is

signal rst_vector : std_logic_vector(15 downto 0):=(other=>'1');

rst_after_power_on: process(clk)
begin
rst_vector <= '0' & rst_vector(15 downto 1);
end procrss rst_after_power_on;

rst <= rst_vector(0);

end Behavioral;

这里只是简单的做了一个上电复位的信号。首先定义一个16为宽度的信号rst_vector,并初始化为全部都是‘1’。在process里每一个时钟周期rst_vector就右移一位,那么在16个周期里面,rst_vector(0)都是‘1’,所以我们可以用这个信号来做复位信号,复位16个周期。16个周期后,rst_vector(0)就变成‘0’,复位结束。这里用的是高电平复位,如果想用低电平复位,可以在初始化时全部赋值为‘0’,并且 rst_vector <= '0' & rst_vector(15 downto 1);改为 rst_vector <= '1' & rst_vector(15 downto 1);即可。

作者:MaoChuangAn
来源:CSDN
原文:https://blog.csdn.net/MaoChuangAn/article/details/80743800

最新文章

最新文章