Guest User

Untitled

a guest
Aug 20th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 6.41 KB | None | 0 0
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.ALL;
  3. use ieee.std_logic_unsigned.all;
  4. -- Uncomment the following library declaration if using
  5. -- arithmetic functions with Signed or Unsigned values
  6. --use IEEE.NUMERIC_STD.ALL;
  7.  
  8. -- Uncomment the following library declaration if instantiating
  9. -- any Xilinx primitives in this code.
  10. --library UNISIM;
  11. --use UNISIM.VComponents.all;
  12.  
  13. entity Plytka is
  14. generic(width   : integer:=1);
  15.         port(   clk                             : in std_logic;
  16.                         ChangeView              : in std_logic_vector(width-1 downto 0);
  17.                         PlusOne                 : in std_logic_vector(width-1 downto 0);
  18.                         A,B,C,D                 : out std_logic_vector(7 downto 0)
  19.                         );
  20. end Plytka;
  21.  
  22. architecture Behavioral of Plytka is
  23. signal div: std_logic_vector(2 downto 0);
  24. signal min : integer range 0 to 60; --sygnał minuty
  25. signal hour : integer range 0 to 24; --sygnał godziny
  26. signal day : integer range 1 to 31; --sygnał dnia
  27. signal month : integer range 1 to 12; --sygnał miesiąca
  28. signal year : integer range 2001 to 2099; --sygnał roku
  29. signal rest : integer range 0 to 3;
  30. signal actuallChangeStatus : integer range 0 to 3;
  31. signal Dmin : integer range 0 to 60; --sygnał dodawania minuty
  32. signal Dhour : integer range 0 to 24; --sygnał dodawania godziny
  33. signal Dday : integer range 1 to 31; --sygnał dodawania dnia
  34. signal Dmonth : integer range 1 to 12; --sygnał dodawania miesiąca
  35. signal Dyear : integer range 2001 to 2099; --sygnał dodawania roku
  36. signal Drest    : integer range 0 to 3;
  37.  
  38. begin
  39.         --A<=ChangeView;
  40.            
  41.         --tu jest zrobienie taktowania zegarowego -> 1 sekunda nastąpi co 5 taktów (chyba)
  42.         clock_process: process(clk)
  43.         begin
  44.                 if rising_edge(clk) then
  45.                         div <= div +1;
  46.                         if div=5 then
  47.                                 div<=(others => '0');
  48.                         end if;
  49.                 end if;
  50.         end process;
  51.          
  52.           change_status: process(ChangeView)
  53.           begin
  54.                 --if rising_edge(ChangeView) then
  55.                 if ChangeView=1 then
  56.                     if actuallChangeStatus=3 then
  57.                         actuallChangeStatus<=0;
  58.                     else
  59.                         actuallChangeStatus<=actuallChangeStatus+1;
  60.                     end if;
  61.                 end if;
  62.           end process;
  63.          
  64.        --min <= Dmin;
  65.             --hour <= Dhour;
  66.             --day <= Dday;
  67.             --month <= Dmonth;
  68.             --year <= Dyear;
  69.            
  70.         set_minutes: process(clk,min,hour,day,month,year,rest)
  71.         begin
  72.                 if rising_edge(clk) then
  73.                         min<=min+1;
  74.                 end if;
  75.                 if min>59 then
  76.                         min<=0;
  77.                 end if;
  78.                
  79.                 if rising_edge(clk) and min=0 then
  80.                         hour<=hour+1;
  81.                 end if;
  82.                 if hour>23 then
  83.                         hour<=0;
  84.                 end if;
  85.                      
  86.                      if rising_edge(clk) and hour=0 then
  87.                                 rest<=year mod 4;
  88.                                
  89.                                 if month=1 and day=31 then
  90.                                     month<=month+1;
  91.                                     day<=1;
  92.                                 elsif month=2 and day=28 and rest>0 then
  93.                                     month<=month+1;
  94.                                     day<=1;
  95.                                 elsif month=2 and day=29 and rest=0 then
  96.                                         month<=month+1;        
  97.                                         day<=1;
  98.                                 elsif month=3 and day=31 then
  99.                                     month<=month+1;
  100.                                     day<=1;
  101.                                 elsif month=4 and day=30 then
  102.                                     month<=month+1;
  103.                                     day<=1;
  104.                                 elsif month=5 and day=31 then
  105.                                     month<=month+1;
  106.                                     day<=1;
  107.                                 elsif month=6 and day=30 then
  108.                                     month<=month+1;
  109.                                     day<=1;
  110.                                 elsif month=7 and day=31 then
  111.                                     month<=month+1;
  112.                                     day<=1;
  113.                                 elsif month=8 and day=31 then
  114.                                     month<=month+1;
  115.                                     day<=1;
  116.                                 elsif month=9 and day=30 then
  117.                                     month<=month+1;
  118.                                     day<=1;
  119.                                 elsif month=10 and day=31 then
  120.                                     month<=month+1;
  121.                                     day<=1;
  122.                                 elsif month=11 and day=30 then
  123.                                     month<=month+1;
  124.                                     day<=1;
  125.                                 elsif month=12 and day=31 and year<2099 then
  126.                                     month<=1;
  127.                                     day<=1;
  128.                                     year<=year+1;
  129.                                 elsif month=12 and day=31 and year=2099 then
  130.                                     month<=1;
  131.                                     day<=1;
  132.                                     year<=2001;
  133.                                 else
  134.                                     day<=day+1;
  135.                                 end if;
  136.                      end if;
  137.         end process;
  138.          
  139.           changeMinute: process(PlusOne,ChangeView,min,hour,day,month,year,rest)
  140.           begin
  141.                 Dmin <= min;
  142.                 Dhour <= hour;
  143.                 Dday <= day;
  144.                 Dmonth <= month;
  145.                 Dyear <= year;
  146.                 Drest <= Dday mod 4;
  147.                 if PlusOne=1 then
  148.                     if ChangeView=0 then
  149.                         Dmin<=Dmin+1;
  150.                
  151.                          if Dmin>59 then
  152.                                     Dmin<=0;
  153.                          end if;
  154.                        
  155.                          if Dmin=0 then
  156.                                 Dhour<=Dhour+1;
  157.                          end if;
  158.                          if Dhour>23 then
  159.                                     Dhour<=0;
  160.                          end if;
  161.                          
  162.                          if Dhour=0 then
  163.                                     Drest<=Dyear mod 4;
  164.                                
  165.                                 if Dmonth=1 and Dday=31 then
  166.                                     Dmonth<=Dmonth+1;
  167.                                     Dday<=1;
  168.                                 elsif Dmonth=2 and Dday=28 and Drest>0 then
  169.                                     Dmonth<=Dmonth+1;
  170.                                     Dday<=1;
  171.                                 elsif Dmonth=2 and Dday=29 and Drest=0 then
  172.                                         Dmonth<=Dmonth+1;          
  173.                                         Dday<=1;
  174.                                 elsif Dmonth=3 and Dday=31 then
  175.                                     Dmonth<=Dmonth+1;
  176.                                     Dday<=1;
  177.                                 elsif Dmonth=4 and Dday=30 then
  178.                                     Dmonth<=Dmonth+1;
  179.                                     Dday<=1;
  180.                                 elsif Dmonth=5 and Dday=31 then
  181.                                     Dmonth<=Dmonth+1;
  182.                                     Dday<=1;
  183.                                 elsif Dmonth=6 and Dday=30 then
  184.                                     Dmonth<=Dmonth+1;
  185.                                     Dday<=1;
  186.                                 elsif Dmonth=7 and Dday=31 then
  187.                                     Dmonth<=Dmonth+1;
  188.                                     Dday<=1;
  189.                                 elsif Dmonth=8 and Dday=31 then
  190.                                     Dmonth<=Dmonth+1;
  191.                                     Dday<=1;
  192.                                 elsif Dmonth=9 and Dday=30 then
  193.                                     Dmonth<=Dmonth+1;
  194.                                     Dday<=1;
  195.                                 elsif Dmonth=10 and Dday=31 then
  196.                                     Dmonth<=Dmonth+1;
  197.                                     Dday<=1;
  198.                                 elsif Dmonth=11 and Dday=30 then
  199.                                     Dmonth<=Dmonth+1;
  200.                                     Dday<=1;
  201.                                 elsif Dmonth=12 and Dday=31 and Dyear<2099 then
  202.                                     Dmonth<=1;
  203.                                     Dday<=1;
  204.                                     Dyear<=Dyear+1;
  205.                                 elsif Dmonth=12 and Dday=31 and Dyear=2099 then
  206.                                     Dmonth<=1;
  207.                                     Dday<=1;
  208.                                     Dyear<=2001;
  209.                                 else
  210.                                     Dday<=Dday+1;
  211.                                 end if; --koniec sprawdzania miesięcy
  212.                         end if; --koniec sprawdzania godziny
  213.                     end if; --koniec ChangeView
  214.                 end if; --koniec Plus
  215.           end process; -- koniec procesu
  216.           --min := Dmin;
  217. end Behavioral;
Add Comment
Please, Sign In to add comment