VHDL 设计的意外结果

Unexpected result from VHDL design

当所有输入都是xclk = 1时,它应该输出Qpl的值,但它不是。以下代码有什么问题;

LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
--This is a D Flip-Flop with Synchronous Reset,Set and Clock Enable(posedge clk).
--Note that the reset input has the highest priority,Set being the next highest
--priority and clock enable having the lowest priority.
ENTITY syn IS
    PORT (
        Q : OUT std_logic; -- Data output
        CLK : IN std_logic; -- Clock input
        Qpl : IN std_logic;
        RESET : IN std_logic; -- Synchronous reset input
        D : IN std_logic; -- Data input
        SET : IN std_logic -- Synchronous set input
    );
END syn;
ARCHITECTURE Behavioral OF syn IS --architecture of the circuit.
BEGIN
    --"begin" statement for architecture.
    PROCESS (CLK) --process with sensitivity list.
    BEGIN
        --"begin" statment for the process.
        IF (CLK'EVENT AND CLK = '1') THEN --This makes the process synchronous(with clock)
            IF (RESET = '1') THEN
                Q <= '0';
            ELSE
                IF (SET = '1') THEN
                    Q <= D;
                ELSE
                    Q <= Qpl; 
                END IF;
            END IF; 
        END IF;
    END PROCESS; --end of process statement.
END Behavioral;

下图显示了上述设计的波形,以及所需的操作要求;

从波形图来看,似乎一切正常,当输入信号SET变为U时,无法判断if条件,因此输出Q也变为因此,即 U。您可以看到 SET0 时,输出 Q 正确获取了 Qpl 的值。

抱歉粗略的绘图,但是您可以看到在 SET0 时圆圈时钟上升,Q 获得 Qpl 的值符合预期。只有在 SET 信号变为 U 后,输出 Q 在下一个时钟上升事件中也失去其值,并且也变为 U

您的代码和注释不同。 table/diagram 也是如此。 D-flipflop/register 是一个非常简单的组件。示例:

entity dff is
    port (
        clk : in std_logic;
        rst : in std_logic;
        set : in std_logic;
        load : in std_logic;
        d : in std_logic;
        q : out std_logic
    );

architecture rtl of dff is
begin
    dff_proc : process(clk)
    begin
        if rising_edge(clk) then
            if rst='1' then
                q <= '0';
            elsif set='1' then
                q <= '1';
            elsif load='1' then
                q <= d;
            end if;
        end if;
    end process;
end architecture;