Vhdl 电源定序器
我正在尝试用VHDL创建电源定序器,以下是我的代码:Vhdl 电源定序器,vhdl,simulation,Vhdl,Simulation,我正在尝试用VHDL创建电源定序器,以下是我的代码: library IEEE; use IEEE.std_logic_1164.all; entity PowerSeq is port ( RESET : out std_logic; POWER : out std_logic; EN : out std_logic; CLOCK : out std_logic;
library IEEE;
use IEEE.std_logic_1164.all;
entity PowerSeq is
port (
RESET : out std_logic;
POWER : out std_logic;
EN : out std_logic;
CLOCK : out std_logic;
SERIAL : out std_logic;
ModuleEN : in std_logic;
ModuleCLK : in std_logic
);
end PowerSeq;
architecture ArchiPowerSeq of PowerSeq is
signal counter :integer :=0;
signal StopCount :std_logic := '0';
begin
process(ModuleCLK)
begin
if ModuleEN = '0' then
RESET <= '0';
POWER <= '1';
EN <= '0';
CLOCK <= '0';
SERIAL <= '0';
end if;
if (rising_edge(ModuleCLK) and StopCount = '0') then
counter <= counter + 1;
end if;
-- 1ms = 250000
case counter is
when 2500000 =>
EN <= '1';
when 5000000 =>
POWER <= '0';
when 7500000 =>
CLOCK <= '1';
when 10000000 =>
RESET <= '1';
when 12500000=>
SERIAL <= '1';
StopCount <= '1';
when others =>
end case;
end process;
end ArchiPowerSeq;
IEEE库;
使用IEEE.std_logic_1164.all;
实体PowerSeq是
港口(
复位:输出标准_逻辑;
电源:输出标准逻辑;
EN:输出标准逻辑;
时钟:输出标准逻辑;
串行:输出标准逻辑;
模块:标准逻辑中;
moduleck:标准逻辑中的
);
端功率均衡器;
PowerSeq的体系结构架构PowerSeq是
信号计数器:整数:=0;
信号停止计数:标准逻辑:='0';
开始
过程(模块化)
开始
如果ModuleEN='0',则
首先重置,将Case语句放在计时部件中。然后,对重置部分(同步重置)执行相同操作,或将重置信号添加到灵敏度列表中。然后修复引入的任何模拟错误。确保重置(ModuleEn)和时钟在您的测试台上正确驱动,然后重新合成,然后重试。正如您在上面看到的,我已经更正了代码,但是当我模拟合成代码时,我继续得到X作为输出。现在我可以看到您从未重置计数器或停止计数。合成可能不支持变量或信号初始化。信号计数器:整数:=0代码>这不是重置它,这是信号初始化。请参阅上一条注释。已解决,我已在ModuleEN中重置计数器和停止计数。若我在声明计数器和停止计数时已将其赋值为0,您能解释一下为什么要在过程中重置计数器和停止计数吗?
RESET <= '0';
POWER <= '1';
EN <= '0';
CLOCK <= '0';
SERIAL <= '0';
library IEEE;
use IEEE.std_logic_1164.all;
entity PowerSeq is
port (
RESET : out std_logic;
POWER : out std_logic;
EN : out std_logic;
CLOCK : out std_logic;
SERIAL : out std_logic;
ModuleEN : in std_logic;
ModuleCLK : in std_logic
);
end PowerSeq;
architecture ArchiPowerSeq of PowerSeq is
signal counter :integer :=0;
signal StopCount :std_logic := '0';
begin
process(ModuleCLK)
begin
if (rising_edge(ModuleCLK) and StopCount = '0') then
if ModuleEN = '0' then
RESET <= '0';
POWER <= '1';
EN <= '0';
CLOCK <= '0';
SERIAL <= '0';
end if;
counter <= counter + 1;
-- 1ms = 250000
case counter is
when 2500000 =>
EN <= '1';
when 5000000 =>
POWER <= '0';
when 7500000 =>
CLOCK <= '1';
when 10000000 =>
RESET <= '1';
when 12500000=>
SERIAL <= '1';
StopCount <= '1';
when others =>
end case;
end if;
end process;
end ArchiPowerSeq;