2、针对vhdl描述的序列信号发生器电路,用vhdl编写测试平台,要求在测试平台中clk激励信号的时钟周期为50ns,rst信号在20ns位置有一个宽度为30ns的高电平脉冲,仿真时间不低于1000ns(assert false语句)。 library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity sigout is port( clk ,rst: in std_logic; cout : out std_logic); end sigout; architecture one of sigout is signal q : std_logic_vector(2 downto 0); begin process(clk,rst) begin if rst=’1’ then q<=”000”; elsif rising_edge(clk) then if q = "110" then q <= "000"; else q <= q + 1; end if; end if; end process; process(q) begin case q is when "000" => cout <= '1'; when "001" => cout <= '1'; when "010" => cout <= '1'; when "011" => cout <= '0'; when "100" => cout <= '0'; when "101" => cout <= '1'; when "110" => cout <= '0'; when others => cout <= '-'; end case; end process; end one;
时间: 2024-02-14 14:20:01 浏览: 184
基于vhdl语言的信号发生器
5星 · 资源好评率100%
您的问题是如何用vhdl编写测试平台来测试序列信号发生器电路?
以下是一个示例测试平台的代码,用于测试您提供的序列信号发生器电路。这个测试平台包括一个时钟信号和一个复位信号,以及一个输出信号。在仿真期间,时钟信号的周期为50ns,复位信号在20ns位置有一个宽度为30ns的高电平脉冲。仿真时间为1000ns,并且在仿真过程中,如果测试失败,将会触发一个assert false语句。
library ieee;
use ieee.std_logic_1164.all;
entity testbench is
end testbench;
architecture sim of testbench is
component sigout
port (
clk : in std_logic;
rst : in std_logic;
cout : out std_logic
);
end component;
signal clk : std_logic := '0';
signal rst : std_logic := '0';
signal cout : std_logic;
begin
uut : sigout
port map (
clk => clk,
rst => rst,
cout => cout
);
-- Clock Generation
clk_gen : process
begin
clk <= '0';
loop
wait for 25 ns;
clk <= not clk;
end loop;
end process;
-- Reset Generation
rst_gen : process
begin
rst <= '1';
wait for 20 ns;
rst <= '0';
wait for 30 ns;
rst <= '1';
wait;
end process;
-- Stimulus
stim : process
begin
wait for 10 ns;
assert cout = '1' report "Test Failed: q = 000" severity error;
wait for 40 ns;
assert cout = '1' report "Test Failed: q = 001" severity error;
wait for 40 ns;
assert cout = '1' report "Test Failed: q = 010" severity error;
wait for 20 ns;
assert cout = '0' report "Test Failed: q = 011" severity error;
wait for 20 ns;
assert cout = '0' report "Test Failed: q = 100" severity error;
wait for 40 ns;
assert cout = '1' report "Test Failed: q = 101" severity error;
wait for 20 ns;
assert cout = '0' report "Test Failed: q = 110" severity error;
wait for 10 ns;
assert false report "Test Passed!" severity note;
wait;
end process;
end sim;
请注意,在实际的工程中,您需要根据您的具体需求来修改测试平台的代码。
阅读全文