You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
library ieee;
use ieee.std_logic_1164.all;
-- alarm automatentity alarm isport (clk, start: instd_logic;
alarm_sound: outstd_logic);
end alarm;
architecture automat of alarm issignal z: std_logic_vector(2downto0) :="000";
begin
alarm_sound <='1'when z ="100"else'0';
process(clk)
beginifrising_edge(clk) thencase z iswhen"000"=>if start ='1'then
z <="001";
endif;
when"001"=>
z <="010";
when"010"=>
z <="011";
when"011"=>
z <="100";
when"100"=>if start ='0'then
z <="000";
endif;
whenothers=>
z <="000";
endcase;
endif;
endprocess;
end automat;
Beispiel: Testbenchcode
-- Testbench fuer alarmlibrary ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity alarm_tb isendentity;
architecture verhalten of alarm_tb iscomponent alarm isport (start, clk: instd_logic;
alarm_sound: outstd_logic);
endcomponent;
signal clk: std_logic:='0';
signal start: std_logic:='0';
signal alarm_sound: std_logic:='0';
begin
clk <=not clk after500ms;
start <='1', '0'after10sec;
dut: alarm portmap (
clk => clk,
start => start,
alarm_sound => alarm_sound
);
endarchitecture;