[英]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.