VHDL-Forum

 
Sie sind nicht eingeloggt.
LoginLogin Kostenlos anmeldenKostenlos anmelden
BeiträgeBeiträge MembersMitglieder SucheSuche HilfeHilfe
VotesUmfragen FilesDateien CalendarKalender BookmarksBookmarks

Anfang   zurück   weiter   Ende
Autor Beitrag
Achim
New PostErstellt: 25.05.07, 11:26     Betreff: Re: Komme nicht weiter :( Antwort mit Zitat  

Eve und der letzte Engländer
Hier doch noch der Code...

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

-- Uncomment the following lines to use the declarations that are
-- provided for instantiating Xilinx primitive components.
--library UNISIM;
--use UNISIM.VComponents.all;

entity Digitales_Messen is
Port ( CLK : in std_logic;
RESET : in std_logic;
ENABLE : in std_logic;
Start : in std_logic;
StartMessung: out std_logic;
Stop : in std_logic;
Neustart : in std_logic;
AN0 : inout std_logic;
AN1 : inout std_logic;
AN2 : inout std_logic;
AN3 : inout std_logic;
LED : out std_logic_vector(7 downto 0));
end Digitales_Messen;

architecture Behavioral of Digitales_Messen is
type statetype is (Ausgangszustand, Zaehler, Ausgabe);
signal state, NextState: statetype;
signal ctr : std_logic_vector(12 downto 0);
signal counterm : std_logic_vector(9 downto 0);
signal Zaehlerstart : std_logic;
signal Ausgabestart : std_logic;
signal Ausgangsstart: std_logic;
signal counter : std_logic_vector(18 downto 0);
signal HEX0 : std_logic_vector (3 downto 0);
signal HEX1 : std_logic_vector (3 downto 0);
signal HEX2 : std_logic_vector (3 downto 0);
signal HEX3 : std_logic_vector (3 downto 0);
signal Ende : std_logic;

begin

--StateTransition:
process (CLK, RESET)
begin
if RESET = '1' then state <= Ausgangszustand;
elsif rising_edge(CLK) then
if ENABLE = '1' then State <= NextState;
end if;
end if;
end process;

--StateCalculation:
process (Start, Stop, Neustart, State, RESET, CLK)
begin
case state is
when Ausgangszustand => if Start = '1' then NextState <= Zaehler;
else NextState <= Ausgangszustand;
end if;
when Zaehler => if Stop = '1' then NextState <= Ausgabe;
else NextState <= Zaehler;
end if;
when Ausgabe => if Neustart = '1' then NextState <= Ausgangszustand;
else NextState <= Ausgabe;
end if;
end case;
end process;

--OutputState:
process (State, RESET)
begin
if State = Zaehler then
Zaehlerstart <= '1';
else Zaehlerstart <= '0';
end if;
if State = Ausgabe then
Ausgabestart <= '1';
else Ausgabestart <= '0';
end if;
if State = Ausgangszustand then
Ausgangsstart <= '1';
else Ausgangsstart <= '0';
end if;
end process;

--Counter:
process (CLK, Ausgangsstart)
begin
if Ausgangsstart = '1' then
counter <= "0000000000000000000";
counterm <= "0000000000";
Ende <= '0';
StartMessung <= '0';
elsif Zaehlerstart = '1' and rising_edge(CLK) then
counter <= counter + 1;
if Ende = '0' then
StartMessung <= '1';
counterm <= counterm+1;
if counterm = "1111101000" then
StartMessung <= '0';
Ende <= '1';
end if;
end if;
end if;
end process;

--Output:
process (CLK, Ausgangsstart)
begin
if Ausgangsstart = '1' then
AN0 <= '1';
AN1 <= '1';
AN2 <= '1';
AN3 <= '1';
elsif Ausgabestart = '1' and rising_edge(CLK) then
HEX0 <= counter(6 downto 3);
HEX1 <= counter(10 downto 7);
HEX2 <= counter(14 downto 11);
HEX3 <= counter(18 downto 15);
if CTR = "0000000000000" then
if AN0 = '1' and AN1 = '1' and AN2 = '1' and AN3 = '1' then
AN0 <= '0';
elsif AN0 = '0' then
AN0 <= '1';
case HEX1 is
when "0000" => LED <= "11000000";
when "0001" => LED <= "11111001";
when "0010" => LED <= "10100100";
when "0011" => LED <= "10110000";
when "0100" => LED <= "10011001";
when "0101" => LED <= "10010010";
when "0110" => LED <= "10000010";
when "0111" => LED <= "11111000";
when "1000" => LED <= "10000000";
when "1001" => LED <= "10010000";
when "1010" => LED <= "10001000";
when "1011" => LED <= "10000011";
when "1100" => LED <= "11000110";
when "1101" => LED <= "10100001";
when "1110" => LED <= "10000110";
when "1111" => LED <= "10001110";
when others => NULL;
end case;
AN1 <= '0';
elsif AN1 = '0' then
AN1 <= '1';
case HEX2 is
when "0000" => LED <= "11000000";
when "0001" => LED <= "11111001";
when "0010" => LED <= "10100100";
when "0011" => LED <= "10110000";
when "0100" => LED <= "10011001";
when "0101" => LED <= "10010010";
when "0110" => LED <= "10000010";
when "0111" => LED <= "11111000";
when "1000" => LED <= "10000000";
when "1001" => LED <= "10010000";
when "1010" => LED <= "10001000";
when "1011" => LED <= "10000011";
when "1100" => LED <= "11000110";
when "1101" => LED <= "10100001";
when "1110" => LED <= "10000110";
when "1111" => LED <= "10001110";
when others => NULL;
end case;
AN2 <= '0';
elsif AN2 = '0' then
AN2 <= '1';
case HEX3 is
when "0000" => LED <= "11000000";
when "0001" => LED <= "11111001";
when "0010" => LED <= "10100100";
when "0011" => LED <= "10110000";
when "0100" => LED <= "10011001";
when "0101" => LED <= "10010010";
when "0110" => LED <= "10000010";
when "0111" => LED <= "11111000";
when "1000" => LED <= "10000000";
when "1001" => LED <= "10010000";
when "1010" => LED <= "10001000";
when "1011" => LED <= "10000011";
when "1100" => LED <= "11000110";
when "1101" => LED <= "10100001";
when "1110" => LED <= "10000110";
when "1111" => LED <= "10001110";
when others => NULL;
end case;
AN3 <= '0';
elsif AN3 = '0' then
AN3 <= '1';
case HEX0 is
when "0000" => LED <= "11000000";
when "0001" => LED <= "11111001";
when "0010" => LED <= "10100100";
when "0011" => LED <= "10110000";
when "0100" => LED <= "10011001";
when "0101" => LED <= "10010010";
when "0110" => LED <= "10000010";
when "0111" => LED <= "11111000";
when "1000" => LED <= "10000000";
when "1001" => LED <= "10010000";
when "1010" => LED <= "10001000";
when "1011" => LED <= "10000011";
when "1100" => LED <= "11000110";
when "1101" => LED <= "10100001";
when "1110" => LED <= "10000110";
when "1111" => LED <= "10001110";
when others => NULL;
end case;
AN0 <= '0';
end if;
end if;
ctr <= ctr + 1;
if (ctr > "1000000000000") then
ctr <= "0000000000000";
end if;
end if;
end process;

end behavioral;
nach oben
Sortierung ändern:  
Anfang   zurück   weiter   Ende
Seite 3.349 von 3.566
Gehe zu:   
Search

powered by carookee.com - eigenes profi-forum kostenlos

Design © trevorj