繁体   English   中英

重置VHDL寄存器中的值并停止进一步写入

[英]resetting values in a VHDL register and stop writing further

我有一个简单的寄存器,并从5个状态机(一次全部)获取单个位的值。 这些值作为std_logic_vector存储在寄存器中,并且必须作为另一个模块的输入提供。 一旦在另一个模块中处理了该寄存器的输出,即该寄存器中的索引发生了更改(例如0至1),则该索引处的值应复位(例如1至0),并且应该对于该特定索引,不再接受任何其他输入(但是状态机不断提供输入)。 有什么建议,应该怎么做?

注册代码为:

entity fault_reg is

port (
  clk           : in  std_logic;
  rst           : in  std_logic;
  reg_in        : in  std_logic_vector(NUM_PORTS - 1 downto 0);
  reg_out       : out std_logic_vector(NUM_PORTS - 1 downto 0));
end fault_reg;

architecture Behavioral of fault_reg is
begin

reg_impl : process(clk, rst)
begin
    if rst = '1' then
        reg_out <= (others => '0');
    elsif clk'event and clk='1' then
        reg_out <= reg_in;
    end if;
end process reg_impl;

end Behavioral;

我不确定您要问的是什么,但是在我看来,您想要这样的东西:

  • 将您的reg_out初始化为所有人
  • 然后在计时过程中执行for循环以遍历所有输入位并清除输入中设置的位

像这样:

reg_out <= reg_in;
for i in reg_in'range loop
    if reg_in(i) = '1' then
        masked_bits(i) := '1';
    end if;
    if masked_bits(i) = '1' then
        reg_out(i) <= '0';
    end if;
end loop;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM