Advertisement
Florii11

intersectie

May 10th, 2021
793
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.95 KB | None | 0 0
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.all;
  3.  
  4. entity SEMAFOR is
  5.     port(CLOCK, RESET, SENZOR1, SENZOR2: in STD_LOGIC;
  6.         ROSU1, ROSU2, GALBEN1, GALBEN2, VERDE1, VERDE2: out STD_LOGIC);
  7. end SEMAFOR;
  8.  
  9. architecture SEMAFOR of SEMAFOR is
  10. type STARE_T is (ST0, ST1, ST2, ST3, ST4, ST5, ST6, ST7);
  11. signal STARE, NXSTARE: STARE_T;
  12. begin
  13.     ACTUALIZEAZA_STARE: process (RESET, CLOCK)
  14.     begin
  15.         if (RESET = '1') then
  16.         STARE <= ST0;
  17.         elsif CLOCK'EVENT and CLOCK = '1' then
  18.         STARE <= NXSTARE;
  19.         end if;
  20.     end process ACTUALIZEAZA_STARE;
  21.    
  22.     STARE_URM: process (SENZOR1, SENZOR2, STARE)
  23.     begin
  24.         if (STARE=ST0) then
  25.             if(SENZOR2 = SENZOR1) then
  26.              NXSTARE <= ST1;
  27.             elsif (SENZOR1 = '0' and SENZOR2 = '1') then
  28.                 NXSTARE <= ST2;
  29.             else NXSTARE <= ST0;
  30.             end if;
  31.         end if;
  32.        
  33.         if (STARE=ST1) then NXSTARE <= ST2;
  34.         elsif (STARE=ST2) then NXSTARE <= ST3;
  35.         elsif (STARE=ST3) then NXSTARE <= ST4;
  36.         elsif (STARE=ST5) then NXSTARE <= ST6;
  37.         elsif (STARE=ST6) then NXSTARE <= ST7;
  38.         elsif (STARE=ST7) then NXSTARE <= ST0;
  39.         end if;
  40.        
  41.         if (STARE=ST4) then  
  42.             if(SENZOR1 = '0' and SENZOR2 = '0') then
  43.                 NXSTARE <= ST5;
  44.             elsif (SENZOR1 = '1' and SENZOR2 = '0') then
  45.                 NXSTARE <= ST6;
  46.             else NXSTARE <= ST4;
  47.             end if;
  48.         end if;
  49.     end process STARE_URM;
  50.    
  51.     IESIRI: process (SENZOR1, SENZOR2, STARE)
  52.     begin
  53.         ROSU1 <= '0'; GALBEN1 <= '0'; VERDE1 <= '0';
  54.         ROSU2 <= '0'; GALBEN2 <= '0'; VERDE2 <= '0';
  55.         case NXSTARE is
  56.         when ST0 => VERDE1 <= '1';
  57.                     ROSU2 <= '1';
  58.         when ST1 => VERDE1 <= '1';
  59.                     ROSU2 <= '1';
  60.         when ST2 => VERDE1 <= '1';
  61.                     ROSU2 <= '1';
  62.         when ST3 => GALBEN1 <= '1';
  63.                     ROSU2 <= '1';                  
  64.         when ST4 => ROSU1 <= '1';
  65.                     VERDE2 <= '1';
  66.         when ST5 => ROSU1 <= '1';
  67.                     VERDE2 <= '1';
  68.         when ST6 => ROSU1 <= '1';
  69.                     VERDE2 <= '1';         
  70.         when ST7 => ROSU1 <= '1';
  71.                     GALBEN2 <= '1';
  72.         end case;
  73.     end process IESIRI;
  74. end SEMAFOR;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement