如何在VHDL中实现时序逻辑和组合逻辑?请举例说明。

实现时序逻辑和组合逻辑的VHDL示例

组合逻辑示例

library ieee;
use ieee.std_logic_1164.all;

entity Combinational_Logic is
    port (
        A, B : in std_logic;
        F : out std_logic
    );
end Combinational_Logic;

architecture Behavioral of Combinational_Logic is
begin
    F <= A and B;
end Behavioral;

时序逻辑示例

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity Sequential_Logic is
    port (
        clk, rst : in std_logic;
        D : in std_logic_vector(3 downto 0);
        Q : out std_logic_vector(3 downto 0)
    );
end Sequential_Logic;

architecture Behavioral of Sequential_Logic is
begin
    process(clk, rst)
    begin
        if rst = '1' then
            Q <= (others => '0');
        elsif rising_edge(clk) then
            Q <= D;
        end if;
    end process;
end Behavioral;