Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library IEEE;
- use IEEE.STD_LOGIC_1164.ALL;
- use ieee.std_logic_unsigned.all;
- -- Uncomment the following library declaration if using
- -- arithmetic functions with Signed or Unsigned values
- --use IEEE.NUMERIC_STD.ALL;
- -- Uncomment the following library declaration if instantiating
- -- any Xilinx primitives in this code.
- --library UNISIM;
- --use UNISIM.VComponents.all;
- entity Plytka is
- generic(width : integer:=1);
- port( clk : in std_logic;
- ChangeView : in std_logic_vector(width-1 downto 0);
- PlusOne : in std_logic_vector(width-1 downto 0);
- A,B,C,D : out std_logic_vector(7 downto 0)
- );
- end Plytka;
- architecture Behavioral of Plytka is
- signal div: std_logic_vector(2 downto 0);
- signal min : integer range 0 to 60; --sygnał minuty
- signal hour : integer range 0 to 24; --sygnał godziny
- signal day : integer range 1 to 31; --sygnał dnia
- signal month : integer range 1 to 12; --sygnał miesiąca
- signal year : integer range 2001 to 2099; --sygnał roku
- signal rest : integer range 0 to 3;
- signal actuallChangeStatus : integer range 0 to 3;
- signal Dmin : integer range 0 to 60; --sygnał dodawania minuty
- signal Dhour : integer range 0 to 24; --sygnał dodawania godziny
- signal Dday : integer range 1 to 31; --sygnał dodawania dnia
- signal Dmonth : integer range 1 to 12; --sygnał dodawania miesiąca
- signal Dyear : integer range 2001 to 2099; --sygnał dodawania roku
- signal Drest : integer range 0 to 3;
- begin
- --A<=ChangeView;
- --tu jest zrobienie taktowania zegarowego -> 1 sekunda nastąpi co 5 taktów (chyba)
- clock_process: process(clk)
- begin
- if rising_edge(clk) then
- div <= div +1;
- if div=5 then
- div<=(others => '0');
- end if;
- end if;
- end process;
- change_status: process(ChangeView)
- begin
- --if rising_edge(ChangeView) then
- if ChangeView=1 then
- if actuallChangeStatus=3 then
- actuallChangeStatus<=0;
- else
- actuallChangeStatus<=actuallChangeStatus+1;
- end if;
- end if;
- end process;
- --min <= Dmin;
- --hour <= Dhour;
- --day <= Dday;
- --month <= Dmonth;
- --year <= Dyear;
- set_minutes: process(clk,min,hour,day,month,year,rest)
- begin
- if rising_edge(clk) then
- min<=min+1;
- end if;
- if min>59 then
- min<=0;
- end if;
- if rising_edge(clk) and min=0 then
- hour<=hour+1;
- end if;
- if hour>23 then
- hour<=0;
- end if;
- if rising_edge(clk) and hour=0 then
- rest<=year mod 4;
- if month=1 and day=31 then
- month<=month+1;
- day<=1;
- elsif month=2 and day=28 and rest>0 then
- month<=month+1;
- day<=1;
- elsif month=2 and day=29 and rest=0 then
- month<=month+1;
- day<=1;
- elsif month=3 and day=31 then
- month<=month+1;
- day<=1;
- elsif month=4 and day=30 then
- month<=month+1;
- day<=1;
- elsif month=5 and day=31 then
- month<=month+1;
- day<=1;
- elsif month=6 and day=30 then
- month<=month+1;
- day<=1;
- elsif month=7 and day=31 then
- month<=month+1;
- day<=1;
- elsif month=8 and day=31 then
- month<=month+1;
- day<=1;
- elsif month=9 and day=30 then
- month<=month+1;
- day<=1;
- elsif month=10 and day=31 then
- month<=month+1;
- day<=1;
- elsif month=11 and day=30 then
- month<=month+1;
- day<=1;
- elsif month=12 and day=31 and year<2099 then
- month<=1;
- day<=1;
- year<=year+1;
- elsif month=12 and day=31 and year=2099 then
- month<=1;
- day<=1;
- year<=2001;
- else
- day<=day+1;
- end if;
- end if;
- end process;
- changeMinute: process(PlusOne,ChangeView,min,hour,day,month,year,rest)
- begin
- Dmin <= min;
- Dhour <= hour;
- Dday <= day;
- Dmonth <= month;
- Dyear <= year;
- Drest <= Dday mod 4;
- if PlusOne=1 then
- if ChangeView=0 then
- Dmin<=Dmin+1;
- if Dmin>59 then
- Dmin<=0;
- end if;
- if Dmin=0 then
- Dhour<=Dhour+1;
- end if;
- if Dhour>23 then
- Dhour<=0;
- end if;
- if Dhour=0 then
- Drest<=Dyear mod 4;
- if Dmonth=1 and Dday=31 then
- Dmonth<=Dmonth+1;
- Dday<=1;
- elsif Dmonth=2 and Dday=28 and Drest>0 then
- Dmonth<=Dmonth+1;
- Dday<=1;
- elsif Dmonth=2 and Dday=29 and Drest=0 then
- Dmonth<=Dmonth+1;
- Dday<=1;
- elsif Dmonth=3 and Dday=31 then
- Dmonth<=Dmonth+1;
- Dday<=1;
- elsif Dmonth=4 and Dday=30 then
- Dmonth<=Dmonth+1;
- Dday<=1;
- elsif Dmonth=5 and Dday=31 then
- Dmonth<=Dmonth+1;
- Dday<=1;
- elsif Dmonth=6 and Dday=30 then
- Dmonth<=Dmonth+1;
- Dday<=1;
- elsif Dmonth=7 and Dday=31 then
- Dmonth<=Dmonth+1;
- Dday<=1;
- elsif Dmonth=8 and Dday=31 then
- Dmonth<=Dmonth+1;
- Dday<=1;
- elsif Dmonth=9 and Dday=30 then
- Dmonth<=Dmonth+1;
- Dday<=1;
- elsif Dmonth=10 and Dday=31 then
- Dmonth<=Dmonth+1;
- Dday<=1;
- elsif Dmonth=11 and Dday=30 then
- Dmonth<=Dmonth+1;
- Dday<=1;
- elsif Dmonth=12 and Dday=31 and Dyear<2099 then
- Dmonth<=1;
- Dday<=1;
- Dyear<=Dyear+1;
- elsif Dmonth=12 and Dday=31 and Dyear=2099 then
- Dmonth<=1;
- Dday<=1;
- Dyear<=2001;
- else
- Dday<=Dday+1;
- end if; --koniec sprawdzania miesięcy
- end if; --koniec sprawdzania godziny
- end if; --koniec ChangeView
- end if; --koniec Plus
- end process; -- koniec procesu
- --min := Dmin;
- end Behavioral;
Add Comment
Please, Sign In to add comment