[英]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;
我不确定您要问的是什么,但是在我看来,您想要这样的东西:
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.