Demo entry 6352823

z

   

Submitted by anonymous on Mar 26, 2017 at 15:33
Language: vhdl. Code size: 2.3 kB.

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_signed.ALL;
entity together is
Port ( clk : in STD_LOGIC;
       arm : in STD_LOGIC;
       front : in STD_LOGIC;
       rear : in STD_LOGIC;
       window : in STD_LOGIC;
       anode : out STD_LOGIC;
       siren : out STD_LOGIC;
       arm_sig : out STD_LOGIC;
       front_sig : out STD_LOGIC;
       rear_sig : out STD_LOGIC;
       window_sig : out STD_LOGIC;
       data : out STD_LOGIC_VECTOR (7 downto 0)
       );
end together;

architecture Behavioral of together is

begin

    process(clk,arm,front,rear,window)
        variable addr:STD_LOGIC_VECTOR (3 downto 0):="0000";
        variable count1:integer :=0; 
        variable count2:STD_LOGIC_VECTOR (3 downto 0):="0000";
    begin
        arm_sig<=arm;
        front_sig<=front;
        rear_sig<=rear;
        window_sig<=window;
        anode<='0';
        
        if (clk'event =true and clk='1') then
            count1:=count1+1;
            
            if arm='1' then
            
                if (front='1' or rear='1' or window='1') then
                     
                    if count1=10 then
                         
                        if count2="0111" then
                            siren<='1';
                        else
                            count2:=count2+"0001";
                            siren<='0';
                        end if;
                        addr:=count2;
                        count1:=0; 
                    end if;
                     
                end if;
                 
            else
                siren<='0';
                count2:="0000";
            end if;
            
        end if;
        
        
        if addr="0000" then
            data<="00000001";
        elsif addr="0001" then
            data<="00000011";
        elsif addr="0010" then
            data<="00000111";
        elsif addr="0011" then
            data<="00001111";
        elsif addr="0100" then
            data<="00011111";
        elsif addr="0101" then
            data<="00111111";
        elsif addr="0110" then
            data<="01111111";
        elsif addr="0111" then
            data<="11111111";
        end if;
    end process;

end Behavioral;

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).