我正在尝试为 VHDL 中的 CPLD 构建一个简单的脉冲发生器。我有一系列简单的if语句,它们应该根据连接到模块的总线的输入状态执行某些任务。
entity pulse_gen is
Port ( CLK : in STD_LOGIC;
pulse_sel_in : in STD_LOGIC_VECTOR (2 downto 0);
pulse_r : in STD_LOGIC;
pulse_s : inout STD_LOGIC);
end pulse_gen;
architecture Behavioral of pulse_gen is
signal pulse_sel: std_logic_vector (2 downto 0);
signal pulse_count: integer;
signal pulse_length: integer range 0 to 100;
signal pulse_a: std_logic;
begin
pulse_sel <= pulse_sel_in;
pulse: process(CLK) is
begin
if(pulse_sel > "000" and pulse_a = '0') then
pulse_s <= '1';
pulse_a <= '1';
end if;
if(pulse_a = '1' and pulse_count < pulse_length) then
pulse_count <= pulse_count + 1;
end if;
if(pulse_a = '1' and pulse_count = pulse_length) then
pulse_s <= '0';
pulse_a <= '0';
pulse_count <= 0;
end if;
end process;
set_max: process(CLK) is
begin
if (CLK'event) then
case pulse_sel is
when "001" => pulse_length <= 1;
when "010" => pulse_length <= 10;
when "011" => pulse_length <= 100;
when others => null;
end case;
end if;
end process;
end Behavioral;
在 iSim 中运行此模块时,强制 _pulse_s_ 总线除 000 之外的任何值都应触发脉冲过程中的第一个 if 语句,它确实如此。但是,在仿真中,_pulse_a_ 信号从未设置为逻辑高电平。现在我花了几个小时以不同的方式编写这个模块,但我完全不知道为什么这不会发生。我对 VHDL 比较陌生,所以我想知道是否有某种语法或程序错误是我完全遗漏的。有任何想法吗?