Saturday 22 March 2014

Example of WAIT statements

D Flip-Flop with synchronous rest using wait-until statement

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

entity dff is
    Port ( clk,d,rst : in  STD_LOGIC;
           q : out  STD_LOGIC);
end dff;

architecture Behavioral of dff is

begin
process
begin
wait until(clk'event and clk='1') ;
if rst='1' then q<='0';
else
q<= d;
end if;
end process;

end Behavioral;

D Flip-Flop with asynchronous reset using wait-on statement

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity dff1 is
    Port ( clk,d,rst : in  STD_LOGIC;
           q : out  STD_LOGIC);
end dff1;

architecture Behavioral of dff1 is
begin

process
begin
if rst='1' then q<='0';
elsif rising_edge(clk)then
q<= d;end if;
wait on rst,clk;
end process;


end Behavioral;

Counter using Wait until statement

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity counter is
    Port ( count : inout  STD_LOGIC_VECTOR (3 downto 0);
           clk : in  STD_LOGIC);
end counter;

architecture Behavioral of counter is

begin

process

begin
wait until( clk'event and clk='1') ;
count<=count + '1' ;
end process;
end Behavioral;

No comments:

Post a Comment