[英]Do input and output ports behave like flip-flops? (VHDL)
VHDL中的输入和输出端口的行为是否类似于触发器,即它们是否在时钟的上升沿或下降沿更新? 这是我的意思的一个例子。
entity main is
port(
clk : in std_logic; -- FPGA clock
x : in std_logic; -- input signal
y : out std_logic -- sampled input signal
);
end entity main;
architecture RTL of main is
signal y_q : std_logic;
begin
y <= y_q; -- set the output
copy : process(clk, x) is
variable y_d : std_logic;
begin
y_d := x; -- continuously sample x
if rising_edge(clk) then -- synchronous logic
y_q <= y_d; -- update flip-flop
end if;
end process copy;
end architecture RTL;
上面的程序仅对输入信号x
采样,然后将其发送到输出y
。 信号y_q
是采样的输入信号x
,而在时钟clk
每个上升沿进行采样。 但是,我对y
信号感到困惑-该信号与y_q
,还是被延迟了一个时钟周期?
因为你问。 下面的代码被Intel / Altera和Xilinx综合所接受。
entity main is
port(
clk : in std_logic; -- FPGA clock
x : in std_logic; -- input signal
y : out std_logic -- sampled input signal
);
end entity main;
architecture RTL of main is begin
y <= x when rising_edge(clk);
end architecture RTL;
是的,您可以使用when
。 您只是无法在2008年之前的流程中使用它。
关于您的问题,信号y与信号y_q是否相同,答案为是。 y <= y_q; 是任何进程中的并发分配,它只是表示两个信号y和y_q应该连接在一起,因此它们当然是相同的。
尽管您的代码在逻辑上看似正确,但您不应以这种方式编写寄存器。 您可以查看xilinx XST用户指南,它将告诉您如何描述几种寄存器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.