下面是一个使用VHDL编写的简单脚本,当输入为1时,输出为1(5V)持续2秒,然后返回为0。
entity test is
port(
input : in std_logic;
output : out std_logic
);
end entity test;
architecture behavior of test is
signal temp : std_logic := '0';
begin
output <= temp;
process(input)
begin
if input = '1' then
temp <= '1';
wait for 2 seconds;
temp <= '0';
end if;
end process;
end architecture behavior;
在上面的代码中,我们定义了一个名为test
的实体,它有一个输入端口input
和一个输出端口output
。在体系结构部分,我们定义了一个名为temp
的信号,用于控制输出。输出端口output
被赋值为temp
。
在进程部分,我们使用了一个过程块,当输入input
为'1'时,temp
被赋值为'1',然后等待2秒,最后temp
被赋值为'0'。因为过程块是在仿真时间中运行的,所以在仿真中会有2秒的时间间隔。
请注意,这只是一个简单的示例,实际应用中可能需要根据具体的需求进行修改和扩展。